Contiki provides us with three network stacks,
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's Network Protocol stack (NETSTACK) organizes the network modules into a complete protocol stack covering all traditional OSI 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).
- 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.
- The node selects a parent based on the received DIO messages and calculates its rank.
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.
- 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.
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 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.
Edited by: Mugdhe, Samarth Pai