00001 /** 00002 * \addtogroup rime 00003 * @{ 00004 */ 00005 00006 /** 00007 * \defgroup rimenetflood Best-effort network flooding 00008 * @{ 00009 * 00010 * The netflood module does best-effort flooding. 00011 * 00012 * The netflood primitive sends a single packet to all nodes in the 00013 * network. The netflood primitive uses polite broadcasts at every hop 00014 * to reduce the number of redundant transmissions. The netflood 00015 * primitive does not perform retransmissions of flooded packets and 00016 * packets are not tagged with version numbers. Instead, the netflood 00017 * primitive sets the end-to-end sender and end-to-end packet ID 00018 * attributes on the packets it sends. A forwarding node saves the 00019 * end-to-end sender and packet ID of the last packet it forwards and 00020 * does not forward a packet if it has the same end-to-end sender and 00021 * packet ID as the last packet. This reduces the risk of routing 00022 * loops, but does not eliminate them entirely as the netflood 00023 * primitive saves the attributes of the latest packet seen only. 00024 * Therefore, the netflood primitive also uses the time to live 00025 * attribute, which is decreased by one before forwarding a packet. 00026 * If the time to live reaches zero, the primitive does not forward 00027 * the packet. 00028 * 00029 * \section channels Channels 00030 * 00031 * The netflood module uses 1 channel. 00032 * 00033 */ 00034 00035 /* 00036 * Copyright (c) 2006, Swedish Institute of Computer Science. 00037 * All rights reserved. 00038 * 00039 * Redistribution and use in source and binary forms, with or without 00040 * modification, are permitted provided that the following conditions 00041 * are met: 00042 * 1. Redistributions of source code must retain the above copyright 00043 * notice, this list of conditions and the following disclaimer. 00044 * 2. Redistributions in binary form must reproduce the above copyright 00045 * notice, this list of conditions and the following disclaimer in the 00046 * documentation and/or other materials provided with the distribution. 00047 * 3. Neither the name of the Institute nor the names of its contributors 00048 * may be used to endorse or promote products derived from this software 00049 * without specific prior written permission. 00050 * 00051 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 00052 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00053 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00054 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 00055 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00056 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00057 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00058 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00059 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00060 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00061 * SUCH DAMAGE. 00062 * 00063 * This file is part of the Contiki operating system. 00064 * 00065 * $Id: netflood.h,v 1.7 2010/06/14 19:19:17 adamdunkels Exp $ 00066 */ 00067 00068 /** 00069 * \file 00070 * Header file for the best-effort network flooding (netflood) 00071 * \author 00072 * Adam Dunkels <adam@sics.se> 00073 */ 00074 00075 #ifndef __NETFLOOD_H__ 00076 #define __NETFLOOD_H__ 00077 00078 #include "net/queuebuf.h" 00079 #include "net/rime/ipolite.h" 00080 00081 struct netflood_conn; 00082 00083 #define NETFLOOD_ATTRIBUTES { PACKETBUF_ADDR_ESENDER, PACKETBUF_ADDRSIZE }, \ 00084 { PACKETBUF_ATTR_HOPS, PACKETBUF_ATTR_BIT * 5 }, \ 00085 { PACKETBUF_ATTR_EPACKET_ID, PACKETBUF_ATTR_BIT * 4 }, \ 00086 IPOLITE_ATTRIBUTES 00087 00088 struct netflood_callbacks { 00089 int (* recv)(struct netflood_conn *c, const rimeaddr_t *from, 00090 const rimeaddr_t *originator, uint8_t seqno, uint8_t hops); 00091 void (* sent)(struct netflood_conn *c); 00092 void (* dropped)(struct netflood_conn *c); 00093 }; 00094 00095 struct netflood_conn { 00096 struct ipolite_conn c; 00097 const struct netflood_callbacks *u; 00098 clock_time_t queue_time; 00099 rimeaddr_t last_originator; 00100 uint8_t last_originator_seqno; 00101 }; 00102 00103 void netflood_open(struct netflood_conn *c, clock_time_t queue_time, 00104 uint16_t channel, const struct netflood_callbacks *u); 00105 void netflood_close(struct netflood_conn *c); 00106 00107 int netflood_send(struct netflood_conn *c, uint8_t seqno); 00108 00109 #endif /* __SIBC_H__ */ 00110 /** @} */ 00111 /** @} */