From 0aa36eaa0a02e634d17e19be73441477a521cc2c Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 4 Mar 2016 15:07:40 +0100 Subject: [PATCH 1/4] TSCH: explicitly turn radio off after ACK tx --- core/net/mac/tsch/tsch-slot-operation.c | 1 + 1 file changed, 1 insertion(+) diff --git a/core/net/mac/tsch/tsch-slot-operation.c b/core/net/mac/tsch/tsch-slot-operation.c index 3174787c2..c632549dd 100644 --- a/core/net/mac/tsch/tsch-slot-operation.c +++ b/core/net/mac/tsch/tsch-slot-operation.c @@ -776,6 +776,7 @@ PT_THREAD(tsch_rx_slot(struct pt *pt, struct rtimer *t)) packet_duration + tsch_timing[tsch_ts_tx_ack_delay] - RADIO_DELAY_BEFORE_TX, "RxBeforeAck"); TSCH_DEBUG_RX_EVENT(); NETSTACK_RADIO.transmit(ack_len); + NETSTACK_RADIO.off(); } /* If the sender is a time source, proceed to clock drift compensation */ From 0fd097f8218be2be8b4cd85e1d0c2de1171b4dda Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 4 Mar 2016 15:08:51 +0100 Subject: [PATCH 2/4] TSCH: bound max packet size to the system's packetbuf size --- core/net/mac/tsch/tsch-packet.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/net/mac/tsch/tsch-packet.h b/core/net/mac/tsch/tsch-packet.h index 24f533a88..c48bd479b 100644 --- a/core/net/mac/tsch/tsch-packet.h +++ b/core/net/mac/tsch/tsch-packet.h @@ -36,6 +36,7 @@ /********** Includes **********/ #include "contiki.h" +#include "net/packetbuf.h" #include "net/mac/tsch/tsch-private.h" #include "net/mac/frame802154.h" #include "net/mac/frame802154e-ie.h" @@ -81,7 +82,7 @@ by default, useful in case of duplicate seqno */ /********** Constants *********/ /* Max TSCH packet lenght */ -#define TSCH_PACKET_MAX_LEN 127 +#define TSCH_PACKET_MAX_LEN MIN(127,PACKETBUF_SIZE) /********** Functions *********/ From 4b4ea36e9b4e8bd6eef939740aa35c62b74b98c2 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 8 Mar 2016 17:11:42 +0100 Subject: [PATCH 3/4] TSCH: substract RADIO_DELAY_BEFORE_DETECT from ACK timestamp (more accurate timeout for the following busy wait) --- core/net/mac/tsch/tsch-slot-operation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/net/mac/tsch/tsch-slot-operation.c b/core/net/mac/tsch/tsch-slot-operation.c index c632549dd..befd5a18f 100644 --- a/core/net/mac/tsch/tsch-slot-operation.c +++ b/core/net/mac/tsch/tsch-slot-operation.c @@ -506,7 +506,7 @@ PT_THREAD(tsch_tx_slot(struct pt *pt, struct rtimer *t)) tx_start_time, tx_duration + tsch_timing[tsch_ts_rx_ack_delay] + tsch_timing[tsch_ts_ack_wait]); TSCH_DEBUG_TX_EVENT(); - ack_start_time = RTIMER_NOW(); + ack_start_time = RTIMER_NOW() - RADIO_DELAY_BEFORE_DETECT; /* Wait for ACK to finish */ BUSYWAIT_UNTIL_ABS(!NETSTACK_RADIO.receiving_packet(), From 3057cb3363d2456ecd04e61cd4da2ff60b05fe0f Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 15 Mar 2016 16:10:01 +0100 Subject: [PATCH 4/4] TSCH: reset now also flushes all queues and resets backoff exponents --- core/net/mac/tsch/tsch-queue.c | 6 +++++- core/net/mac/tsch/tsch-queue.h | 4 ++-- core/net/mac/tsch/tsch.c | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/net/mac/tsch/tsch-queue.c b/core/net/mac/tsch/tsch-queue.c index afe868030..1fdf04232 100644 --- a/core/net/mac/tsch/tsch-queue.c +++ b/core/net/mac/tsch/tsch-queue.c @@ -302,14 +302,17 @@ tsch_queue_free_packet(struct tsch_packet *p) /*---------------------------------------------------------------------------*/ /* Flush all neighbor queues */ void -tsch_queue_flush_all(void) +tsch_queue_reset(void) { /* Deallocate unneeded neighbors */ if(!tsch_is_locked()) { struct tsch_neighbor *n = list_head(neighbor_list); while(n != NULL) { struct tsch_neighbor *next_n = list_item_next(n); + /* Flush queue */ tsch_queue_flush_nbr_queue(n); + /* Reset backoff exponent */ + tsch_queue_backoff_reset(n); n = next_n; } } @@ -379,6 +382,7 @@ tsch_queue_get_packet_for_dest_addr(const linkaddr_t *addr, struct tsch_link *li } return NULL; } +/*---------------------------------------------------------------------------*/ /* Returns the head packet of any neighbor queue with zero backoff counter. * Writes pointer to the neighbor in *n */ struct tsch_packet * diff --git a/core/net/mac/tsch/tsch-queue.h b/core/net/mac/tsch/tsch-queue.h index b4061be23..c350ab063 100644 --- a/core/net/mac/tsch/tsch-queue.h +++ b/core/net/mac/tsch/tsch-queue.h @@ -166,8 +166,8 @@ int tsch_queue_packet_count(const linkaddr_t *addr); struct tsch_packet *tsch_queue_remove_packet_from_queue(struct tsch_neighbor *n); /* Free a packet */ void tsch_queue_free_packet(struct tsch_packet *p); -/* Flush all neighbor queues */ -void tsch_queue_flush_all(void); +/* Reset neighbor queues */ +void tsch_queue_reset(void); /* Deallocate neighbors with empty queue */ void tsch_queue_free_unused_neighbors(void); /* Is the neighbor queue empty? */ diff --git a/core/net/mac/tsch/tsch.c b/core/net/mac/tsch/tsch.c index 4e24ea8da..fa92fe8ad 100644 --- a/core/net/mac/tsch/tsch.c +++ b/core/net/mac/tsch/tsch.c @@ -199,8 +199,8 @@ tsch_reset(void) frame802154_set_pan_id(0xffff); /* First make sure pending packet callbacks are sent etc */ process_post_synch(&tsch_pending_events_process, PROCESS_EVENT_POLL, NULL); - /* Empty all neighbor queues */ - /* tsch_queue_flush_all(); */ + /* Reset neighbor queues */ + tsch_queue_reset(); /* Remove unused neighbors */ tsch_queue_free_unused_neighbors(); tsch_queue_update_time_source(NULL);