Contiki 3.x
link-stats.h
1 /*
2  * Copyright (c) 2015, SICS Swedish ICT.
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  *
30  * Authors: Simon Duquennoy <simonduq@sics.se>
31  */
32 
33 #ifndef LINK_STATS_H_
34 #define LINK_STATS_H_
35 
36 #include "core/net/linkaddr.h"
37 
38 /* ETX fixed point divisor. 128 is the value used by RPL (RFC 6551 and RFC 6719) */
39 #ifdef LINK_STATS_CONF_ETX_DIVISOR
40 #define LINK_STATS_ETX_DIVISOR LINK_STATS_CONF_ETX_DIVISOR
41 #else /* LINK_STATS_CONF_ETX_DIVISOR */
42 #define LINK_STATS_ETX_DIVISOR 128
43 #endif /* LINK_STATS_CONF_ETX_DIVISOR */
44 
45 /* All statistics of a given link */
46 struct link_stats {
47  uint16_t etx; /* ETX using ETX_DIVISOR as fixed point divisor */
48  int16_t rssi; /* RSSI (received signal strength) */
49  uint8_t freshness; /* Freshness of the statistics */
50  clock_time_t last_tx_time; /* Last Tx timestamp */
51 };
52 
53 /* Returns the neighbor's link statistics */
54 const struct link_stats *link_stats_from_lladdr(const linkaddr_t *lladdr);
55 /* Are the statistics fresh? */
56 int link_stats_is_fresh(const struct link_stats *stats);
57 
58 /* Initializes link-stats module */
59 void link_stats_init(void);
60 /* Packet sent callback. Updates statistics for transmissions on a given link */
61 void link_stats_packet_sent(const linkaddr_t *lladdr, int status, int numtx);
62 /* Packet input callback. Updates statistics for receptions on a given link */
63 void link_stats_input_callback(const linkaddr_t *lladdr);
64 
65 #endif /* LINK_STATS_H_ */
Header file for the Rime address representation