TSCH: before associating on an EB, check that the Rx timestamp is sensible

This commit is contained in:
Simon Duquennoy 2018-10-03 13:16:59 +02:00
parent 17c2158229
commit e6dec9ee4a
1 changed files with 11 additions and 1 deletions

View File

@ -749,16 +749,26 @@ PT_THREAD(tsch_scan(struct pt *pt))
}
if(is_packet_pending) {
rtimer_clock_t t1;
/* Read packet */
input_eb.len = NETSTACK_RADIO.read(input_eb.payload, TSCH_PACKET_MAX_LEN);
/* Save packet timestamp */
NETSTACK_RADIO.get_object(RADIO_PARAM_LAST_PACKET_TIMESTAMP, &t0, sizeof(rtimer_clock_t));
t1 = RTIMER_NOW();
/* Parse EB and attempt to associate */
LOG_INFO("scan: received packet (%u bytes) on channel %u\n", input_eb.len, current_channel);
tsch_associate(&input_eb, t0);
/* Sanity-check the timestamp */
if(ABS(RTIMER_CLOCK_DIFF(t0, t1)) < tsch_timing[tsch_ts_timeslot_length]) {
tsch_associate(&input_eb, t0);
} else {
LOG_WARN("scan: dropping packet, timestamp too far from current time %u %u\n",
(unsigned)t0,
(unsigned)t1
);
}
}
if(tsch_is_associated) {