From ae88ed04f13250fe9c543f1fa6cc0ffadfefbcd8 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Sun, 3 Oct 2010 20:37:32 +0000 Subject: [PATCH] Moved the definition of the channel check rate used by the radio duty cycling layer. This definition was previously held in net/mac/mac.h, with the name MAC_CONF_CHANNEL_CHECK_RATE. But since the rate is used by the radio duty cycling layer, it makes more sense to change its name to reflect this. Also, the configuration option should be tied to the netstack configuration instead. So the new configuration option is called NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE. --- core/net/mac/csma.c | 12 ++++++------ core/net/mac/cxmac.c | 4 ++-- core/net/mac/lpp.c | 4 ++-- core/net/mac/mac.h | 14 +------------- core/net/netstack.h | 16 +++++++++++++++- 5 files changed, 26 insertions(+), 24 deletions(-) diff --git a/core/net/mac/csma.c b/core/net/mac/csma.c index 2c9c93269..3f8a7ca2a 100644 --- a/core/net/mac/csma.c +++ b/core/net/mac/csma.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: csma.c,v 1.19 2010/06/16 10:08:30 nifi Exp $ + * $Id: csma.c,v 1.20 2010/10/03 20:37:32 adamdunkels Exp $ */ /** @@ -96,7 +96,7 @@ retransmit_packet(void *ptr) struct queued_packet *q = ptr; queuebuf_to_packetbuf(q->buf); - PRINTF("csma: resending number %d\n", q->transmissions); + PRINTF("csma: resending number %d %p\n", q->transmissions, q); NETSTACK_RDC.send(packet_sent, q); } /*---------------------------------------------------------------------------*/ @@ -159,16 +159,16 @@ packet_sent(void *ptr, int status, int num_transmissions) does not turn the radio off), we make the retransmission time proportional to the configured MAC channel check rate. */ if(time == 0) { - time = CLOCK_SECOND / MAC_CHANNEL_CHECK_RATE; + time = CLOCK_SECOND / NETSTACK_RDC_CHANNEL_CHECK_RATE; } /* The retransmission time uses a linear backoff so that the interval between the transmissions increase with each retransmit. */ time = time + (random_rand() % ((q->transmissions + 1) * 3 * time)); - - if(q->transmissions < q->max_transmissions) { - PRINTF("csma: retransmitting with time %lu\n", time); + + if(q->transmissions + q->collisions < q->max_transmissions) { + PRINTF("csma: retransmitting with time %lu %p\n", time, q); ctimer_set(&q->retransmit_timer, time, retransmit_packet, q); } else { diff --git a/core/net/mac/cxmac.c b/core/net/mac/cxmac.c index a346268d5..d01750156 100644 --- a/core/net/mac/cxmac.c +++ b/core/net/mac/cxmac.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: cxmac.c,v 1.14 2010/08/01 21:18:07 dak664 Exp $ + * $Id: cxmac.c,v 1.15 2010/10/03 20:37:32 adamdunkels Exp $ */ /** @@ -114,7 +114,7 @@ struct cxmac_hdr { #ifdef CXMAC_CONF_OFF_TIME #define DEFAULT_OFF_TIME (CXMAC_CONF_OFF_TIME) #else -#define DEFAULT_OFF_TIME (RTIMER_ARCH_SECOND / MAC_CHANNEL_CHECK_RATE - DEFAULT_ON_TIME) +#define DEFAULT_OFF_TIME (RTIMER_ARCH_SECOND / NETSTACK_RDC_CHANNEL_CHECK_RATE - DEFAULT_ON_TIME) #endif #define DEFAULT_PERIOD (DEFAULT_OFF_TIME + DEFAULT_ON_TIME) diff --git a/core/net/mac/lpp.c b/core/net/mac/lpp.c index 65415e022..64f948680 100644 --- a/core/net/mac/lpp.c +++ b/core/net/mac/lpp.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: lpp.c,v 1.36 2010/06/15 19:22:25 adamdunkels Exp $ + * $Id: lpp.c,v 1.37 2010/10/03 20:37:32 adamdunkels Exp $ */ /** @@ -83,7 +83,7 @@ #define WITH_STREAMING 1 #define LISTEN_TIME (CLOCK_SECOND / 128) -#define OFF_TIME (CLOCK_SECOND / MAC_CHANNEL_CHECK_RATE - LISTEN_TIME) +#define OFF_TIME (CLOCK_SECOND / NETSTACK_RDC_CHANNEL_CHECK_RATE - LISTEN_TIME) #define PACKET_LIFETIME (LISTEN_TIME + OFF_TIME) #define UNICAST_TIMEOUT (1 * PACKET_LIFETIME) diff --git a/core/net/mac/mac.h b/core/net/mac/mac.h index f464d0bbb..2e0fd83d1 100644 --- a/core/net/mac/mac.h +++ b/core/net/mac/mac.h @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: mac.h,v 1.13 2010/02/28 20:18:30 adamdunkels Exp $ + * $Id: mac.h,v 1.14 2010/10/03 20:37:32 adamdunkels Exp $ */ /** @@ -98,17 +98,5 @@ enum { error will be fatal then as well. */ MAC_TX_ERR_FATAL, }; -#ifndef MAC_CHANNEL_CHECK_RATE -#ifdef MAC_CONF_CHANNEL_CHECK_RATE -#define MAC_CHANNEL_CHECK_RATE MAC_CONF_CHANNEL_CHECK_RATE -#else /* MAC_CONF_CHANNEL_CHECK_RATE */ -#define MAC_CHANNEL_CHECK_RATE 4 -#endif /* MAC_CONF_CHANNEL_CHECK_RATE */ -#endif /* MAC_CHANNEL_CHECK_RATE */ - -#if (MAC_CHANNEL_CHECK_RATE & (MAC_CHANNEL_CHECK_RATE - 1)) != 0 -#error MAC_CONF_CHANNEL_CHECK_RATE must be a power of two (i.e., 1, 2, 4, 8, 16, 32, 64, ...). -#error Change MAC_CONF_CHANNEL_CHECK_RATE in contiki-conf.h or in your Makefile. -#endif #endif /* __MAC_H__ */ diff --git a/core/net/netstack.h b/core/net/netstack.h index 1e67869ab..775e237f7 100644 --- a/core/net/netstack.h +++ b/core/net/netstack.h @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: netstack.h,v 1.5 2010/03/01 13:30:21 nifi Exp $ + * $Id: netstack.h,v 1.6 2010/10/03 20:37:32 adamdunkels Exp $ */ /** @@ -67,6 +67,20 @@ #endif /* NETSTACK_CONF_RDC */ #endif /* NETSTACK_RDC */ +#ifndef NETSTACK_RDC_CHANNEL_CHECK_RATE +#ifdef NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE +#define NETSTACK_RDC_CHANNEL_CHECK_RATE NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE +#else /* NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE */ +#define NETSTACK_RDC_CHANNEL_CHECK_RATE 4 +#endif /* NETSTACK_CONF_RDC_CHANNEL_CHECK_RATE */ +#endif /* NETSTACK_RDC_CHANNEL_CHECK_RATE */ + +#if (NETSTACK_RDC_CHANNEL_CHECK_RATE & (NETSTACK_RDC_CHANNEL_CHECK_RATE - 1)) != 0 +#error NETSTACK_RDC_CONF_CHANNEL_CHECK_RATE must be a power of two (i.e., 1, 2, 4, 8, 16, 32, 64, ...). +#error Change NETSTACK_RDC_CONF_CHANNEL_CHECK_RATE in contiki-conf.h, project-conf.h or in your Makefile. +#endif + + #ifndef NETSTACK_RADIO #ifdef NETSTACK_CONF_RADIO #define NETSTACK_RADIO NETSTACK_CONF_RADIO