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 DoStart ();
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