From 7a1576815e5b4555d940867e05152328f2f1eeda Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Wed, 29 Jun 2016 17:06:12 +0200 Subject: [PATCH] rpl-tsch example: use RPL non-storing mode --- examples/ipv6/rpl-tsch/node.c | 62 ++++++++++++++----- examples/ipv6/rpl-tsch/project-conf.h | 15 ++++- regression-tests/11-ipv6/19-z1-rpl-tsch.csc | 2 +- .../11-ipv6/20-z1-rpl-tsch-orchestra.csc | 2 +- .../11-ipv6/21-z1-rpl-tsch-security.csc | 2 +- 5 files changed, 61 insertions(+), 22 deletions(-) diff --git a/examples/ipv6/rpl-tsch/node.c b/examples/ipv6/rpl-tsch/node.c index 35852b608..a49540f7a 100644 --- a/examples/ipv6/rpl-tsch/node.c +++ b/examples/ipv6/rpl-tsch/node.c @@ -41,6 +41,7 @@ #include "net/rpl/rpl.h" #include "net/ipv6/uip-ds6-route.h" #include "net/mac/tsch/tsch.h" +#include "net/rpl/rpl-private.h" #if WITH_ORCHESTRA #include "orchestra.h" #endif /* WITH_ORCHESTRA */ @@ -68,46 +69,73 @@ print_network_status(void) int i; uint8_t state; uip_ds6_defrt_t *default_route; +#if RPL_WITH_STORING uip_ds6_route_t *route; +#endif /* RPL_WITH_STORING */ +#if RPL_WITH_NON_STORING + rpl_ns_node_t *link; +#endif /* RPL_WITH_NON_STORING */ - PRINTA("--- Network status ---\n"); + PRINTF("--- Network status ---\n"); /* Our IPv6 addresses */ - PRINTA("- Server IPv6 addresses:\n"); + PRINTF("- Server IPv6 addresses:\n"); for(i = 0; i < UIP_DS6_ADDR_NB; i++) { state = uip_ds6_if.addr_list[i].state; if(uip_ds6_if.addr_list[i].isused && (state == ADDR_TENTATIVE || state == ADDR_PREFERRED)) { - PRINTA("-- "); - uip_debug_ipaddr_print(&uip_ds6_if.addr_list[i].ipaddr); - PRINTA("\n"); + PRINTF("-- "); + PRINT6ADDR(&uip_ds6_if.addr_list[i].ipaddr); + PRINTF("\n"); } } /* Our default route */ - PRINTA("- Default route:\n"); + PRINTF("- Default route:\n"); default_route = uip_ds6_defrt_lookup(uip_ds6_defrt_choose()); if(default_route != NULL) { - PRINTA("-- "); - uip_debug_ipaddr_print(&default_route->ipaddr); - PRINTA(" (lifetime: %lu seconds)\n", (unsigned long)default_route->lifetime.interval); + PRINTF("-- "); + PRINT6ADDR(&default_route->ipaddr); + PRINTF(" (lifetime: %lu seconds)\n", (unsigned long)default_route->lifetime.interval); } else { - PRINTA("-- None\n"); + PRINTF("-- None\n"); } +#if RPL_WITH_STORING /* Our routing entries */ - PRINTA("- Routing entries (%u in total):\n", uip_ds6_route_num_routes()); + PRINTF("- Routing entries (%u in total):\n", uip_ds6_route_num_routes()); route = uip_ds6_route_head(); while(route != NULL) { - PRINTA("-- "); - uip_debug_ipaddr_print(&route->ipaddr); - PRINTA(" via "); - uip_debug_ipaddr_print(uip_ds6_route_nexthop(route)); - PRINTA(" (lifetime: %lu seconds)\n", (unsigned long)route->state.lifetime); + PRINTF("-- "); + PRINT6ADDR(&route->ipaddr); + PRINTF(" via "); + PRINT6ADDR(uip_ds6_route_nexthop(route)); + PRINTF(" (lifetime: %lu seconds)\n", (unsigned long)route->state.lifetime); route = uip_ds6_route_next(route); } +#endif - PRINTA("----------------------\n"); +#if RPL_WITH_NON_STORING + /* Our routing links */ + PRINTF("- Routing links (%u in total):\n", rpl_ns_num_nodes()); + link = rpl_ns_node_head(); + while(link != NULL) { + if(link->parent != NULL) { + uip_ipaddr_t child_ipaddr; + uip_ipaddr_t parent_ipaddr; + rpl_ns_get_node_global_addr(&child_ipaddr, link); + rpl_ns_get_node_global_addr(&parent_ipaddr, link->parent); + PRINTF("-- "); + PRINT6ADDR(&child_ipaddr); + PRINTF(" to "); + PRINT6ADDR(&parent_ipaddr); + PRINTF(" (lifetime: %lu seconds)\n", (unsigned long)link->lifetime); + } + link = rpl_ns_node_next(link); + } +#endif + + PRINTF("----------------------\n"); } /*---------------------------------------------------------------------------*/ static void diff --git a/examples/ipv6/rpl-tsch/project-conf.h b/examples/ipv6/rpl-tsch/project-conf.h index 8ac0a93b6..9a0d98d58 100644 --- a/examples/ipv6/rpl-tsch/project-conf.h +++ b/examples/ipv6/rpl-tsch/project-conf.h @@ -45,6 +45,17 @@ #define WITH_SECURITY 0 #endif /* WITH_SECURITY */ +/*******************************************************/ +/********* Enable RPL non-storing mode *****************/ +/*******************************************************/ + +#undef UIP_CONF_MAX_ROUTES +#define UIP_CONF_MAX_ROUTES 0 /* No need for routes */ +#undef RPL_CONF_MOP +#define RPL_CONF_MOP RPL_MOP_NON_STORING /* Mode of operation*/ +#undef ORCHESTRA_CONF_RULES +#define ORCHESTRA_CONF_RULES { &eb_per_time_source, &unicast_per_neighbor_rpl_ns, &default_common } /* Orchestra in non-storing */ + /*******************************************************/ /********************* Enable TSCH *********************/ /*******************************************************/ @@ -140,8 +151,8 @@ #define UIP_CONF_TCP 0 #undef QUEUEBUF_CONF_NUM #define QUEUEBUF_CONF_NUM 3 -#undef UIP_CONF_MAX_ROUTES -#define UIP_CONF_MAX_ROUTES 8 +#undef RPL_NS_CONF_LINK_NUM +#define RPL_NS_CONF_LINK_NUM 8 #undef NBR_TABLE_CONF_MAX_NEIGHBORS #define NBR_TABLE_CONF_MAX_NEIGHBORS 8 #undef UIP_CONF_ND6_SEND_NA diff --git a/regression-tests/11-ipv6/19-z1-rpl-tsch.csc b/regression-tests/11-ipv6/19-z1-rpl-tsch.csc index 7488e8c3b..3a679a140 100644 --- a/regression-tests/11-ipv6/19-z1-rpl-tsch.csc +++ b/regression-tests/11-ipv6/19-z1-rpl-tsch.csc @@ -272,7 +272,7 @@ make node.z1 TARGET=z1 MAKE_WITH_ORCHESTRA=0 MAKE_WITH_SECURITY=0 /* Wait until a node (can only be the DAGRoot) has * 8 routing entries (i.e. can reach every node) */ log.log("Waiting for routing tables to fill\n"); -WAIT_UNTIL(msg.endsWith("Routing entries (8 in total):")); +WAIT_UNTIL(msg.endsWith("Routing links (8 in total):")); log.log("Root routing table ready\n"); log.testOK(); /* Report test success and quit */ diff --git a/regression-tests/11-ipv6/20-z1-rpl-tsch-orchestra.csc b/regression-tests/11-ipv6/20-z1-rpl-tsch-orchestra.csc index 3fecd2040..9c8c19b5b 100644 --- a/regression-tests/11-ipv6/20-z1-rpl-tsch-orchestra.csc +++ b/regression-tests/11-ipv6/20-z1-rpl-tsch-orchestra.csc @@ -277,7 +277,7 @@ log.log("Orchestra started\n"); /* Wait until a node (can only be the DAGRoot) has * 8 routing entries (i.e. can reach every node) */ log.log("Waiting for routing tables to fill\n"); -WAIT_UNTIL(msg.endsWith("Routing entries (8 in total):")); +WAIT_UNTIL(msg.endsWith("Routing links (8 in total):")); log.log("Root routing table ready\n"); log.testOK(); /* Report test success and quit */ diff --git a/regression-tests/11-ipv6/21-z1-rpl-tsch-security.csc b/regression-tests/11-ipv6/21-z1-rpl-tsch-security.csc index e2cda7e44..a5924fb88 100644 --- a/regression-tests/11-ipv6/21-z1-rpl-tsch-security.csc +++ b/regression-tests/11-ipv6/21-z1-rpl-tsch-security.csc @@ -274,7 +274,7 @@ log.log("Waiting for association with security\n"); /* Wait until a node (can only be the DAGRoot) has * 8 routing entries (i.e. can reach every node) */ log.log("Waiting for routing tables to fill\n"); -WAIT_UNTIL(msg.endsWith("Routing entries (8 in total):")); +WAIT_UNTIL(msg.endsWith("Routing links (8 in total):")); log.log("Root routing table ready\n"); log.testOK(); /* Report test success and quit */