26 #include "ns3/llc-snap-header.h"
28 #include "ns3/mesh-point-device.h"
29 #include "ns3/mesh-wifi-interface-mac.h"
30 #include "ns3/packet.h"
31 #include "ns3/simulator.h"
32 #include "ns3/wifi-net-device.h"
75 for (
int j = 0; j < 6; j++)
80 for (
int j = 0; j < 6; j++)
90 for (
int j = 0; j < 6; j++)
95 for (
int j = 0; j < 6; j++)
116 .SetGroupName(
"Mesh")
118 .AddAttribute(
"BroadcastInterval",
119 "How often we must send broadcast packets",
123 .AddAttribute(
"MaxCost",
124 "Cost threshold after which packet will be dropped",
127 MakeUintegerChecker<uint8_t>(3));
133 m_broadcastInterval(
Seconds(5)),
158 uint16_t protocolType,
162 if (sourceIface ==
m_mp->GetIfIndex())
168 NS_FATAL_ERROR(
"FLAME tag is not supposed to be received from upper layers");
251 NS_LOG_DEBUG(
"unicast packet dropped, because no route! I am "
288 uint16_t& protocolType)
299 NS_FATAL_ERROR(
"FLAME tag must exist when packet is coming to protocol");
326 std::vector<Ptr<NetDevice>>
interfaces = mp->GetInterfaces();
343 mac->SetBeaconGeneration(
false);
344 mac->InstallPlugin(flameMac);
346 mp->SetRoutingProtocol(
this);
348 mp->AggregateObject(
this);
364 uint32_t fromInterface)
373 ((int16_t)(result.
seqnum - seqno) >= 0))
413 << totalDropped <<
"\"/>" << std::endl;
423 <<
"maxCost=\"" << (uint16_t)
m_maxCost <<
"\">" << std::endl;
427 plugin->second->Report(os);
429 os <<
"</Flame>" << std::endl;
438 plugin->second->ResetStats();
void CopyFrom(const uint8_t buffer[6])
static Mac48Address ConvertFrom(const Address &address)
static Mac48Address GetBroadcast()
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() 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.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Ptr< Packet > Copy() const
performs a COW copy of the 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.
static Time Now()
Return the current simulation virtual time.
TAG_BUFFER_INLINE void WriteU8(uint8_t v)
TAG_BUFFER_INLINE uint8_t ReadU8()
tag a set of bytes in a packet
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
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() const
uint32_t GetIfIndex() const override
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:
~FlameProtocol() override
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.
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.
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.
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:
Mac48Address transmitter
transmitter for incoming:
void Deserialize(TagBuffer i) override
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#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 AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
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.
uint32_t ifIndex
IF index.
uint16_t seqnum
sequence number
Mac48Address retransmitter
retransmitter