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-wifi-interface-mac.h" 50 .SetGroupName (
"Mesh")
73 for (
int j = 0; j < 6; j++)
78 for (
int j = 0; j < 6; j++)
89 for (
int j = 0; j < 6; j++)
94 for (
int j = 0; j < 6; j++)
114 static TypeId tid =
TypeId (
"ns3::flame::FlameProtocol")
116 .SetGroupName (
"Mesh")
118 .AddAttribute (
"BroadcastInterval",
119 "How often we must send broadcast packets",
125 .AddAttribute (
"MaxCost",
126 "Cost threshold after which packet will be dropped",
130 MakeUintegerChecker<uint8_t> (3)
155 if (sourceIface ==
m_mp->GetIfIndex ())
161 NS_FATAL_ERROR (
"FLAME tag is not supposed to be received from upper layers");
210 flameHdr.AddCost (1);
251 flameHdr.AddCost (1);
274 NS_FATAL_ERROR (
"FLAME tag must exist when packet is coming to protocol");
292 protocolType = flameHdr.GetProtocol ();
299 std::vector<Ptr<NetDevice> >
interfaces = mp->GetInterfaces ();
316 mac->SetBeaconGeneration (
false);
317 mac->InstallPlugin (flameMac);
319 mp->SetRoutingProtocol (
this);
321 mp->AggregateObject (
this);
354 txUnicast (0), txBroadcast (0), txBytes (0), droppedTtl (0), totalDropped (0)
361 "txUnicast=\"" << txUnicast <<
"\" " 362 "txBroadcast=\"" << txBroadcast <<
"\" " 363 "txBytes=\"" << txBytes <<
"\" " 364 "droppedTtl=\"" << droppedTtl <<
"\" " 365 "totalDropped=\"" << totalDropped <<
"\"/>" << std::endl;
371 "address=\"" <<
m_address <<
"\"" << std::endl <<
373 "maxCost=\"" << (uint16_t)
m_maxCost <<
"\">" << std::endl;
377 plugin->second->Report (os);
379 os <<
"</Flame>" << std::endl;
387 plugin->second->ResetStats ();
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
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 AddPath(const Mac48Address destination, const Mac48Address retransmitter, const uint32_t interface, const uint8_t cost, const uint16_t seqnum)
Add path.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
void ResetStats()
Reset statistics function.
TAG_BUFFER_INLINE uint8_t ReadU8(void)
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.
void CopyTo(uint8_t buffer[6]) const
Ptr< FlameRtable > m_rtable
Routing table:
static TypeId GetTypeId()
Get the type ID.
uint32_t GetIfIndex(void) const override
Ptr< MeshPointDevice > m_mp
Host mesh point.
uint16_t droppedTtl
dropped TTL
AttributeValue implementation for Time.
uint32_t GetSerializedSize() const
FlamePluginMap m_interfaces
interfaces
Hold an unsigned integer type.
uint32_t txBytes
transmit bytes
bool Install(Ptr< MeshPointDevice > mp)
Install FLAME on given mesh point.
Mac48Address retransmitter
retransmitter
Hold together all Wifi-related objects.
static Mac48Address GetBroadcast(void)
uint16_t totalDropped
total dropped
Mac48Address GetAddress()
Get address of this instance.
static Mac48Address ConvertFrom(const Address &address)
uint16_t seqnum
sequence number
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
tag a set of bytes in a packet
Mac48Address m_address
address
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Route lookup result, return type of LookupXXX methods.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
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)
void Serialize(TagBuffer i) const
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void CopyFrom(const uint8_t buffer[6])
static Time Now(void)
Return the current simulation virtual time.
Interface for L2 mesh routing protocol and mesh point communication.
void DoDispose()
Destructor implementation.
Ptr< WifiMac > GetMac(void) const
static const uint32_t INTERFACE_ANY
Means all interfaces.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
Mac48Address receiver
Receiver of the packet:
static TypeId GetTypeId()
Get the type ID.
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.
uint16_t txUnicast
transmit unicast
static const uint16_t FLAME_PROTOCOL
LLC protocol number reserved by flame.
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
uint32_t ifIndex
IF index.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
LookupResult Lookup(Mac48Address destination)
Lookup path to destination.
Basic MAC of mesh point Wi-Fi interface.
void AddHeader(const Header &header)
Add header to this packet.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Transmitter and receiver addresses.
TypeId GetInstanceTypeId() const
Get the most derived TypeId for this Object.
Mac48Address transmitter
transmitter for incoming: