Welcome, Guest! Log In | Create Account

IEEE802.15.4/ZigBee Stack for Linux

The main SourceForge project space is located here: https://sourceforge.net/projects/linux-zigbee/

This project is a little bit special - it includes two parts, kernel and userspace. Due to the fact, that kernel git shall be cloned from upstream, we need 2 repositories.

Kernel components (git repository of Linux kernel with our modifications): git://linux-zigbee.git.sourceforge.net/gitroot/linux-zigbee/kernel, GitWeb

User tools (separate git for tools, such as iz, izcoordinator, izchat, etc.): git://linux-zigbee.git.sourceforge.net/gitroot/linux-zigbee/linux-zigbee, GitWeb

For communication about technical aspects of the stack, coordination of development efforts, etc. you can use the linux-zigbee-devel@… mailing list. Subscription is required for posting to the list. For your convenience the mailing list is mirrored on the Gmane.

Overview

ZigBee is a new wireless networking standard, developed by ZigBee Alliance. It is targeted to monitoring and control applications (such as light control, sensors data acquisition, etc). ZigBee designed to be low cost, extremely power efficient and provide effective communication with low data rate, needed for most home automation scenarios. Key technical information is provided in the following table:

  • Frequencies: 868MHz, 915MHz, 2.4GHz (in revision 2003, more added in later revisions)
  • Data rates: 20kb/s, 40kb/s, 250kb/s
  • Typical distance: 10-75 meters
  • Network: Mesh
  • Battery life: Several years

ZigBee is based on IEEE 802.15.4-2003 WPAN (Wireless Personal Area Network) specification, which defines physical (PHY) and medium access control (MAC) layers of protocol. Higher layers, including network (NWK), application support sub-layer (APS) and ZigBee Device Objects (ZDO) are described by ZigBee standard.

One of the most interesting features of ZigBee is possibility of mesh networking, i.e. dynamic network formation from existing nodes. This extends network range and provides higher network reliability by creation of new paths in case of network configuration changes.

ZigBee specification defines so called Profiles of devices, which allow equipment from different manufacturers to interoperate. Usage of ZigBee for standardized products makes it possible to provide a unified integration solution, which will create a link between different types of home automation and serve as a basis for "smart home".

Why use Linux?

Major advantages of native Linux implementation of IEEE 802.15.4 / ZigBee / WirelessHART / 6LoWPAN protocol stacks are:

  • Simple and well-known socket interface for user applications
  • Fake radio driver and support for multiple logical devices on single physical radio provide framework for network simulation and testing prior to deployment
  • Existing network analysis and configuration infrastructure (Wireshark)
  • Native integration with Linux networking subsystem (gateways, tools, etc.)

Hardware Support

