19#include "ns3/mesh-wifi-interface-mac.h" 
   20#include "ns3/mgt-action-headers.h" 
   21#include "ns3/nstime.h" 
   22#include "ns3/packet.h" 
   23#include "ns3/simulator.h" 
   24#include "ns3/wifi-mac-header.h" 
   60    if (packet->PeekPacketTag(tag))
 
   62        NS_FATAL_ERROR(
"HWMP tag is not supposed to be received by network");
 
   65    packet->RemoveHeader(meshHdr);
 
   67    m_stats.rxDataBytes += packet->GetSize();
 
   79        NS_FATAL_ERROR(
"6-address scheme is not yet supported and 4-address extension is not " 
   80                       "supposed to be used for data frames.");
 
   84    packet->AddPacketTag(tag);
 
   89        NS_LOG_DEBUG(
"Dropping frame; source " << source << 
" dest " << destination << 
" seqno " 
 
  101    m_stats.rxMgtBytes += packet->GetSize();
 
  103    packet->RemoveHeader(actionHdr);
 
  111    packet->RemoveHeader(elements, packet->GetSize());
 
  112    std::vector<HwmpProtocol::FailedDestination> failedDestinations;
 
  113    for (
auto i = elements.
Begin(); i != elements.
End(); i++)
 
  115        if ((*i)->ElementId() == 
IE_RANN)
 
  119        if ((*i)->ElementId() == 
IE_PREQ)
 
  124            if (preq->GetOriginatorAddress() == 
m_protocol->GetAddress())
 
  128            if (preq->GetTtl() == 0)
 
  132            preq->DecrementTtl();
 
  139        if ((*i)->ElementId() == 
IE_PREP)
 
  144            if (prep->GetTtl() == 0)
 
  148            prep->DecrementTtl();
 
  155        if ((*i)->ElementId() == 
IE_PERR)
 
  160            std::vector<HwmpProtocol::FailedDestination> destinations =
 
  161                perr->GetAddressUnitVector();
 
  162            for (
auto i = destinations.begin(); i != destinations.end(); i++)
 
  164                failedDestinations.push_back(*i);
 
  168    if (!failedDestinations.empty())
 
 
  212    bool tagExists = packet->RemovePacketTag(tag);
 
  218    m_stats.txDataBytes += packet->GetSize();
 
  222    packet->AddHeader(meshHdr);
 
 
  242    std::vector<IePreq> preq_vector;
 
  243    preq_vector.push_back(preq);
 
 
  253    for (
auto i = preq.begin(); i != preq.end(); i++)
 
  257    packet->AddHeader(elements);
 
  268    for (
auto i = receivers.begin(); i != receivers.end(); i++)
 
  273        m_stats.txMgtBytes += packet->GetSize();
 
  274        m_parent->SendManagementFrame(packet, hdr);
 
 
  289        i->AddDestinationAddressElement(
m_protocol->GetDoFlag(),
 
 
  337    packet->AddHeader(elements);
 
  350    m_stats.txMgtBytes += packet->GetSize();
 
  351    m_parent->SendManagementFrame(packet, hdr);
 
 
  356                             std::vector<Mac48Address> receivers)
 
  362    for (
auto i = failedDestinations.begin(); i != failedDestinations.end(); i++)
 
  366            perr->AddAddressUnit(*i);
 
  374    if (perr->GetNumOfDest() > 0)
 
  378    packet->AddHeader(elements);
 
  387    if (receivers.size() >= 
m_protocol->GetUnicastPerrThreshold())
 
  393    for (
auto i = receivers.begin(); i != receivers.end(); i++)
 
  403        m_stats.txMgtBytes += packet->GetSize();
 
  404        m_parent->SendManagementFrame(packet, hdr);
 
 
  410                              std::vector<Mac48Address> receivers)
 
  416        for (
auto i = receivers.begin(); i != receivers.end(); i++)
 
  418            bool should_add = 
true;
 
  419            for (
auto j = 
m_myPerr.receivers.begin(); j != 
m_myPerr.receivers.end(); j++)
 
  429                NS_LOG_DEBUG(
"Initiate PERR:  Adding receiver: " << (*i));
 
  434        for (
auto i = failedDestinations.begin(); i != failedDestinations.end(); i++)
 
  436            bool should_add = 
true;
 
  437            for (
auto j = 
m_myPerr.destinations.begin(); j != 
m_myPerr.destinations.end(); j++)
 
  439                if (((*i).destination == (*j).destination) && ((*j).seqnum > (*i).seqnum))
 
  446                m_myPerr.destinations.push_back(*i);
 
  447                NS_LOG_DEBUG(
"Initiate PERR:  Adding failed destination: " << (*i).destination);
 
 
  472    return m_parent->GetLinkMetric(peerAddress);
 
 
  478    return m_parent->GetFrequencyChannel();
 
 
  504       << 
txPreq << 
"\"" << std::endl
 
  505       << 
"txPrep=\"" << 
txPrep << 
"\"" << std::endl
 
  506       << 
"txPerr=\"" << 
txPerr << 
"\"" << std::endl
 
  507       << 
"rxPreq=\"" << 
rxPreq << 
"\"" << std::endl
 
  508       << 
