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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Kirill Andreev <andreev@iitp.ru>
7 */
8
9#ifndef FLAME_PROTOCOL_H
10#define FLAME_PROTOCOL_H
11
12#include "ns3/mesh-l2-routing-protocol.h"
13#include "ns3/nstime.h"
14#include "ns3/tag.h"
15
16#include <map>
17
18/**
19 * \ingroup mesh
20 * \defgroup flame FLAME
21 *
22 * \brief Forwarding LAyer for MEshing protocol
23 *
24 * Simple L2.5 mesh routing protocol developed by
25 * Herman Elfrink <herman.elfrink@ti-wmc.nl> and presented in
26 * "Easy Wireless: broadband ad-hoc networking for emergency services"
27 * by Maurits de Graaf et. al. at The Sixth Annual Mediterranean Ad Hoc
28 * Networking WorkShop, Corfu, Greece, June 12-15, 2007
29 *
30 * see also Linux kernel mailing list discussion at
31 * http://lkml.org/lkml/2006/5/23/82
32 */
33namespace ns3
34{
35namespace flame
36{
37class FlameProtocolMac;
38class FlameHeader;
39class FlameRtable;
40
41/**
42 * \ingroup flame
43 * \brief Transmitter and receiver addresses
44 */
45class FlameTag : public Tag
46{
47 public:
48 /// transmitter for incoming:
50 /// Receiver of the packet:
52
53 /**
54 * Constructor
55 *
56 * \param a receiver MAC address
57 */
59 : receiver(a)
60 {
61 }
62
63 /**
64 * \brief Get the type ID.
65 * \return the object TypeId
66 */
67 static TypeId GetTypeId();
68 // Inherited from Tag
69 TypeId GetInstanceTypeId() const override;
70 uint32_t GetSerializedSize() const override;
71 void Serialize(TagBuffer i) const override;
72 void Deserialize(TagBuffer i) override;
73 void Print(std::ostream& os) const override;
74};
75
76/**
77 * \ingroup flame
78 * \brief FLAME routing protocol
79 */
81{
82 public:
83 /**
84 * \brief Get the type ID.
85 * \return the object TypeId
86 */
87 static TypeId GetTypeId();
88
90 ~FlameProtocol() override;
91
92 // Delete copy constructor and assignment operator to avoid misuse
93 FlameProtocol(const FlameProtocol&) = delete;
95
96 void DoDispose() override;
97
98 /**
99 * Route request, inherited from MeshL2RoutingProtocol
100 *
101 * \param sourceIface the source interface
102 * \param source the source address
103 * \param destination the destination address
104 * \param packet the packet to route
105 * \param protocolType the protocol type
106 * \param routeReply the route reply
107 * \returns if route exists
108 */
109 bool RequestRoute(uint32_t sourceIface,
110 const Mac48Address source,
111 const Mac48Address destination,
112 Ptr<const Packet> packet,
113 uint16_t protocolType,
114 RouteReplyCallback routeReply) override;
115 /**
116 * Cleanup flame headers!
117 *
118 * \param fromIface the from interface
119 * \param source the source address
120 * \param destination the destination address
121 * \param packet the packet
122 * \param protocolType the protocol type
123 * \returns if the route removed
124 */
125 bool RemoveRoutingStuff(uint32_t fromIface,
126 const Mac48Address source,
127 const Mac48Address destination,
128 Ptr<Packet> packet,
129 uint16_t& protocolType) override;
130 /**
131 * \brief Install FLAME on given mesh point.
132 * \param mp the MeshPointDevice
133 * \returns true if successful
134 *
135 * Installing protocol causes installation of its interface MAC plugins.
136 *
137 * Also MP aggregates all installed protocols, FLAME protocol can be accessed
138 * via MeshPointDevice::GetObject<flame::FlameProtocol>();
139 */
141 /**
142 * Get address of this instance
143 * \returns the MAC address
144 */
146 /**
147 * Statistics
148 * \param os the output stream
149 */
150 void Report(std::ostream& os) const;
151 /// Reset statistics function
152 void ResetStats();
153
154 private:
155 /// LLC protocol number reserved by flame
156 static const uint16_t FLAME_PROTOCOL = 0x4040;
157 /**
158 * \brief Handles a packet: adds a routing information and drops packets by TTL or Seqno
159 *
160 * \param seqno
161 * \param source
162 * \param flameHdr
163 * \param receiver
164 * \param fromIface
165 * \return true if packet shall be dropped
166 */
167 bool HandleDataFrame(uint16_t seqno,
168 Mac48Address source,
169 const FlameHeader flameHdr,
170 Mac48Address receiver,
171 uint32_t fromIface);
172 /**
173 * \name Information about MeshPointDeviceaddress, plugins
174 * \{
175 */
176 typedef std::map<uint32_t, Ptr<FlameProtocolMac>> FlamePluginMap;
179 //\}
180 /**
181 * \name Broadcast timers:
182 * \{
183 */
186 //\}
187 /// Max Cost value (or TTL, because cost is actually hopcount)
188 uint8_t m_maxCost;
189 /// Sequence number:
191 /// Routing table:
193
194 /// Statistics structure
196 {
197 uint16_t txUnicast; ///< transmit unicast
198 uint16_t txBroadcast; ///< transmit broadcast
199 uint32_t txBytes; ///< transmit bytes
200 uint16_t droppedTtl; ///< dropped TTL
201 uint16_t totalDropped; ///< total dropped
202 /**
203 * Print function
204 * \param os the output stream to print to
205 */
206 void Print(std::ostream& os) const;
207 /// constructor
208 Statistics();
209 };
210
211 Statistics m_stats; ///< statistics
212};
213} // namespace flame
214} // namespace ns3
215#endif /* FLAME_PROTOCOL_H */
Callback template class.
Definition callback.h:422
an EUI-48 address
Interface for L2 mesh routing protocol and mesh point communication.
Smart pointer class similar to boost::intrusive_ptr.
read and write tag data
Definition tag-buffer.h:41
tag a set of bytes in a packet
Definition tag.h:28
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
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
void Print(std::ostream &os) const
Print function.