Based on kernel version 3.9. Page generated on 2013-05-02 23:11 EST.
1 2 Linux IEEE 802.15.4 implementation 3 4 5 Introduction 6 ============ 7 The IEEE 802.15.4 working group focuses on standartization of bottom 8 two layers: Medium Accsess Control (MAC) and Physical (PHY). And there 9 are mainly two options available for upper layers: 10 - ZigBee - proprietary protocol from ZigBee Alliance 11 - 6LowPAN - IPv6 networking over low rate personal area networks 12 13 The Linux-ZigBee project goal is to provide complete implementation 14 of IEEE 802.15.4 and 6LoWPAN protocols. IEEE 802.15.4 is a stack 15 of protocols for organizing Low-Rate Wireless Personal Area Networks. 16 17 The 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 23 24 25 Socket API 26 ========== 27 28 int sd = socket(PF_IEEE802154, SOCK_DGRAM, 0); 29 ..... 30 31 The address family, socket addresses etc. are defined in the 32 include/net/af_ieee802154.h header or in the special header 33 in our userspace package (see either linux-zigbee sourceforge download page 34 or git tree at git://linux-zigbee.git.sourceforge.net/gitroot/linux-zigbee). 35 36 One can use SOCK_RAW for passing raw data towards device xmit function. YMMV. 37 38 39 Kernel side 40 ============= 41 42 Like with WiFi, there are several types of devices implementing IEEE 802.15.4. 43 1) 'HardMAC'. The MAC layer is implemented in the device itself, the device 44 exports MLME and data API. 45 2) '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 49 Those types of devices require different approach to be hooked into Linux kernel. 50 51 52 MLME - MAC Level Management 53 ============================ 54 55 Most of IEEE 802.15.4 MLME interfaces are directly mapped on netlink commands. 56 See the include/net/nl802154.h header. Our userspace tools package 57 (see above) provides CLI configuration utility for radio interfaces and simple 58 coordinator for IEEE 802.15.4 networks as an example users of MLME protocol. 59 60 61 HardMAC 62 ======= 63 64 See the header include/net/ieee802154_netdev.h. You have to implement Linux 65 net_device, with .type = ARPHRD_IEEE802154. Data is exchanged with socket family 66 code via plain sk_buffs. On skb reception skb->cb must contain additional 67 info as described in the struct ieee802154_mac_cb. During packet transmission 68 the skb->cb is used to provide additional data to device's header_ops->create 69 function. Be aware, that this data can be overriden later (when socket code 70 submits skb to qdisc), so if you need something from that cb later, you should 71 store info in the skb->data on your own. 72 73 To hook the MLME interface you have to populate the ml_priv field of your 74 net_device with a pointer to struct ieee802154_mlme_ops instance. All fields are 75 required. 76 77 We provide an example of simple HardMAC driver at drivers/ieee802154/fakehard.c 78 79 80 SoftMAC 81 ======= 82 83 The MAC is the middle layer in the IEEE 802.15.4 Linux stack. This moment it 84 provides interface for drivers registration and management of slave interfaces. 85 86 NOTE: Currently the only monitor device type is supported - it's IEEE 802.15.4 87 stack interface for network sniffers (e.g. WireShark). 88 89 This layer is going to be extended soon. 90 91 See header include/net/mac802154.h and several drivers in drivers/ieee802154/. 92 93 94 Device drivers API 95 ================== 96 97 The include/net/mac802154.h defines following functions: 98 - struct ieee802154_dev *ieee802154_alloc_device 99 (size_t priv_size, struct ieee802154_ops *ops): 100 allocation of IEEE 802.15.4 compatible device 101 102 - void ieee802154_free_device(struct ieee802154_dev *dev): 103 freeing allocated device 104 105 - int ieee802154_register_device(struct ieee802154_dev *dev): 106 register PHY in the system 107 108 - void ieee802154_unregister_device(struct ieee802154_dev *dev): 109 freeing registered PHY 110 111 Moreover IEEE 802.15.4 device operations structure should be filled. 112 113 Fake drivers 114 ============ 115 116 In addition there are two drivers available which simulate real devices with 117 HardMAC (fakehard) and SoftMAC (fakelb - IEEE 802.15.4 loopback driver) 118 interfaces. This option provides possibility to test and debug stack without 119 usage of real hardware. 120 121 See sources in drivers/ieee802154 folder for more details. 122 123 124 6LoWPAN Linux implementation 125 ============================ 126 127 The IEEE 802.15.4 standard specifies an MTU of 128 bytes, yielding about 80 128 octets of actual MAC payload once security is turned on, on a wireless link 129 with a link throughput of 250 kbps or less. The 6LoWPAN adaptation format 130 [RFC4944] was specified to carry IPv6 datagrams over such constrained links, 131 taking into account limited bandwidth, memory, or energy resources that are 132 expected in applications such as wireless Sensor Networks. [RFC4944] defines 133 a Mesh Addressing header to support sub-IP forwarding, a Fragmentation header 134 to support the IPv6 minimum MTU requirement [RFC2460], and stateless header 135 compression for IPv6 datagrams (LOWPAN_HC1 and LOWPAN_HC2) to reduce the 136 relatively large IPv6 and UDP headers down to (in the best case) several bytes. 137 138 In Semptember 2011 the standard update was published - [RFC6282]. 139 It deprecates HC1 and HC2 compression and defines IPHC encoding format which is 140 used in this Linux implementation. 141 142 All the code related to 6lowpan you may find in files: net/ieee802154/6lowpan.* 143 144 To setup 6lowpan interface you need (busybox release > 1.17.0): 145 1. Add IEEE802.15.4 interface and initialize PANid; 146 2. Add 6lowpan interface by command like: 147 # ip link add link wpan0 name lowpan0 type lowpan 148 3. Set MAC (if needs): 149 # ip link set lowpan0 address de:ad:be:ef:ca:fe:ba:be 150 4. Bring up 'lowpan0' interface