How to set up a 6LoWPAN network - Embedded.com

How to set up a 6LoWPAN network

Research engineer teaches some of the ins and outs of networking low-power embedded devices, specifically how to configure 6LoWPAN.

As a research engineer studying ways to improve the networking of low-power embedded devices, I've taught several workshops and tutorials in the past few months on how to configure 6LoWPAN (IPv6 over Low power Wireless Personal Area Networks). All this work is part of a larger movement toward the Internet of Things , which is supported by several organizations such as IPSO Alliance [1] (of which, if you're reading this, you're probably already aware) and the eSONIA European project [2]. I present here an excerpt from the tutorial I've taught. This tutorial is meant to explain the different choices a developer faces when setting up a 6LoWPAN network. The goal is to speed up your knowledge of 6LoWPAN so you can rapidly exploit its full potential.

The relationship between 6LoWPAN and IPv6
The 6LoWPAN is a header compression mechanism that allows IPv6 packages to be routed in low-power networks (particularly in IEEE 802.15.4). Therefore, to understand how to configure and use 6LoWPAN, it's very important to have some background in IPv6.

The most common problem when training engineers how-to configure 6LoWPAN is their general lack of knowledge of IPv6. Several engineers I've taught see IPv6 as a complex technology that they don't currently need. This would be true if you were the average user but as engineers, we need to keep in the top of the game–where lack of information is not an option. Therefore, the first step toward understanding 6LoWPAN is to get familiar with IPv6. Several online sources explain the basic addressing format and features of IPv6 (see [3] ).

Basics of working with IPv6
First thing to know is the fact that IPv6 addresses contain several zeros that can be shortened in several forms, such as:

FE80:0000:0000:0000:0000:0000:0000:F123 = FE80:0:0:0:0:0:0:F123 = FE80::F123

Additionally, the huge address space of IPv6 allows devices to have several addresses used for various purposes (for example, local communication, global communication). Here are some of the most important special IPv6 addresses used in this tutorial (for a complete list see [4]):

  • The loopback address (::1 ) is a similar address than 127.0.0.0 in IPv4 used to check the status of the interface (is good for checking if you have enabled IPv6 in your OS).
  • The local-link addresses (FE80::/10 ) is used to communicate with devices in the same link (however, the link can be extended with Layer 2 switches).
  • The global addresses (everything else ) are used for communicating devices globally. There are still other special addresses, for more information check [4] .

The 128 bits of IPv6 addresses are divided in two parts: the network prefix (64 bits) and the host address (64 bits). The 6LoWPAN header compression mechanism omits the 64 most significant bits (network prefix) because they're fixed for a given 6LoWPAN. Moreover, the 64 least significant bits can address very large address space (up to 1.84467441 x 1019 ). Therefore, 6LoWPAN provides options for compressing the host address (the common usage is 16 bits). In a nutshell, a 128-bit IPv6 address can be compressed down to 16 bits using 6LoWPAN. The 6LoWPAN offers further header compression mechanisms that are not covered in this tutorial (see [5] ).

In practice, two things need to be configured in a 6LoWPAN: the network prefix and the host address. The network-prefix set up determines if the device can be addressed globally whereas the host address should be unique within the 6LoWPAN. Next I'll describe the different options for setting up the 6LoWPANs.

6LoWPAN is an IP
Before going to the actual configuration of the 6LoWPAN, I want to remark another fact of 6LoWPAN: it is an Internet Protocol (IP) . It may seem simple but the second most common issue when training engineers to use 6LoWPAN is that they don't realize that it is an IP. If you're still wondering what this means, this means that a 6LoWPAN device can be addressed from anywhere in the world (if properly configured) with a standard computer. This is a huge advantage although it has its consequences.

The main advantages of 6LoWPAN being an IP is that it doesn't require additional software and uses a widely known L3 protocol. The only addition is that between a 6LoWPAN and an IPv6 network there is an edge router (ER) that performs the header compression, although this is transparent for the end user.

The 6LoWPAN devices normally host a web server that is used for configuring and visualizing the users' data. Nowadays 6LoWPAN is just like the early stages of Internet (before search engines): If you wanted to address a web page, you needed to know the specific address of this server. In those early times, it was simple enough to write down or memorize this address. Now imagine that this address is randomly generated every time the server is restarted. The result is a hard-to-address web page, which is similar to the problem when configuring a 6LoWPAN. However, if the 6LoWPAN is properly configured, this will not be an issue.

Configuring a 6LoWPAN

