Contiki 3.x
netflood.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006, 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 best-effort network flooding (netflood)
36  * \author
37  * Adam Dunkels <adam@sics.se>
38  */
39 
40 /**
41  * \addtogroup rime
42  * @{
43  */
44 
45 /**
46  * \defgroup rimenetflood Best-effort network flooding
47  * @{
48  *
49  * The netflood module does best-effort flooding.
50  *
51  * The netflood primitive sends a single packet to all nodes in the
52  * network. The netflood primitive uses polite broadcasts at every hop
53  * to reduce the number of redundant transmissions. The netflood
54  * primitive does not perform retransmissions of flooded packets and
55  * packets are not tagged with version numbers. Instead, the netflood
56  * primitive sets the end-to-end sender and end-to-end packet ID
57  * attributes on the packets it sends. A forwarding node saves the
58  * end-to-end sender and packet ID of the last packet it forwards and
59  * does not forward a packet if it has the same end-to-end sender and
60  * packet ID as the last packet. This reduces the risk of routing
61  * loops, but does not eliminate them entirely as the netflood
62  * primitive saves the attributes of the latest packet seen only.
63  * Therefore, the netflood primitive also uses the time to live
64  * attribute, which is decreased by one before forwarding a packet.
65  * If the time to live reaches zero, the primitive does not forward
66  * the packet.
67  *
68  * \section channels Channels
69  *
70  * The netflood module uses 1 channel.
71  *
72  */
73 
74 #ifndef NETFLOOD_H_
75 #define NETFLOOD_H_
76 
77 #include "net/queuebuf.h"
78 #include "net/rime/ipolite.h"
79 
80 struct netflood_conn;
81 
82 #define NETFLOOD_ATTRIBUTES { PACKETBUF_ADDR_ESENDER, PACKETBUF_ADDRSIZE }, \
83  { PACKETBUF_ATTR_HOPS, PACKETBUF_ATTR_BIT * 5 }, \
84  { PACKETBUF_ATTR_EPACKET_ID, PACKETBUF_ATTR_BIT * 4 }, \
85  IPOLITE_ATTRIBUTES
86 
87 struct netflood_callbacks {
88  int (* recv)(struct netflood_conn *c, const linkaddr_t *from,
89  const linkaddr_t *originator, uint8_t seqno, uint8_t hops);
90  void (* sent)(struct netflood_conn *c);
91  void (* dropped)(struct netflood_conn *c);
92 };
93 
94 struct netflood_conn {
95  struct ipolite_conn c;
96  const struct netflood_callbacks *u;
97  clock_time_t queue_time;
98  linkaddr_t last_originator;
99  uint8_t last_originator_seqno;
100 };
101 
102 void netflood_open(struct netflood_conn *c, clock_time_t queue_time,
103  uint16_t channel, const struct netflood_callbacks *u);
104 void netflood_close(struct netflood_conn *c);
105 
106 int netflood_send(struct netflood_conn *c, uint8_t seqno);
107 
108 #endif /* SIBC_H_ */
109 /** @} */
110 /** @} */
Header file for Ipolite best effort local Broadcast (ipolite)
An opaque structure with no user-visible elements that holds the state of an ipolite connection...
Definition: ipolite.h:135
Header file for the Rime queue buffer management