From 74f1754d88a5a05bdecf09041f17ad0e4695e7ec Mon Sep 17 00:00:00 2001 From: Adam Dunkels Date: Wed, 13 Apr 2011 14:10:39 +0200 Subject: [PATCH] Bugfix: energy consumption for retransmissions was miscounted --- core/net/mac/csma.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/net/mac/csma.c b/core/net/mac/csma.c index 6a82e3717..e2776e35d 100644 --- a/core/net/mac/csma.c +++ b/core/net/mac/csma.c @@ -241,6 +241,13 @@ packet_sent(void *ptr, int status, int num_transmissions) PRINTF("csma: retransmitting with time %lu %p\n", time, q); ctimer_set(&transmit_timer, time, transmit_queued_packet, NULL); + + /* This is needed to correctly attribute energy that we spent + transmitting this packet. */ + q = list_head(queued_packet_list); + queuebuf_free(q->buf); + q->buf = queuebuf_new_from_packetbuf(); + } else { PRINTF("csma: drop with status %d after %d transmissions, %d collisions\n", status, q->transmissions, q->collisions);