Contiki 3.x
collect-link-estimate.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010, Swedish Institute of Computer Science.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  *
31  */
32 
33 /**
34  * \file
35  * Header file for the Collect link estimate
36  * \author
37  * Adam Dunkels <adam@sics.se>
38  */
39 
40 /**
41  * \addtogroup rime
42  * @{
43  */
44 
45 /**
46  * \defgroup rimelinkestimate Link estimate management
47  *
48  * The link estimate module is used for computing estimations of link
49  * quality. It computes a quality index for links, based on
50  * information about how many times a packet has been transmitted, as
51  * well as information about incoming packets. The link estimate
52  * module exposes an interface that provides functions that are called
53  * for incoming and outgoing packets.
54  */
55 
56 #ifndef COLLECT_LINK_ESTIMATE_H
57 #define COLLECT_LINK_ESTIMATE_H
58 
59 #define COLLECT_LINK_ESTIMATE_UNIT 8
60 
61 
62 
63 struct collect_link_estimate {
64  uint32_t etx_accumulator;
65  uint8_t num_estimates;
66 };
67 
68 /**
69  * \brief Initialize a new link estimate
70  * \param le A pointer to a link estimate structure
71  *
72  * This function initializes a link estimate.
73  */
75 
76 /**
77  * \brief Update a link estimate when a packet has been sent.
78  * \param le A pointer to a link estimate structure
79  * \param num_tx The number of times the packet was transmitted before it was ACKed
80  *
81  * This function updates a link estimate. This function is
82  * called when a packet has been sent. The function may
83  * use information from the packet buffer and the packet
84  * buffer attributes when computing the link estimate.
85  */
87  uint8_t num_tx);
88 
89 /**
90  * \brief Update a link estimate when a packet has failed to be sent.
91  * \param le A pointer to a link estimate structure
92  * \param num_tx The number of times the packet was transmitted before it was given up on.
93  *
94  * This function updates a link estimate. This function is
95  * called when a packet has been sent. The function may
96  * use information from the packet buffer and the packet
97  * buffer attributes when computing the link estimate.
98  */
100  uint8_t num_tx);
101 
102 /**
103  * \brief Update a link estimate when a packet has been received.
104  * \param le A pointer to a link estimate structure
105  *
106  * This function updates a link estimate. This function is
107  * called when a packet has been received. The function
108  * uses information from the packet buffer and its
109  * attributes.
110  */
112 
113 
114 /**
115  * \brief Compute the link estimate metric for a link estimate
116  * \param le A pointer to a link estimate structure
117  * \return The current link estimate metric
118  *
119  */
120 uint16_t collect_link_estimate(struct collect_link_estimate *le);
121 
122 int collect_link_estimate_num_estimates(struct collect_link_estimate *le);
123 
124 #endif /* COLLECT_LINK_ESTIMATE_H */
125 
126 /** @} */
void collect_link_estimate_update_tx(struct collect_link_estimate *le, uint8_t tx)
Update a link estimate when a packet has been sent.
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.