title: Reply to broadcasted packets using Simple UDP API in CONTIKI
body: <p>Good morning everyone,</p>
  <p>In order to understand how mote communication works in Contiki, I am currently trying to set up a simple communication scenario.
  This scenario involves two motes &quot;Root&quot; and &quot;Node&quot;.</p>
  <p>Root is going to <strong>broadcast</strong> a &quot;Test&quot; message.</p>
  <p>Node has to reply to Root by <strong>unicasting</strong> an &quot;OK&quot; message.</p>
  <p>I am currently using the simple_udp API to allow the motes to communicate.</p>
  <p>Here is the Root code</p>
  <pre><code>  #include &quot;contiki.h&quot;
  #include &quot;lib/random.h&quot;
  #include &quot;sys/ctimer.h&quot;
  #include &quot;sys/etimer.h&quot;
  #include &quot;net/ip/uip.h&quot;
  #include &quot;net/ipv6/uip-ds6.h&quot;
  
  #include &quot;simple-udp.h&quot;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  #define UDP_PORT 1234
  
  #define DELAY   (60 * CLOCK_SECOND)
  
  
  
  static struct etimer wait;
  static struct simple_udp_connection connection;
  
  
  
  
  
  static void receiver(struct simple_udp_connection *c,
           const uip_ipaddr_t *sender_addr,
           uint16_t sender_port,
           const uip_ipaddr_t *receiver_addr,
           uint16_t receiver_port,
           const uint8_t *data,
           uint16_t datalen)
  {
    printf(&quot;Data received on port %d from port %d with length %d\n&quot;,
           receiver_port, sender_port, datalen);
  }
  
  
  
  
  
  /*---------------------------------------------------------------------------*/
  PROCESS(Root_process, &quot;Root process&quot;);
  AUTOSTART_PROCESSES(&amp;Root_process);
  /*---------------------------------------------------------------------------*/
  
  /*---------------------------------------------------------------------------*/
  PROCESS_THREAD(Root_process, ev, data)
  {
    PROCESS_BEGIN();
  
  simple_udp_register(&amp;connection, UDP_PORT,NULL,UDP_PORT,receiver); // setting up the connection
    
  
     
     etimer_set(&amp;wait, 5*DELAY); // waiting for Node to initialize
  
  PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&amp;wait));
  
  
   uip_ipaddr_t broadcast;
  
   uip_create_linklocal_allnodes_mcast(&amp;broadcast); // generating a broadcast address
  
  
    simple_udp_sendto(&amp;connection, &quot;Test&quot;, 4, &amp;broadcast); // broadcasting
    
  
  while(1) {
  PROCESS_WAIT_EVENT();
    }
  
  PROCESS_END();  
  
  }
  </code></pre>
  <p>Here is the Node code</p>
  <pre><code>#include &quot;contiki.h&quot;
  #include &quot;lib/random.h&quot;
  #include &quot;sys/ctimer.h&quot;
  #include &quot;sys/etimer.h&quot;
  #include &quot;net/ip/uip.h&quot;
  #include &quot;net/ipv6/uip-ds6.h&quot;
  
  #include &quot;simple-udp.h&quot;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  #define UDP_PORT 1234
  
  
  
  
  
  static struct simple_udp_connection connection;
  
  
  
  
  static void receiver(struct simple_udp_connection *c,
           const uip_ipaddr_t *sender_addr,
           uint16_t sender_port,
           const uip_ipaddr_t *receiver_addr,
           uint16_t receiver_port,
           const uint8_t *data,
           uint16_t datalen)
  {
    printf(&quot;Data received on port %d from port %d with length %d\n&quot;,
           receiver_port, sender_port, datalen);
  
  
    simple_udp_sendto(&amp;connection, &quot;OK&quot;, 2, sender_addr); // sending the reply
  }
  
  
  
  
  /*---------------------------------------------------------------------------*/
  PROCESS(Node_process, &quot;Node process&quot;);
  AUTOSTART_PROCESSES(&amp;Node_process);
  /*---------------------------------------------------------------------------*/
  
  /*---------------------------------------------------------------------------*/
  PROCESS_THREAD(Node_process, ev, data)
  {
    PROCESS_BEGIN();
    simple_udp_register(&amp;connection, UDP_PORT,NULL, UDP_PORT,receiver);
   
    while(1) {
    PROCESS_WAIT_EVENT();
        
      }
  
  PROCESS_END();
  }
  </code></pre>
  <p>The problem is that <strong>Node receives the broadcasted &quot;Test&quot; message</strong>  but <strong>the reply is not being sent</strong></p>
  <p>I would be grateful for any provided help.</p>
  <p>Thank you.</p>