A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
flame-protocol.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 IITP RAS
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Kirill Andreev <andreev@iitp.ru>
18 */
19
20#ifndef FLAME_PROTOCOL_H
21#define FLAME_PROTOCOL_H
22
23#include "ns3/mesh-l2-routing-protocol.h"
24#include "ns3/nstime.h"
25#include "ns3/tag.h"
26
27#include <map>
28
29/**
30 * \ingroup mesh
31 * \defgroup flame FLAME
32 *
33 * \brief Forwarding LAyer for MEshing protocol
34 *
35 * Simple L2.5 mesh routing protocol developed by
36 * Herman Elfrink <herman.elfrink@ti-wmc.nl> and presented in
37 * "Easy Wireless: broadband ad-hoc networking for emergency services"
38 * by Maurits de Graaf et. al. at The Sixth Annual Mediterranean Ad Hoc
39 * Networking WorkShop, Corfu, Greece, June 12-15, 2007
40 *
41 * see also Linux kernel mailing list discussion at
42 * http://lkml.org/lkml/2006/5/23/82
43 */
44namespace ns3
45{
46namespace flame
47{
48class FlameProtocolMac;
49class FlameHeader;
50class FlameRtable;
51
52/**
53 * \ingroup flame
54 * \brief Transmitter and receiver addresses
55 */
56class FlameTag : public Tag
57{
58 public:
59 /// transmitter for incoming:
61 /// Receiver of the packet:
63
64 /**
65 * Constructor
66 *
67 * \param a receiver MAC address
68 */
70 : receiver(a)
71 {
72 }
73
74 /**
75 * \brief Get the type ID.
76 * \return the object TypeId
77 */
78 static TypeId GetTypeId();
79 // Inherited from Tag
80 TypeId GetInstanceTypeId() const override;
81 uint32_t GetSerializedSize() const override;
82 void Serialize(TagBuffer i) const override;
83 void Deserialize(TagBuffer i) override;
84 void Print(std::ostream& os) const override;
85};
86
87/**
88 * \ingroup flame
89 * \brief FLAME routing protocol
90 */
92{
93 public:
94 /**
95 * \brief Get the type ID.
96 * \return the object TypeId
97 */
98 static TypeId GetTypeId();
99
101 ~FlameProtocol() override;
102
103 // Delete copy constructor and assignment operator to avoid misuse
104 FlameProtocol(const FlameProtocol&) = delete;
106
107 void DoDispose() override;
108
109 /**
110 * Route request, inherited from MeshL2RoutingProtocol
111 *
112 * \param sourceIface the source interface
113 * \param source the source address
114 * \param destination the destination address
115 * \param packet the packet to route
116 * \param protocolType the protocol type
117 * \param routeReply the route reply
118 * \returns if route exists
119 */
120 bool RequestRoute(uint32_t sourceIface,
121 const Mac48Address source,
122 const Mac48Address destination,
123 Ptr<const Packet> packet,
124 uint16_t protocolType,
125 RouteReplyCallback routeReply) override;
126 /**
127 * Cleanup flame headers!
128 *
129 * \param fromIface the from interface
130 * \param source the source address
131 * \param destination the destination address
132 * \param packet the packet
133 * \param protocolType the protocol type
134 * \returns if the route removed
135 */
136 bool RemoveRoutingStuff(uint32_t fromIface,
137 const Mac48Address source,
138 const Mac48Address destination,
139 Ptr<Packet> packet,
140 uint16_t& protocolType) override;
141 /**
142 * \brief Install FLAME on given mesh point.
143 * \param mp the MeshPointDevice
144 * \returns true if successful
145 *
146 * Installing protocol causes installation of its interface MAC plugins.
147 *
148 * Also MP aggregates all installed protocols, FLAME protocol can be accessed
149 * via MeshPointDevice::GetObject<flame::FlameProtocol>();
150 */
152 /**
153 * Get address of this instance
154 * \returns the MAC address
155 */
157 /**
158 * Statistics
159 * \param os the output stream
160 */
161 void Report(std::ostream& os) const;
162 /// Reset statistics function
163 void ResetStats();
164
165 private:
166 /// LLC protocol number reserved by flame
167 static const uint16_t FLAME_PROTOCOL = 0x4040;
168 /**
169 * \brief Handles a packet: adds a routing information and drops packets by TTL or Seqno
170 *
171 * \param seqno
172 * \param source
173 * \param flameHdr
174 * \param receiver
175 * \param fromIface
176 * \return true if packet shall be dropped
177 */
178 bool HandleDataFrame(uint16_t seqno,
179 Mac48Address source,
180 const FlameHeader flameHdr,
181 Mac48Address receiver,
182 uint32_t fromIface);
183 /**
184 * \name Information about MeshPointDeviceaddress, plugins
185 * \{
186 */
187 typedef std::map<uint32_t, Ptr<FlameProtocolMac>> FlamePluginMap;
190 //\}
191 /**
192 * \name Broadcast timers:
193 * \{
194 */
197 //\}
198 /// Max Cost value (or TTL, because cost is actually hopcount)
199 uint8_t m_maxCost;
200 /// Sequence number:
202 /// Routing table:
204
205 /// Statistics structure
207 {
208 uint16_t txUnicast; ///< transmit unicast
209 uint16_t txBroadcast; ///< transmit broadcast
210 uint32_t txBytes; ///< transmit bytes
211 uint16_t droppedTtl; ///< dropped TTL
212 uint16_t totalDropped; ///< total dropped
213 /**
214 * Print function
215 * \param os the output stream to print to
216 */
217 void Print(std::ostream& os) const;
218 /// constructor
219 Statistics();
220 };
221
222 Statistics m_stats; ///< statistics
223};
224} // namespace flame
225} // namespace ns3
226#endif /* FLAME_PROTOCOL_H */
Callback template class.
Definition: callback.h:438
an EUI-48 address
Definition: mac48-address.h:46
Interface for L2 mesh routing protocol and mesh point communication.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
read and write tag data
Definition: tag-buffer.h:52
tag a set of bytes in a packet
Definition: tag.h:39
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
FLAME routing protocol.
FlameProtocol & operator=(const FlameProtocol &)=delete
bool RemoveRoutingStuff(uint32_t fromIface, const Mac48Address source, const Mac48Address destination, Ptr< Packet > packet, uint16_t &protocolType) override
Cleanup flame headers!
Time m_broadcastInterval
Max Cost value (or TTL, because cost is actually hopcount)
void DoDispose() override
Destructor implementation.
static TypeId GetTypeId()
Get the type ID.
static const uint16_t FLAME_PROTOCOL
LLC protocol number reserved by flame.
bool RequestRoute(uint32_t sourceIface, const Mac48Address source, const Mac48Address destination, Ptr< const Packet > packet, uint16_t protocolType, RouteReplyCallback routeReply) override
Route request, inherited from MeshL2RoutingProtocol.
uint16_t m_myLastSeqno
Sequence number:
std::map< uint32_t, Ptr< FlameProtocolMac > > FlamePluginMap
interfaces
Ptr< FlameRtable > m_rtable
Routing table:
bool HandleDataFrame(uint16_t seqno, Mac48Address source, const FlameHeader flameHdr, Mac48Address receiver, uint32_t fromIface)
Handles a packet: adds a routing information and drops packets by TTL or Seqno.
Mac48Address GetAddress()
Get address of this instance.
FlameProtocol(const FlameProtocol &)=delete
uint8_t m_maxCost
Max Cost value (or TTL, because cost is actually hopcount)
bool Install(Ptr< MeshPointDevice > mp)
Install FLAME on given mesh point.
Time m_lastBroadcast
Max Cost value (or TTL, because cost is actually hopcount)
Statistics m_stats
statistics
Mac48Address m_address
address
void ResetStats()
Reset statistics function.
void Report(std::ostream &os) const
Statistics.
FlamePluginMap m_interfaces
interfaces
Transmitter and receiver addresses.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
void Serialize(TagBuffer i) const override
void Print(std::ostream &os) const override
uint32_t GetSerializedSize() const override
static TypeId GetTypeId()
Get the type ID.
Mac48Address receiver
Receiver of the packet:
FlameTag(Mac48Address a=Mac48Address())
Constructor.
Mac48Address transmitter
transmitter for incoming:
void Deserialize(TagBuffer i) override
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint16_t txBroadcast
transmit broadcast
uint16_t txUnicast
transmit unicast
void Print(std::ostream &os) const
Print function.