* Added configurable default number of transmissions for CSMA to use when not specified using packetbuf attributes (CSMA_CONF_MAX_MAC_TRANSMISSIONS).

* Renamed packetbuf attribute PACKETBUF_ATTR_MAX_MAC_REXMIT to PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS where value 0 (attribute not set) means that default number of transmissions should be used.
This commit is contained in:
nifi 2010-03-26 12:29:29 +00:00
parent ce5d19fefd
commit 9508d2c4d7
5 changed files with 30 additions and 11 deletions

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: csma.c,v 1.14 2010/03/09 20:38:55 adamdunkels Exp $
* $Id: csma.c,v 1.15 2010/03/26 12:29:29 nifi Exp $
*/
/**
@ -60,6 +60,19 @@
#define PRINTF(...)
#endif /* DEBUG */
#ifndef CSMA_MAX_MAC_TRANSMISSIONS
#ifdef CSMA_CONF_MAX_MAC_TRANSMISSIONS
#define CSMA_MAX_MAC_TRANSMISSIONS CSMA_CONF_MAX_MAC_TRANSMISSIONS
#else
#define CSMA_MAX_MAC_TRANSMISSIONS 1
#endif /* CSMA_CONF_MAX_MAC_TRANSMISSIONS */
#endif /* CSMA_MAX_MAC_TRANSMISSIONS */
#if CSMA_MAX_MAC_TRANSMISSIONS < 1
#error CSMA_CONF_MAX_MAC_TRANSMISSIONS must be at least 1.
#error Change CSMA_CONF_MAX_MAC_TRANSMISSIONS in contiki-conf.h or in your Makefile.
#endif /* CSMA_CONF_MAX_MAC_TRANSMISSIONS < 1 */
struct queued_packet {
struct queued_packet *next;
struct queuebuf *buf;
@ -179,7 +192,13 @@ send_packet(mac_callback_t sent, void *ptr)
if(q != NULL) {
q->buf = queuebuf_new_from_packetbuf();
if(q != NULL) {
q->max_transmissions = packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_REXMIT) + 1;
if(packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS) == 0) {
/* Use default configuration for max transmissions */
q->max_transmissions = CSMA_MAX_MAC_TRANSMISSIONS;
} else {
q->max_transmissions =
packetbuf_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS);
}
q->transmissions = 0;
q->collisions = 0;
q->deferrals = 0;

View file

@ -33,7 +33,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: collect.c,v 1.42 2010/03/25 08:51:07 adamdunkels Exp $
* $Id: collect.c,v 1.43 2010/03/26 12:29:29 nifi Exp $
*/
/**
@ -277,7 +277,7 @@ send_queued_packet(void)
c->max_rexmits = packetbuf_attr(PACKETBUF_ATTR_MAX_REXMIT);
PRINTF("max_rexmits %d\n", c->max_rexmits);
packetbuf_set_attr(PACKETBUF_ATTR_RELIABLE, 1);
packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_REXMIT, 2);
packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS, 3);
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_ID, c->seqno);
unicast_send(&c->unicast_conn, &n->addr);
rexmit_time_scaling = c->transmissions;
@ -382,7 +382,7 @@ send_ack(struct collect_conn *tc, const rimeaddr_t *to, int congestion, int drop
packetbuf_set_attr(PACKETBUF_ATTR_RELIABLE, 0);
packetbuf_set_attr(PACKETBUF_ATTR_ERELIABLE, 0);
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_ID, packet_seqno);
packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_REXMIT, 2);
packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS, 3);
unicast_send(&tc->unicast_conn, to);
PRINTF("%d.%d: collect: Sending ACK to %d.%d for %d\n",

View file

@ -40,7 +40,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: packetbuf.h,v 1.6 2010/02/28 09:19:43 adamdunkels Exp $
* $Id: packetbuf.h,v 1.7 2010/03/26 12:29:29 nifi Exp $
*/
/**
@ -341,7 +341,7 @@ enum {
PACKETBUF_ATTR_RADIO_TXPOWER,
PACKETBUF_ATTR_LISTEN_TIME,
PACKETBUF_ATTR_TRANSMIT_TIME,
PACKETBUF_ATTR_MAX_MAC_REXMIT,
PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS,
/* Scope 1 attributes: used between two neighbors only. */
PACKETBUF_ATTR_RELIABLE,

View file

@ -34,7 +34,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: runicast.c,v 1.11 2010/03/19 13:21:59 adamdunkels Exp $
* $Id: runicast.c,v 1.12 2010/03/26 12:29:29 nifi Exp $
*/
/**
@ -233,7 +233,7 @@ runicast_send(struct runicast_conn *c, const rimeaddr_t *receiver,
packetbuf_set_attr(PACKETBUF_ATTR_RELIABLE, 1);
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_TYPE, PACKETBUF_ATTR_PACKET_TYPE_DATA);
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_ID, c->sndnxt);
packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_REXMIT, 2);
packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS, 3);
c->max_rxmit = max_retransmissions;
c->rxmit = 0;
c->is_tx = 1;

View file

@ -32,7 +32,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: sicslowpan.c,v 1.33 2010/03/26 10:28:52 joxe Exp $
* $Id: sicslowpan.c,v 1.34 2010/03/26 12:29:29 nifi Exp $
*/
/**
* \file
@ -1342,7 +1342,7 @@ output(uip_lladdr_t *localdest)
packetbuf_clear();
rime_ptr = packetbuf_dataptr();
packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_REXMIT, 2);
packetbuf_set_attr(PACKETBUF_ATTR_MAX_MAC_TRANSMISSIONS, 3);
if(UIP_IP_BUF->proto == UIP_PROTO_TCP) {
/* packetbuf_set_attr(PACKETBUF_ATTR_PACKET_TYPE,