ieee802154.txt 4.2 KB

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