It describes how to send and receive raw UDP datagrams with Contiki-NG. It focus on the module simple-udp.
Open the file location -->/home/user/Desktop/contiki-ng/os/net/ipv6
simple-udp.c file
First, register a socket, both at the sender and receiver.
#include "net/ipv6/simple-udp.h"
simple_udp_register(struct simple_udp_connection *c,
uint16_t local_port,
uip_ipaddr_t *remote_addr,
uint16_t remote_port,
simple_udp_callback receive_callback)
For each incoming datagram, the function above will be called with parameters that provide source/destination addresses and ports, and the payload.
c->receive_callback(c,
&(UIP_IP_BUF->srcipaddr),
UIP_HTONS(UIP_UDP_BUF->srcport),
&(UIP_IP_BUF->destipaddr),
UIP_HTONS(UIP_UDP_BUF->destport),
databuffer, uip_datalen());