A Discrete-Event Network Simulator
API
flame-protocol.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 IITP RAS
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Kirill Andreev <andreev@iitp.ru>
19  */
20 
21 #ifndef FLAME_PROTOCOL_H
22 #define FLAME_PROTOCOL_H
23 
24 
25 #include "ns3/mesh-l2-routing-protocol.h"
26 #include "ns3/nstime.h"
27 #include "ns3/tag.h"
28 #include <map>
29 
45 namespace ns3 {
46 namespace flame {
47 class FlameProtocolMac;
48 class FlameHeader;
49 class FlameRtable;
54 class FlameTag : public Tag
55 {
56 public:
61 
68  receiver (a){}
69 
74  static TypeId GetTypeId ();
75  // Inherited from Tag
76  TypeId GetInstanceTypeId () const;
77  uint32_t GetSerializedSize () const;
78  void Serialize (TagBuffer i) const;
79  void Deserialize (TagBuffer i);
80  void Print (std::ostream &os) const;
81 
82 };
83 
89 {
90 public:
95  static TypeId GetTypeId ();
96  FlameProtocol ();
97  ~FlameProtocol ();
98  void DoDispose ();
99 
111  bool RequestRoute (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination,
112  Ptr<const Packet> packet, uint16_t protocolType, RouteReplyCallback routeReply);
123  bool RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source,
124  const Mac48Address destination, Ptr<Packet> packet, uint16_t& protocolType);
144  void Report (std::ostream & os) const;
146  void ResetStats ();
147 private:
154  FlameProtocol& operator= (const FlameProtocol & flame);
156  FlameProtocol (const FlameProtocol &);
157 
159  static const uint16_t FLAME_PROTOCOL = 0x4040;
170  bool HandleDataFrame (uint16_t seqno, Mac48Address source, const FlameHeader flameHdr, Mac48Address receiver, uint32_t fromIface);
175  typedef std::map<uint32_t, Ptr<FlameProtocolMac> > FlamePluginMap;
178  //\}
185  //\}
187  uint8_t m_maxCost;
189  uint16_t m_myLastSeqno;
193  struct Statistics
194  {
195  uint16_t txUnicast;
196  uint16_t txBroadcast;
197  uint32_t txBytes;
198  uint16_t droppedTtl;
199  uint16_t totalDropped;
200 
204  void Print (std::ostream & os) const;
206  Statistics ();
207  };
209 
210 };
211 } // namespace flame
212 } // namespace ns3
213 #endif /* FLAME_PROTOCOL_H */
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Callback template class.
Definition: callback.h:1176
FLAME routing protocol.
bool RemoveRoutingStuff(uint32_t fromIface, const Mac48Address source, const Mac48Address destination, Ptr< Packet > packet, uint16_t &protocolType)
Cleanup flame headers!
Statistics m_stats
statistics
uint16_t txBroadcast
transmit broadcast
void ResetStats()
Reset statistics function.
FlameProtocol & operator=(const FlameProtocol &flame)
assignment operator
void Print(std::ostream &os) const
Print function.
uint8_t m_maxCost
Max Cost value (or TTL, because cost is actually hopcount)
void Report(std::ostream &os) const
Statistics.
void Print(std::ostream &os) const
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.
Ptr< FlameRtable > m_rtable
Routing table:
static TypeId GetTypeId()
Get the type ID.
uint32_t GetSerializedSize() const
FlamePluginMap m_interfaces
interfaces
Mac48Address GetAddress()
Get address of this instance.
tag a set of bytes in a packet
Definition: tag.h:36
Mac48Address m_address
address
Every class exported by the ns3 library is enclosed in the ns3 namespace.
bool Install(Ptr< MeshPointDevice >)
Install FLAME on given mesh point.
bool RequestRoute(uint32_t sourceIface, const Mac48Address source, const Mac48Address destination, Ptr< const Packet > packet, uint16_t protocolType, RouteReplyCallback routeReply)
Route request, inherited from MeshL2RoutingProtocol.
void Deserialize(TagBuffer i)
an EUI-48 address
Definition: mac48-address.h:43
void Serialize(TagBuffer i) const
Interface for L2 mesh routing protocol and mesh point communication.
void DoDispose()
Destructor implementation.
read and write tag data
Definition: tag-buffer.h:51
Mac48Address receiver
Receiver of the packet:
static TypeId GetTypeId()
Get the type ID.
uint16_t m_myLastSeqno
Sequence number:
uint16_t txUnicast
transmit unicast
std::map< uint32_t, Ptr< FlameProtocolMac > > FlamePluginMap
interfaces
static const uint16_t FLAME_PROTOCOL
LLC protocol number reserved by flame.
FlameTag(Mac48Address a=Mac48Address())
Constructor.
a unique identifier for an interface.
Definition: type-id.h:58
Transmitter and receiver addresses.
TypeId GetInstanceTypeId() const
Get the most derived TypeId for this Object.
Mac48Address transmitter
transmitter for incoming: