TSCH: use sequence number only for unicast data frames

This commit is contained in:
Simon Duquennoy 2016-06-23 18:25:52 +02:00 committed by Simon Duquennoy
parent f1922c13b6
commit beb532e7e8
4 changed files with 14 additions and 20 deletions

View file

@ -86,14 +86,16 @@ create_frame(int type, int do_create)
params.fcf.frame_pending = packetbuf_attr(PACKETBUF_ATTR_PENDING);
if(packetbuf_holds_broadcast()) {
params.fcf.ack_required = 0;
/* Suppress seqno on broadcast if supported (frame v2 or more) */
params.fcf.sequence_number_suppression = FRAME802154_VERSION >= FRAME802154_IEEE802154E_2012;
} else {
params.fcf.ack_required = packetbuf_attr(PACKETBUF_ATTR_MAC_ACK);
params.fcf.sequence_number_suppression = FRAME802154_SUPPR_SEQNO;
}
/* We do not compress PAN ID in outgoing frames, i.e. include one PAN ID (dest by default)
* There is one exception, seemingly a typo in Table 2a: rows 2 and 3: when there is no
* source nor destination address, we have dest PAN ID iff compression is *set*. */
params.fcf.panid_compression = 0;
params.fcf.sequence_number_suppression = FRAME802154_SUPPR_SEQNO;
/* Insert IEEE 802.15.4 version bits. */
params.fcf.frame_version = FRAME802154_VERSION;

View file

@ -189,7 +189,7 @@ tsch_packet_parse_eack(const uint8_t *buf, int buf_size,
/*---------------------------------------------------------------------------*/
/* Create an EB packet */
int
tsch_packet_create_eb(uint8_t *buf, int buf_size, uint8_t seqno,
tsch_packet_create_eb(uint8_t *buf, int buf_size,
uint8_t *hdr_len, uint8_t *tsch_sync_ie_offset)
{
int ret = 0;
@ -210,8 +210,7 @@ tsch_packet_create_eb(uint8_t *buf, int buf_size, uint8_t seqno,
p.fcf.frame_version = FRAME802154_IEEE802154E_2012;
p.fcf.src_addr_mode = FRAME802154_LONGADDRMODE;
p.fcf.dest_addr_mode = FRAME802154_SHORTADDRMODE;
p.seq = seqno;
p.fcf.sequence_number_suppression = FRAME802154_SUPPR_SEQNO;
p.fcf.sequence_number_suppression = 1;
/* It is important not to compress PAN ID, as this would result in not including either
* source nor destination PAN ID, leaving potential joining devices unaware of the PAN ID. */
p.fcf.panid_compression = 0;

View file

@ -94,7 +94,7 @@ int tsch_packet_parse_eack(const uint8_t *buf, int buf_size,
uint8_t seqno, frame802154_t *frame, struct ieee802154_ies *ies, uint8_t *hdr_len);
/* Create an EB packet */
int tsch_packet_create_eb(uint8_t *buf, int buf_size,
uint8_t seqno, uint8_t *hdr_len, uint8_t *tsch_sync_ie_ptr);
uint8_t *hdr_len, uint8_t *tsch_sync_ie_ptr);
/* Update ASN in EB packet */
int tsch_packet_update_eb(uint8_t *buf, int buf_size, uint8_t tsch_sync_ie_offset);
/* Parse EB and extract ASN and join priority */

View file

@ -134,7 +134,7 @@ struct asn_t current_asn;
/* Device rank or join priority:
* For PAN coordinator: 0 -- lower is better */
uint8_t tsch_join_priority;
/* The current TSCH sequence number, used for both data and EBs */
/* The current TSCH sequence number, used for unicast data frames only */
static uint8_t tsch_packet_seqno = 0;
/* Current period for EB output */
static clock_time_t tsch_current_eb_period;
@ -728,12 +728,7 @@ PROCESS_THREAD(tsch_send_eb_process, ev, data)
uint8_t tsch_sync_ie_offset;
/* Prepare the EB packet and schedule it to be sent */
packetbuf_clear();
/* We don't use seqno 0 */
if(++tsch_packet_seqno == 0) {
tsch_packet_seqno++;
}
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_TYPE, FRAME802154_BEACONFRAME);
packetbuf_set_attr(PACKETBUF_ATTR_MAC_SEQNO, tsch_packet_seqno);
#if LLSEC802154_ENABLED
if(tsch_is_pan_secured) {
/* Set security level, key id and index */
@ -743,7 +738,7 @@ PROCESS_THREAD(tsch_send_eb_process, ev, data)
}
#endif /* LLSEC802154_ENABLED */
eb_len = tsch_packet_create_eb(packetbuf_dataptr(), PACKETBUF_SIZE,
tsch_packet_seqno, &hdr_len, &tsch_sync_ie_offset);
&hdr_len, &tsch_sync_ie_offset);
if(eb_len != 0) {
struct tsch_packet *p;
packetbuf_set_datalen(eb_len);
@ -876,14 +871,14 @@ send_packet(mac_callback_t sent, void *ptr)
return;
}
/* PACKETBUF_ATTR_MAC_SEQNO cannot be zero, due to a pecuilarity
in framer-802154.c. */
if(++tsch_packet_seqno == 0) {
tsch_packet_seqno++;
}
/* Ask for ACK if we are sending anything other than broadcast */
if(!linkaddr_cmp(addr, &linkaddr_null)) {
/* PACKETBUF_ATTR_MAC_SEQNO cannot be zero, due to a pecuilarity
in framer-802154.c. */
if(++tsch_packet_seqno == 0) {
tsch_packet_seqno++;
}
packetbuf_set_attr(PACKETBUF_ATTR_MAC_SEQNO, tsch_packet_seqno);
packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, 1);
} else {
/* Broadcast packets shall be added to broadcast queue
@ -893,7 +888,6 @@ send_packet(mac_callback_t sent, void *ptr)
}
packetbuf_set_attr(PACKETBUF_ATTR_FRAME_TYPE, FRAME802154_DATAFRAME);
packetbuf_set_attr(PACKETBUF_ATTR_MAC_SEQNO, tsch_packet_seqno);
#if LLSEC802154_ENABLED
if(tsch_is_pan_secured) {
@ -949,7 +943,6 @@ packet_input(void)
/* Check for duplicates */
duplicate = mac_sequence_is_duplicate();
if(duplicate) {
extern clock_time_t duplicate_age;
/* Drop the packet. */
PRINTF("TSCH:! drop dup ll from %u seqno %u\n",
TSCH_LOG_ID_FROM_LINKADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER)),