Added MAC-layer duplicate message suppression, which is very helpful when running with duty cycling turned off

This commit is contained in:
adamdunkels 2010-04-05 19:28:07 +00:00
parent f38a3ff06c
commit e06a30fdb0
2 changed files with 20 additions and 4 deletions

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: contikimac.c,v 1.28 2010/04/04 21:01:24 adamdunkels Exp $
* $Id: contikimac.c,v 1.29 2010/04/05 19:28:07 adamdunkels Exp $
*/
/**
@ -192,6 +192,8 @@ static volatile rtimer_clock_t stream_until;
#define MIN(a, b) ((a) < (b)? (a) : (b))
#endif /* MIN */
static int last_received_seqno;
static rimeaddr_t last_received_sender;
/*---------------------------------------------------------------------------*/
static void
@ -862,7 +864,21 @@ input_packet(void)
phase_remove(&phase_list, packetbuf_addr(PACKETBUF_ADDR_SENDER));
}
#endif /* WITH_PHASE_OPTIMIZATION */
/* Check for duplicate packet by comparing the sequence number
of the incoming packet with the last one we saw. */
if(packetbuf_attr(PACKETBUF_ATTR_PACKET_ID) == last_received_seqno &&
rimeaddr_cmp(packetbuf_addr(PACKETBUF_ADDR_SENDER),
&last_received_sender)) {
/* Drop the packet. */
/* printf("Drop duplicate ContikiMAC layer packet\n");*/
return;
}
last_received_seqno = packetbuf_attr(PACKETBUF_ATTR_PACKET_ID);
rimeaddr_copy(&last_received_sender, packetbuf_addr(PACKETBUF_ADDR_SENDER));
#if CONTIKIMAC_CONF_COMPOWER
/* Accumulate the power consumption for the packet reception. */
compower_accumulate(&current_packet);

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: framer-802154.c,v 1.8 2010/04/03 13:28:30 adamdunkels Exp $
* $Id: framer-802154.c,v 1.9 2010/04/05 19:28:07 adamdunkels Exp $
*/
/**
@ -186,7 +186,7 @@ parse(void)
packetbuf_set_addr(PACKETBUF_ADDR_SENDER, (rimeaddr_t *)&frame.src_addr);
packetbuf_set_attr(PACKETBUF_ATTR_PENDING, frame.fcf.frame_pending);
/* packetbuf_set_attr(PACKETBUF_ATTR_RELIABLE, frame.fcf.ack_required);*/
/* packetbuf_set_attr(PACKETBUF_ATTR_PACKET_ID, frame.seq);*/
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_ID, frame.seq);
PRINTF("15.4-IN: %2X", frame.fcf.frame_type);
PRINTADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER));