OLD | NEW |
(Empty) | |
| 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 <vector> |
| 28 #include <map> |
| 29 |
| 30 namespace ns3 { |
| 31 class MeshPointDevice; |
| 32 class Packet; |
| 33 class Mac48Address; |
| 34 namespace dot11s { |
| 35 class HwmpProtocolMac; |
| 36 class HwmpRtable; |
| 37 class IePerr; |
| 38 class IePreq; |
| 39 class IePrep; |
| 40 /** |
| 41 * \ingroup dot11s |
| 42 * |
| 43 * \brief Hybrid wireless mesh protocol -- a routing protocol of IEEE 802.11s dr
aft. |
| 44 */ |
| 45 class HwmpProtocol : public MeshL2RoutingProtocol |
| 46 { |
| 47 public: |
| 48 static TypeId GetTypeId (); |
| 49 HwmpProtocol (); |
| 50 ~HwmpProtocol (); |
| 51 void DoDispose (); |
| 52 /** |
| 53 * \brief structure of unreachable destination - address and sequence number |
| 54 */ |
| 55 typedef struct |
| 56 { |
| 57 Mac48Address destination; |
| 58 uint32_t seqnum; |
| 59 } FailedDestination; |
| 60 /// Route request, inherited from MeshL2RoutingProtocol |
| 61 bool RequestRoute (uint32_t sourceIface, const Mac48Address source, const Mac
48Address destination, |
| 62 Ptr<const Packet> packet, uint16_t protocolType, RouteReplyCallback rou
teReply); |
| 63 /// Cleanup packet from all tags |
| 64 bool RemoveRoutingStuff (uint32_t fromIface, const Mac48Address source, |
| 65 const Mac48Address destination, Ptr<Packet> packet, uint16_t& protocolTy
pe); |
| 66 /** |
| 67 * \brief Install HWMP on given mesh point. |
| 68 * |
| 69 * Installing protocol cause installing its interface MAC plugins. |
| 70 * |
| 71 * Also MP aggregates all installed protocols, HWMP protocol can be accessed |
| 72 * via MeshPointDevice::GetObject<dot11s::HwmpProtocol>(); |
| 73 */ |
| 74 bool Install (Ptr<MeshPointDevice>); |
| 75 void PeerLinkStatus (Mac48Address meshPontAddress, Mac48Address peerAddress, u
int32_t interface,bool status); |
| 76 ///\brief This callback is used to obtain active neighbours on a given interfa
ce |
| 77 ///\param cb is a callback, which returns a list of addresses on given interfa
ce (uint32_t)·· |
| 78 void SetNeighboursCallback (Callback<std::vector<Mac48Address>, uint32_t> cb); |
| 79 ///\name Proactive PREQ mechanism: |
| 80 ///\{ |
| 81 void SetRoot (); |
| 82 void UnsetRoot (); |
| 83 ///\} |
| 84 ///\brief Statistics: |
| 85 void Report (std::ostream &) const; |
| 86 void ResetStats (); |
| 87 private: |
| 88 friend class HwmpProtocolMac; |
| 89 /** |
| 90 * \brief Structure of path error: IePerr and list of receivers: |
| 91 * interfaces and MAC address |
| 92 */ |
| 93 struct PathError |
| 94 { |
| 95 std::vector<FailedDestination> destinations; ///< destination list: Mac48Add
ress and sequence number |
| 96 std::vector<std::pair<uint32_t, Mac48Address> > receivers; ///< list of Path
Error receivrs (in case of unicast PERR) |
| 97 }; |
| 98 /// Packet waiting its routing information |
| 99 struct QueuedPacket |
| 100 { |
| 101 Ptr<Packet> pkt; ///< the packet |
| 102 Mac48Address src; ///< src address |
| 103 Mac48Address dst; ///< dst address |
| 104 uint16_t protocol; ///< protocol number |
| 105 uint32_t inInterface; ///< incoming device interface ID. (if packet has come
from upper layers, this is Mesh point ID) |
| 106 RouteReplyCallback reply; ///< how to reply |
| 107 |
| 108 QueuedPacket (); |
| 109 }; |
| 110 typedef std::map<uint32_t, Ptr<HwmpProtocolMac> > HwmpProtocolMacMap; |
| 111 /// Like RequestRoute, but for unicast packets |
| 112 bool ForwardUnicast (uint32_t sourceIface, const Mac48Address source, const M
ac48Address destination, |
| 113 Ptr<Packet> packet, uint16_t protocolType, RouteReplyCallback routeRepl
y, uint32_t ttl); |
| 114 |
| 115 ///\name Interaction with HWMP MAC plugin |
| 116 //\{ |
| 117 void ReceivePreq (IePreq preq, Mac48Address from, uint32_t interface, Mac48Add
ress fromMp, uint32_t metric); |
| 118 void ReceivePrep (IePrep prep, Mac48Address from, uint32_t interface, Mac48Add
ress fromMp, uint32_t metric); |
| 119 void ReceivePerr (std::vector<FailedDestination>, Mac48Address from, uint32_t
interface, Mac48Address fromMp); |
| 120 void SendPrep ( |
| 121 Mac48Address src, |
| 122 Mac48Address dst, |
| 123 Mac48Address retransmitter, |
| 124 uint32_t initMetric, |
| 125 uint32_t originatorDsn, |
| 126 uint32_t destinationSN, |
| 127 uint32_t lifetime, |
| 128 uint32_t interface); |
| 129 /** |
| 130 * \brief forms a path error information element when list of destination fail
s on a given interface |
| 131 * \attention removes all entries from routing table! |
| 132 */ |
| 133 PathError MakePathError (std::vector<FailedDestination> destinations); |
| 134 ///\brief Forwards a received path error |
| 135 void ForwardPathError (PathError perr); |
| 136 ///\brief Pasess a selg-generated PERR to interface-plugin |
| 137 void InitiatePathError (PathError perr); |
| 138 /// \return list of addresses where a PERR should be sent to |
| 139 std::vector<std::pair<uint32_t, Mac48Address> > GetPerrReceivers (std::vector<
FailedDestination> failedDest); |
| 140 |
| 141 /// \return list of addresses where a PERR should be sent to |
| 142 std::vector<Mac48Address> GetPreqReceivers (uint32_t interface); |
| 143 /// \return list of addresses where a broadcast should be |
| 144 //retransmitted |
| 145 std::vector<Mac48Address> GetBroadcastReceivers (uint32_t interface); |
| 146 /** |
| 147 * \brief MAC-plugin asks whether the frame can be dropped. Protocol automatic
ally updates seqno. |
| 148 * |
| 149 * \return true if frame can be dropped |
| 150 * \param seqno is the sequence number of source |
| 151 * \param source is the source address |
| 152 */ |
| 153 bool DropDataFrame (uint32_t seqno, Mac48Address source); |
| 154 //\} |
| 155 ///\name Methods related to Queue/Dequeue procedures |
| 156 ///\{ |
| 157 bool QueuePacket (QueuedPacket packet); |
| 158 QueuedPacket DequeueFirstPacketByDst (Mac48Address dst); |
| 159 QueuedPacket DequeueFirstPacket (); |
| 160 void ReactivePathResolved (Mac48Address dst); |
| 161 void ProactivePathResolved (); |
| 162 ///\} |
| 163 ///\name Methods responsible for path discovery retry procedure: |
| 164 ///\{ |
| 165 /** |
| 166 * \brief checks when the last path discovery procedure was started for a give
n destination. |
| 167 * |
| 168 * If the retry counter has not achieved the maximum level - preq should not b
e sent |
| 169 */ |
| 170 bool ShouldSendPreq (Mac48Address dst); |
| 171 |
| 172 /** |
| 173 * \brief Generates PREQ retry when retry timeout has expired and route is sti
ll unresolved. |
| 174 * |
| 175 * When PREQ retry has achieved the maximum level - retry mechanism should be
canceled |
| 176 */ |
| 177 void RetryPathDiscovery (Mac48Address dst, uint8_t numOfRetry); |
| 178 /// Proactive Preq routines: |
| 179 void SendProactivePreq (); |
| 180 ///\} |
| 181 ///\return address of MeshPointDevice |
| 182 Mac48Address GetAddress (); |
| 183 ///\name Methods needed by HwmpMacLugin to access protocol parameters: |
| 184 ///\{ |
| 185 bool GetDoFlag (); |
| 186 bool GetRfFlag (); |
| 187 Time GetPreqMinInterval (); |
| 188 Time GetPerrMinInterval (); |
| 189 uint8_t GetMaxTtl (); |
| 190 uint32_t GetNextPreqId (); |
| 191 uint32_t GetNextHwmpSeqno (); |
| 192 uint32_t GetActivePathLifetime (); |
| 193 uint8_t GetUnicastPerrThreshold (); |
| 194 ///\} |
| 195 private: |
| 196 ///\name Statistics: |
| 197 ///\{ |
| 198 struct Statistics |
| 199 { |
| 200 uint16_t txUnicast; |
| 201 uint16_t txBroadcast; |
| 202 uint32_t txBytes; |
| 203 uint16_t droppedTtl; |
| 204 uint16_t totalQueued; |
| 205 uint16_t totalDropped; |
| 206 uint16_t initiatedPreq; |
| 207 uint16_t initiatedPrep; |
| 208 uint16_t initiatedPerr; |
| 209 |
| 210 void Print (std::ostream & os) const; |
| 211 Statistics (); |
| 212 }; |
| 213 Statistics m_stats; |
| 214 ///\} |
| 215 HwmpProtocolMacMap m_interfaces; |
| 216 Mac48Address m_address; |
| 217 uint32_t m_dataSeqno; |
| 218 uint32_t m_hwmpSeqno; |
| 219 uint32_t m_preqId; |
| 220 ///\name Sequence number filters |
| 221 ///\{ |
| 222 /// Data sequence number database |
| 223 std::map<Mac48Address, uint32_t> m_lastDataSeqno; |
| 224 /// DSN databse |
| 225 std::map<Mac48Address, uint32_t> m_lastHwmpSeqno; |
| 226 /// Metric database |
| 227 std::map<Mac48Address, uint32_t> m_lastHwmpMetric; |
| 228 ///\} |
| 229 |
| 230 /// Routing table |
| 231 Ptr<HwmpRtable> m_rtable; |
| 232 |
| 233 ///\name Timers: |
| 234 ///\{ |
| 235 std::map<Mac48Address, EventId> m_preqTimeouts; |
| 236 EventId m_proactivePreqTimer; |
| 237 /// Random start in Proactive PREQ propagation |
| 238 Time m_randomStart; |
| 239 ///\} |
| 240 /// Packet Queue |
| 241 std::vector<QueuedPacket> m_rqueue; |
| 242 ///\name HWMP-protocol parameters (attributes of GetTypeId) |
| 243 ///\{ |
| 244 uint16_t m_maxQueueSize; |
| 245 uint8_t m_dot11MeshHWMPmaxPREQretries; |
| 246 Time m_dot11MeshHWMPnetDiameterTraversalTime; |
| 247 Time m_dot11MeshHWMPpreqMinInterval; |
| 248 Time m_dot11MeshHWMPperrMinInterval; |
| 249 Time m_dot11MeshHWMPactiveRootTimeout; |
| 250 Time m_dot11MeshHWMPactivePathTimeout; |
| 251 Time m_dot11MeshHWMPpathToRootInterval; |
| 252 Time m_dot11MeshHWMPrannInterval; |
| 253 bool m_isRoot; |
| 254 uint8_t m_maxTtl; |
| 255 uint8_t m_unicastPerrThreshold; |
| 256 uint8_t m_unicastPreqThreshold; |
| 257 uint8_t m_unicastDataThreshold; |
| 258 bool m_doFlag; |
| 259 bool m_rfFlag; |
| 260 ///\} |
| 261 Callback <std::vector<Mac48Address>, uint32_t> m_neighboursCallback; |
| 262 }; |
| 263 } //namespace dot11s |
| 264 } //namespace ns3 |
| 265 #endif |
OLD | NEW |