I am simulating using the Cooja simulator an IoT network with the nodes running the Contiki-NG operating system. Several UDP client nodes send sensor data to a UDP server node that is the root node in RPL-Classic running on top of 6LoWPAN. I want to measure each client node's packet sending ratio and packet receiving ratio, so I have to count the number of packets being sent from each neighbour. For this I programmed the UDP client nodes to use the 6LoWPAN netstack sniffer. Thus, every time a packet is sent or received at the 6LoWPAN layer, I use the packetbuf_addr(PACKETBUF_ADDR_SENDER)
function to get the IP address of the packet (which is either about to be sent or just received) from the packet buffer. However, when I use the LOG_INFO_6ADDR()
function to print this address, I don't see an IPv6 address but rather some gibberish. What could be causing this?
With what I understand of Contiki-NG and 6LoWPAN, I could think of two things that could have happened. Either the packet headers are compressed and hence the headers can't be read directly, or the position of the IPv6 header is offset by the UDP packet headers being encapsulated by the 6LoWPAN packet headers. If the issue is that I'm reading a compressed packet, how do I get the uncompressed IPv6 address from this packet without it affecting the original 6LoWPAN packet in the packet buffer? Or if the issue is the chained headers of 6LoWPAN, how do I fetch the IPv6 address from the right location? If the issue could be anything else, please do tell me how to go about it.