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");
274 NS_FATAL_ERROR (
"FLAME tag must exist when packet is coming to protocol");
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 ();
static Mac48Address GetBroadcast(void)
void CopyFrom(const uint8_t buffer[6])
static Mac48Address ConvertFrom(const Address &address)
void CopyTo(uint8_t buffer[6]) const
Interface for L2 mesh routing protocol and mesh point communication.
Ptr< MeshPointDevice > m_mp
Host mesh point.
Basic MAC of mesh point Wi-Fi interface.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void AddHeader(const Header &header)
Add header to this packet.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
static Time Now(void)
Return the current simulation virtual time.
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
TAG_BUFFER_INLINE uint8_t ReadU8(void)
tag a set of bytes in a packet
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
Hold together all Wifi-related objects.
Ptr< WifiMac > GetMac(void) const
uint32_t GetIfIndex(void) const override
Time m_broadcastInterval
Max Cost value (or TTL, because cost is actually hopcount)
void DoDispose()
Destructor implementation.
static TypeId GetTypeId()
Get the type ID.
static const uint16_t FLAME_PROTOCOL
LLC protocol number reserved by flame.
uint16_t m_myLastSeqno
Sequence number:
Ptr< FlameRtable > m_rtable
Routing table:
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.
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.
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.
bool RemoveRoutingStuff(uint32_t fromIface, const Mac48Address source, const Mac48Address destination, Ptr< Packet > packet, uint16_t &protocolType)
Cleanup flame headers!
FlamePluginMap m_interfaces
interfaces
LookupResult Lookup(Mac48Address destination)
Lookup path to destination.
static const uint32_t INTERFACE_ANY
Means all interfaces.
void AddPath(const Mac48Address destination, const Mac48Address retransmitter, const uint32_t interface, const uint8_t cost, const uint16_t seqnum)
Add path.
Transmitter and receiver addresses.
void Serialize(TagBuffer i) const
void Deserialize(TagBuffer i)
static TypeId GetTypeId()
Get the type ID.
Mac48Address receiver
Receiver of the packet:
TypeId GetInstanceTypeId() const
Get the most derived TypeId for this Object.
Mac48Address transmitter
transmitter for incoming:
void Print(std::ostream &os) const
uint32_t GetSerializedSize() const
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
uint16_t txBroadcast
transmit broadcast
uint32_t txBytes
transmit bytes
uint16_t totalDropped
total dropped
uint16_t droppedTtl
dropped TTL
uint16_t txUnicast
transmit unicast
void Print(std::ostream &os) const
Print function.
Route lookup result, return type of LookupXXX methods.