The following radio hardware is supported by the stack:

  • Fake radio driver, to provide emulated environment without usage of physical radios
  • Atmel AT86RF231, using SPI on AT91SAM9G20-EK ARM9 evaluation hardware with embedded Linux
  • Freescale MC13192, using serial interface on Freescale SARD and EVB boards with custom firmware (13192DSK)
  • Freescale MC1322x, using serial interface, thanks to Mariano Alvira efforts (http://mc1322x.devl.org/)

Implementation

Our implementation covers kernel protocol stack and user utilities, which include the following components:

  • iz - controls stack parameters over netlink; does scanning, association/disassociation, etc.
  • izattach - associates PHY-level device with serial port to work with serial device
  • izcoordinator - IEEE 802.15.4 coordinator, it allocates and manages short address database

Also, the following additional tools are supported:

  • izchat - allows transfer of text messages between nodes
  • libpcap - libpcap with small patch to recognize interface
  • tcpdump - with a small patch to permit enabling of our packet type
  • wireshark - with a patch to use "-nofcs" dissector for IEEE802.15.4 and additional dissector for ZigBee

In order to work with physical radio, a firmware implementing basic PHY-like commands set is necessary (currently exists for Freescale SARD boards).

Getting started

Please note, these instructions are for Debian Lenny users. If you are lucky Ubuntu owner, you may need to build your own packages from sources.

IEEE 802.15.4 / ZigBee stack has a capability to support of multiple radio drivers, as well as multiple logical interfaces on one radio. Also, the stack includes so-called fake radio drivers, which will forward traffic to all fake radio drivers on the system, thus making possible to implement several "virtual" radio nodes on one host. We will use this capability to demonstrate functionality of the stack without real hardware.

First, download the following files from http://linux-zigbee.sourceforge.net/ (kernel, user space utilities and ZigBee-enabled Wireshark):

 liblowpan-dev_0.1-3_all.deb
 libpcap0.8_1.0.0-1.1_i386.deb
 libpcap0.8-dbg_1.0.0-1.1_i386.deb
 libpcap0.8-dev_1.0.0-1.1_i386.deb
 libpcap-dev_1.0.0-1.1_all.deb
 lowpan-tools_0.1-3_i386.deb
 tcpdump_4.0.0-2.1_i386.deb
 tshark_1.0.7-1.1_i386.deb
 wireshark_1.0.7-1.1_i386.deb
 wireshark-common_1.0.7-1.1_i386.deb
 wireshark-dev_1.0.7-1.1_i386.deb
 zigbee-kernel-0.1.tar.gz

Build ZigBee-enabled kernel with the following options:

 CONFIG_IEEE802154=y
 CONFIG_IEEE802154_DRIVERS=y
 CONFIG_IEEE802154_FAKELB=y
 CONFIG_IEEE802154_SERIAL=y

Update your GRUB menu, boot into the ZigBee kernel and install necessary packages:

 dpkg -i liblowpan-dev_0.1-3_all.deb \
  libpcap0.8_1.0.0-1.1_i386.deb \
  libpcap0.8-dbg_1.0.0-1.1_i386.deb \
  libpcap0.8-dev_1.0.0-1.1_i386.deb \
  libpcap-dev_1.0.0-1.1_all.deb \
  lowpan-tools_0.1-3_i386.deb \
  tcpdump_4.0.0-2.1_i386.deb \
  tshark_1.0.7-1.1_i386.deb \
  wireshark_1.0.7-1.1_i386.deb \
  wireshark-common_1.0.7-1.1_i386.deb \
  wireshark-dev_1.0.7-1.1_i386.deb

On our simulated network we will have 3 fake radios (mwpan0 is created by default and we will add 2 more). One these radio interfaces, we will start 3 nodes which will have short addresses 0x1, 0x8001 and 0x8002. Node 0x1 will act as a coordinator and shall run izcoordinator on it, which will handle network with PAN ID 0x777. Nodes 0x8001 and 0x8002 will associate with coordinator and will receive addresses after association. We will start izchat tool on these nodes, and will use Wireshark to monitor network traffic.

Add fake radio interfaces for network devices:

 echo ca:fe:ca:fe:ca:fe:ca:fe > /sys/bus/platform/devices/ieee80215fakelb/adddev
 echo be:be:be:be:be:be:be:be > /sys/bus/platform/devices/ieee80215fakelb/adddev

Bring all master (radio) interfaces up:

 ifconfig mwpan0 up
 ifconfig mwpan1 up
 ifconfig mwpan2 up

Bring up logical interfaces (by default, one logical interface is associated with each radio):

 ifconfig wpan0 up
 ifconfig wpan1 up
 ifconfig wpan2 up

Set first interface short address:

 izconfig wpan0 short 777:1

Start wireshark to monitor traffic on the network:

 wireshark -i mwpan0 -k

Start coordinator (you need to do it as root as well):

 touch lease
 izcoordinator -d 1 -l lease -i wpan0

Start devices (also, shall be done by root):

 iz wpan1 assoc 777 1 0 short
 iz wpan2 assoc 777 1 0 short

Start simple chat program (0x8001 and 0x8002 are the short addresses are received during association):

 izchat 777 8001 8002
 izchat 777 8002 8001

Now please feel free to experiment and remember that our work is still in progress!