-
Notifications
You must be signed in to change notification settings - Fork 0
Contiki
In this page, we will be covering the file structure of Contiki and some of the files relevant for this project.
For our project, we are concerned with two main layers: the IP layer and the CoAP layer. Here we will try to identify the header data structure of both the layers and the modules involved in processing them.
The source code for the components of IP are found in the path contiki/core/net and the code for the components of CoAP are found in contiki/app/er-coap
The source code for the uIP TCP/IP stack is present in the file uip.h in the path contiki/core/net/ip
uIP (also called as micro IP) is an open source implementation of the TCP/IP network protocol stack intended for use with tiny 8-bit and 16-bit micro-controllers. As Contiki is mainly used in IoT environment, it uses uIP by default. uIP is fully compliant with the RFCs that define TCP, UDP and IP (It also implements the mandatory maintenance protocol ICMP).
The IP header is located in line 1706 in the uip.h file.
The IPv6 header data structure has the following components:
- vtc: An element of data type uint8, it contains both the Version field (bit 0 to bit 3) and part of Traffic Class field (bit 4 to bit 7).
- tcflow: An element of data type uint8, it contains the remaining part of Traffic Class field (bit 8 to bit 11) and a part of Flow Label field (bit 12 to bit 15).
- flow: An element of data type uint16, it contains the remaining part of Flow Label field (bit 16 to bit 31).
- len: An array of 2 elements, both of type uint8, it contains the Payload length field (bit 32 to bit 47).
- proto, ttl: Elements of data type uint8, it contains the Next Header field (next layer protocol, bit 48 to bit 55) and the Time-to-live field (hop limit, bit 56 to bit 63) respectively.
Since the ECN bits are present as bit 10 and bit 11 in the Traffic Class header, ECN bits are present as the third and fourth bits in the 'tcflow' element of the IPv6 header data structure.
The IPv4 header data structure has the following components:
- vhl: An element of data type uint8, it contains the Version field (bit 0 to bit 3) and the Internet Header Length field (bit 4 to bit 7).
- tos: An element of data type uint8, it contains the Type of Service field (bit 8 to bit 15).
- len: An array of 2 elements, both of type uint8, it contains the Payload length field (bit 16 to bit 31).
- ipid: An array of 2 elements, both of type uint8, it contains the Identification field (bit 32 to bit 47).
- ipoffset: An array of 2 elements, both of type uint8, it contains the Flags field (bit 48 and bit 49) and the Fragment Offset field (bit 50 to bit 63).
- ttl, proto: Elements of data type uint8, it contains the Time-to-live field (hop limit, bit 64 to bit 71) and the Next Header field (next layer protocol, bit 72 to bit 79) respectively.
- ipchksum: Element of data type uint16, it contains the IP Checksum field (byte 80 to byte 95).
Since the ECN bits are present as bit 6 and bit 7 in the Type of Service header, ECN bits are present as the 6th and 7th bits in the 'tos' element of the IPv4 header data structure.