rdc: duplicate packets: Keep only the last sequence number for each address

According to IEEE 802.15.4e (§6.4.3.9), in order to detect duplicate received
MAC-layer frames, only the most recently received frame's sequence number needs
to be stored for each unique device address. Doing so limits the possible false
duplicate packet detections to a single sequence number. This also allows to
keep the last sequence number of more device addresses for the same value of
MAX_SEQNOS.

Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau@advansee.com>
This commit is contained in:
Benoît Thébaudeau 2013-11-15 19:31:02 +01:00
parent 477a4a7178
commit 4deba89f81

View file

@ -72,11 +72,13 @@ mac_sequence_is_duplicate(void)
* packet with the last few ones we saw.
*/
for(i = 0; i < MAX_SEQNOS; ++i) {
if(packetbuf_attr(PACKETBUF_ATTR_PACKET_ID) == received_seqnos[i].seqno &&
rimeaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_SENDER),
if(rimeaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_SENDER),
&received_seqnos[i].sender)) {
/* Duplicate packet. */
return 1;
if(packetbuf_attr(PACKETBUF_ATTR_PACKET_ID) == received_seqnos[i].seqno) {
/* Duplicate packet. */
return 1;
}
break;
}
}
return 0;
@ -85,10 +87,20 @@ mac_sequence_is_duplicate(void)
void
mac_sequence_register_seqno(void)
{
int i;
int i, j;
for(i = MAX_SEQNOS - 1; i > 0; --i) {
memcpy(&received_seqnos[i], &received_seqnos[i - 1], sizeof(struct seqno));
/* Locate possible previous sequence number for this address. */
for(i = 0; i < MAX_SEQNOS; ++i) {
if(rimeaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_SENDER),
&received_seqnos[i].sender)) {
i++;
break;
}
}
/* Keep the last sequence number for each address as per 802.15.4e. */
for(j = i - 1; j > 0; --j) {
memcpy(&received_seqnos[j], &received_seqnos[j - 1], sizeof(struct seqno));
}
received_seqnos[0].seqno = packetbuf_attr(PACKETBUF_ATTR_PACKET_ID);
rimeaddr_copy(&received_seqnos[0].sender,