1

我正在尝试在 6LoWPAN 边界路由器中实现 ECC。我正在为所有 udp_sender.c 使用 contiki Wismote 微尘作为发件人,并且边界路由器 (border_router.c) 需要接收一些消息并回复 ECC 密钥。我在 makefile 中禁用了默认服务器 (WITH_WEBSERVER=0) 并启用了 debug_print。

udp_sender.c 正确发送消息,但边界路由器没有收到消息。在border_router.c之后什么都没有执行PROCESS_YIELD

while(1) {
     PROCESS_YIELD(); **//Nothing executes from this point**
     if(ev == tcpip_event) {
          tcpip_handler();
     } else if (ev == sensors_event && data == &button_sensor) {
          PRINTF("Initiaing global repair\n");
          rpl_repair_root(RPL_DEFAULT_INSTANCE);
     }
 }

`

#define DEBUG DEBUG_PRINT
#include "net/uip-debug.h"

uint16_t dag_id[] = {0x1111, 0x1100, 0, 0, 0, 0, 0, 0x0011};
static uip_ipaddr_t prefix;
static uint8_t prefix_set;

#define UIP_IP_BUF   ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
#define UDP_CLIENT_PORT 8765
#define UDP_SERVER_PORT 5678
static struct uip_udp_conn *server_conn;

PROCESS(border_router_process, "Border router process");
PROCESS(startup_process, "Startup process");

#if WEBSERVER==0
/* No webserver */
AUTOSTART_PROCESSES(&startup_process, &border_router_process);
#elif WEBSERVER>1
/* Use an external webserver application */
#include "webserver-nogui.h"
AUTOSTART_PROCESSES(&border_router_process,&webserver_nogui_process);
#else

#include "httpd-simple.h"

#define WEBSERVER_CONF_LOADTIME 0
#define WEBSERVER_CONF_FILESTATS 0
#define WEBSERVER_CONF_NEIGHBOR_STATUS 0

#define WEBSERVER_CONF_ROUTE_LINKS 0
#if WEBSERVER_CONF_ROUTE_LINKS
#define BUF_USES_STACK 1
#endif

PROCESS ( startup_process, "Statup Process" );
PROCESS(webserver_nogui_process, "Web server");
PROCESS_THREAD(webserver_nogui_process, ev, data)
{
  PROCESS_BEGIN();
  httpd_init();
  while(1) {
    PROCESS_WAIT_EVENT_UNTIL(ev == tcpip_event);
    httpd_appcall(data);
  }
  PROCESS_END();
}
AUTOSTART_PROCESSES(&border_router_process,&webserver_nogui_process, &startup_process);

//webserver codes
/*-----------------------------------------*/
static void 
tcpip_handler(void)
{
  char *appdata;

  if(uip_newdata()) {
    appdata = (char *)uip_appdata;
    appdata[uip_datalen()] = 0;
    PRINTF("DATA recv '%s' from ", appdata);
    PRINTF("%d",
           UIP_IP_BUF->srcipaddr.u8[sizeof(UIP_IP_BUF->srcipaddr.u8) - 1]);
    PRINTF("\n");
#if SERVER_REPLY
    PRINTF("DATA sending reply\n");
    uip_ipaddr_copy(&server_conn->ripaddr, &UIP_IP_BUF->srcipaddr);
    uip_udp_packet_send(server_conn, "Reply", sizeof("Reply"));
    uip_create_unspecified(&server_conn->ripaddr);
#endif
  }
}

PROCESS_THREAD ( startup_process, ev, data )
{
        PROCESS_BEGIN();
    //some ECC codes here
      process_start ( &border_router_process, ev );
        PROCESS_END();
}

PROCESS_THREAD(border_router_process, ev, data)
{
  static struct etimer et;
  rpl_dag_t *dag;

  PROCESS_BEGIN();
  ....
  .....
  server_conn = udp_new(NULL, UIP_HTONS(UDP_CLIENT_PORT), NULL);
  if(server_conn == NULL) {
    PRINTF("No UDP connection available, exiting the process!\n");
    PROCESS_EXIT();
  }
  udp_bind(server_conn, UIP_HTONS(UDP_SERVER_PORT));

  PRINTF("Created a server connection with remote address ");
  PRINT6ADDR(&server_conn->ripaddr);
  PRINTF(" local/remote port %u/%u\n", UIP_HTONS(server_conn->lport),
         UIP_HTONS(server_conn->rport));

  while(1) {
   PROCESS_YIELD();
   //Nothing executes from this point
    if(ev == tcpip_event) {
      tcpip_handler();
    } else if (ev == sensors_event && data == &button_sensor) {
      PRINTF("Initiaing global repair\n");
      rpl_repair_root(RPL_DEFAULT_INSTANCE);
    }
  }
  PROCESS_END();
}

这是我的输出

08:46.163   ID:2    Rime started with address 0.0.0.0.0.0.0.2
08:46.174   ID:2    MAC 00:00:00:00:00:00:00:02 Contiki 2.6 started. Node id is set to 2.
08:46.183   ID:2    nullmac nullrdc, channel check rate 128 Hz, radio channel 26
08:46.194   ID:2    Tentative link-local IPv6 address fe80:0000:0000:0000:0200:0000:0000:0002
08:46.199   ID:2    Starting 'UDP client process'
08:46.207   ID:2    ECC INITIALIZED: key bit len: 128 NN_DIGIT_BITS: 16
08:46.660   ID:1    Rime started with address 0.0.0.0.0.0.0.1
08:46.672   ID:1    MAC 00:00:00:00:00:00:00:01 Contiki 2.6 started. Node id is set to 1.
08:46.681   ID:1    nullmac nullrdc, channel check rate 128 Hz, radio channel 26
08:46.693   ID:1    Tentative link-local IPv6 address fe80:0000:0000:0000:0200:0000:0000:0001
08:46.697   ID:1    Starting 'Startup process'
08:46.701   ID:1    Inside STARTUP process
08:46.708   ID:1    ECC INITIALIZED: key bit len: 128 NN_DIGIT_BITS: 16
08:46.711   ID:2    # [1024 bytes, no line ending]:                     ...
08:46.938   ID:2    # [1024 bytes, no line ending]:                     ...

08:49.078   ID:1    # [1024 bytes, no line ending]:                     ...
08:49.207   ID:2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  UDP client process started
08:49.213   ID:2    Client IPv6 addresses: aaaa::200:0:0:2
08:49.215   ID:2    fe80::200:0:0:2
08:49.224   ID:2    Created a connection with the server :: local/remote port 8765/5678
08:49.311   ID:1    # [1024 bytes, no line ending]:                     ...
08:49.545   ID:1    # [1024 bytes, no line ending]:                     ...
08:49.778   ID:1    # [1024 bytes, no line ending]:                     ...
08:50.010   ID:1    # [1024 bytes, no line ending]:                     ...
08:50.242   ID:1    # [1024 bytes, no line ending]:                     ...
08:50.475   ID:1    # [1024 bytes, no line ending]:                     ...
08:50.748   ID:1    # [1024 bytes, no line ending]:                     ...
08:50.751   ID:1    der router process
08:50.756   ID:1    RPL-Border router started
08:50.766   ID:1    ?PGot configuration message of type P
08:50.769   ID:1    Setting prefix aaaa::
08:51.758   ID:1    after PREFIX
08:51.761   ID:1    created a new RPL dag
08:51.765   ID:1    Server IPv6 addresses:
08:51.768   ID:1     aaaa::200:0:0:1
08:51.770   ID:1     fe80::200:0:0:1
08:51.782   ID:1    Created a server connection with remote address :: local/remote port 5678/8765
10:40.719   ID:2    DATA send to 1 'Hello 1'
11:38.321   ID:2    DATA send to 1 'Hello 2'
12:24.887   ID:2    DATA send to 1 'Hello 3'
13:37.051   ID:2    DATA send to 1 'Hello 4'
14:22.934   ID:2    DATA send to 1 'Hello 5'
15:24.160   ID:2    DATA send to 1 'Hello 6'
16:01.856   ID:2    DATA send to 1 'Hello 7'
\\more messages like above

4

0 回答 0