48 #define INITIAL_LINK_ESTIMATE 16
50 #define COLLECT_LINK_ESTIMATE_ALPHA ((3 * (COLLECT_LINK_ESTIMATE_UNIT)) / 8)
52 #define MAX_ESTIMATES 255
57 #define PRINTF(...) printf(__VA_ARGS__)
69 le->num_estimates = 0;
70 le->etx_accumulator = COLLECT_LINK_ESTIMATE_UNIT;
84 if(le->num_estimates == 0) {
85 le->etx_accumulator = tx * COLLECT_LINK_ESTIMATE_UNIT;
88 if(le->num_estimates < MAX_ESTIMATES) {
92 le->etx_accumulator = (((uint32_t)tx * COLLECT_LINK_ESTIMATE_UNIT) *
93 COLLECT_LINK_ESTIMATE_ALPHA +
94 le->etx_accumulator * (COLLECT_LINK_ESTIMATE_UNIT -
95 COLLECT_LINK_ESTIMATE_ALPHA)) /
96 COLLECT_LINK_ESTIMATE_UNIT;
123 if(le->num_estimates == 0) {
124 return INITIAL_LINK_ESTIMATE * COLLECT_LINK_ESTIMATE_UNIT;
127 return le->etx_accumulator;
134 return le->num_estimates;
void collect_link_estimate_update_tx(struct collect_link_estimate *le, uint8_t tx)
Update a link estimate when a packet has been sent.
Header file for hop-by-hop reliable data collection
#define NULL
The null pointer.
Header file for the Collect link estimate
void collect_link_estimate_new(struct collect_link_estimate *le)
Initialize a new link estimate.
void collect_link_estimate_update_rx(struct collect_link_estimate *n)
Update a link estimate when a packet has been received.
uint16_t collect_link_estimate(struct collect_link_estimate *le)
Compute the link estimate metric for a link estimate.
void collect_link_estimate_update_tx_fail(struct collect_link_estimate *le, uint8_t tx)
Update a link estimate when a packet has failed to be sent.