26 #include "ns3/simulator.h"
27 #include "ns3/packet.h"
28 #include "ns3/mesh-point-device.h"
29 #include "ns3/wifi-net-device.h"
30 #include "ns3/mesh-point-device.h"
31 #include "ns3/mesh-wifi-interface-mac.h"
32 #include "ns3/random-variable-stream.h"
36 #include "ns3/trace-source-accessor.h"
51 .AddConstructor<HwmpProtocol> ()
52 .AddAttribute (
"RandomStart",
53 "Random delay at first proactive PREQ",
59 .AddAttribute (
"MaxQueueSize",
60 "Maximum number of packets we can store when resolving route",
62 MakeUintegerAccessor (
64 MakeUintegerChecker<uint16_t> (1)
66 .AddAttribute (
"Dot11MeshHWMPmaxPREQretries",
67 "Maximum number of retries before we suppose the destination to be unreachable",
69 MakeUintegerAccessor (
71 MakeUintegerChecker<uint8_t> (1)
73 .AddAttribute (
"Dot11MeshHWMPnetDiameterTraversalTime",
74 "Time we suppose the packet to go from one edge of the network to another",
80 .AddAttribute (
"Dot11MeshHWMPpreqMinInterval",
81 "Minimal interval between to successive PREQs",
87 .AddAttribute (
"Dot11MeshHWMPperrMinInterval",
88 "Minimal interval between to successive PREQs",
93 .AddAttribute (
"Dot11MeshHWMPactiveRootTimeout",
94 "Lifetime of poractive routing information",
100 .AddAttribute (
"Dot11MeshHWMPactivePathTimeout",
101 "Lifetime of reactive routing information",
107 .AddAttribute (
"Dot11MeshHWMPpathToRootInterval",
108 "Interval between two successive proactive PREQs",
114 .AddAttribute (
"Dot11MeshHWMPrannInterval",
115 "Lifetime of poractive routing information",
121 .AddAttribute (
"MaxTtl",
122 "Initial value of Time To Live field",
124 MakeUintegerAccessor (
126 MakeUintegerChecker<uint8_t> (2)
128 .AddAttribute (
"UnicastPerrThreshold",
129 "Maximum number of PERR receivers, when we send a PERR as a chain of unicasts",
131 MakeUintegerAccessor (
133 MakeUintegerChecker<uint8_t> (1)
135 .AddAttribute (
"UnicastPreqThreshold",
136 "Maximum number of PREQ receivers, when we send a PREQ as a chain of unicasts",
138 MakeUintegerAccessor (
140 MakeUintegerChecker<uint8_t> (1)
142 .AddAttribute (
"UnicastDataThreshold",
143 "Maximum number ofbroadcast receivers, when we send a broadcast as a chain of unicasts",
145 MakeUintegerAccessor (
147 MakeUintegerChecker<uint8_t> (1)
149 .AddAttribute (
"DoFlag",
150 "Destination only HWMP flag",
152 MakeBooleanAccessor (
154 MakeBooleanChecker ()
156 .AddAttribute (
"RfFlag",
157 "Reply and forward flag",
159 MakeBooleanAccessor (
161 MakeBooleanChecker ()
163 .AddTraceSource (
"RouteDiscoveryTime",
164 "The time of route discovery procedure",
177 m_randomStart (Seconds (0.1)),
178 m_maxQueueSize (255),
179 m_dot11MeshHWMPmaxPREQretries (3),
180 m_dot11MeshHWMPnetDiameterTraversalTime (MicroSeconds (1024*100)),
181 m_dot11MeshHWMPpreqMinInterval (MicroSeconds (1024*100)),
182 m_dot11MeshHWMPperrMinInterval (MicroSeconds (1024*100)),
183 m_dot11MeshHWMPactiveRootTimeout (MicroSeconds (1024*5000)),
184 m_dot11MeshHWMPactivePathTimeout (MicroSeconds (1024*5000)),
185 m_dot11MeshHWMPpathToRootInterval (MicroSeconds (1024*2000)),
186 m_dot11MeshHWMPrannInterval (MicroSeconds (1024*5000)),
189 m_unicastPerrThreshold (32),
190 m_unicastPreqThreshold (1),
191 m_unicastDataThreshold (1),
220 i->second.preqTimeout.Cancel ();
234 uint32_t sourceIface,
238 uint16_t protocolType,
249 NS_FATAL_ERROR (
"HWMP tag has come with a packet from upper layer. This must not occur...");
262 NS_FATAL_ERROR (
"HWMP tag is supposed to be here at this point.");
276 std::vector<uint16_t> channels;
279 bool shouldSend =
true;
280 for (std::vector<uint16_t>::const_iterator chan = channels.begin (); chan != channels.end (); chan++)
282 if ((*chan) == plugin->second->GetChannelId ())
291 channels.push_back (plugin->second->GetChannelId ());
293 for (std::vector<Mac48Address>::const_iterator i = receivers.begin (); i != receivers.end (); i++)
303 routeReply (
true, packetCopy, source, destination, protocolType, plugin->first);
309 return ForwardUnicast (sourceIface, source, destination, packet, protocolType, routeReply, tag.
GetTtl ());
320 NS_FATAL_ERROR (
"HWMP tag must exist when packet received from the network");
343 routeReply (
true, packet, source, destination, protocolType, result.
ifIndex);
375 uint32_t dst_seqno = 0;
378 dst_seqno = result.
seqnum;
383 i->second->RequestDestination (destination, originator_seqno, dst_seqno);
388 pkt.
dst = destination;
391 pkt.
reply = routeReply;
411 bool freshInfo (
true);
421 if (i->second.second <= preq.
GetMetric ())
474 NS_ASSERT (((*i)->IsDo ()) && ((*i)->IsRf ()));
507 if ((*i)->GetDestinationAddress () ==
GetAddress ())
529 if ((lifetime > 0) && ((int32_t)(result.
seqnum - (*i)->GetDestSeqNumber ()) >= 0))
532 (*i)->GetDestinationAddress (),
545 (*i)->SetFlags (
true,
false, (*i)->IsUsn ());
564 i->second->SendPreq (preq);
574 bool freshInfo (
true);
578 if ((int32_t)(i->second.first - sequence) > 0)
582 if (i->second.first == sequence)
642 HwmpProtocolMacMap::const_iterator prep_sender =
m_interfaces.find (result.ifIndex);
644 prep_sender->second->SendPrep (prep, result.retransmitter);
651 std::vector<FailedDestination> retval;
653 for (
unsigned int i = 0; i < destinations.size (); i++)
658 (result.
ifIndex != interface) ||
659 ((int32_t)(result.
seqnum - destinations[i].seqnum) > 0)
662 retval.push_back (destinations[i]);
665 if (retval.size () == 0)
677 uint32_t originatorDsn,
678 uint32_t destinationSN,
691 HwmpProtocolMacMap::const_iterator prep_sender =
m_interfaces.find (interface);
693 prep_sender->second->SendPrep (prep, retransmitter);
700 std::vector<Ptr<NetDevice> >
interfaces = mp->GetInterfaces ();
701 for (std::vector<
Ptr<NetDevice> >::const_iterator i = interfaces.begin (); i != interfaces.end (); i++)
717 mac->InstallPlugin (hwmpMac);
722 mp->SetRoutingProtocol (
this);
724 mp->AggregateObject (
this);
750 std::map<Mac48Address, uint32_t,std::less<Mac48Address> >::const_iterator i =
m_lastDataSeqno.find (source);
757 if ((int32_t)(i->second - seqno) >= 0)
776 for (
unsigned int i = 0; i < destinations.size (); i++)
788 std::vector<Mac48Address> receivers_for_interface;
789 for (
unsigned int j = 0; j < perr.
receivers.size (); j++)
793 receivers_for_interface.push_back (perr.
receivers[j].second);
796 i->second->InitiatePerr (perr.
destinations, receivers_for_interface);
804 std::vector<Mac48Address> receivers_for_interface;
805 for (
unsigned int j = 0; j < perr.
receivers.size (); j++)
809 receivers_for_interface.push_back (perr.
receivers[j].second);
812 i->second->ForwardPerr (perr.
destinations, receivers_for_interface);
816 std::vector<std::pair<uint32_t, Mac48Address> >
820 for (
unsigned int i = 0; i < failedDest.size (); i++)
825 for (
unsigned int j = 0; j < precursors.size (); j++)
827 retval.push_back (precursors[j]);
831 for (
unsigned int i = 0; i < retval.size (); i++)
833 for (
unsigned int j = i+1; j < retval.size (); j++)
835 if (retval[i].second == retval[j].second)
837 retval.erase (retval.begin () + j);
843 std::vector<Mac48Address>
846 std::vector<Mac48Address> retval;
858 std::vector<Mac48Address>
861 std::vector<Mac48Address> retval;
890 for (std::vector<QueuedPacket>::iterator i =
m_rqueue.begin (); i !=
m_rqueue.end (); i++)
918 std::map<Mac48Address, PreqEvent>::iterator i =
m_preqTimeouts.find (dst);
928 while (packet.
pkt != 0)
949 while (packet.
pkt != 0)
970 std::map<Mac48Address, PreqEvent>::const_iterator i =
m_preqTimeouts.find (dst);
991 std::map<Mac48Address, PreqEvent>::iterator i =
m_preqTimeouts.find (dst);
1000 while (packet.
pkt != 0)
1006 std::map<Mac48Address, PreqEvent>::iterator i =
m_preqTimeouts.find (dst);
1017 i->second->RequestDestination (dst, originator_seqno, dst_seqno);
1053 i->second->SendPreq (preq);
1124 os <<
"<Statistics "
1125 "txUnicast=\"" << txUnicast <<
"\" "
1126 "txBroadcast=\"" << txBroadcast <<
"\" "
1127 "txBytes=\"" << txBytes <<
"\" "
1128 "droppedTtl=\"" << droppedTtl <<
"\" "
1129 "totalQueued=\"" << totalQueued <<
"\" "
1130 "totalDropped=\"" << totalDropped <<
"\" "
1131 "initiatedPreq=\"" << initiatedPreq <<
"\" "
1132 "initiatedPrep=\"" << initiatedPrep <<
"\" "
1133 "initiatedPerr=\"" << initiatedPerr <<
"\"/>" << std::endl;
1139 "address=\"" <<
m_address <<
"\"" << std::endl <<
1149 "isRoot=\"" <<
m_isRoot <<
"\"" << std::endl <<
1150 "maxTtl=\"" << (uint16_t)
m_maxTtl <<
"\"" << std::endl <<
1154 "doFlag=\"" <<
m_doFlag <<
"\"" << std::endl <<
1155 "rfFlag=\"" <<
m_rfFlag <<
"\">" << std::endl;
1159 plugin->second->Report (os);
1161 os <<
"</Hwmp>" << std::endl;
1169 plugin->second->ResetStats ();
Time m_dot11MeshHWMPrannInterval
Structure of path error: IePerr and list of receivers: interfaces and MAC address.
void SetDestinationAddress(Mac48Address dest_address)
void SetPreqID(uint32_t id)
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.
Simulation virtual time values and global simulation resolution.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
uint32_t GetDestinationSeqNumber() const
Hwmp tag implements interaction between HWMP protocol and MeshWifiMac.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
void IncrementMetric(uint32_t metric)
static const uint32_t MAX_METRIC
Maximum (the best?) path metric.
void SetOriginatorSeqNumber(uint32_t originator_seq_number)
Route lookup result, return type of LookupXXX methods.
Time m_dot11MeshHWMPpreqMinInterval
Time m_dot11MeshHWMPperrMinInterval
void SendPrep(Mac48Address src, Mac48Address dst, Mac48Address retransmitter, uint32_t initMetric, uint32_t originatorDsn, uint32_t destinationSN, uint32_t lifetime, uint32_t interface)
forms a path error information element when list of destination fails on a given interface ...
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Time m_dot11MeshHWMPactiveRootTimeout
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
void ForwardPathError(PathError perr)
Forwards a received path error.
#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).
LookupResult LookupReactiveExpired(Mac48Address destination)
Return all reactive paths, including expired.
Mac48Address GetDestinationAddress() const
Mac48Address src
src address
bool Install(Ptr< MeshPointDevice >)
Install HWMP on given mesh point.
#define NS_FATAL_ERROR(msg)
fatal error handling
void InitiatePathError(PathError perr)
Passes a self-generated PERR to interface-plugin.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
uint32_t CalculateMetric(Mac48Address peerAddress, Ptr< MeshWifiInterfaceMac > mac)
uint32_t GetLifetime() const
void ReactivePathResolved(Mac48Address dst)
void SetOriginatorAddress(Mac48Address originator_address)
std::map< Mac48Address, std::pair< uint32_t, uint32_t > > m_hwmpSeqnoMetricDatabase
keeps HWMP seqno (first in pair) and HWMP metric (second in pair) for each address ...
void SetAddress(Mac48Address retransmitter)
uint8_t m_unicastDataThreshold
LookupResult LookupReactive(Mac48Address destination)
Lookup path to destination.
TracedCallback< Time > m_routeDiscoveryTimeCallback
Route discovery time:
void SetLifetime(uint32_t lifetime)
void ReceivePrep(IePrep prep, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric)
forms a path error information element when list of destination fails on a given interface ...
void SendProactivePreq()
Proactive Preq routines:
bool DropDataFrame(uint32_t seqno, Mac48Address source)
MAC-plugin asks whether the frame can be dropped.
QueuedPacket DequeueFirstPacket()
Ptr< T > CreateObject(void)
std::vector< std::pair< uint32_t, Mac48Address > > PrecursorList
Path precursor = {MAC, interface ID}.
Mac48Address GetOriginatorAddress() const
Ptr< Packet > pkt
the packet
Routing table for HWMP – 802.11s routing protocol.
void Print(std::ostream &os) const
std::vector< Mac48Address > GetPreqReceivers(uint32_t interface)
double GetSeconds(void) const
bool RemoveRoutingStuff(uint32_t fromIface, const Mac48Address source, const Mac48Address destination, Ptr< Packet > packet, uint16_t &protocolType)
Cleanup packet from all tags.
Mac48Address GetOriginatorAddress() const
bool PeekPacketTag(Tag &tag) const
Search a matching tag and call Tag::Deserialize if it is found.
Time GetPerrMinInterval()
Ptr< MeshPointDevice > GetMeshPoint() const
Each mesh protocol must be installed on the mesh point to work.
uint8_t m_unicastPerrThreshold
std::vector< QueuedPacket > m_rqueue
Packet Queue.
std::vector< std::pair< uint32_t, Mac48Address > > GetPerrReceivers(std::vector< FailedDestination > failedDest)
int64_t GetMicroSeconds(void) const
std::vector< HwmpProtocol::FailedDestination > GetUnreachableDestinations(Mac48Address peerAddress)
When peer link with a given MAC-address fails - it returns list of unreachable destination addresses...
void RetryPathDiscovery(Mac48Address dst, uint8_t numOfRetry)
Generates PREQ retry when retry timeout has expired and route is still unresolved.
Ptr< MeshPointDevice > m_mp
Host mesh point.
void IncrementMetric(uint32_t metric)
hold objects of type ns3::Time
void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
See 7.3.2.96 of 802.11s draft 2.07.
Hold an unsigned integer type.
PrecursorList GetPrecursors(Mac48Address destination)
bool ForwardUnicast(uint32_t sourceIface, const Mac48Address source, const Mac48Address destination, Ptr< Packet > packet, uint16_t protocolType, RouteReplyCallback routeReply, uint32_t ttl)
Like RequestRoute, but for unicast packets.
Packet waiting its routing information.
Hold together all Wifi-related objects.
static Mac48Address GetBroadcast(void)
void ProactivePathResolved()
HwmpProtocolMacMap m_interfaces
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
uint32_t GetOriginatorSeqNumber() const
uint32_t GetActivePathLifetime()
void AddPrecursor(Mac48Address destination, uint32_t precursorInterface, Mac48Address precursorAddress, Time lifetime)
Ptr< HwmpRtable > m_rtable
Routing table.
void SetOriginatorAddress(Mac48Address originator_address)
void SetLifetime(uint32_t lifetime)
static TypeId GetTypeId()
uint8_t m_unicastPreqThreshold
LookupResult LookupProactiveExpired()
Return all proactive paths, including expired.
void ReceivePreq(IePreq preq, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric)
forms a path error information element when list of destination fails on a given interface ...
Time m_randomStart
Random start in Proactive PREQ propagation.
Mac48Address GetAddress()
static Mac48Address ConvertFrom(const Address &address)
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
void SetOriginatorSeqNumber(uint32_t originator_seq_number)
uint16_t protocol
protocol number
void SetMetric(uint32_t metric)
uint8_t m_dot11MeshHWMPmaxPREQretries
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 AddReactivePath(Mac48Address destination, Mac48Address retransmitter, uint32_t interface, uint32_t metric, Time lifetime, uint32_t seqnum)
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
void DelDestinationAddressElement(Mac48Address dest_address)
Delete a destination address unit by destination.
PathError MakePathError(std::vector< FailedDestination > destinations)
forms a path error information element when list of destination fails on a given interface ...
std::vector< std::pair< uint32_t, Mac48Address > > receivers
list of PathError receivers (in case of unicast PERR)
bool IsNeedNotPrep() const
uint32_t GetNextHwmpSeqno()
uint8_t GetDestCount() const
static Time Now(void)
Return the "current simulation time".
std::vector< Ptr< DestinationAddressUnit > > GetDestinationList()
Get all destinations, which are stored in PREQ:
RouteReplyCallback reply
how to reply
Interface for L2 mesh routing protocol and mesh point communication.
void Report(std::ostream &) const
Statistics:
Mac48Address dst
dst address
void DeleteProactivePath()
Ptr< UniformRandomVariable > m_coefficient
Random variable for random start time.
uint8_t GetUnicastPerrThreshold()
EventId m_proactivePreqTimer
Random start in Proactive PREQ propagation.
Mac48Address retransmitter
Time m_dot11MeshHWMPactivePathTimeout
std::vector< Mac48Address > GetBroadcastReceivers(uint32_t interface)
std::vector< FailedDestination > destinations
destination list: Mac48Address and sequence number
Time m_dot11MeshHWMPpathToRootInterval
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Callback< std::vector< Mac48Address >, uint32_t > m_neighboursCallback
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method.
uint32_t GetLifetime() const
std::map< Mac48Address, uint32_t > m_lastDataSeqno
keeps HWMP seqno (first in pair) and HWMP metric (second in pair) for each address ...
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
void DeleteReactivePath(Mac48Address destination)
QueuedPacket DequeueFirstPacketByDst(Mac48Address dst)
Time GetPreqMinInterval()
void AddProactivePath(uint32_t metric, Mac48Address root, Mac48Address retransmitter, uint32_t interface, Time lifetime, uint32_t seqnum)
uint32_t GetMetric() const
void SetSeqno(uint32_t seqno)
uint32_t inInterface
incoming device interface ID. (if packet has come from upper layers, this is Mesh point ID) ...
bool QueuePacket(QueuedPacket packet)
uint32_t GetMetric() const
bool ShouldSendPreq(Mac48Address dst)
checks when the last path discovery procedure was started for a given destination.
Hold a floating point type.
void SetDestinationSeqNumber(uint32_t dest_seq_number)
void SetHopcount(uint8_t hopcount)
void PeerLinkStatus(Mac48Address meshPontAddress, Mac48Address peerAddress, uint32_t interface, bool status)
void SetAttribute(std::string name, const AttributeValue &value)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Basic MAC of mesh point Wi-Fi interface.
void SetHopcount(uint8_t hopcount)
std::map< Mac48Address, PreqEvent > m_preqTimeouts
Random start in Proactive PREQ propagation.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Time m_dot11MeshHWMPnetDiameterTraversalTime
LookupResult LookupProactive()
Find proactive path to tree root. Note that calling this method has side effect of deleting expired p...
void ReceivePerr(std::vector< FailedDestination >, Mac48Address from, uint32_t interface, Mac48Address fromMp)
forms a path error information element when list of destination fails on a given interface ...
void SetNeighboursCallback(Callback< std::vector< Mac48Address >, uint32_t > cb)
This callback is used to obtain active neighbours on a given interface.
virtual void DoInitialize()
This method is called only once by Object::Initialize.