Network Stack

From Contiki
Jump to: navigation, search

Back to Contiki Tutorials

Contiki provides us with three network stacks,

1. IPv4
2. IPv6
3. Rime

The uIP TCP/IP stack, which provides us with IPv4 networking, the uIPv6 stack, which provides IPv6 networking, and the Rime stack, which is a set of custom lightweight networking protocols designed for low-power wireless networks.

Contiki Netstack

Contiki's Network Protocol stack (NETSTACK) organizes the network modules into a complete protocol stack covering all traditional OSI Layers.

Contiki Network Stack

Netstack Concepts

Four Layers
1. Network layer - NETSTACK_NETWORK
2. MAC (Medium Access Control) layer - NETSTACK_MAC
3. RDC (Radio Duty Cycling) layer - NETSTACK_RDC
4. Radio layer - NETSTACK_RADIO

The packet buffer - packetbuf

  • One buffer, holds a single packet.
  • All layers of the netstack operate on the packetbuf.
  • Large enough to hold a single radio packet - PACKETBUF_CONF_LEN

Queue buffers - queuebuf

  • The packetbuf only holds the current packet.
  • To store packets on queues, use a queuebuf.
  • Use a list to keep track of them.

uIP packet buffer - uip_buf

Framers - NETSTACK_FRAMER

  • The framer module converts link-layer headers to packet attributes - parse()
  • And packet attributes to link-layer headers - create()

Network & Routing Layer

  • Contiki automatically forms a wireless IPv6 network with the help of routing protocol called RPL (Routing Protocol for Low-power and Lossy Networks (LLNs)).
  • RPL forms routing graph from root node or AP (Access Point). It builds acyclic graph from root node called DODAG (Destination Oriented Directed Acyclic Graph).
RPL DODAG

  • DIO (DODAG Information Object) messages are broadcast by all nodes starting from the root node. It includes the node's rank, ETX, DAG version number etc.
5 nodes Network

DIO message sent by root node

DIO message broadcasted by receiving nodes

DIO message broadcasted by receiving nodes

Rank of the nodes with respect to the root

  • The node selects a parent based on the received DIO messages and calculates its rank.


Adaptation Layer

The network layer contains two sublayers, the upper IPv6 layer and the lower adaption layer.

The Adaptation Layer provides IPv6 and UDP header compression and fragmentation to transport IPv6 packets with a maximum transmission (MTU) of 1280 bytes over IEEE 802.15.4 with a MTU of 127 byte.

MAC Layer

  • The simplest layer in the IoT/IP stack.
  • Avoid collisions, back-off if there is traffic.
  • CSMA/CA: Carrier Sense Multiple Access with Collision Avoidance
+ Sense the medium before sending.
+ Back-off if someone else is sending.
+ Timing depends on RDC layer.
+ Network layer decided number of transmissions.
  • nullmac: Forwards packets from the upper layer to the radio driver and vice versa.

RDC Layer

Radio Duty Cycling layer saves energy by allowing a node to keep its radio transceiver off most of the time.

Contiki has three duty cycling mechanisms: ContikiMAC, X-MAC and LPP. ContikiMAC is a protocol based on the principles behind low-power listening but with better power efficiency. Contiki's X-MAC is based on the original X-MAC protocol, but has been enhanced to reduce power consumption and maintain good network conditions. Contiki's LPP is based on the Low-Power Probing (LPP) protocol but with enhancements that improve power consumption as well as provide mechanisms for sending broadcast data.

Radio Layer

Radio Layer is the lowest layer in the Contiki Netstack. Here, the data arrives in bytes or as a full packet via interrupt handlers. The input data is read out into the buffer, packetbuf and the process is polled. This polling process will cause the process to be sent to the special event and passed to the upper layers.

References

http://www.slideshare.net/ADunkels/building-day-2-upload-building-the-internet-of-things-with-thingsquare-and-contiki-day-2-part-3
http://www.slideshare.net/ADunkels/building-the-internet-of-things-with-thingsquare-and-contiki-day-1-part-2?related=1
https://tools.ietf.org/html/rfc6550
http://www.slideshare.net/ADunkels/building-day-2-upload-1?next_slideshow=1
http://www.slideshare.net/ADunkels/advanced-internet-of-things-firmware-engineering-with-thingsquare-and-contiki-day-1-part-2
http://contiki.sourceforge.net/docs/2.6/a01793.html#_details
https://github.com/contiki-os/contiki/wiki/Radio-duty-cycling
https://github.com/hso-esk/emb6/wiki/The-emb6-Network-Stack


Back to Contiki Tutorials

Edited by: Mugdhe, Samarth Pai