From 666e4263cdc74aa95ac4029358acd2053150c91b Mon Sep 17 00:00:00 2001 From: Takeshi Sakoda Date: Wed, 21 Nov 2018 17:27:20 +0900 Subject: [PATCH 1/4] tsch-rpl: add tsch_rpl_check_dodag_joined function in tsch-rpl. --- os/net/mac/tsch/tsch-rpl.c | 8 ++++++++ os/net/mac/tsch/tsch-rpl.h | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/os/net/mac/tsch/tsch-rpl.c b/os/net/mac/tsch/tsch-rpl.c index 951648d91..e8db94b57 100644 --- a/os/net/mac/tsch/tsch-rpl.c +++ b/os/net/mac/tsch/tsch-rpl.c @@ -136,5 +136,13 @@ tsch_rpl_callback_parent_switch(rpl_parent_t *old, rpl_parent_t *new) rpl_parent_get_ipaddr(new))); } } +/*---------------------------------------------------------------------------*/ +/* Check RPL has joined DODAG. + * To use, set #define TSCH_RPL_CHECK_DODAG_JOINED tsch_rpl_check_dodag_joined */ +int +tsch_rpl_check_dodag_joined(void) +{ + return NETSTACK_ROUTING.node_has_joined(); +} #endif /* UIP_CONF_IPV6_RPL */ /** @} */ diff --git a/os/net/mac/tsch/tsch-rpl.h b/os/net/mac/tsch/tsch-rpl.h index 23a148db8..95412e3d2 100644 --- a/os/net/mac/tsch/tsch-rpl.h +++ b/os/net/mac/tsch/tsch-rpl.h @@ -79,6 +79,12 @@ void tsch_rpl_callback_new_dio_interval(clock_time_t dio_interval); * \param new The new RPL parent */ void tsch_rpl_callback_parent_switch(rpl_parent_t *old, rpl_parent_t *new); +/** + * \brief Check RPL has joined DODAG. + * To use, set TSCH_RPL_CHECK_DODAG_JOINED tsch_rpl_check_dodag_joined + * \return 1 if joined, 0 otherwise + */ +int tsch_rpl_check_dodag_joined(void); #endif /* __TSCH_RPL_H__ */ /** @} */ From 3a1d604418e2a4efe88ad68bf68d893b881d6ee8 Mon Sep 17 00:00:00 2001 From: Takeshi Sakoda Date: Wed, 21 Nov 2018 17:27:35 +0900 Subject: [PATCH 2/4] tsch: add start sending EB when a node joins RPL newwork in tsch. --- os/net/mac/tsch/tsch.c | 9 +++++++++ os/net/mac/tsch/tsch.h | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/os/net/mac/tsch/tsch.c b/os/net/mac/tsch/tsch.c index a33feeef1..bb1018677 100644 --- a/os/net/mac/tsch/tsch.c +++ b/os/net/mac/tsch/tsch.c @@ -862,6 +862,12 @@ PROCESS_THREAD(tsch_send_eb_process, ev, data) unsigned long delay; if(tsch_is_associated && tsch_current_eb_period > 0) { +#ifdef TSCH_RPL_CHECK_DODAG_JOINED + /* Implementation section 6.3 of RFC 8180 */ + if(!TSCH_RPL_CHECK_DODAG_JOINED()) { + goto tsch_send_eb_skipped; + } +#endif /* TSCH_RPL_CHECK_DODAG_JOINED */ /* Enqueue EB only if there isn't already one in queue */ if(tsch_queue_packet_count(&tsch_eb_address) == 0) { uint8_t hdr_len = 0; @@ -881,6 +887,9 @@ PROCESS_THREAD(tsch_send_eb_process, ev, data) } } } +#ifdef TSCH_RPL_CHECK_DODAG_JOINED +tsch_send_eb_skipped: +#endif /* TSCH_RPL_CHECK_DODAG_JOINED */ if(tsch_current_eb_period > 0) { /* Next EB transmission with a random delay * within [tsch_current_eb_period*0.75, tsch_current_eb_period[ */ diff --git a/os/net/mac/tsch/tsch.h b/os/net/mac/tsch/tsch.h index db23b4851..2683d24b1 100644 --- a/os/net/mac/tsch/tsch.h +++ b/os/net/mac/tsch/tsch.h @@ -88,6 +88,10 @@ frequency hopping for enhanced reliability. #define TSCH_CALLBACK_KA_SENT tsch_rpl_callback_ka_sent #endif /* TSCH_CALLBACK_KA_SENT */ +#ifndef TSCH_RPL_CHECK_DODAG_JOINED +#define TSCH_RPL_CHECK_DODAG_JOINED tsch_rpl_check_dodag_joined +#endif /* TSCH_RPL_CHECK_DODAG_JOINED */ + #endif /* UIP_CONF_IPV6_RPL */ #if BUILD_WITH_ORCHESTRA @@ -117,6 +121,11 @@ void TSCH_CALLBACK_LEAVING_NETWORK(); void TSCH_CALLBACK_KA_SENT(); #endif +/* Called by TSCH before sending a EB */ +#ifdef TSCH_RPL_CHECK_DODAG_JOINED +int TSCH_RPL_CHECK_DODAG_JOINED(); +#endif + /* Called by TSCH form interrupt after receiving a frame, enabled upper-layer to decide * whether to ACK or NACK */ #ifdef TSCH_CALLBACK_DO_NACK From 855089af8d4636572d287201917970bb65040c7f Mon Sep 17 00:00:00 2001 From: Takeshi Sakoda Date: Tue, 15 Jan 2019 14:10:59 +0900 Subject: [PATCH 3/4] tsch: fix for https://github.com/contiki-ng/contiki-ng/pull/769#discussion_r247239784 --- os/net/mac/tsch/tsch.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/os/net/mac/tsch/tsch.c b/os/net/mac/tsch/tsch.c index bb1018677..6278ce0dc 100644 --- a/os/net/mac/tsch/tsch.c +++ b/os/net/mac/tsch/tsch.c @@ -861,13 +861,12 @@ PROCESS_THREAD(tsch_send_eb_process, ev, data) while(1) { unsigned long delay; - if(tsch_is_associated && tsch_current_eb_period > 0) { + if(tsch_is_associated && tsch_current_eb_period > 0 #ifdef TSCH_RPL_CHECK_DODAG_JOINED /* Implementation section 6.3 of RFC 8180 */ - if(!TSCH_RPL_CHECK_DODAG_JOINED()) { - goto tsch_send_eb_skipped; - } + && TSCH_RPL_CHECK_DODAG_JOINED() #endif /* TSCH_RPL_CHECK_DODAG_JOINED */ + ) { /* Enqueue EB only if there isn't already one in queue */ if(tsch_queue_packet_count(&tsch_eb_address) == 0) { uint8_t hdr_len = 0; @@ -887,9 +886,6 @@ PROCESS_THREAD(tsch_send_eb_process, ev, data) } } } -#ifdef TSCH_RPL_CHECK_DODAG_JOINED -tsch_send_eb_skipped: -#endif /* TSCH_RPL_CHECK_DODAG_JOINED */ if(tsch_current_eb_period > 0) { /* Next EB transmission with a random delay * within [tsch_current_eb_period*0.75, tsch_current_eb_period[ */ From 87acf4a6459b52740375d33a62bcc611f8931e83 Mon Sep 17 00:00:00 2001 From: Atis Elsts Date: Mon, 18 Feb 2019 16:38:29 +0200 Subject: [PATCH 4/4] 23-rpl-tsch-z1.csc - remove one node that does not like to be routed --- tests/07-simulation-base/23-rpl-tsch-z1.csc | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/tests/07-simulation-base/23-rpl-tsch-z1.csc b/tests/07-simulation-base/23-rpl-tsch-z1.csc index f5a182ecd..170300f55 100644 --- a/tests/07-simulation-base/23-rpl-tsch-z1.csc +++ b/tests/07-simulation-base/23-rpl-tsch-z1.csc @@ -7,7 +7,7 @@ [APPS_DIR]/powertracker RPL+TSCH (Z1) - 123456 + 1 1000000 org.contikios.cooja.radiomediums.UDGM @@ -108,20 +108,6 @@ z11 - - - - org.contikios.cooja.interfaces.Position - 10.622284947035123 - 109.81862399725188 - 0.0 - - - org.contikios.cooja.mspmote.interfaces.MspMoteID - 6 - - z11 - org.contikios.cooja.plugins.SimControl @@ -168,7 +154,6 @@ 2 3 4 - 5