A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  //\{
135  void ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric);
136  void ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric);
137  void ReceivePerr (std::vector<FailedDestination>, Mac48Address from, uint32_t interface, Mac48Address fromMp);
138  void SendPrep (
139  Mac48Address src,
140  Mac48Address dst,
141  Mac48Address retransmitter,
142  uint32_t initMetric,
143  uint32_t originatorDsn,
144  uint32_t destinationSN,
145  uint32_t lifetime,
146  uint32_t interface);
151  PathError MakePathError (std::vector<FailedDestination> destinations);
153  void ForwardPathError (PathError perr);
155  void InitiatePathError (PathError perr);
157  std::vector<std::pair<uint32_t, Mac48Address> > GetPerrReceivers (std::vector<FailedDestination> failedDest);
158 
160  std::vector<Mac48Address> GetPreqReceivers (uint32_t interface);
162  //retransmitted
163  std::vector<Mac48Address> GetBroadcastReceivers (uint32_t interface);
171  bool DropDataFrame (uint32_t seqno, Mac48Address source);
172  //\}
177  bool QueuePacket (QueuedPacket packet);
181  void ProactivePathResolved ();
185 
190  bool ShouldSendPreq (Mac48Address dst);
191 
197  void RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry);
199  void SendProactivePreq ();
205  bool GetDoFlag ();
206  bool GetRfFlag ();
209  uint8_t GetMaxTtl ();
210  uint32_t GetNextPreqId ();
211  uint32_t GetNextHwmpSeqno ();
212  uint32_t GetActivePathLifetime ();
213  uint8_t GetUnicastPerrThreshold ();
215 private:
218  struct Statistics
219  {
220  uint16_t txUnicast;
221  uint16_t txBroadcast;
222  uint32_t txBytes;
223  uint16_t droppedTtl;
224  uint16_t totalQueued;
225  uint16_t totalDropped;
226  uint16_t initiatedPreq;
227  uint16_t initiatedPrep;
228  uint16_t initiatedPerr;
229 
230  void Print (std::ostream & os) const;
231  Statistics ();
232  };
237  uint32_t m_dataSeqno;
238  uint32_t m_hwmpSeqno;
239  uint32_t m_preqId;
243  std::map<Mac48Address, uint32_t> m_lastDataSeqno;
245  std::map<Mac48Address, std::pair<uint32_t, uint32_t> > m_hwmpSeqnoMetricDatabase;
247 
250 
252  //\{
253  struct PreqEvent {
256  };
257  std::map<Mac48Address, PreqEvent> m_preqTimeouts;
263  std::vector<QueuedPacket> m_rqueue;
266  uint16_t m_maxQueueSize;
275  bool m_isRoot;
276  uint8_t m_maxTtl;
280  bool m_doFlag;
281  bool m_rfFlag;
286 };
287 } // namespace dot11s
288 } // namespace ns3
289 #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:79
Callback template class.
Definition: callback.h:924
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)
forms a path error information element when list of destination fails on a given interface ...
structure of unreachable destination - address and sequence number
Definition: hwmp-protocol.h:57
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
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)
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()
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()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
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)
forms a path error information element when list of destination fails on a given interface ...
Time m_randomStart
Random start in Proactive PREQ propagation.
Interface MAC plugin for HWMP – 802.11s routing protocol.
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:41
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:46
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:49
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)
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.