From 0eae63b29a9b54e6f00c17b9682a37733796bfe7 Mon Sep 17 00:00:00 2001 From: nvt-se Date: Fri, 19 Mar 2010 16:55:29 +0000 Subject: [PATCH] Set a higher start ETX. Avoiding adding a neighbor after a failed packet transmission. --- core/net/neighbor-info.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/net/neighbor-info.c b/core/net/neighbor-info.c index 298fa9420..1bf37acae 100644 --- a/core/net/neighbor-info.c +++ b/core/net/neighbor-info.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * $Id: neighbor-info.c,v 1.3 2010/03/17 15:08:46 nvt-se Exp $ + * $Id: neighbor-info.c,v 1.4 2010/03/19 16:55:29 nvt-se Exp $ */ /** * \file @@ -56,7 +56,7 @@ #define ETX_SCALE 100 #define ETX_ALPHA 60 -#define ETX_FIRST_GUESS 1 +#define ETX_FIRST_GUESS (ETX_LIMIT - 1) #define ETX_COLLISION_PENALTY 5 #define ETX_NO_ACK_PENALTY (ETX_LIMIT + 1) /*---------------------------------------------------------------------------*/ @@ -77,6 +77,7 @@ update_etx(const rimeaddr_t *dest, int packet_etx) recorded_etx = *etxp; } + /* Update the EWMA of the ETX for the neighbor. */ new_etx = (ETX_SCALE / 2 + ETX_ALPHA * recorded_etx + (ETX_SCALE - ETX_ALPHA) * packet_etx) / ETX_SCALE; PRINTF("neighbor-info: ETX changed from %d to %d (packet ETX = %d)\n", @@ -85,7 +86,7 @@ update_etx(const rimeaddr_t *dest, int packet_etx) if(new_etx > ETX_LIMIT) { neighbor_attr_remove_neighbor(dest); subscriber_callback(dest, 0, new_etx); - } else { + } else if(neighbor_attr_has_neighbor(dest)) { neighbor_attr_set_data(&etx, dest, &new_etx); if(new_etx != recorded_etx && subscriber_callback != NULL) { subscriber_callback(dest, 1, new_etx);