I have explained the basics of networking 6LoWPAN packages and gave some insight on the possible challenges when setting up a 6LoWPAN. Now it's time to configure the network. Figure 1 depicts a traditional topology of a 6LoWPAN connected to a standard IP network.


Figure 1: A simple 6LoWPAN topology.
Click on image to enlarge.

The 6LoWPAN configurations are made in three devices: the edge router (where the IPv6 to 6LoWPAN header compression is performed), at the 6LoWPAN devices, and in some very specific cases, at the addressing device (normally a server or standard computer). Depending on the different features of your network the configuration of these different will differ. Therefore, it's important that you first decide what features are desired.

Communication direction: in, out, or in/out
It's very important to identify what your communication requirements are. If you only want to send information to a server, an out-only may be sufficient. If you only want to obtain (or request) information from the devices, an in-only may be enough. However, if you want to receive information in a server (out) and want to configure the devices remotely (in), you need an in/out communication.

  • In only: the addressing device must know the host address of the 6LoWPAN device and the host address must be within the addressing scope.
  • Out only: the 6LoWPAN device must know the address of the addressing server (this time is being addressed) and this address must be within the scope of the edge router.
  • In/Out: Both devices (6LoWPAN device and addressing device ) should know each other's addresses, and the addresses should be within scope.

Address scope: local or global
Do you want to isolate your application from Internet or do you want it to be addressable from anywhere in the globe? If you decide to isolate your application (most likely because of security reasons or lack of IPv6 support), you must set the network address (64 more significant bits, typically set to AAAA::/64). This setup is performed in the edge router and in the 6LoWPAN device. Moreover, if you want to address this device using your standard computer, you'll need to add the path to your routing table. For example, this is performed using the ROUTE command in Windows:

route ADD AAAA::/64 AAAB::2

where any package directed to the AAAA:: networks will be forwarded to the AAAB::2 address (the address of the edge router). In some cases, it's necessary also to specify the interface.

On the other hand, if you want your network to be addressed globally, you only need to have a native IPv6 router (which sends the Neighbor discovery) and automatically your full network will be addressable. Now you may be asking: is that simple? As you've probably already guessed, there is still the problem of how to know if and what addresses your devices obtained (without sniffing the network or brute force the 216 addresses of the network). These issues are covered when selecting between dynamic or static address assignments.

Address assignment: dynamic or static [or hybrid]
Once you decided if you need the previously-mentioned requirements, it's time to select an addressing assignment mechanism. Similar to traditional IP, there are two different ways for the devices to obtain their addresses: dynamic or static. The dynamic configuration makes use of the stateless address autoconfiguration of IPv6 called Neighbor discovery (ND) or Dynamic Host address Configuration Protocol (DHCPv6) and requires very little (or no) configuration in order to provide local or global scope. When using the ND mechanism, the addresses are assigned based in a pseudo-random mechanism (which uses the MAC address of the devices) and therefore the address of the 6LoWPAN device is unknown. It's similar to connecting your computer to a network. Do you know you own IP address? No, unless you check it on your computer, which in the case of 6LoWPAN devices is not normally an option. DHCPv6 can help to alleviate this problem by performing mappings between devices MAC and IPv6 addresses.

The static address assignment needs to be set manually on every device. This process is more time consuming, although the user has full control and knowledge of the network (this feature alone may be enough for several engineers to use only static addresses). Moreover, the devices may lose connectivity if they change from network to network. However, it's easy to keep a list of the different addresses registered in order to access them.

Worthy of a mention is a hybrid approach that has been observed in some devices (particularly using the Contiki OS [6] ) where the local-link host address (16 least significant bits) are set on a specific address (e.g., FE80::FABC, remember that FE80:: means that is a local-link address and the actual host address is ::FABC). When the 6LoWPAN device tries to dynamically obtain its address, the actual global address is formed from the network prefix (advertised by the edge router) and the local-link host address (statically set by the user). Therefore, the user can easily reconstruct the address of a 6LoWPAN device in order to be addressed. This solution offers a good balance between both approaches, and it is my preferred approach when I have installed networks of 100+ devices.

Address assignment: compile-time or run-time
It's widely known that there are many things that can be set at compile-time and at run time. As you guess it, the address is one of them. Before you go on and discard the idea of setting the address at compile-time, let me introduce one use of this addressing assignment mechanism: safe-mode. When you are testing your 6LoWPAN devices and you want to make sure that you are addressing the right device (which is nothing more than a black box in many cases), there is no actual way to verify that the address you think that device has is the correct one. The only way to ensure it is to update the firmware (that may include going back to your office for your JTAG and compiling sources, which I guess you may want to avoid) or to set the device in safe-mode (such as by pressing a button, changing a jumper or switch). This will set the device on a particular address (for example, FE80::EEEE) which you can be sure about it in order to test connectivity. For all other cases, I will suggest using dynamic or static run-time address assignment as explained in Address assignment: dynamic or static [or hybrid].

