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 namespace dot11s {
37 class HwmpProtocolMac;
38 class HwmpRtable;
39 class IePerr;
40 class IePreq;
41 class IePrep;
42 
47 {
48  std::string type;
51  uint32_t interface;
52  uint32_t metric;
54  uint32_t seqnum;
55 };
63 {
64 public:
69  static TypeId GetTypeId ();
70  HwmpProtocol ();
71  ~HwmpProtocol ();
72  void DoDispose ();
77  {
79  uint32_t seqnum;
80  };
81 
94  bool RequestRoute (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination,
95  Ptr<const Packet> packet, uint16_t protocolType, RouteReplyCallback routeReply);
106  bool RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source,
107  const Mac48Address destination, Ptr<Packet> packet, uint16_t& protocolType);
117  bool Install (Ptr<MeshPointDevice>);
125  void PeerLinkStatus (Mac48Address meshPontAddress, Mac48Address peerAddress, uint32_t interface,bool status);
130  void SetNeighboursCallback (Callback<std::vector<Mac48Address>, uint32_t> cb);
133  void SetRoot ();
134  void UnsetRoot ();
137  void Report (std::ostream &) const;
139  void ResetStats ();
148  int64_t AssignStreams (int64_t stream);
149 
154  Ptr<HwmpRtable> GetRoutingTable (void) const;
155 
156 private:
158  friend class HwmpProtocolMac;
159 
160  virtual void DoInitialize ();
161 
167  HwmpProtocol& operator= (const HwmpProtocol & hwmp);
172  HwmpProtocol (const HwmpProtocol &);
173 
178  struct PathError
179  {
180  std::vector<FailedDestination> destinations;
181  std::vector<std::pair<uint32_t, Mac48Address> > receivers;
182  };
185  {
189  uint16_t protocol;
190  uint32_t inInterface;
192 
193  QueuedPacket ();
194  };
195  typedef std::map<uint32_t, Ptr<HwmpProtocolMac> > HwmpProtocolMacMap;
196 
208  bool ForwardUnicast (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination,
209  Ptr<Packet> packet, uint16_t protocolType, RouteReplyCallback routeReply, uint32_t ttl);
210 
212  //\{
222  void ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric);
232  void ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric);
241  void ReceivePerr (std::vector<FailedDestination> destinations, Mac48Address from, uint32_t interface, Mac48Address fromMp);
253  void SendPrep (
254  Mac48Address src,
255  Mac48Address dst,
257  uint32_t initMetric,
258  uint32_t originatorDsn,
259  uint32_t destinationSN,
260  uint32_t lifetime,
261  uint32_t interface);
269  PathError MakePathError (std::vector<FailedDestination> destinations);
274  void ForwardPathError (PathError perr);
279  void InitiatePathError (PathError perr);
286  std::vector<std::pair<uint32_t, Mac48Address> > GetPerrReceivers (std::vector<FailedDestination> failedDest);
287 
294  std::vector<Mac48Address> GetPreqReceivers (uint32_t interface);
301  std::vector<Mac48Address> GetBroadcastReceivers (uint32_t interface);
309  bool DropDataFrame (uint32_t seqno, Mac48Address source);
310  //\}
319  bool QueuePacket (QueuedPacket packet);
320  QueuedPacket DequeueFirstPacketByDst (Mac48Address dst);
321  QueuedPacket DequeueFirstPacket ();
322  void ReactivePathResolved (Mac48Address dst);
323  void ProactivePathResolved ();
327 
334  bool ShouldSendPreq (Mac48Address dst);
335 
343  void RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry);
345  void SendProactivePreq ();
348  Mac48Address GetAddress ();
350 
354  bool GetDoFlag ();
359  bool GetRfFlag ();
364  Time GetPreqMinInterval ();
369  Time GetPerrMinInterval ();
374  uint8_t GetMaxTtl ();
379  uint32_t GetNextPreqId ();
384  uint32_t GetNextHwmpSeqno ();
389  uint32_t GetActivePathLifetime ();
394  uint8_t GetUnicastPerrThreshold ();
395 private:
397  struct Statistics
398  {
399  uint16_t txUnicast;
400  uint16_t txBroadcast;
401  uint32_t txBytes;
402  uint16_t droppedTtl;
403  uint16_t totalQueued;
404  uint16_t totalDropped;
405  uint16_t initiatedPreq;
406  uint16_t initiatedPrep;
407  uint16_t initiatedPerr;
408 
413  void Print (std::ostream & os) const;
415  Statistics ();
416  };
418 
419  HwmpProtocolMacMap m_interfaces;
421  uint32_t m_dataSeqno;
422  uint32_t m_hwmpSeqno;
423  uint32_t m_preqId;
424  std::map<Mac48Address, uint32_t> m_lastDataSeqno;
429  std::map<Mac48Address, std::pair<uint32_t, uint32_t> > m_hwmpSeqnoMetricDatabase;
431 
434 
436  struct PreqEvent {
439  };
440 
441  std::map<Mac48Address, PreqEvent> m_preqTimeouts;
443  Time m_randomStart;
446  std::vector<QueuedPacket> m_rqueue;
447 
451  uint16_t m_maxQueueSize;
460  bool m_isRoot;
461  uint8_t m_maxTtl;
465  bool m_doFlag;
466  bool m_rfFlag;
468 
472 };
473 } // namespace dot11s
474 } // namespace ns3
475 #endif
Structure of path error: IePerr and list of receivers: interfaces and MAC address.
uint16_t txBroadcast
transmit broadcast
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Mac48Address retransmitter
route source
Definition: hwmp-protocol.h:50
std::string type
type of change
Definition: hwmp-protocol.h:48
Callback template class.
Definition: callback.h:1176
std::map< uint32_t, Ptr< HwmpProtocolMac > > HwmpProtocolMacMap
HwmpProtocolMacMap typedef.
uint16_t initiatedPreq
initiated PREQ
structure of unreachable destination - address and sequence number
Definition: hwmp-protocol.h:76
Forward calls to a chain of Callback.
TracedCallback< struct RouteChange > RouteChangeTracedCallback
RouteChangeTracedCallback typedef.
See 7.3.2.97 of 802.11s draft 2.07.
Time lifetime
lifetime of route
Definition: hwmp-protocol.h:53
Statistics m_stats
statistics
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< Time > m_routeDiscoveryTimeCallback
Route discovery time:
std::vector< QueuedPacket > m_rqueue
Packet Queue.
Mac48Address destination
route destination
Definition: hwmp-protocol.h:49
Hybrid wireless mesh protocol – a mesh routing protocol defined in IEEE 802.11-2012 standard...
Definition: hwmp-protocol.h:62
See 7.3.2.96 of 802.11s draft 2.07.
uint32_t seqnum
sequence number of route
Definition: hwmp-protocol.h:54
Packet waiting its routing information.
HwmpProtocolMacMap m_interfaces
interfaces
uint16_t totalDropped
total dropped
Ptr< HwmpRtable > m_rtable
Routing table.
uint16_t initiatedPerr
initiated PERR
uint32_t m_dataSeqno
data sequence no
Interface MAC plugin for HWMP – 802.11s routing protocol.
uint32_t m_hwmpSeqno
HWMP sequence no.
Mac48Address m_address
address
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint16_t initiatedPrep
initiated PREP
std::vector< std::pair< uint32_t, Mac48Address > > receivers
list of PathError receivers (in case of unicast PERR)
an EUI-48 address
Definition: mac48-address.h:43
RouteReplyCallback reply
how to reply
uint32_t m_preqId
PREQ ID.
Interface for L2 mesh routing protocol and mesh point communication.
Mac48Address destination
destination address
Definition: hwmp-protocol.h:78
uint32_t metric
metric of route
Definition: hwmp-protocol.h:52
Ptr< UniformRandomVariable > m_coefficient
Random variable for random start time.
EventId m_proactivePreqTimer
proactive PREQ timer
An identifier for simulation events.
Definition: event-id.h:53
std::vector< FailedDestination > destinations
destination list: Mac48Address and sequence number
uint16_t txUnicast
transmit unicast
void Print(ComponentCarrier cc)
Callback< std::vector< Mac48Address >, uint32_t > m_neighboursCallback
neighbors callback
TracedCallback< struct RouteChange > m_routeChangeTraceSource
Route change trace source.
uint32_t inInterface
incoming device interface ID. (if packet has come from upper layers, this is Mesh point ID) ...
a unique identifier for an interface.
Definition: type-id.h:58
uint32_t interface
interface index
Definition: hwmp-protocol.h:51
std::map< Mac48Address, PreqEvent > m_preqTimeouts
PREQ timeouts.
Structure to encapsulate route change information.
Definition: hwmp-protocol.h:46