Don't count collisions as transmissions
This commit is contained in:
parent
f95a6cce85
commit
74da90a06b
1 changed files with 9 additions and 4 deletions
|
@ -28,12 +28,12 @@
|
||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* This file is part of the Contiki operating system.
|
||||||
*
|
*
|
||||||
* $Id: csma.c,v 1.9 2010/02/28 08:35:16 adamdunkels Exp $
|
* $Id: csma.c,v 1.10 2010/02/28 10:07:17 adamdunkels Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file
|
* \file
|
||||||
* A MAC
|
* A Carrier Sense Multiple Access (CSMA) MAC layer
|
||||||
* \author
|
* \author
|
||||||
* Adam Dunkels <adam@sics.se>
|
* Adam Dunkels <adam@sics.se>
|
||||||
*/
|
*/
|
||||||
|
@ -69,6 +69,7 @@ struct queued_packet {
|
||||||
mac_callback_t sent;
|
mac_callback_t sent;
|
||||||
void *cptr;
|
void *cptr;
|
||||||
uint8_t transmissions, max_transmissions;
|
uint8_t transmissions, max_transmissions;
|
||||||
|
uint8_t collisions;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_QUEUED_PACKETS 8
|
#define MAX_QUEUED_PACKETS 8
|
||||||
|
@ -97,7 +98,7 @@ packet_sent(void *ptr, int status, int num_transmissions)
|
||||||
|
|
||||||
sent = q->sent;
|
sent = q->sent;
|
||||||
cptr = q->cptr;
|
cptr = q->cptr;
|
||||||
num_tx = q->transmissions;
|
num_tx = q->transmissions - q->collisions;
|
||||||
|
|
||||||
if(status != MAC_TX_OK) {
|
if(status != MAC_TX_OK) {
|
||||||
switch(status) {
|
switch(status) {
|
||||||
|
@ -178,6 +179,9 @@ sent_packet(void *ptr, int status, int num_transmissions)
|
||||||
/* If the packet couldn't be sent because of a collision or the
|
/* If the packet couldn't be sent because of a collision or the
|
||||||
lack of an ACK, we let the other transmissions get through
|
lack of an ACK, we let the other transmissions get through
|
||||||
before we try again. */
|
before we try again. */
|
||||||
|
if(status == MAC_TX_COLLISION) {
|
||||||
|
q->collisions++;
|
||||||
|
}
|
||||||
time = NETSTACK_RDC.channel_check_interval();
|
time = NETSTACK_RDC.channel_check_interval();
|
||||||
if(time == 0) {
|
if(time == 0) {
|
||||||
time = CLOCK_SECOND;
|
time = CLOCK_SECOND;
|
||||||
|
@ -193,7 +197,7 @@ sent_packet(void *ptr, int status, int num_transmissions)
|
||||||
|
|
||||||
sent = q->sent;
|
sent = q->sent;
|
||||||
cptr = q->cptr;
|
cptr = q->cptr;
|
||||||
num_tx = q->transmissions;
|
num_tx = q->transmissions - q->collisions;
|
||||||
free_packet(q);
|
free_packet(q);
|
||||||
mac_call_sent_callback(sent, cptr, status, num_tx);
|
mac_call_sent_callback(sent, cptr, status, num_tx);
|
||||||
}
|
}
|
||||||
|
@ -211,6 +215,7 @@ send_packet(mac_callback_t sent, void *ptr)
|
||||||
if(q != NULL) {
|
if(q != NULL) {
|
||||||
q->max_transmissions = packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_REXMIT) + 1;
|
q->max_transmissions = packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_REXMIT) + 1;
|
||||||
q->transmissions = 1;
|
q->transmissions = 1;
|
||||||
|
q->collisions = 0;
|
||||||
q->sent = sent;
|
q->sent = sent;
|
||||||
q->cptr = ptr;
|
q->cptr = ptr;
|
||||||
NETSTACK_RDC.send(sent_packet, q);
|
NETSTACK_RDC.send(sent_packet, q);
|
||||||
|
|
Loading…
Reference in a new issue