Packet forwarding event in Contiki

312 views Asked by At

I am doing some work on worm-attack detection in RPL. In RPL, the communication between the clients might be multiple hops, with the packets going through many nodes.

However, only the receiver gets a tcpip_event on reception of the packet. The nodes that the route passes through do not get this event. Is there any way to detect the packet on the intermediate nodes?

1

There are 1 answers

2
kfx On BEST ANSWER

You cannot get a notification or callback when a packet is forwarded. However, you can get a callback when a packet is received or sent by the lower layers.

In Contiki, use the function rime_sniffer_add for that. Check apps/powertrace/powertrace.c for an example.

In Contiki-NG the function has been renamed to netstack_sniffer_add.

Usage example:

Declare the sniffer like this, in the global scope:

RIME_SNIFFER(packet_sniffer, input_packet, output_packet);

Then add the sniffer from your code, once, at the start of the application execution:

rime_sniffer_add(&packet_sniffer);

The functions input_packet and output_packets are callbacks defined by you and can be used to examine the packets; for example, like this:

static void
input_packet(void)
{
  int rssi = (int)packetbuf_attr(PACKETBUF_ATTR_RSSI);
  printf("received a packet with RSSI=%d\n", rssi);
}