From 3a1d604418e2a4efe88ad68bf68d893b881d6ee8 Mon Sep 17 00:00:00 2001 From: Takeshi Sakoda Date: Wed, 21 Nov 2018 17:27:35 +0900 Subject: [PATCH] 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