improved ETX calculation

This commit is contained in:
joxe 2010-10-28 08:54:54 +00:00
parent 0ef1171705
commit 932fed8cc7

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: neighbor-info.c,v 1.16 2010/10/27 00:45:24 nvt-se Exp $
* $Id: neighbor-info.c,v 1.17 2010/10/28 08:54:54 joxe Exp $
*/
/**
* \file
@ -50,8 +50,10 @@
#define ETX_LIMIT 15
#define ETX_SCALE 100
#define ETX_ALPHA 85
#define ETX_FIRST_GUESS 3
#define ETX_ALPHA 90
#define ETX_FIRST_GUESS 5
#define NOACK_PACKET_ETX 8
/*---------------------------------------------------------------------------*/
NEIGHBOR_ATTRIBUTE(uint8_t, etx, NULL);
@ -74,8 +76,9 @@ update_etx(const rimeaddr_t *dest, int packet_etx)
packet_etx = ETX2FIX(packet_etx);
new_etx = ((uint16_t)recorded_etx * ETX_ALPHA +
(uint16_t)packet_etx * (ETX_SCALE - ETX_ALPHA)) / ETX_SCALE;
PRINTF("neighbor-info: ETX changed from %d to %d (packet ETX = %d)\n",
FIX2ETX(recorded_etx), FIX2ETX(new_etx), FIX2ETX(packet_etx));
PRINTF("neighbor-info: ETX changed from %d to %d (packet ETX = %d) %d\n",
FIX2ETX(recorded_etx), FIX2ETX(new_etx), FIX2ETX(packet_etx),
dest->u8[7]);
if(neighbor_attr_has_neighbor(dest)) {
neighbor_attr_set_data(&etx, dest, &new_etx);
@ -123,14 +126,20 @@ neighbor_info_packet_sent(int status, int numtx)
packet_etx = numtx;
add_neighbor(dest);
break;
case MAC_TX_ERR:
case MAC_TX_COLLISION:
packet_etx = numtx;
break;
case MAC_TX_NOACK:
packet_etx = NOACK_PACKET_ETX;
/* error and collissions will not cause high hits ??? */
break;
case MAC_TX_ERR:
default:
packet_etx = ETX_LIMIT;
packet_etx = 0;
break;
}
update_etx(dest, packet_etx);
if (packet_etx > 0) update_etx(dest, packet_etx);
}
/*---------------------------------------------------------------------------*/
void