/usr/include/ns3.26/ns3/hwmp-protocol.h is in libns3-dev 3.26+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2008,2009 IITP RAS
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Authors: Kirill Andreev <andreev@iitp.ru>
*/
#ifndef HWMP_PROTOCOL_H
#define HWMP_PROTOCOL_H
#include "ns3/mesh-l2-routing-protocol.h"
#include "ns3/nstime.h"
#include "ns3/event-id.h"
#include "ns3/traced-value.h"
#include <vector>
#include <map>
namespace ns3 {
class MeshPointDevice;
class Packet;
class Mac48Address;
class UniformRandomVariable;
namespace dot11s {
class HwmpProtocolMac;
class HwmpRtable;
class IePerr;
class IePreq;
class IePrep;
/**
* \ingroup dot11s
*
* \brief Hybrid wireless mesh protocol -- a routing protocol of IEEE 802.11s draft.
*/
class HwmpProtocol : public MeshL2RoutingProtocol
{
public:
static TypeId GetTypeId ();
HwmpProtocol ();
~HwmpProtocol ();
void DoDispose ();
/**
* \brief structure of unreachable destination - address and sequence number
*/
typedef struct
{
Mac48Address destination;
uint32_t seqnum;
} FailedDestination;
/// Route request, inherited from MeshL2RoutingProtocol
bool RequestRoute (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination,
Ptr<const Packet> packet, uint16_t protocolType, RouteReplyCallback routeReply);
/// Cleanup packet from all tags
bool RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source,
const Mac48Address destination, Ptr<Packet> packet, uint16_t& protocolType);
/**
* \brief Install HWMP on given mesh point.
*
* Installing protocol cause installing its interface MAC plugins.
*
* Also MP aggregates all installed protocols, HWMP protocol can be accessed
* via MeshPointDevice::GetObject<dot11s::HwmpProtocol>();
*/
bool Install (Ptr<MeshPointDevice>);
void PeerLinkStatus (Mac48Address meshPontAddress, Mac48Address peerAddress, uint32_t interface,bool status);
///\brief This callback is used to obtain active neighbours on a given interface
///\param cb is a callback, which returns a list of addresses on given interface (uint32_t)
void SetNeighboursCallback (Callback<std::vector<Mac48Address>, uint32_t> cb);
///\name Proactive PREQ mechanism:
///\{
void SetRoot ();
void UnsetRoot ();
///\}
///\brief Statistics:
void Report (std::ostream &) const;
void ResetStats ();
/**
* Assign a fixed random variable stream number to the random variables
* used by this model. Return the number of streams (possibly zero) that
* have been assigned.
*
* \param stream first stream index to use
* \return the number of stream indices assigned by this model
*/
int64_t AssignStreams (int64_t stream);
private:
friend class HwmpProtocolMac;
virtual void DoInitialize ();
HwmpProtocol& operator= (const HwmpProtocol &);
HwmpProtocol (const HwmpProtocol &);
/**
* \brief Structure of path error: IePerr and list of receivers:
* interfaces and MAC address
*/
struct PathError
{
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
struct QueuedPacket
{
Ptr<Packet> pkt; ///< the packet
Mac48Address src; ///< src address
Mac48Address dst; ///< dst address
uint16_t protocol; ///< protocol number
uint32_t inInterface; ///< incoming device interface ID. (if packet has come from upper layers, this is Mesh point ID)
RouteReplyCallback reply; ///< how to reply
QueuedPacket ();
};
typedef std::map<uint32_t, Ptr<HwmpProtocolMac> > HwmpProtocolMacMap;
/// Like RequestRoute, but for unicast packets
bool ForwardUnicast (uint32_t sourceIface, const Mac48Address source, const Mac48Address destination,
Ptr<Packet> packet, uint16_t protocolType, RouteReplyCallback routeReply, uint32_t ttl);
///\name Interaction with HWMP MAC plugin
//\{
///\brief Handler for receiving Path Request
void ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric);
///\brief Handler for receiving Path Reply
void ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, Mac48Address fromMp, uint32_t metric);
///\brief Handler for receiving Path Error
void ReceivePerr (std::vector<FailedDestination>, Mac48Address from, uint32_t interface, Mac48Address fromMp);
///\brief Send Path Reply
void SendPrep (
Mac48Address src,
Mac48Address dst,
Mac48Address retransmitter,
uint32_t initMetric,
uint32_t originatorDsn,
uint32_t destinationSN,
uint32_t lifetime,
uint32_t interface);
/**
* \brief forms a path error information element when list of destination fails on a given interface
* \attention removes all entries from routing table!
*/
PathError MakePathError (std::vector<FailedDestination> destinations);
///\brief Forwards a received path error
void ForwardPathError (PathError perr);
///\brief Passes a self-generated PERR to interface-plugin
void InitiatePathError (PathError perr);
/// \return list of addresses where a PERR should be sent to
std::vector<std::pair<uint32_t, Mac48Address> > GetPerrReceivers (std::vector<FailedDestination> failedDest);
/// \return list of addresses where a PREQ should be sent to
std::vector<Mac48Address> GetPreqReceivers (uint32_t interface);
/// \return list of addresses where a broadcast should be
//retransmitted
std::vector<Mac48Address> GetBroadcastReceivers (uint32_t interface);
/**
* \brief MAC-plugin asks whether the frame can be dropped. Protocol automatically updates seqno.
*
* \return true if frame can be dropped
* \param seqno is the sequence number of source
* \param source is the source address
*/
bool DropDataFrame (uint32_t seqno, Mac48Address source);
//\}
/// Route discovery time:
TracedCallback<Time> m_routeDiscoveryTimeCallback;
///\name Methods related to Queue/Dequeue procedures
///\{
bool QueuePacket (QueuedPacket packet);
QueuedPacket DequeueFirstPacketByDst (Mac48Address dst);
QueuedPacket DequeueFirstPacket ();
void ReactivePathResolved (Mac48Address dst);
void ProactivePathResolved ();
///\}
///\name Methods responsible for path discovery retry procedure:
///\{
/**
* \brief checks when the last path discovery procedure was started for a given destination.
*
* If the retry counter has not achieved the maximum level - preq should not be sent
*/
bool ShouldSendPreq (Mac48Address dst);
/**
* \brief Generates PREQ retry when retry timeout has expired and route is still unresolved.
*
* When PREQ retry has achieved the maximum level - retry mechanism should be canceled
*/
void RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry);
/// Proactive Preq routines:
void SendProactivePreq ();
///\}
///\return address of MeshPointDevice
Mac48Address GetAddress ();
///\name Methods needed by HwmpMacLugin to access protocol parameters:
///\{
bool GetDoFlag ();
bool GetRfFlag ();
Time GetPreqMinInterval ();
Time GetPerrMinInterval ();
uint8_t GetMaxTtl ();
uint32_t GetNextPreqId ();
uint32_t GetNextHwmpSeqno ();
uint32_t GetActivePathLifetime ();
uint8_t GetUnicastPerrThreshold ();
///\}
private:
///\name Statistics:
///\{
struct Statistics
{
uint16_t txUnicast;
uint16_t txBroadcast;
uint32_t txBytes;
uint16_t droppedTtl;
uint16_t totalQueued;
uint16_t totalDropped;
uint16_t initiatedPreq;
uint16_t initiatedPrep;
uint16_t initiatedPerr;
void Print (std::ostream & os) const;
Statistics ();
};
Statistics m_stats;
///\}
HwmpProtocolMacMap m_interfaces;
Mac48Address m_address;
uint32_t m_dataSeqno;
uint32_t m_hwmpSeqno;
uint32_t m_preqId;
///\name Sequence number filters
///\{
/// Data sequence number database
std::map<Mac48Address, uint32_t> m_lastDataSeqno;
/// keeps HWMP seqno (first in pair) and HWMP metric (second in pair) for each address
std::map<Mac48Address, std::pair<uint32_t, uint32_t> > m_hwmpSeqnoMetricDatabase;
///\}
/// Routing table
Ptr<HwmpRtable> m_rtable;
///\name Timers:
//\{
struct PreqEvent {
EventId preqTimeout;
Time whenScheduled;
};
std::map<Mac48Address, PreqEvent> m_preqTimeouts;
EventId m_proactivePreqTimer;
/// Random start in Proactive PREQ propagation
Time m_randomStart;
///\}
/// Packet Queue
std::vector<QueuedPacket> m_rqueue;
/// \name HWMP-protocol parameters
/// These are all Attributes
/// \{
uint16_t m_maxQueueSize;
uint8_t m_dot11MeshHWMPmaxPREQretries;
Time m_dot11MeshHWMPnetDiameterTraversalTime;
Time m_dot11MeshHWMPpreqMinInterval;
Time m_dot11MeshHWMPperrMinInterval;
Time m_dot11MeshHWMPactiveRootTimeout;
Time m_dot11MeshHWMPactivePathTimeout;
Time m_dot11MeshHWMPpathToRootInterval;
Time m_dot11MeshHWMPrannInterval;
bool m_isRoot;
uint8_t m_maxTtl;
uint8_t m_unicastPerrThreshold;
uint8_t m_unicastPreqThreshold;
uint8_t m_unicastDataThreshold;
bool m_doFlag;
bool m_rfFlag;
///\}
/// Random variable for random start time
Ptr<UniformRandomVariable> m_coefficient;
Callback <std::vector<Mac48Address>, uint32_t> m_neighboursCallback;
};
} // namespace dot11s
} // namespace ns3
#endif
|