-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlibp-link-metric.h
76 lines (65 loc) · 2.47 KB
/
libp-link-metric.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/**
* \file
* Header file for the libp link metric
* \author
* Lutando Ngqakaza <lutando.ngqakaza@gmail.com>
*/
#ifndef LIBP_LINK_METRIC_H
#define LIBP_LINK_METRIC_H
#define LIBP_LINK_METRIC_UNIT 8
struct libp_link_metric {
uint32_t children_accumulator;
uint8_t num_children;
uint32_t etx_accumulator;
uint8_t num_estimates;
};
/**
* \brief Initialize a new link
* \param le A pointer to a link metric structure
*
* This function initializes a link metric.
*/
void libp_link_metric_new(struct libp_link_metric *lm);
/**
* \brief Update a link metric when a packet has been sent.
* \param le A pointer to a link metric structure
* \param num_tx The number of times the packet was transmitted before it was ACKed
*
* This function updates a link metric. This function is
* called when a packet has been sent. The function may
* use information from the packet buffer and the packet
* buffer attributes when computing the link metric.
*/
void libp_link_metric_update_tx(struct libp_link_metric *lm,
uint8_t num_tx);
/**
* \brief Update a link metric when a packet has failed to be sent.
* \param le A pointer to a link metric structure
* \param num_tx The number of times the packet was transmitted before it was given up on.
*
* This function updates a link metric. This function is
* called when a packet has been sent. The function may
* use information from the packet buffer and the packet
* buffer attributes when computing the link metric.
*/
void libp_link_metric_update_tx_fail(struct libp_link_metric *lm,
uint8_t num_tx);
/**
* \brief Update a link metric when a packet has been received.
* \param le A pointer to a link metric structure
*
* This function updates a link metric. This function is
* called when a packet has been received. The function
* uses information from the packet buffer and its
* attributes.
*/
void libp_link_metric_update_rx(struct libp_link_metric *lm);
/**
* \brief Compute the link metric metric for a link metric
* \param le A pointer to a link metric structure
* \return The current link metric metric
*
*/
uint16_t libp_link_metric(struct libp_link_metric *lm);
int libp_link_metric_num_metrics(struct libp_link_metric *lm);
#endif