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;
48 {
49 public:
50  static TypeId GetTypeId ();
51  HwmpProtocol ();
52  ~HwmpProtocol ();
53  void DoDispose ();
57  typedef struct
58  {
60  uint32_t seqnum;
63  bool RequestRoute (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination,
64  Ptr<const Packet> packet, uint16_t protocolType, RouteReplyCallback routeReply);
66  bool RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source,
67  const Mac48Address destination, Ptr<Packet> packet, uint16_t& protocolType);
77  void PeerLinkStatus (Mac48Address meshPontAddress, Mac48Address peerAddress, uint32_t interface,bool status);
80  void SetNeighboursCallback (Callback<std::vector<Mac48Address>, uint32_t> cb);
83  void SetRoot ();
84  void UnsetRoot ();
87  void Report (std::ostream &) const;
88  void ResetStats ();
97  int64_t AssignStreams (int64_t stream);
98 
99 private:
100  friend class HwmpProtocolMac;
101 
102  virtual void DoInitialize ();
103 
105  HwmpProtocol (const HwmpProtocol &);
106 
111  struct PathError
112  {
113  std::vector<FailedDestination> destinations;
114  std::vector<std::pair<uint32_t, Mac48Address> > receivers;
115  };
118  {
122  uint16_t protocol;
123  uint32_t inInterface;
125 
126  QueuedPacket ();
127  };
128  typedef std::map<uint32_t, Ptr<HwmpProtocolMac> > HwmpProtocolMacMap;
130  bool ForwardUnicast (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination,
131  Ptr<Packet> packet, uint16_t protocolType, RouteReplyCallback routeReply, uint32_t ttl);
132 
134  //\{
136  void ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric);
138  void ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric);
140  void ReceivePerr (std::vector<FailedDestination>, Mac48Address from, uint32_t interface, Mac48Address fromMp);
142  void SendPrep (
143  Mac48Address src,
144  Mac48Address dst,
145  Mac48Address retransmitter,
146  uint32_t initMetric,
147  uint32_t originatorDsn,
148  uint32_t destinationSN,
149  uint32_t lifetime,
150  uint32_t interface);
155  PathError MakePathError (std::vector<FailedDestination> destinations);
157  void ForwardPathError (PathError perr);
159  void InitiatePathError (PathError perr);
161  std::vector<std::pair<uint32_t, Mac48Address> > GetPerrReceivers (std::vector<FailedDestination> failedDest);
162 
164  std::vector<Mac48Address> GetPreqReceivers (uint32_t interface);
166  //retransmitted
167  std::vector<Mac48Address> GetBroadcastReceivers (uint32_t interface);
175  bool DropDataFrame (uint32_t seqno, Mac48Address source);
176  //\}
181  bool QueuePacket (QueuedPacket packet);
185  void ProactivePathResolved ();
189 
194  bool ShouldSendPreq (Mac48Address dst);
195 
201  void RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry);
203  void SendProactivePreq ();
209  bool GetDoFlag ();
210  bool GetRfFlag ();
213  uint8_t GetMaxTtl ();
214  uint32_t GetNextPreqId ();
215  uint32_t GetNextHwmpSeqno ();
216  uint32_t GetActivePathLifetime ();
217  uint8_t GetUnicastPerrThreshold ();
219 private:
222  struct Statistics
223  {
224  uint16_t txUnicast;
225  uint16_t txBroadcast;
226  uint32_t txBytes;
227  uint16_t droppedTtl;
228  uint16_t totalQueued;
229  uint16_t totalDropped;
230  uint16_t initiatedPreq;
231  uint16_t initiatedPrep;
232  uint16_t initiatedPerr;
233 
234  void Print (std::ostream & os) const;
235  Statistics ();
236  };
239  HwmpProtocolMacMap m_interfaces;
241  uint32_t m_dataSeqno;
242  uint32_t m_hwmpSeqno;
243  uint32_t m_preqId;
247  std::map<Mac48Address, uint32_t> m_lastDataSeqno;
249  std::map<Mac48Address, std::pair<uint32_t, uint32_t> > m_hwmpSeqnoMetricDatabase;
251 
254 
256  //\{
257  struct PreqEvent {
260  };
261  std::map<Mac48Address, PreqEvent> m_preqTimeouts;
267  std::vector<QueuedPacket> m_rqueue;
268 
272  uint16_t m_maxQueueSize;
281  bool m_isRoot;
282  uint8_t m_maxTtl;
286  bool m_doFlag;
287  bool m_rfFlag;
289 
293 };
294 } // namespace dot11s
295 } // namespace ns3
296 #endif
Structure of path error: IePerr and list of receivers: interfaces and MAC address.
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.
Definition: nstime.h:102
Callback template class.
Definition: callback.h:1176
std::map< uint32_t, Ptr< HwmpProtocolMac > > HwmpProtocolMacMap
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.
structure of unreachable destination - address and sequence number
Definition: hwmp-protocol.h:57
Forward calls to a chain of Callback.
Callback< void, bool, Ptr< Packet >, Mac48Address, Mac48Address, uint16_t, uint32_t > RouteReplyCallback
Callback to be invoked when route discovery procedure is completed.
void ForwardPathError(PathError perr)
Forwards a received path error.
See 7.3.2.97 of 802.11s draft 2.07.
bool Install(Ptr< MeshPointDevice >)
Install HWMP on given mesh point.
void InitiatePathError(PathError perr)
Passes a self-generated PERR to interface-plugin.
void ReactivePathResolved(Mac48Address dst)
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:
void ReceivePrep(IePrep prep, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric)
Handler for receiving Path Reply.
void SendProactivePreq()
Proactive Preq routines:
bool DropDataFrame(uint32_t seqno, Mac48Address source)
MAC-plugin asks whether the frame can be dropped.
QueuedPacket DequeueFirstPacket()
void Print(std::ostream &os) const
std::vector< Mac48Address > GetPreqReceivers(uint32_t interface)
bool RemoveRoutingStuff(uint32_t fromIface, const Mac48Address source, const Mac48Address destination, Ptr< Packet > packet, uint16_t &protocolType)
Cleanup packet from all tags.
std::vector< QueuedPacket > m_rqueue
Packet Queue.
std::vector< std::pair< uint32_t, Mac48Address > > GetPerrReceivers(std::vector< FailedDestination > failedDest)
void RetryPathDiscovery(Mac48Address dst, uint8_t numOfRetry)
Generates PREQ retry when retry timeout has expired and route is still unresolved.
void DoDispose()
Destructor implementation.
Hybrid wireless mesh protocol – a routing protocol of IEEE 802.11s draft.
Definition: hwmp-protocol.h:47
See 7.3.2.96 of 802.11s draft 2.07.
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.
HwmpProtocolMacMap m_interfaces
Ptr< HwmpRtable > m_rtable
Routing table.
static TypeId GetTypeId()
void ReceivePreq(IePreq preq, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric)
Handler for receiving Path Request.
Time m_randomStart
Random start in Proactive PREQ propagation.
Interface MAC plugin for HWMP – 802.11s routing protocol.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
HwmpProtocol & operator=(const HwmpProtocol &)
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)
an EUI-48 address
Definition: mac48-address.h:43
RouteReplyCallback reply
how to reply
Interface for L2 mesh routing protocol and mesh point communication.
void Report(std::ostream &) const
Statistics:
Ptr< UniformRandomVariable > m_coefficient
Random variable for random start time.
EventId m_proactivePreqTimer
Random start in Proactive PREQ propagation.
An identifier for simulation events.
Definition: event-id.h:53
std::vector< Mac48Address > GetBroadcastReceivers(uint32_t interface)
std::vector< FailedDestination > destinations
destination list: Mac48Address and sequence number
Callback< std::vector< Mac48Address >, uint32_t > m_neighboursCallback
std::map< Mac48Address, uint32_t > m_lastDataSeqno
keeps HWMP seqno (first in pair) and HWMP metric (second in pair) for each address ...
QueuedPacket DequeueFirstPacketByDst(Mac48Address dst)
uint32_t inInterface
incoming device interface ID. (if packet has come from upper layers, this is Mesh point ID) ...
bool QueuePacket(QueuedPacket packet)
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)
a unique identifier for an interface.
Definition: type-id.h:58
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...
void ReceivePerr(std::vector< FailedDestination >, Mac48Address from, uint32_t interface, Mac48Address fromMp)
Handler for receiving Path Error.
void SetNeighboursCallback(Callback< std::vector< Mac48Address >, uint32_t > cb)
This callback is used to obtain active neighbours on a given interface.
virtual void DoInitialize()
Initialize() implementation.