"rxPrep=\"" << 
rxPrep << 
"\"" << std::endl
 
  509       << 
"rxPerr=\"" << 
rxPerr << 
"\"" << std::endl
 
  510       << 
"txMgt=\"" << 
txMgt << 
"\"" << std::endl
 
  511       << 
"txMgtBytes=\"" << 
txMgtBytes << 
"\"" << std::endl
 
  512       << 
"rxMgt=\"" << 
rxMgt << 
"\"" << std::endl
 
  513       << 
"rxMgtBytes=\"" << 
rxMgtBytes << 
"\"" << std::endl
 
  514       << 
"txData=\"" << 
txData << 
"\"" << std::endl
 
  515       << 
"txDataBytes=\"" << 
txDataBytes << 
"\"" << std::endl
 
  516       << 
"rxData=\"" << 
rxData << 
"\"" << std::endl
 
  517       << 
"rxDataBytes=\"" << 
rxDataBytes << 
"\"/>" << std::endl;
 
 
  523    os << 
"<HwmpProtocolMac" << std::endl
 
  524       << 
"address =\"" << 
m_parent->GetAddress() << 
"\">" << std::endl;
 
  526    os << 
"</HwmpProtocolMac>" << std::endl;
 
 
static Mac48Address GetBroadcast()
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static WifiActionHeader GetWifiActionHeader()
void SendMyPreq()
Sends one PREQ when PreqMinInterval after last PREQ expires (if any PREQ exists in rhe queue)
void SendPreq(IePreq preq)
Send PREQ function.
HwmpProtocolMac(uint32_t ifIndex, Ptr< HwmpProtocol > protocol)
Constructor.
void SetParent(Ptr< MeshWifiInterfaceMac > parent) override
Each plugin must be installed on an interface to work.
~HwmpProtocolMac() override
void SendPreqVector(std::vector< IePreq > preq)
Send PREQ function for vector of PREQ.
void SendPrep(IePrep prep, Mac48Address receiver)
Send PREP function.
void SendMyPerr()
Send PERR function.
uint16_t GetChannelId() const
Get the channel ID.
bool Receive(Ptr< Packet > packet, const WifiMacHeader &header) override
Process received frame.
void ForwardPerr(std::vector< HwmpProtocol::FailedDestination > destinations, std::vector< Mac48Address > receivers)
Forward a path error.
uint32_t m_ifIndex
IF index.
Ptr< HwmpProtocol > m_protocol
protocol
bool ReceiveData(Ptr< Packet > packet, const WifiMacHeader &header)
Receive data frame.
Statistics m_stats
statistics
EventId m_preqTimer
Timer for PREQs.
void ResetStats()
Reset statistics.
uint32_t GetLinkMetric(Mac48Address peerAddress) const
bool ReceiveAction(Ptr< Packet > packet, const WifiMacHeader &header)
Receive action management frame.
void InitiatePerr(std::vector< HwmpProtocol::FailedDestination > destinations, std::vector< Mac48Address > receivers)
initiate my own path error
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
std::vector< IePreq > m_myPreq
container of PREQs
void Report(std::ostream &os) const
Report statistics.
bool UpdateOutcomingFrame(Ptr< Packet > packet, WifiMacHeader &header, Mac48Address from, Mac48Address to) override
Update frame before it will be forwarded down.
Ptr< MeshWifiInterfaceMac > m_parent
parent
void RequestDestination(Mac48Address dest, uint32_t originator_seqno, uint32_t dst_seqno)
Request a destination.
Hwmp tag implements interaction between HWMP protocol and MeshWifiMac.
void SetTtl(uint8_t ttl)
Set the TTL value.
uint32_t GetSeqno() const
Get the sequence number.
void SetSeqno(uint32_t seqno)
Set sequence number.
uint8_t GetTtl() const
Get the TTL value.
Mac48Address GetAddress()
Get address from tag.
See 7.3.2.97 of 802.11s draft 2.07.
See 7.3.2.96 of 802.11s draft 2.07.
void SetHopcount(uint8_t hopcount)
Set number of hops from originator to mesh STA transmitting this element.
void SetOriginatorSeqNumber(uint32_t originator_seq_number)
Set originator sequence number.
void SetTTL(uint8_t ttl)
Set remaining number of hops allowed for this element.
void SetOriginatorAddress(Mac48Address originator_address)
Set originator address value.
void SetPreqID(uint32_t id)
Set path discovery id field.
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 SetLifetime(uint32_t lifetime)
Set lifetime in TUs for the forwarding information to be considered valid.
#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.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
uint32_t txMgtBytes
transmit management bytes
void Print(std::ostream &os) const
Print function.
uint16_t txPrep
transmit PREP
uint16_t rxMgt
receive management
uint16_t txPreq
transmit PREQ
uint16_t rxPerr
receive PERR
uint16_t rxPrep
receive PREP
uint32_t txDataBytes
transmit data bytes
uint16_t txData
transmit data
uint16_t txMgt
transmit management
uint16_t rxPreq
receive PREQ
uint16_t rxData
receive data
uint32_t rxMgtBytes
receive management bytes
uint32_t rxDataBytes
receive data bytes
uint16_t txPerr
transmit PERR