blob: 22bbc7225f8ed599e8c8b51653c017a6c4845c53 [file] [log] [blame]
Sergey Lapin02cf2282009-06-08 12:18:50 +00001
2 Linux IEEE 802.15.4 implementation
3
4
5Introduction
6============
Masanari Iidac17cb8b2013-10-30 16:46:15 +09007The IEEE 802.15.4 working group focuses on standardization of bottom
Stefan Huber3d9738a2013-06-05 12:24:34 +02008two layers: Medium Access Control (MAC) and Physical (PHY). And there
alex.bluesman.smirnov@gmail.comdd456d42012-05-15 20:50:31 +00009are mainly two options available for upper layers:
10 - ZigBee - proprietary protocol from ZigBee Alliance
11 - 6LowPAN - IPv6 networking over low rate personal area networks
Sergey Lapin02cf2282009-06-08 12:18:50 +000012
13The Linux-ZigBee project goal is to provide complete implementation
alex.bluesman.smirnov@gmail.comdd456d42012-05-15 20:50:31 +000014of IEEE 802.15.4 and 6LoWPAN protocols. IEEE 802.15.4 is a stack
Sergey Lapin02cf2282009-06-08 12:18:50 +000015of protocols for organizing Low-Rate Wireless Personal Area Networks.
16
alex.bluesman.smirnov@gmail.comdd456d42012-05-15 20:50:31 +000017The stack is composed of three main parts:
18 - IEEE 802.15.4 layer; We have chosen to use plain Berkeley socket API,
19 the generic Linux networking stack to transfer IEEE 802.15.4 messages
20 and a special protocol over genetlink for configuration/management
21 - MAC - provides access to shared channel and reliable data delivery
22 - PHY - represents device drivers
Sergey Lapin02cf2282009-06-08 12:18:50 +000023
24
25Socket API
26==========
27
28int sd = socket(PF_IEEE802154, SOCK_DGRAM, 0);
29.....
30
31The address family, socket addresses etc. are defined in the
Dmitry Baryshkov48a2f112009-08-07 02:58:39 +000032include/net/af_ieee802154.h header or in the special header
Sergey Lapin02cf2282009-06-08 12:18:50 +000033in our userspace package (see either linux-zigbee sourceforge download page
34or git tree at git://linux-zigbee.git.sourceforge.net/gitroot/linux-zigbee).
35
36One can use SOCK_RAW for passing raw data towards device xmit function. YMMV.
37
38
Sergey Lapin02cf2282009-06-08 12:18:50 +000039Kernel side
40=============
41
42Like with WiFi, there are several types of devices implementing IEEE 802.15.4.
431) 'HardMAC'. The MAC layer is implemented in the device itself, the device
44 exports MLME and data API.
452) 'SoftMAC' or just radio. These types of devices are just radio transceivers
46 possibly with some kinds of acceleration like automatic CRC computation and
47 comparation, automagic ACK handling, address matching, etc.
48
49Those types of devices require different approach to be hooked into Linux kernel.
50
51
alex.bluesman.smirnov@gmail.comdd456d42012-05-15 20:50:31 +000052MLME - MAC Level Management
53============================
54
55Most of IEEE 802.15.4 MLME interfaces are directly mapped on netlink commands.
56See the include/net/nl802154.h header. Our userspace tools package
57(see above) provides CLI configuration utility for radio interfaces and simple
58coordinator for IEEE 802.15.4 networks as an example users of MLME protocol.
59
60
Sergey Lapin02cf2282009-06-08 12:18:50 +000061HardMAC
62=======
63
Dmitry Baryshkov48a2f112009-08-07 02:58:39 +000064See the header include/net/ieee802154_netdev.h. You have to implement Linux
Sergey Lapin02cf2282009-06-08 12:18:50 +000065net_device, with .type = ARPHRD_IEEE802154. Data is exchanged with socket family
Dmitry Eremin-Solenikova0aea572009-08-19 18:53:39 +040066code via plain sk_buffs. On skb reception skb->cb must contain additional
67info as described in the struct ieee802154_mac_cb. During packet transmission
68the skb->cb is used to provide additional data to device's header_ops->create
Masanari Iidac17cb8b2013-10-30 16:46:15 +090069function. Be aware that this data can be overridden later (when socket code
Dmitry Eremin-Solenikova0aea572009-08-19 18:53:39 +040070submits skb to qdisc), so if you need something from that cb later, you should
71store info in the skb->data on your own.
Sergey Lapin02cf2282009-06-08 12:18:50 +000072
73To hook the MLME interface you have to populate the ml_priv field of your
Werner Almesberger56aa0912013-04-04 06:32:35 +000074net_device with a pointer to struct ieee802154_mlme_ops instance. The fields
75assoc_req, assoc_resp, disassoc_req, start_req, and scan_req are optional.
76All other fields are required.
Sergey Lapin02cf2282009-06-08 12:18:50 +000077
78We provide an example of simple HardMAC driver at drivers/ieee802154/fakehard.c
79
80
81SoftMAC
82=======
83
alex.bluesman.smirnov@gmail.comdd456d42012-05-15 20:50:31 +000084The MAC is the middle layer in the IEEE 802.15.4 Linux stack. This moment it
85provides interface for drivers registration and management of slave interfaces.
86
87NOTE: Currently the only monitor device type is supported - it's IEEE 802.15.4
88stack interface for network sniffers (e.g. WireShark).
89
90This layer is going to be extended soon.
Sergey Lapin02cf2282009-06-08 12:18:50 +000091
Dmitry Baryshkov48a2f112009-08-07 02:58:39 +000092See header include/net/mac802154.h and several drivers in drivers/ieee802154/.
Dmitry Eremin-Solenikova0aea572009-08-19 18:53:39 +040093
alex.bluesman.smirnov@gmail.comdd456d42012-05-15 20:50:31 +000094
95Device drivers API
96==================
97
98The include/net/mac802154.h defines following functions:
99 - struct ieee802154_dev *ieee802154_alloc_device
100 (size_t priv_size, struct ieee802154_ops *ops):
101 allocation of IEEE 802.15.4 compatible device
102
103 - void ieee802154_free_device(struct ieee802154_dev *dev):
104 freeing allocated device
105
106 - int ieee802154_register_device(struct ieee802154_dev *dev):
107 register PHY in the system
108
109 - void ieee802154_unregister_device(struct ieee802154_dev *dev):
110 freeing registered PHY
111
112Moreover IEEE 802.15.4 device operations structure should be filled.
113
114Fake drivers
115============
116
117In addition there are two drivers available which simulate real devices with
118HardMAC (fakehard) and SoftMAC (fakelb - IEEE 802.15.4 loopback driver)
119interfaces. This option provides possibility to test and debug stack without
120usage of real hardware.
121
122See sources in drivers/ieee802154 folder for more details.
123
124
alex.bluesman.smirnov@gmail.com63ce40e2011-11-10 07:41:11 +00001256LoWPAN Linux implementation
126============================
127
128The IEEE 802.15.4 standard specifies an MTU of 128 bytes, yielding about 80
129octets of actual MAC payload once security is turned on, on a wireless link
130with a link throughput of 250 kbps or less. The 6LoWPAN adaptation format
131[RFC4944] was specified to carry IPv6 datagrams over such constrained links,
132taking into account limited bandwidth, memory, or energy resources that are
133expected in applications such as wireless Sensor Networks. [RFC4944] defines
134a Mesh Addressing header to support sub-IP forwarding, a Fragmentation header
135to support the IPv6 minimum MTU requirement [RFC2460], and stateless header
136compression for IPv6 datagrams (LOWPAN_HC1 and LOWPAN_HC2) to reduce the
137relatively large IPv6 and UDP headers down to (in the best case) several bytes.
138
139In Semptember 2011 the standard update was published - [RFC6282].
140It deprecates HC1 and HC2 compression and defines IPHC encoding format which is
141used in this Linux implementation.
142
143All the code related to 6lowpan you may find in files: net/ieee802154/6lowpan.*
144
145To setup 6lowpan interface you need (busybox release > 1.17.0):
1461. Add IEEE802.15.4 interface and initialize PANid;
1472. Add 6lowpan interface by command like:
148 # ip link add link wpan0 name lowpan0 type lowpan
1493. Set MAC (if needs):
150 # ip link set lowpan0 address de:ad:be:ef:ca:fe:ba:be
1514. Bring up 'lowpan0' interface