21 #include "ns3/mesh-wifi-interface-mac.h"
22 #include "ns3/packet.h"
23 #include "ns3/simulator.h"
24 #include "ns3/nstime.h"
26 #include "ns3/mgt-headers.h"
42 m_ifIndex (ifIndex), m_protocol (protocol)
66 NS_FATAL_ERROR (
"HWMP tag is not supposed to be received by network");
76 switch (meshHdr.GetAddressExt ())
84 "6-address scheme is not yet supported and 4-address extension is not supposed to be used for data frames.");
86 tag.
SetSeqno (meshHdr.GetMeshSeqno ());
87 tag.
SetTtl (meshHdr.GetMeshTtl ());
114 std::vector<HwmpProtocol::FailedDestination> failedDestinations;
117 if ((*i)->ElementId () ==
IE_RANN)
121 if ((*i)->ElementId () ==
IE_PREQ)
126 if (preq->GetOriginatorAddress () ==
m_protocol->GetAddress ())
130 if (preq->GetTtl () == 0)
134 preq->DecrementTtl ();
138 if ((*i)->ElementId () ==
IE_PREP)
143 if (prep->GetTtl () == 0)
147 prep->DecrementTtl ();
151 if ((*i)->ElementId () ==
IE_PERR)
156 std::vector<HwmpProtocol::FailedDestination> destinations = perr->GetAddressUnitVector ();
157 for (std::vector<HwmpProtocol::FailedDestination>::const_iterator i = destinations.begin (); i
158 != destinations.end (); i++)
160 failedDestinations.push_back (*i);
164 if (failedDestinations.size () > 0)
230 std::vector<IePreq> preq_vector;
231 preq_vector.push_back (preq);
240 for (std::vector<IePreq>::iterator i = preq.begin (); i != preq.end (); i++)
255 for (std::vector<Mac48Address>::const_iterator i = receivers.begin (); i != receivers.end (); i++)
261 m_parent->SendManagementFrame (packet, hdr);
268 for (std::vector<IePreq>::iterator i =
m_myPreq.begin (); i !=
m_myPreq.end (); i++)
275 i->AddDestinationAddressElement (
m_protocol->GetDoFlag (),
m_protocol->GetRfFlag (), dst, dst_seqno);
328 m_parent->SendManagementFrame (packet, hdr);
338 for (std::vector<HwmpProtocol::FailedDestination>::const_iterator i = failedDestinations.begin (); i
339 != failedDestinations.end (); i++)
341 if (!perr->IsFull ())
343 perr->AddAddressUnit (*i);
351 if (perr->GetNumOfDest () > 0)
353 elements.AddInformationElement (perr);
364 if (receivers.size () >=
m_protocol->GetUnicastPerrThreshold ())
370 for (std::vector<Mac48Address>::const_iterator i = receivers.begin (); i != receivers.end (); i++)
381 m_parent->SendManagementFrame (packet, hdr);
392 std::vector<Mac48Address>::const_iterator end = receivers.end ();
393 for (std::vector<Mac48Address>::const_iterator i = receivers.begin (); i != end; i++)
395 bool should_add =
true;
396 for (std::vector<Mac48Address>::const_iterator j =
m_myPerr.
receivers.begin (); j
407 NS_LOG_DEBUG (
"Initiate PERR: Adding receiver: " << (*i));
412 std::vector<HwmpProtocol::FailedDestination>::const_iterator end = failedDestinations.end ();
413 for (std::vector<HwmpProtocol::FailedDestination>::const_iterator i = failedDestinations.begin (); i != end; i++)
415 bool should_add =
true;
416 for (std::vector<HwmpProtocol::FailedDestination>::const_iterator j =
m_myPerr.
destinations.begin (); j
419 if (((*i).destination == (*j).destination) && ((*j).seqnum > (*i).seqnum))
427 NS_LOG_DEBUG (
"Initiate PERR: Adding failed destination: " << (*i).destination);
449 return m_parent->GetLinkMetric (peerAddress);
454 return m_parent->GetFrequencyChannel ();
457 txPreq (0), rxPreq (0), txPrep (0), rxPrep (0), txPerr (0), rxPerr (0), txMgt (0), txMgtBytes (0),
458 rxMgt (0), rxMgtBytes (0), txData (0), txDataBytes (0), rxData (0), rxDataBytes (0)
465 "txPreq= \"" << txPreq <<
"\"" << std::endl <<
466 "txPrep=\"" << txPrep <<
"\"" << std::endl <<
467 "txPerr=\"" << txPerr <<
"\"" << std::endl <<
468 "rxPreq=\"" << rxPreq <<
"\"" << std::endl <<
469 "rxPrep=\"" << rxPrep <<
"\"" << std::endl <<
470 "rxPerr=\"" << rxPerr <<
"\"" << std::endl <<
471 "txMgt=\"" << txMgt <<
"\"" << std::endl <<
472 "txMgtBytes=\"" << txMgtBytes <<
"\"" << std::endl <<
473 "rxMgt=\"" << rxMgt <<
"\"" << std::endl <<
474 "rxMgtBytes=\"" << rxMgtBytes <<
"\"" << std::endl <<
475 "txData=\"" << txData <<
"\"" << std::endl <<
476 "txDataBytes=\"" << txDataBytes <<
"\"" << std::endl <<
477 "rxData=\"" << rxData <<
"\"" << std::endl <<
478 "rxDataBytes=\"" << rxDataBytes <<
"\"/>" << std::endl;
483 os <<
"<HwmpProtocolMac" << std::endl <<
484 "address =\"" <<
m_parent->GetAddress () <<
"\">" << std::endl;
486 os <<
"</HwmpProtocolMac>" << std::endl;
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
bool ReceiveAction(Ptr< Packet > packet, const WifiMacHeader &header)
Receive action management frame.
void SetPreqID(uint32_t id)
Set path discovery id field.
uint32_t GetLinkMetric(Mac48Address peerAddress) const
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SendMyPerr()
Send PERR function.
uint16_t txData
transmit data
void SetParent(Ptr< MeshWifiInterfaceMac > parent)
Update beacon is empty, because HWMP does not know anything about beacons.
void SendMyPreq()
Sends one PREQ when PreqMinInterval after last PREQ expires (if any PREQ exists in rhe queue) ...
uint16_t rxPrep
receive PREP
Hwmp tag implements interaction between HWMP protocol and MeshWifiMac.
void SetTTL(uint8_t ttl)
Set remaining number of hops allowed for this element.
void SendPrep(IePrep prep, Mac48Address receiver)
Send PREP function.
uint16_t txMgt
transmit management
void RequestDestination(Mac48Address dest, uint32_t originator_seqno, uint32_t dst_seqno)
Request a destination.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
#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.
See 7.3.2.97 of 802.11s draft 2.07.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
std::vector< IePreq > m_myPreq
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
uint32_t GetSeqno()
Get the sequence number.
void SetTtl(uint8_t ttl)
Set the TTL value.
uint16_t rxPerr
receive PERR
void SetLifetime(uint32_t lifetime)
Set lifetime in TUs for the forwarding information to be considered valid.
void SendPreq(IePreq preq)
Send PREQ function.
uint16_t rxMgt
receive management
Mac48Address GetAddress()
Get address from tag.
void Report(std::ostream &os) const
Report statistics.
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
static WifiActionHeader GetWifiActionHeader()
void ResetStats()
Reset statistics.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
See 7.3.2.96 of 802.11s draft 2.07.
uint32_t txDataBytes
transmit data bytes
uint32_t rxMgtBytes
receive management bytes
uint16_t txPerr
transmit PERR
Ptr< MeshWifiInterfaceMac > m_parent
parent
static Mac48Address GetBroadcast(void)
std::vector< Mac48Address > receivers
receivers
void SetOriginatorAddress(Mac48Address originator_address)
Set originator address value.
uint32_t txMgtBytes
transmit management bytes
void SetOriginatorSeqNumber(uint32_t originator_seq_number)
Set originator sequence number.
uint16_t txPrep
transmit PREP
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void AddDestinationAddressElement(bool doFlag, bool rfFlag, Mac48Address dest_address, uint32_t dest_seq_number)
Add a destination address unit: flags, destination and sequence number.
void Print(std::ostream &os) const
Print function.
std::vector< HwmpProtocol::FailedDestination > destinations
destinations
uint32_t rxDataBytes
receive data bytes
uint16_t rxData
receive data
HwmpProtocolMac(uint32_t ifIndex, Ptr< HwmpProtocol > protocol)
Constructor.
bool UpdateOutcomingFrame(Ptr< Packet > packet, WifiMacHeader &header, Mac48Address from, Mac48Address to)
Update beacon is empty, because HWMP does not know anything about beacons.
Ptr< HwmpProtocol > m_protocol
protocol
uint8_t GetTtl()
Get the TTL value.
int64_t AssignStreams(int64_t stream)
Update beacon is empty, because HWMP does not know anything about beacons.
bool ReceiveData(Ptr< Packet > packet, const WifiMacHeader &header)
Receive data frame.
uint32_t m_ifIndex
IF index.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
void ForwardPerr(std::vector< HwmpProtocol::FailedDestination > destinations, std::vector< Mac48Address > receivers)
Forward a path error.
uint16_t rxPreq
receive PREQ
bool Receive(Ptr< Packet > packet, const WifiMacHeader &header)
Update beacon is empty, because HWMP does not know anything about beacons.
void InitiatePerr(std::vector< HwmpProtocol::FailedDestination > destinations, std::vector< Mac48Address > receivers)
initiate my own path error
Statistics m_stats
statistics
void SetSeqno(uint32_t seqno)
Set sequence number.
uint16_t txPreq
transmit PREQ
void SetHopcount(uint8_t hopcount)
Set number of hops from originator to mesh STA transmitting this element.
void AddHeader(const Header &header)
Add header to this packet.
uint16_t GetChannelId() const
Get the channel ID.