From 97f76126e6df84012e017f141ae66f26bb3c1cfe Mon Sep 17 00:00:00 2001 From: fros4943 Date: Tue, 17 Feb 2009 12:40:18 +0000 Subject: [PATCH] remembering last received packet id to avoid multiple recv callbacks for the same retransmitted packet (but still sending back acks of course) --- core/net/rime/runicast.c | 15 ++++++++++++--- core/net/rime/runicast.h | 3 ++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/core/net/rime/runicast.c b/core/net/rime/runicast.c index 610c9a72a..c7863337c 100644 --- a/core/net/rime/runicast.c +++ b/core/net/rime/runicast.c @@ -34,7 +34,7 @@ * * This file is part of the Contiki operating system. * - * $Id: runicast.c,v 1.2 2008/07/07 23:27:57 adamdunkels Exp $ + * $Id: runicast.c,v 1.3 2009/02/17 12:40:18 fros4943 Exp $ */ /** @@ -163,9 +163,17 @@ recv_from_stunicast(struct stunicast_conn *stunicast, rimeaddr_t *from) queuebuf_to_rimebuf(q); queuebuf_free(q); - } + } if(c->u->recv != NULL) { - c->u->recv(c, from, packet_seqno); + if (packet_seqno != c->lastrecv) { + c->u->recv(c, from, packet_seqno); + c->lastrecv = packet_seqno; /* remember last received packet */ + } else { + PRINTF("%d.%d: runicast: Supressing duplicate receive callback from %d.%d for %d\n", + rimeaddr_node_addr.u8[0],rimeaddr_node_addr.u8[1], + from->u8[0], from->u8[1], + packet_seqno); + } } } } @@ -181,6 +189,7 @@ runicast_open(struct runicast_conn *c, uint16_t channel, c->u = u; c->rxmit = 0; c->sndnxt = 0; + c->lastrecv = 0xFF; } /*---------------------------------------------------------------------------*/ void diff --git a/core/net/rime/runicast.h b/core/net/rime/runicast.h index 9ad1b700d..6ed70d185 100644 --- a/core/net/rime/runicast.h +++ b/core/net/rime/runicast.h @@ -45,7 +45,7 @@ * * This file is part of the Contiki operating system. * - * $Id: runicast.h,v 1.1 2008/07/03 21:52:25 adamdunkels Exp $ + * $Id: runicast.h,v 1.2 2009/02/17 12:40:18 fros4943 Exp $ */ /** @@ -75,6 +75,7 @@ struct runicast_conn { struct stunicast_conn c; const struct runicast_callbacks *u; uint8_t sndnxt; + uint8_t lastrecv; uint8_t rxmit; uint8_t max_rxmit; };