15#include "ns3/llc-snap-header.h"
17#include "ns3/mesh-point-device.h"
18#include "ns3/mesh-wifi-interface-mac.h"
19#include "ns3/packet.h"
20#include "ns3/simulator.h"
21#include "ns3/wifi-net-device.h"
64 for (
int j = 0; j < 6; j++)
69 for (
int j = 0; j < 6; j++)
79 for (
int j = 0; j < 6; j++)
84 for (
int j = 0; j < 6; j++)
105 .SetGroupName(
"Mesh")
107 .AddAttribute(
"BroadcastInterval",
108 "How often we must send broadcast packets",
112 .AddAttribute(
"MaxCost",
113 "Cost threshold after which packet will be dropped",
122 m_broadcastInterval(
Seconds(5)),
147 uint16_t protocolType,
151 if (sourceIface ==
m_mp->GetIfIndex())
155 if (packet->PeekPacketTag(tag))
157 NS_FATAL_ERROR(
"FLAME tag is not supposed to be received from upper layers");
177 packet->AddHeader(flameHdr);
188 packet->AddPacketTag(tag);
194 packet->RemoveHeader(flameHdr);
197 if (!packet->RemovePacketTag(tag))
212 packet->AddHeader(flameHdr);
213 packet->AddPacketTag(tag);
240 NS_LOG_DEBUG(
"unicast packet dropped, because no route! I am "
262 packet->AddHeader(flameHdr);
263 packet->AddPacketTag(tag);
277 uint16_t& protocolType)
286 if (!packet->RemovePacketTag(tag))
288 NS_FATAL_ERROR(
"FLAME tag must exist when packet is coming to protocol");
291 packet->RemoveHeader(flameHdr);
314 std::vector<Ptr<NetDevice>> interfaces = mp->GetInterfaces();
315 for (
auto i = interfaces.begin(); i != interfaces.end(); i++)
331 mac->SetBeaconGeneration(
false);
332 mac->InstallPlugin(flameMac);
334 mp->SetRoutingProtocol(
this);
336 mp->AggregateObject(
this);
361 ((int16_t)(result.
seqnum - seqno) >= 0))
401 << totalDropped <<
"\"/>" << std::endl;
411 <<
"maxCost=\"" << (uint16_t)
m_maxCost <<
"\">" << std::endl;
415 plugin->second->Report(os);
417 os <<
"</Flame>" << std::endl;
426 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.
Smart pointer class similar to boost::intrusive_ptr.
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.
bool IsZero() const
Exactly equivalent to t == 0.
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.
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
static const uint32_t INTERFACE_ANY
Means all interfaces.
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,...
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 AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Ptr< const AttributeChecker > MakeUintegerChecker()
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.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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