All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
neighbor.h File Reference

Records statistics about link layer neighbors. More...

Detailed Description

Records statistics about link layer neighbors.

Neighbor stats definitions

Author
Koen Zandberg koen@.nosp@m.berg.nosp@m.zand..nosp@m.net

Definition in file neighbor.h.

#include <string.h>
#include "net/netif.h"
#include "timex.h"
+ Include dependency graph for neighbor.h:

Go to the source code of this file.

Functions

void netstats_nb_init (netif_t *netif)
 Initialize the neighbor stats.
 
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.
 
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_tnetstats_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_tnetstats_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.
 
bool netstats_nb_isfresh (netif_t *netif, netstats_nb_t *stats)
 Check if a record is fresh.
 

@ref EWMA parameters

#define NETSTATS_NB_EWMA_SCALE   100
 Multiplication factor of the EWMA.
 
#define NETSTATS_NB_EWMA_ALPHA   15
 Alpha factor of the EWMA.
 
#define NETSTATS_NB_EWMA_ALPHA_RAMP   30
 Alpha factor of the EWMA when stats are not fresh.
 

@ref ETX parameters

#define NETSTATS_NB_ETX_NOACK_PENALTY   6
 ETX penalty for not receiving any ACK.
 
#define NETSTATS_NB_ETX_DIVISOR   128
 ETX fixed point divisor (rfc 6551)
 
#define NETSTATS_NB_ETX_INIT   2
 Initial ETX, assume a mediocre link.
 

@ref Freshness parameters

#define NETSTATS_NB_FRESHNESS_HALF   600
 seconds after the freshness counter is halved
 
#define NETSTATS_NB_FRESHNESS_TARGET   4
 freshness count needed before considering the statistics fresh
 
#define NETSTATS_NB_FRESHNESS_MAX   16
 Maximum freshness.
 
#define NETSTATS_NB_FRESHNESS_EXPIRATION   1200
 seconds after statistics have expired
 

@ref Timeout Parameters

#define NETSTATS_NB_TX_TIMEOUT_MS   100
 milliseconds without TX done notification after which a TX event is discarded
 
enum  netstats_nb_result_t { NETSTATS_NB_BUSY , NETSTATS_NB_NOACK , NETSTATS_NB_SUCCESS }
 Result of the transmission. More...
 

Macro Definition Documentation

◆ NETSTATS_NB_ETX_DIVISOR

#define NETSTATS_NB_ETX_DIVISOR   128

ETX fixed point divisor (rfc 6551)

Definition at line 72 of file neighbor.h.

◆ NETSTATS_NB_ETX_INIT

#define NETSTATS_NB_ETX_INIT   2

Initial ETX, assume a mediocre link.

Definition at line 76 of file neighbor.h.

◆ NETSTATS_NB_ETX_NOACK_PENALTY

#define NETSTATS_NB_ETX_NOACK_PENALTY   6

ETX penalty for not receiving any ACK.

Definition at line 68 of file neighbor.h.

◆ NETSTATS_NB_EWMA_ALPHA

#define NETSTATS_NB_EWMA_ALPHA   15

Alpha factor of the EWMA.

Definition at line 53 of file neighbor.h.

◆ NETSTATS_NB_EWMA_ALPHA_RAMP

#define NETSTATS_NB_EWMA_ALPHA_RAMP   30

Alpha factor of the EWMA when stats are not fresh.

Definition at line 58 of file neighbor.h.

◆ NETSTATS_NB_EWMA_SCALE

#define NETSTATS_NB_EWMA_SCALE   100

Multiplication factor of the EWMA.

Definition at line 48 of file neighbor.h.

◆ NETSTATS_NB_FRESHNESS_EXPIRATION

#define NETSTATS_NB_FRESHNESS_EXPIRATION   1200

seconds after statistics have expired

Definition at line 98 of file neighbor.h.

◆ NETSTATS_NB_FRESHNESS_HALF

#define NETSTATS_NB_FRESHNESS_HALF   600

seconds after the freshness counter is halved

Definition at line 86 of file neighbor.h.

◆ NETSTATS_NB_FRESHNESS_MAX

#define NETSTATS_NB_FRESHNESS_MAX   16

Maximum freshness.

Definition at line 94 of file neighbor.h.

◆ NETSTATS_NB_FRESHNESS_TARGET

#define NETSTATS_NB_FRESHNESS_TARGET   4

freshness count needed before considering the statistics fresh

Definition at line 90 of file neighbor.h.

◆ NETSTATS_NB_TX_TIMEOUT_MS

#define NETSTATS_NB_TX_TIMEOUT_MS   100

milliseconds without TX done notification after which a TX event is discarded

Definition at line 108 of file neighbor.h.

Enumeration Type Documentation

◆ netstats_nb_result_t

Result of the transmission.

Enumerator
NETSTATS_NB_BUSY 

Failed due to medium busy.

NETSTATS_NB_NOACK 

Failed due to no ack received.

NETSTATS_NB_SUCCESS 

Successful transmission.

Definition at line 34 of file neighbor.h.

Function Documentation

◆ netstats_nb_get()

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.

Parameters
[in]netifnetwork interface descriptor
[in]l2_addrpointer to the L2 address
[in]lenlength of the L2 address
[out]outdestination for the matching neighbor entry
Returns
true if a matching peer was found, false otherwise

◆ netstats_nb_init()

void netstats_nb_init ( netif_t * netif)

Initialize the neighbor stats.

Parameters
[in]netifnetwork interface descriptor

◆ netstats_nb_isfresh()

bool netstats_nb_isfresh ( netif_t * netif,
netstats_nb_t * stats )

Check if a record is fresh.

Freshness half time is checked and updated before verifying freshness.

Parameters
[in]netifnetwork interface the statistic belongs to
[in]statspointer to the statistic

◆ netstats_nb_record()

void netstats_nb_record ( netif_t * netif,
const uint8_t * l2_addr,
uint8_t len )

Store this neighbor as next in the transmission queue.

Set len to zero if a nop record is needed, for example if the transmission has a multicast address as a destination.

Parameters
[in]netifnetwork interface descriptor
[in]l2_addrpointer to the L2 address
[in]lenlength of the L2 address

◆ netstats_nb_update_rx()

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.

Parameters
[in]netifnetwork interface descriptor
[in]l2_addrpointer to the L2 address
[in]l2_addr_lenlength of the L2 address
[in]rssiRSSI of the received transmission in abs([dBm])
[in]lqiLink Quality Indication provided by the radio
Returns
pointer to the updated record

◆ netstats_nb_update_tx()

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.

This only increments the statistics if the length of the l2-address of the retrieved record is non-zero. See also netstats_nb_record. The numbers indicate the number of transmissions the radio had to perform before a successful transmission was performed. For example: in the case of a single send operation needing 3 tries before an ACK was received, there are 2 failed transmissions and 1 successful transmission.

Parameters
[in]netifnetwork interface descriptor
[in]resultResult of the transmission
[in]transmissionsNumber of times the packet was sent over the air
Returns
pointer to the record