我在Make文件中添加了"MAKE_ROUTING = MAKE_ROUTING_RPL_CLASSIC“,以启用RPL-经典
#include "contiki.h"
#include "sys/node-id.h"
#include "sys/log.h"
#include "net/ipv6/uip-ds6-route.h"
#include "net/ipv6/uip-sr.h"
#include "net/mac/tsch/tsch.h"
#include "net/routing/routing.h"
#define DEBUG DEBUG_PRINT
#include "net/ipv6/uip-debug.h"
/*---------------------------------------------------------------------------*/
PROCESS(node_process, "RPL Node");
AUTOSTART_PROCESSES(&node_process);
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(node_process, ev, data)
{
int is_coordinator;
PROCESS_BEGIN();
is_coordinator = 0;
#if CONTIKI_TARGET_COOJA || CONTIKI_TARGET_Z1
is_coordinator = (node_id == 1);
#endif
if(is_coordinator) {
NETSTACK_ROUTING.root_start();
}
NETSTACK_MAC.on();
{
static struct etimer et;
/* Print out routing tables every minute */
etimer_set(&et, CLOCK_SECOND * 60);
while(1) {
PRINTF("Routing entries: %u\n", uip_ds6_route_num_routes());
PROCESS_YIELD_UNTIL(etimer_expired(&et));
etimer_reset(&et);
}
}
PROCESS_END();
}发布于 2020-08-19 15:10:11
这些步骤对我有效:
MAKE_ROUTING=MAKE_ROUTING_RPL_CLASSIC添加到Makefile以确保使用RPL经典模式;默认情况下是打开存储模式的。 /* Log configuration */
#include "sys/log.h"
#define LOG_MODULE "App"
#define LOG_LEVEL LOG_LEVEL_DBGwhile(1)循环: LOG_INFO("Routing entries: %u\n", uip_ds6_route_num_routes());
uip_ds6_route_t *route = uip_ds6_route_head();
while(route) {
LOG_INFO("Route ");
LOG_INFO_6ADDR(&route->ipaddr);
LOG_INFO_("/128 via ");
LOG_INFO_6ADDR(uip_ds6_route_nexthop(route));
LOG_INFO_("\n");
route = uip_ds6_route_next(route);
}根节点上的输出:
01:00.382 ID:1 [INFO: App ] Routing entries: 7
01:00.382 ID:1 [INFO: App ] Route fd00::205:5:5:5/128 via fe80::205:5:5:5
01:00.382 ID:1 [INFO: App ] Route fd00::204:4:4:4/128 via fe80::204:4:4:4
01:00.382 ID:1 [INFO: App ] Route fd00::208:8:8:8/128 via fe80::203:3:3:3
01:00.382 ID:1 [INFO: App ] Route fd00::203:3:3:3/128 via fe80::203:3:3:3
01:00.382 ID:1 [INFO: App ] Route fd00::207:7:7:7/128 via fe80::203:3:3:3
01:00.382 ID:1 [INFO: App ] Route fd00::206:6:6:6/128 via fe80::203:3:3:3
01:00.382 ID:1 [INFO: App ] Route fd00::202:2:2:2/128 via fe80::203:3:3:3转发节点上的输出:
01:00.899 ID:3 [INFO: App ] Routing entries: 4
01:00.899 ID:3 [INFO: App ] Route fd00::208:8:8:8/128 via fe80::206:6:6:6
01:00.899 ID:3 [INFO: App ] Route fd00::207:7:7:7/128 via fe80::206:6:6:6
01:00.899 ID:3 [INFO: App ] Route fd00::206:6:6:6/128 via fe80::206:6:6:6
01:00.899 ID:3 [INFO: App ] Route fd00::202:2:2:2/128 via fe80::202:2:2:2https://stackoverflow.com/questions/63485343
复制相似问题