A Discrete-Event Network Simulator
API
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 
44 namespace ns3
45 {
46 namespace flame
47 {
48 class FlameProtocolMac;
49 class FlameHeader;
50 class FlameRtable;
51 
56 class FlameTag : public Tag
57 {
58  public:
63 
70  : receiver(a)
71  {
72  }
73 
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 
92 {
93  public:
98  static TypeId GetTypeId();
99 
100  FlameProtocol();
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 
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;
136  bool RemoveRoutingStuff(uint32_t fromIface,
137  const Mac48Address source,
138  const Mac48Address destination,
139  Ptr<Packet> packet,
140  uint16_t& protocolType) override;
151  bool Install(Ptr<MeshPointDevice> mp);
161  void Report(std::ostream& os) const;
163  void ResetStats();
164 
165  private:
167  static const uint16_t FLAME_PROTOCOL = 0x4040;
178  bool HandleDataFrame(uint16_t seqno,
179  Mac48Address source,
180  const FlameHeader flameHdr,
181  Mac48Address receiver,
182  uint32_t fromIface);
187  typedef std::map<uint32_t, Ptr<FlameProtocolMac>> FlamePluginMap;
190  //\}
197  //\}
199  uint8_t m_maxCost;
201  uint16_t m_myLastSeqno;
204 
206  struct Statistics
207  {
208  uint16_t txUnicast;
209  uint16_t txBroadcast;
210  uint32_t txBytes;
211  uint16_t droppedTtl;
212  uint16_t totalDropped;
217  void Print(std::ostream& os) const;
219  Statistics();
220  };
221 
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.
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.
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
FlameProtocol & operator=(const FlameProtocol &)=delete
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.