From 877eb2fbe9a771f7bd26644664ee9afa650bf1e5 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Wed, 31 Mar 2010 11:54:38 +0000 Subject: [PATCH] Fiddled with the timing --- core/net/mac/contikimac.c | 9 +++++---- core/net/mac/phase.c | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/core/net/mac/contikimac.c b/core/net/mac/contikimac.c index e3002ef6e..f1b162a44 100644 --- a/core/net/mac/contikimac.c +++ b/core/net/mac/contikimac.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: contikimac.c,v 1.19 2010/03/30 23:01:32 adamdunkels Exp $ + * $Id: contikimac.c,v 1.20 2010/03/31 11:54:38 adamdunkels Exp $ */ /** @@ -99,7 +99,7 @@ struct announcement_msg { #define CYCLE_TIME (RTIMER_ARCH_SECOND / MAC_CHANNEL_CHECK_RATE) #endif -#define MAX_PHASE_STROBES 8 +#define MAX_PHASE_STROBES 12 #define CCA_COUNT_MAX 2 #define CCA_CHECK_TIME RTIMER_ARCH_SECOND / 8192 @@ -108,7 +108,7 @@ struct announcement_msg { #define STREAM_CCA_COUNT (CYCLE_TIME / (CCA_SLEEP_TIME + CCA_CHECK_TIME) - CCA_COUNT_MAX) -#define GUARD_TIME 3 * CHECK_TIME +#define GUARD_TIME 7 * CHECK_TIME #define INTER_PACKET_INTERVAL RTIMER_ARCH_SECOND / 5000 #define AFTER_ACK_DETECTECT_WAIT_TIME RTIMER_ARCH_SECOND / 1500 @@ -694,7 +694,8 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr) if(len == ACK_LEN) { leds_on(LEDS_BLUE); got_strobe_ack = 1; - encounter_time = last_transmission_time; + // encounter_time = last_transmission_time; + encounter_time = now; break; } else { PRINTF("contikimac: collisions while sending\n"); diff --git a/core/net/mac/phase.c b/core/net/mac/phase.c index 514a4ccf9..7368fcd5c 100644 --- a/core/net/mac/phase.c +++ b/core/net/mac/phase.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: phase.c,v 1.5 2010/03/29 21:50:01 adamdunkels Exp $ + * $Id: phase.c,v 1.6 2010/03/31 11:54:38 adamdunkels Exp $ */ /** @@ -73,7 +73,7 @@ MEMB(phase_memb, struct phase_queueitem, PHASE_QUEUESIZE); /*---------------------------------------------------------------------------*/ void phase_update(const struct phase_list *list, - const rimeaddr_t * neighbor, rtimer_clock_t time, + const rimeaddr_t *neighbor, rtimer_clock_t time, int mac_status) { struct phase *e; @@ -89,7 +89,7 @@ phase_update(const struct phase_list *list, phase (rebooted). We try a number of transmissions to it before we drop it from the phase list. */ if(mac_status == MAC_TX_NOACK) { - printf("phase noacks %d\n", e->noacks); + printf("phase noacks %d to %d.%d\n", e->noacks, neighbor->u8[0], neighbor->u8[1]); e->noacks++; if(e->noacks >= MAX_NOACKS) { list_remove(*list->list, e); @@ -162,7 +162,8 @@ phase_wait(struct phase_list *list, /* printf("neighbor phase 0x%02x (cycle 0x%02x)\n", e->time & (cycle_time - 1), cycle_time);*/ now = RTIMER_NOW(); - wait = (rtimer_clock_t)((e->time - now - e->noacks * cycle_time) & (cycle_time - 1)); + wait = (rtimer_clock_t)((e->time - now - e->noacks * wait_before) & + (cycle_time - 1)); if(wait < wait_before) { wait += cycle_time; }