25 #include "ns3/llc-snap-header.h"
27 #include "ns3/simulator.h"
28 #include "ns3/packet.h"
29 #include "ns3/mesh-point-device.h"
30 #include "ns3/wifi-net-device.h"
31 #include "ns3/mesh-point-device.h"
32 #include "ns3/mesh-wifi-interface-mac.h"
70 for (
int j = 0; j < 6; j++)
75 for (
int j = 0; j < 6; j++)
86 for (
int j = 0; j < 6; j++)
91 for (
int j = 0; j < 6; j++)
111 static TypeId tid =
TypeId (
"ns3::flame::FlameProtocol")
113 .AddConstructor<FlameProtocol> ()
114 .AddAttribute (
"BroadcastInterval",
115 "How often we must send broadcast packets",
121 .AddAttribute (
"MaxCost",
122 "Cost threshold after which packet will be dropped",
124 MakeUintegerAccessor (
126 MakeUintegerChecker<uint8_t> (3)
132 m_address (
Mac48Address ()), m_broadcastInterval (Seconds (5)), m_lastBroadcast (Seconds (0)),
151 if (sourceIface ==
m_mp->GetIfIndex ())
157 NS_FATAL_ERROR (
"FLAME tag is not supposed to be received from upper layers");
206 flameHdr.AddCost (1);
247 flameHdr.AddCost (1);
270 NS_FATAL_ERROR (
"FLAME tag must exist when packet is coming to protocol");
288 protocolType = flameHdr.GetProtocol ();
295 std::vector<Ptr<NetDevice> >
interfaces = mp->GetInterfaces ();
296 for (std::vector<
Ptr<NetDevice> >::const_iterator i = interfaces.begin (); i != interfaces.end (); i++)
312 mac->SetBeaconGeneration (
false);
313 mac->InstallPlugin (flameMac);
315 mp->SetRoutingProtocol (
this);
317 mp->AggregateObject (
this);
350 txUnicast (0), txBroadcast (0), txBytes (0), droppedTtl (0), totalDropped (0)
357 "txUnicast=\"" << txUnicast <<
"\" "
358 "txBroadcast=\"" << txBroadcast <<
"\" "
359 "txBytes=\"" << txBytes <<
"\" "
360 "droppedTtl=\"" << droppedTtl <<
"\" "
361 "totalDropped=\"" << totalDropped <<
"\"/>" << std::endl;
367 "address=\"" <<
m_address <<
"\"" << std::endl <<
369 "maxCost=\"" << (uint16_t)
m_maxCost <<
"\">" << std::endl;
373 plugin->second->Report (os);
375 os <<
"</Flame>" << std::endl;
383 plugin->second->ResetStats ();
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void Print(std::ostream &os) const
uint32_t GetSerializedSize() const
bool RemoveRoutingStuff(uint32_t fromIface, const Mac48Address source, const Mac48Address destination, Ptr< Packet > packet, uint16_t &protocolType)
Cleanup flame headers!
void Print(std::ostream &os) const
void AddPacketTag(const Tag &tag) const
Add a packet tag.
#define NS_ASSERT(condition)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
uint32_t GetSize(void) const
TAG_BUFFER_INLINE uint8_t ReadU8(void)
#define NS_FATAL_ERROR(msg)
fatal error handling
uint8_t m_maxCost
Max Cost value (or TTL, because cost is actually hopcount)
Ptr< T > CreateObject(void)
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.
double GetSeconds(void) const
void CopyTo(uint8_t buffer[6]) const
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Ptr< FlameRtable > m_rtable
Routing table:
static TypeId GetTypeId()
Ptr< MeshPointDevice > m_mp
Host mesh point.
void Serialize(TagBuffer i) const
hold objects of type ns3::Time
FlamePluginMap m_interfaces
Hold an unsigned integer type.
Mac48Address retransmitter
Hold together all Wifi-related objects.
static Mac48Address GetBroadcast(void)
Mac48Address GetAddress()
static Mac48Address ConvertFrom(const Address &address)
NS_LOG_COMPONENT_DEFINE("FlameProtocol")
Ptr< Packet > Copy(void) const
tag a set of bytes in a packet
Route lookup result, return type of LookupXXX methods.
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)
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
void CopyFrom(const uint8_t buffer[6])
static Time Now(void)
Return the "current simulation time".
Interface for L2 mesh routing protocol and mesh point communication.
void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
static const uint32_t INTERFACE_ANY
Means all interfaces.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
#define NS_LOG_DEBUG(msg)
void Report(std::ostream &) const
Statistics.
TypeId GetInstanceTypeId() const
Mac48Address receiver
Receiver of the packet:
static TypeId GetTypeId()
uint16_t m_myLastSeqno
Sequence number:
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
static const uint16_t FLAME_PROTOCOL
LLC protocol number reserved by flame.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Basic MAC of mesh point Wi-Fi interface.
void AddHeader(const Header &header)
Add header to this packet.
Transmitter and receiver addresses.
Mac48Address transmitter
transmitter for incoming: