mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-08-29 13:29:09 +00:00
improved ETX calculation
This commit is contained in:
parent
0ef1171705
commit
932fed8cc7
@ -28,7 +28,7 @@
|
|||||||
*
|
*
|
||||||
* This file is part of the Contiki operating system.
|
* 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
|
* \file
|
||||||
@ -50,8 +50,10 @@
|
|||||||
|
|
||||||
#define ETX_LIMIT 15
|
#define ETX_LIMIT 15
|
||||||
#define ETX_SCALE 100
|
#define ETX_SCALE 100
|
||||||
#define ETX_ALPHA 85
|
#define ETX_ALPHA 90
|
||||||
#define ETX_FIRST_GUESS 3
|
#define ETX_FIRST_GUESS 5
|
||||||
|
|
||||||
|
#define NOACK_PACKET_ETX 8
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
NEIGHBOR_ATTRIBUTE(uint8_t, etx, NULL);
|
NEIGHBOR_ATTRIBUTE(uint8_t, etx, NULL);
|
||||||
|
|
||||||
@ -74,8 +76,9 @@ update_etx(const rimeaddr_t *dest, int packet_etx)
|
|||||||
packet_etx = ETX2FIX(packet_etx);
|
packet_etx = ETX2FIX(packet_etx);
|
||||||
new_etx = ((uint16_t)recorded_etx * ETX_ALPHA +
|
new_etx = ((uint16_t)recorded_etx * ETX_ALPHA +
|
||||||
(uint16_t)packet_etx * (ETX_SCALE - ETX_ALPHA)) / ETX_SCALE;
|
(uint16_t)packet_etx * (ETX_SCALE - ETX_ALPHA)) / ETX_SCALE;
|
||||||
PRINTF("neighbor-info: ETX changed from %d to %d (packet ETX = %d)\n",
|
PRINTF("neighbor-info: ETX changed from %d to %d (packet ETX = %d) %d\n",
|
||||||
FIX2ETX(recorded_etx), FIX2ETX(new_etx), FIX2ETX(packet_etx));
|
FIX2ETX(recorded_etx), FIX2ETX(new_etx), FIX2ETX(packet_etx),
|
||||||
|
dest->u8[7]);
|
||||||
|
|
||||||
if(neighbor_attr_has_neighbor(dest)) {
|
if(neighbor_attr_has_neighbor(dest)) {
|
||||||
neighbor_attr_set_data(&etx, dest, &new_etx);
|
neighbor_attr_set_data(&etx, dest, &new_etx);
|
||||||
@ -123,14 +126,20 @@ neighbor_info_packet_sent(int status, int numtx)
|
|||||||
packet_etx = numtx;
|
packet_etx = numtx;
|
||||||
add_neighbor(dest);
|
add_neighbor(dest);
|
||||||
break;
|
break;
|
||||||
case MAC_TX_ERR:
|
case MAC_TX_COLLISION:
|
||||||
|
packet_etx = numtx;
|
||||||
|
break;
|
||||||
case MAC_TX_NOACK:
|
case MAC_TX_NOACK:
|
||||||
|
packet_etx = NOACK_PACKET_ETX;
|
||||||
|
/* error and collissions will not cause high hits ??? */
|
||||||
|
break;
|
||||||
|
case MAC_TX_ERR:
|
||||||
default:
|
default:
|
||||||
packet_etx = ETX_LIMIT;
|
packet_etx = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
update_etx(dest, packet_etx);
|
if (packet_etx > 0) update_etx(dest, packet_etx);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user