MAC protocols in ContikiOS
This tutorial covers the main features of Medium Access Control (MAC) protocols available on ContikiOS 2.7. Medium Access Control protocols take care of the organization of medium access in wireless networks. They can be interpreted as rules that coordinate when each node is going to transmit/receive packets.
There are a large number of protocols available in the literature, they can usually be classified as contention-based or reservation-based protocols. The first group is based on Carrier Sensing for detecting medium activity and are prone to collisions and lower efficiency; however, they are of easy implementation. The second group is more efficient in terms of throughput and energy, but require precise synchronization and is less adaptable to dynamic traffic. ContikiOS only presents MAC protocols of the first category.
There are about 5 types of MAC layers that can be used in ContikiOS. They are usually implementation of well-known MAC protocols for Wireless Sensor Networks; a few of them are implementations of protocols developed exclusively for ContikiOS, but that were based on previous work present in the literature.
You will learn
Here you are going to be to be more familiar with all MAC protocols implemented on ContikiOS. You are going to understand the organization of MAC protocols, where all files are located and where you should start when you want to modify a protocol. You will also learn the steps you need to take in order to implement your own MAC protocol. And finally, we evaluate two famous MAC protocols: ContikiMAC and X-MAC, showing a few statistics regarding their performance.
MAC, RDC and Framer drivers
The network stack implemented in ContikiOS is a little bit different than the usual 5-layers model typically adopted in TCP/IP. In-between the Physical and the Network layers, where usually is located the MAC, we have 3 different layers: Framer, Radio Duty-Cycle (RDC) and Medium Access Control (MAC). The figure below shows the organization of layers in ContikiOS.
The network layers can be accessed through the global variables NETSTACK_FRAMER, NETSTACK_RDC and NETSTACK_MAC, which are defined in compilation time. All network layers variables can be found in core/net/netstack.h. Every network layer is defined by the pragmas #define in the beginning of this file.
Framer layer is not a common layer implementation; it is actually a collection of auxiliary functions that are called for framezation of transmitting data and parsing of data being received. Examples of Framer types can be found in core/net/mac; there are two types of Framer layers: framer-802154.c and framer-nullmac.c.
Radio Duty-Cycle (RDC) layer takes care of the sleep period of nodes. This is the most important layer because it is the one responsible for deciding exactly when the packets will be transmitted and it is responsible for makeing sure that the node is awake when packets are to be received. RDC protocols' source codes are also located in core/net/mac. Examples of RDC layers that are implemented: contikimac.c, xmac.c, lpp.c, nullrdc-noframer.c, nullrdc.c and sicslowmac.c.
Finally, the MAC layer takes care of addressing and retransmission of lost packets. The source files can be located in core/net/mac; we have only two types of MAC layers available: csma.c and nullmac.c.
How to choose and change your protocols
How to code your own protocol
Evaluating ContikiMAC and XMAC protocols
Edited by: Pedro