Sergey Lapin | 02cf228 | 2009-06-08 12:18:50 +0000 | [diff] [blame] | 1 | |
| 2 | Linux IEEE 802.15.4 implementation |
| 3 | |
| 4 | |
| 5 | Introduction |
| 6 | ============ |
| 7 | |
| 8 | The Linux-ZigBee project goal is to provide complete implementation |
| 9 | of IEEE 802.15.4 / ZigBee / 6LoWPAN protocols. IEEE 802.15.4 is a stack |
| 10 | of protocols for organizing Low-Rate Wireless Personal Area Networks. |
| 11 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 12 | Currently only IEEE 802.15.4 layer is implemented. We have chosen |
Sergey Lapin | 02cf228 | 2009-06-08 12:18:50 +0000 | [diff] [blame] | 13 | to use plain Berkeley socket API, the generic Linux networking stack |
| 14 | to transfer IEEE 802.15.4 messages and a special protocol over genetlink |
| 15 | for configuration/management |
| 16 | |
| 17 | |
| 18 | Socket API |
| 19 | ========== |
| 20 | |
| 21 | int sd = socket(PF_IEEE802154, SOCK_DGRAM, 0); |
| 22 | ..... |
| 23 | |
| 24 | The address family, socket addresses etc. are defined in the |
Dmitry Baryshkov | 48a2f11 | 2009-08-07 02:58:39 +0000 | [diff] [blame] | 25 | include/net/af_ieee802154.h header or in the special header |
Sergey Lapin | 02cf228 | 2009-06-08 12:18:50 +0000 | [diff] [blame] | 26 | in our userspace package (see either linux-zigbee sourceforge download page |
| 27 | or git tree at git://linux-zigbee.git.sourceforge.net/gitroot/linux-zigbee). |
| 28 | |
| 29 | One can use SOCK_RAW for passing raw data towards device xmit function. YMMV. |
| 30 | |
| 31 | |
| 32 | MLME - MAC Level Management |
| 33 | ============================ |
| 34 | |
| 35 | Most of IEEE 802.15.4 MLME interfaces are directly mapped on netlink commands. |
Dmitry Baryshkov | 48a2f11 | 2009-08-07 02:58:39 +0000 | [diff] [blame] | 36 | See the include/net/nl802154.h header. Our userspace tools package |
Sergey Lapin | 02cf228 | 2009-06-08 12:18:50 +0000 | [diff] [blame] | 37 | (see above) provides CLI configuration utility for radio interfaces and simple |
| 38 | coordinator for IEEE 802.15.4 networks as an example users of MLME protocol. |
| 39 | |
| 40 | |
| 41 | Kernel side |
| 42 | ============= |
| 43 | |
| 44 | Like with WiFi, there are several types of devices implementing IEEE 802.15.4. |
| 45 | 1) 'HardMAC'. The MAC layer is implemented in the device itself, the device |
| 46 | exports MLME and data API. |
| 47 | 2) 'SoftMAC' or just radio. These types of devices are just radio transceivers |
| 48 | possibly with some kinds of acceleration like automatic CRC computation and |
| 49 | comparation, automagic ACK handling, address matching, etc. |
| 50 | |
| 51 | Those types of devices require different approach to be hooked into Linux kernel. |
| 52 | |
| 53 | |
| 54 | HardMAC |
| 55 | ======= |
| 56 | |
Dmitry Baryshkov | 48a2f11 | 2009-08-07 02:58:39 +0000 | [diff] [blame] | 57 | See the header include/net/ieee802154_netdev.h. You have to implement Linux |
Sergey Lapin | 02cf228 | 2009-06-08 12:18:50 +0000 | [diff] [blame] | 58 | net_device, with .type = ARPHRD_IEEE802154. Data is exchanged with socket family |
Dmitry Eremin-Solenikov | a0aea57 | 2009-08-19 18:53:39 +0400 | [diff] [blame] | 59 | code via plain sk_buffs. On skb reception skb->cb must contain additional |
| 60 | info as described in the struct ieee802154_mac_cb. During packet transmission |
| 61 | the skb->cb is used to provide additional data to device's header_ops->create |
| 62 | function. Be aware, that this data can be overriden later (when socket code |
| 63 | submits skb to qdisc), so if you need something from that cb later, you should |
| 64 | store info in the skb->data on your own. |
Sergey Lapin | 02cf228 | 2009-06-08 12:18:50 +0000 | [diff] [blame] | 65 | |
| 66 | To hook the MLME interface you have to populate the ml_priv field of your |
| 67 | net_device with a pointer to struct ieee802154_mlme_ops instance. All fields are |
| 68 | required. |
| 69 | |
| 70 | We provide an example of simple HardMAC driver at drivers/ieee802154/fakehard.c |
| 71 | |
| 72 | |
| 73 | SoftMAC |
| 74 | ======= |
| 75 | |
Thadeu Lima de Souza Cascardo | 987b881 | 2009-07-26 12:34:40 -0300 | [diff] [blame] | 76 | We are going to provide intermediate layer implementing IEEE 802.15.4 MAC |
Sergey Lapin | 02cf228 | 2009-06-08 12:18:50 +0000 | [diff] [blame] | 77 | in software. This is currently WIP. |
| 78 | |
Dmitry Baryshkov | 48a2f11 | 2009-08-07 02:58:39 +0000 | [diff] [blame] | 79 | See header include/net/mac802154.h and several drivers in drivers/ieee802154/. |
Dmitry Eremin-Solenikov | a0aea57 | 2009-08-19 18:53:39 +0400 | [diff] [blame] | 80 | |
alex.bluesman.smirnov@gmail.com | 63ce40e | 2011-11-10 07:41:11 +0000 | [diff] [blame] | 81 | 6LoWPAN Linux implementation |
| 82 | ============================ |
| 83 | |
| 84 | The IEEE 802.15.4 standard specifies an MTU of 128 bytes, yielding about 80 |
| 85 | octets of actual MAC payload once security is turned on, on a wireless link |
| 86 | with a link throughput of 250 kbps or less. The 6LoWPAN adaptation format |
| 87 | [RFC4944] was specified to carry IPv6 datagrams over such constrained links, |
| 88 | taking into account limited bandwidth, memory, or energy resources that are |
| 89 | expected in applications such as wireless Sensor Networks. [RFC4944] defines |
| 90 | a Mesh Addressing header to support sub-IP forwarding, a Fragmentation header |
| 91 | to support the IPv6 minimum MTU requirement [RFC2460], and stateless header |
| 92 | compression for IPv6 datagrams (LOWPAN_HC1 and LOWPAN_HC2) to reduce the |
| 93 | relatively large IPv6 and UDP headers down to (in the best case) several bytes. |
| 94 | |
| 95 | In Semptember 2011 the standard update was published - [RFC6282]. |
| 96 | It deprecates HC1 and HC2 compression and defines IPHC encoding format which is |
| 97 | used in this Linux implementation. |
| 98 | |
| 99 | All the code related to 6lowpan you may find in files: net/ieee802154/6lowpan.* |
| 100 | |
| 101 | To setup 6lowpan interface you need (busybox release > 1.17.0): |
| 102 | 1. Add IEEE802.15.4 interface and initialize PANid; |
| 103 | 2. Add 6lowpan interface by command like: |
| 104 | # ip link add link wpan0 name lowpan0 type lowpan |
| 105 | 3. Set MAC (if needs): |
| 106 | # ip link set lowpan0 address de:ad:be:ef:ca:fe:ba:be |
| 107 | 4. Bring up 'lowpan0' interface |