neighbor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Koen Zandberg <koen@bergzand.net>
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for
6  * more details.
7  */
8 
19 #ifndef NET_NETSTATS_NEIGHBOR_H
20 #define NET_NETSTATS_NEIGHBOR_H
21 
22 #include <string.h>
23 #include "net/netif.h"
24 #include "timex.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
34 typedef enum {
48 #define NETSTATS_NB_EWMA_SCALE 100
49 
53 #define NETSTATS_NB_EWMA_ALPHA 15
54 
58 #define NETSTATS_NB_EWMA_ALPHA_RAMP 30
68 #define NETSTATS_NB_ETX_NOACK_PENALTY 6
72 #define NETSTATS_NB_ETX_DIVISOR 128
76 #define NETSTATS_NB_ETX_INIT 2
86 #define NETSTATS_NB_FRESHNESS_HALF 600
90 #define NETSTATS_NB_FRESHNESS_TARGET 4
94 #define NETSTATS_NB_FRESHNESS_MAX 16
98 #define NETSTATS_NB_FRESHNESS_EXPIRATION 1200
108 #define NETSTATS_NB_TX_TIMEOUT_MS 100
118 
129 bool netstats_nb_get(netif_t *netif, const uint8_t *l2_addr, uint8_t len, netstats_nb_t *out);
130 
142 void netstats_nb_record(netif_t *netif, const uint8_t *l2_addr, uint8_t len);
143 
160  uint8_t transmissions);
161 
173 netstats_nb_t *netstats_nb_update_rx(netif_t *netif, const uint8_t *l2_addr,
174  uint8_t l2_addr_len, uint8_t rssi, uint8_t lqi);
175 
185 
186 #ifdef __cplusplus
187 }
188 #endif
189 
190 #endif /* NET_NETSTATS_NEIGHBOR_H */
bool netstats_nb_isfresh(netif_t *netif, netstats_nb_t *stats)
Check if a record is fresh.
void netstats_nb_init(netif_t *netif)
Initialize the neighbor stats.
void netstats_nb_record(netif_t *netif, const uint8_t *l2_addr, uint8_t len)
Store this neighbor as next in the transmission queue.
netstats_nb_result_t
Result of the transmission.
Definition: neighbor.h:34
@ NETSTATS_NB_NOACK
Failed due to no ack received.
Definition: neighbor.h:36
@ NETSTATS_NB_BUSY
Failed due to medium busy.
Definition: neighbor.h:35
@ NETSTATS_NB_SUCCESS
Successful transmission.
Definition: neighbor.h:37
bool netstats_nb_get(netif_t *netif, const uint8_t *l2_addr, uint8_t len, netstats_nb_t *out)
Find a neighbor stat by the mac address.
netstats_nb_t * netstats_nb_update_tx(netif_t *netif, netstats_nb_result_t result, uint8_t transmissions)
Update the next recorded neighbor with the provided numbers.
netstats_nb_t * netstats_nb_update_rx(netif_t *netif, const uint8_t *l2_addr, uint8_t l2_addr_len, uint8_t rssi, uint8_t lqi)
Record rx stats for the l2_addr.
Common network interface API definitions.
Network interface descriptor.
Definition: netif.h:71
Stats per peer struct.
Definition: netstats.h:76
Utility library for comparing and computing timestamps.