Further considerations
There are several other considerations that need to be made when using a networking protocol. It is important to mention that 6LoWPAN has been designed for devices compliant with the IEEE 802.15.4 (low power wireless communication standard) and it is used in several other protocols (such as ZigBee, WirelessHART, ISA100.11a). The IEEE 802.15.4 need to be synchronized on the same channel in order to communicate. This procedure is performed either at compile-time or at run-time (and perhaps going to a safe-mode default channel configuration). The channel configuration can vary from hardware to hardware; therefore, check with the manufacturer in order to set it properly.

It's important to use small packages even if it's an IP network. For example, picture this scenario: An engineer is tempted to use as 6LoWPAN to send uncompressed SOAP Web Service information. Given the low-power nature of 6LoWPAN, fragmented messages are sent over IEEE 802.15.4 (127 bytes of MTU) using UDP. A normal size of a SOAP message (in order to send a couple of messages with environment sensor information) is around 800 to 1,000 bytes. This means that the messages are fragmented in 7 to 8 UDP datagrams each. If you consider a 90% probability that a datagram will arrive (from one node to another), the probability that all fragmented datagrams of the message will arrive is less than 50%! And this is the best case where there is just one node from the edge router. If the edge router is three hops away, the probability of the message arriving is lower than 10%. By using compressed messages, the reliability of message arrival can be improved to 90% (in single hop) and over 70% (three-hops distance). Therefore, message size has great impact on the reliability of your wireless sensor network and needs to be defined carefully.

Where to find more training
This tutorial presents the decisions you'll need to make when deploying a 6LoWPAN. The mainly, you need to identify the flow of information (in, out), designate the scope of the addressing (global or local), select an address-assignment policy (dynamic, static or hybrid), and use a safe-mode for debugging applications. Moreover, I gave you a brief introduction of several other issues, such as channel selection and message size. Finally, you need to take into account several other important issues deployment of your 6LoWPAN (such as hardware, operating system, message compression) that I did not cover in this short tutorial but you can find more information about them on at IPSO Alliance web page, including webinars and white papers. [1]

Axel Vidales Ramos is a researcher at the Factory Automation Systems and Technologies (FAST) Laboratory in the Department of Production Engineering at Tampere University, Finland. At FAST lab, he and his colleagues have been working on IPv6 embedded devices. He can be reached at axel.vidales@tut.fi. FAST Laboratory's homepage is www.tut.fi/fast.

IPSO Alliance: The IPSO Alliance is the primary advocate for IP for smart objects for use in energy, consumer, healthcare and industrial applications. The Alliance, a non-profit organization whose members include leading technology, communications and energy companies, is providing the foundation for a network that will allow any sensor-enabled physical object to communicate to another as individuals do over the Internet. The IPSO Alliance membership is open to any organization supporting an IP-based approach to connecting smart objects. For more information, visit www.ipso-alliance.org or contact Kate Easton.

Endnotes

  1. “IPSO Alliance | Enabling the Internet of Things”. [Online]. Available: http://www.ipso-alliance.org/. [Accessed: 16-Feb-2012].
  2. “The eSONIA European project.” [Online]. Available: http://esonia.eu/. [Accessed: 16-Feb-2012].
  3. Kozierok, C. M. The TCP/IP Guide: A Comprehensive Illustrated Internet Protocols Reference, 1st ed. NO STARCH PRESS, 2005.
  4. Blanchet, M. “RFC-5156: Special-Use IPv6 Addresses'. [Online]. Available: http://tools.ietf.org/html/rfc5156. [Accessed: 30-Jan-2012].
  5. Shelby, Z. and C. Bormann. 6LoWPAN: The Wireless Embedded Internet. Wiley-Blackwell, 2009.
  6. “The Contiki OS.” [Online]. Available: http://www.contiki-os.org/. [Accessed: 16-Feb-2012].


1 thought on “How to set up a 6LoWPAN network

  1. Could someone please fix the article's title?

    “Setup”, “login” and the like are NOUNS. The verb forms are “set up”, “log in” etc.

    I am setting up my 6LowPAN network. I am NOT “setupping” my network. So the title might be “How to Set up a 6LoWPAN Netwo

    Log in to Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.