A Discrete-Event Network Simulator
API
hwmp-protocol.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008,2009 IITP RAS
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Kirill Andreev <andreev@iitp.ru>
19  */
20 
21 #ifndef HWMP_PROTOCOL_H
22 #define HWMP_PROTOCOL_H
23 
24 #include "ns3/mesh-l2-routing-protocol.h"
25 #include "ns3/nstime.h"
26 #include "ns3/event-id.h"
27 #include "ns3/traced-value.h"
28 #include <vector>
29 #include <map>
30 
31 namespace ns3 {
32 class MeshPointDevice;
33 class Packet;
34 class Mac48Address;
35 class UniformRandomVariable;
36 class RandomVariableStream;
37 namespace dot11s {
38 class HwmpProtocolMac;
39 class HwmpRtable;
40 class IePerr;
41 class IePreq;
42 class IePrep;
43 
48 {
49  std::string type;
52  uint32_t interface;
53  uint32_t metric;
55  uint32_t seqnum;
56 };
64 {
65 public:
70  static TypeId GetTypeId ();
71  HwmpProtocol ();
72  ~HwmpProtocol ();
73  void DoDispose ();
74 
79  {
81  uint32_t seqnum;
82  };
83 
95  bool RequestRoute (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination,
96  Ptr<const Packet> packet, uint16_t protocolType, RouteReplyCallback routeReply);
107  bool RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source,
108  const Mac48Address destination, Ptr<Packet> packet, uint16_t& protocolType);
119  bool Install (Ptr<MeshPointDevice> mp);
127  void PeerLinkStatus (Mac48Address meshPontAddress, Mac48Address peerAddress, uint32_t interface,bool status);
132  void SetNeighboursCallback (Callback<std::vector<Mac48Address>, uint32_t> cb);
136  void SetRoot ();
138  void UnsetRoot ();
140 
143 
147  void Report (std::ostream & os) const;
149  void ResetStats ();
151 
160  int64_t AssignStreams (int64_t stream);
161 
166  Ptr<HwmpRtable> GetRoutingTable (void) const;
167 
168 private:
170  friend class HwmpProtocolMac;
171 
172  virtual void DoInitialize ();
173 
184  HwmpProtocol (const HwmpProtocol & hwmp);
185 
190  struct PathError
191  {
192  std::vector<FailedDestination> destinations;
193  std::vector<std::pair<uint32_t, Mac48Address> > receivers;
194  };
197  {
201  uint16_t protocol;
202  uint32_t inInterface;
204 
205  QueuedPacket ();
206  };
207  typedef std::map<uint32_t, Ptr<HwmpProtocolMac> > HwmpProtocolMacMap;
220  bool ForwardUnicast (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination,
221  Ptr<Packet> packet, uint16_t protocolType, RouteReplyCallback routeReply, uint32_t ttl);
222 
225 
234  void ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric);
244  void ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric);
253  void ReceivePerr (std::vector<FailedDestination> destinations, Mac48Address from, uint32_t interface, Mac48Address fromMp);
265  void SendPrep (
266  Mac48Address src,
267  Mac48Address dst,
268  Mac48Address retransmitter,
269  uint32_t initMetric,
270  uint32_t originatorDsn,
271  uint32_t destinationSN,
272  uint32_t lifetime,
273  uint32_t interface);
281  PathError MakePathError (std::vector<FailedDestination> destinations);
286  void ForwardPathError (PathError perr);
291  void InitiatePathError (PathError perr);
298  std::vector<std::pair<uint32_t, Mac48Address> > GetPerrReceivers (std::vector<FailedDestination> failedDest);
299 
306  std::vector<Mac48Address> GetPreqReceivers (uint32_t interface);
313  std::vector<Mac48Address> GetBroadcastReceivers (uint32_t interface);
321  bool DropDataFrame (uint32_t seqno, Mac48Address source);
323 
330 
331  // /\name Methods related to Queue/Dequeue procedures
333 
338  bool QueuePacket (QueuedPacket packet);
358  void ProactivePathResolved ();
360 
363 
370  bool ShouldSendPreq (Mac48Address dst);
371 
379  void RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry);
381  void SendProactivePreq ();
383 
388 
392  bool GetDoFlag ();
397  bool GetRfFlag ();
412  uint8_t GetMaxTtl ();
417  uint32_t GetNextPreqId ();
422  uint32_t GetNextHwmpSeqno ();
427  uint32_t GetActivePathLifetime ();
432  uint8_t GetUnicastPerrThreshold ();
434 
435 private:
437  struct Statistics
438  {
439  uint16_t txUnicast;
440  uint16_t txBroadcast;
441  uint32_t txBytes;
442  uint16_t droppedTtl;
443  uint16_t totalQueued;
444  uint16_t totalDropped;
445  uint16_t initiatedPreq;
446  uint16_t initiatedPrep;
447  uint16_t initiatedPerr;
448 
453  void Print (std::ostream & os) const;
455  Statistics ();
456  };
458 
461  uint32_t m_dataSeqno;
462  uint32_t m_hwmpSeqno;
463  uint32_t m_preqId;
467  std::map<Mac48Address, uint32_t> m_lastDataSeqno;
469  std::map<Mac48Address, std::pair<uint32_t, uint32_t> > m_hwmpSeqnoMetricDatabase;
471 
474 
476  struct PreqEvent {
479  };
480 
481  std::map<Mac48Address, PreqEvent> m_preqTimeouts;
486  std::vector<QueuedPacket> m_rqueue;
487 
491  uint16_t m_maxQueueSize;
500  bool m_isRoot;
501  uint8_t m_maxTtl;
505  bool m_doFlag;
506  bool m_rfFlag;
508 
512 };
513 } // namespace dot11s
514 } // namespace ns3
515 #endif
Callback template class.
Definition: callback.h:1279
An identifier for simulation events.
Definition: event-id.h:54
an EUI-48 address
Definition: mac48-address.h:44
Interface for L2 mesh routing protocol and mesh point communication.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Hybrid wireless mesh protocol – a mesh routing protocol defined in IEEE 802.11-2012 standard.
Definition: hwmp-protocol.h:64
void SetRoot()
Unset the current node as root.
std::vector< Mac48Address > GetPreqReceivers(uint32_t interface)
Get PREQ receivers.
QueuedPacket DequeueFirstPacket()
Dequeue the first packet in the queue.
Ptr< HwmpRtable > m_rtable
Routing table.
uint8_t m_unicastDataThreshold
Maximum number of broadcast receivers, when we send a broadcast as a chain of unicasts.
void ReceivePrep(IePrep prep, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric)
Handler for receiving Path Reply.
void Report(std::ostream &os) const
Statistics:
uint32_t GetNextHwmpSeqno()
Get next HWMP sequence no function.
PathError MakePathError(std::vector< FailedDestination > destinations)
forms a path error information element when list of destination fails on a given interface
Time m_dot11MeshHWMPrannInterval
Lifetime of proactive routing information.
Time GetPerrMinInterval()
Get PERR minimum interval function.
uint8_t m_unicastPreqThreshold
Maximum number of PREQ receivers, when we send a PREQ as a chain of unicasts.
void UnsetRoot()
Unset the current node as root.
uint32_t m_dataSeqno
data sequence no
Time m_dot11MeshHWMPnetDiameterTraversalTime
Time we suppose the packet to go from one edge of the network to another.
Time m_dot11MeshHWMPactivePathTimeout
Lifetime of reactive routing information.
bool QueuePacket(QueuedPacket packet)
Queue a packet.
bool m_isRoot
True if the node is a root.
Statistics m_stats
statistics
uint32_t m_hwmpSeqno
HWMP sequence no.
bool RemoveRoutingStuff(uint32_t fromIface, const Mac48Address source, const Mac48Address destination, Ptr< Packet > packet, uint16_t &protocolType)
Clean HWMP packet tag from packet; only the packet parameter is used.
Time m_randomStart
Random start in Proactive PREQ propagation.
void SendPrep(Mac48Address src, Mac48Address dst, Mac48Address retransmitter, uint32_t initMetric, uint32_t originatorDsn, uint32_t destinationSN, uint32_t lifetime, uint32_t interface)
Send Path Reply.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
virtual void DoInitialize()
Initialize() implementation.
TracedCallback< struct RouteChange > RouteChangeTracedCallback
RouteChangeTracedCallback typedef.
TracedCallback< Time > m_routeDiscoveryTimeCallback
Route discovery time:
static TypeId GetTypeId()
Get the type ID.
bool GetRfFlag()
Get rf flag function.
bool ShouldSendPreq(Mac48Address dst)
checks when the last path discovery procedure was started for a given destination.
void PeerLinkStatus(Mac48Address meshPontAddress, Mac48Address peerAddress, uint32_t interface, bool status)
Peer link status function.
void ReceivePerr(std::vector< FailedDestination > destinations, Mac48Address from, uint32_t interface, Mac48Address fromMp)
Handler for receiving Path Error.
std::map< Mac48Address, PreqEvent > m_preqTimeouts
PREQ timeouts.
Time m_dot11MeshHWMPperrMinInterval
Minimal interval between to successive PREQs.
bool m_rfFlag
Reply and forward flag.
bool GetDoFlag()
Get do flag function.
Time GetPreqMinInterval()
Get PREQ minimum interval function.
QueuedPacket DequeueFirstPacketByDst(Mac48Address dst)
Dequeue the first packet for a given destination.
EventId m_proactivePreqTimer
proactive PREQ timer
Ptr< UniformRandomVariable > m_coefficient
Random variable for random start time.
uint32_t GetNextPreqId()
Get next period function.
void InitiatePathError(PathError perr)
Passes a self-generated PERR to interface-plugin.
uint8_t GetUnicastPerrThreshold()
Get unicast PERR threshold function.
void SendProactivePreq()
Proactive Preq routines:
void ForwardPathError(PathError perr)
Forwards a received path error.
void DoDispose()
Destructor implementation.
Time m_dot11MeshHWMPpathToRootInterval
Interval between two successive proactive PREQs.
void RetryPathDiscovery(Mac48Address dst, uint8_t numOfRetry)
Generates PREQ retry when retry timeout has expired and route is still unresolved.
bool m_doFlag
Destination only HWMP flag.
Mac48Address m_address
address
Time m_dot11MeshHWMPactiveRootTimeout
Lifetime of proactive routing information.
void ReceivePreq(IePreq preq, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric)
Handler for receiving Path Request.
Time m_dot11MeshHWMPpreqMinInterval
Minimal interval between to successive PREQs.
uint8_t GetMaxTtl()
Get maximum TTL function.
void ReactivePathResolved(Mac48Address dst)
Signal the protocol that the reactive path toward a destination is now available.
std::vector< Mac48Address > GetBroadcastReceivers(uint32_t interface)
Get broadcast receivers.
bool Install(Ptr< MeshPointDevice > mp)
Install HWMP on given mesh point.
uint32_t GetActivePathLifetime()
Get active path lifetime function.
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.
void ProactivePathResolved()
Signal the protocol that the proactive path is now available.
void SetNeighboursCallback(Callback< std::vector< Mac48Address >, uint32_t > cb)
This callback is used to obtain active neighbours on a given interface.
std::vector< QueuedPacket > m_rqueue
Packet Queue.
Callback< std::vector< Mac48Address >, uint32_t > m_neighboursCallback
neighbors callback
std::vector< std::pair< uint32_t, Mac48Address > > GetPerrReceivers(std::vector< FailedDestination > failedDest)
Get PERR receivers.
HwmpProtocol & operator=(const HwmpProtocol &hwmp)
assignment operator
HwmpProtocolMacMap m_interfaces
interfaces
Ptr< HwmpRtable > GetRoutingTable(void) const
Get pointer to HWMP routing table.
uint16_t m_maxQueueSize
Maximum number of packets we can store when resolving route.
uint8_t m_maxTtl
Initial value of Time To Live field.
std::map< Mac48Address, uint32_t > m_lastDataSeqno
keeps HWMP seqno (first in pair) and HWMP metric (second in pair) for each address
void ResetStats()
Reset Statistics:
bool DropDataFrame(uint32_t seqno, Mac48Address source)
MAC-plugin asks whether the frame can be dropped.
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.
uint8_t m_unicastPerrThreshold
Maximum number of PERR receivers, when we send a PERR as a chain of unicasts.
uint32_t m_preqId
PREQ ID.
uint8_t m_dot11MeshHWMPmaxPREQretries
Maximum number of retries before we suppose the destination to be unreachable.
HwmpProtocol(const HwmpProtocol &hwmp)
Copy constructor - defined but not implemented (on purpose)
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
TracedCallback< struct RouteChange > m_routeChangeTraceSource
Route change trace source.
std::map< uint32_t, Ptr< HwmpProtocolMac > > HwmpProtocolMacMap
HwmpProtocolMacMap typedef.
Interface MAC plugin for HWMP – 802.11s routing protocol.
See 7.3.2.97 of 802.11s draft 2.07.
See 7.3.2.96 of 802.11s draft 2.07.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
structure of unreachable destination - address and sequence number
Definition: hwmp-protocol.h:79
Mac48Address destination
destination address
Definition: hwmp-protocol.h:80
Structure of path error: IePerr and list of receivers: interfaces and MAC address.
std::vector< FailedDestination > destinations
destination list: Mac48Address and sequence number
std::vector< std::pair< uint32_t, Mac48Address > > receivers
list of PathError receivers (in case of unicast PERR)
Packet waiting its routing information.
RouteReplyCallback reply
how to reply
uint32_t inInterface
incoming device interface ID. (if packet has come from upper layers, this is Mesh point ID)
void Print(std::ostream &os) const
Print function.
uint16_t initiatedPrep
initiated PREP
uint16_t txBroadcast
transmit broadcast
uint16_t txUnicast
transmit unicast
uint16_t initiatedPerr
initiated PERR
uint16_t initiatedPreq
initiated PREQ
Structure to encapsulate route change information.
Definition: hwmp-protocol.h:48
Time lifetime
lifetime of route
Definition: hwmp-protocol.h:54
Mac48Address retransmitter
route source
Definition: hwmp-protocol.h:51
uint32_t seqnum
sequence number of route
Definition: hwmp-protocol.h:55
uint32_t metric
metric of route
Definition: hwmp-protocol.h:53
Mac48Address destination
route destination
Definition: hwmp-protocol.h:50
std::string type
type of change
Definition: hwmp-protocol.h:49
uint32_t interface
interface index
Definition: hwmp-protocol.h:52