OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2010 Hemanth Narra, Yufei Cheng |
| 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 * Author: Hemanth Narra <hemanth@ittc.ku.com> |
| 19 * Author: Yufei Cheng <yfcheng@ittc.ku.edu> |
| 20 * |
| 21 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director |
| 22 * ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets |
| 23 * Information and Telecommunication Technology Center (ITTC) |
| 24 * and Department of Electrical Engineering and Computer Science |
| 25 * The University of Kansas Lawrence, KS USA. |
| 26 * |
| 27 * Work supported in part by NSF FIND (Future Internet Design) Program |
| 28 * under grant CNS-0626918 (Postmodern Internet Architecture), |
| 29 * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimenta
tion on GENI), |
| 30 * US Department of Defense (DoD), and ITTC at The University of Kansas. |
| 31 * Modifíed by: Gonçalo Atanásio <goncalo.atanasio@tecnico.ulisboa.pt> |
| 32 */ |
| 33 |
| 34 #ifndef DSDVIPV6_ROUTING_PROTOCOL_H |
| 35 #define DSDVIPV6_ROUTING_PROTOCOL_H |
| 36 |
| 37 #include "dsdv-rtable-ipv6.h" |
| 38 #include "dsdv-packet-queue-ipv6.h" |
| 39 #include "dsdv-packet-ipv6.h" |
| 40 #include "ns3/node.h" |
| 41 #include "ns3/random-variable-stream.h" |
| 42 #include "ns3/ipv6-routing-protocol.h" |
| 43 #include "ns3/ipv6-interface.h" |
| 44 #include "ns3/ipv6-l3-protocol.h" |
| 45 #include "ns3/output-stream-wrapper.h" |
| 46 |
| 47 namespace ns3 { |
| 48 namespace dsdvipv6 { |
| 49 |
| 50 /** |
| 51 * \ingroup dsdvipv6 |
| 52 * \brief Dsdvipv6 routing protocol. |
| 53 */ |
| 54 class RoutingProtocolIpv6 : public Ipv6RoutingProtocol |
| 55 { |
| 56 public: |
| 57 static TypeId |
| 58 GetTypeId (void); |
| 59 static const uint32_t DSDV_PORT; |
| 60 |
| 61 /// c-tor |
| 62 RoutingProtocolIpv6 (); |
| 63 virtual |
| 64 ~RoutingProtocolIpv6 (); |
| 65 virtual void |
| 66 DoDispose (); |
| 67 |
| 68 Ptr<OutputStreamWrapper> routingStream; |
| 69 |
| 70 // From Ipv6RoutingProtocol |
| 71 Ptr<Ipv6Route> RouteOutput (Ptr<Packet> p, const Ipv6Header &header, Ptr<NetDe
vice> oif, Socket::SocketErrno &sockerr); |
| 72 bool RouteInput (Ptr<const Packet> p, const Ipv6Header &header, Ptr<const NetD
evice> idev, UnicastForwardCallback ucb, |
| 73 MulticastForwardCallback mcb, LocalDeliverCallback lcb, Error
Callback ecb); |
| 74 virtual void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address ne
xtHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero()); |
| 75 virtual void NotifyInterfaceDown (uint32_t interface); |
| 76 virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const; |
| 77 virtual void NotifyInterfaceUp (uint32_t interface); |
| 78 virtual void NotifyAddAddress (uint32_t interface, Ipv6InterfaceAddress addre
ss); |
| 79 virtual void NotifyRemoveAddress (uint32_t interface, Ipv6InterfaceAddress add
ress); |
| 80 virtual void SetIpv6 (Ptr<Ipv6> ipv6); |
| 81 virtual void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address
nextHop, uint32_t interface, Ipv6Address prefixToUse=Ipv6Address::GetZero()); |
| 82 // Methods to handle protocol parameters |
| 83 void SetEnableBufferFlag (bool f); |
| 84 bool GetEnableBufferFlag () const; |
| 85 void SetWSTFlag (bool f); |
| 86 bool GetWSTFlag () const; |
| 87 void SetEnableRAFlag (bool f); |
| 88 bool GetEnableRAFlag () const; |
| 89 |
| 90 /** |
| 91 * Assign a fixed random variable stream number to the random variables |
| 92 * used by this model. Return the number of streams (possibly zero) that |
| 93 * have been assigned. |
| 94 * |
| 95 * \param stream first stream index to use |
| 96 * \return the number of stream indices assigned by this model |
| 97 */ |
| 98 int64_t AssignStreams (int64_t stream); |
| 99 |
| 100 private: |
| 101 ·· |
| 102 // Protocol parameters. |
| 103 /// Holdtimes is the multiplicative factor of PeriodicUpdateInterval for which
the node waits since the last update |
| 104 /// before flushing a route from the routing table. If PeriodicUpdateInterval
is 8s and Holdtimes is 3, the node |
| 105 /// waits for 24s since the last update to flush this route from its routing t
able. |
| 106 uint32_t Holdtimes; |
| 107 /// PeriodicUpdateInterval specifies the periodic time interval between which
the a node broadcasts |
| 108 /// its entire routing table. |
| 109 Time m_periodicUpdateInterval; |
| 110 /// SettlingTime specifies the time for which a node waits before propagating
an update. |
| 111 /// It waits for this time interval in hope of receiving an update with a bett
er metric. |
| 112 Time m_settlingTime; |
| 113 /// Nodes IP address |
| 114 Ipv6Address m_mainAddress; |
| 115 /// IP protocol |
| 116 Ptr<Ipv6> m_ipv6; |
| 117 /// Raw socket per each IP interface, map socket -> iface address (IP + mask) |
| 118 std::map<Ptr<Socket>, Ipv6InterfaceAddress> m_socketAddresses; |
| 119 /// Loopback device used to defer route requests until a route is found |
| 120 Ptr<NetDevice> m_lo; |
| 121 /// Main Routing table for the node |
| 122 RoutingTable m_routingTable; |
| 123 /// Advertised Routing table for the node |
| 124 RoutingTable m_advRoutingTable; |
| 125 /// The maximum number of packets that we allow a routing protocol to buffer. |
| 126 uint32_t m_maxQueueLen; |
| 127 /// The maximum number of packets that we allow per destination to buffer. |
| 128 uint32_t m_maxQueuedPacketsPerDst; |
| 129 /// The maximum period of time that a routing protocol is allowed to buffer a
packet for. |
| 130 Time m_maxQueueTime; |
| 131 /// A "drop front on full" queue used by the routing layer to buffer packets t
o which it does not have a route. |
| 132 PacketQueue m_queue; |
| 133 /// Flag that is used to enable or disable buffering |
| 134 bool EnableBuffering; |
| 135 /// Flag that is used to enable or disable Weighted Settling Time |
| 136 bool EnableWST; |
| 137 /// This is the wighted factor to determine the weighted settling time |
| 138 double m_weightedFactor; |
| 139 /// This is a flag to enable route aggregation. Route aggregation will aggrega
te all routes for |
| 140 /// 'RouteAggregationTime' from the time an update is received by a node and s
ends them as a single update . |
| 141 bool EnableRouteAggregation; |
| 142 /// Is this node a source of updates? |
| 143 bool m_generateUpdates; |
| 144 /// Parameter that holds the route aggregation time interval |
| 145 Time m_routeAggregationTime; |
| 146 /// Unicast callback for own packets |
| 147 UnicastForwardCallback m_scb; |
| 148 /// Error callback for own packets |
| 149 ErrorCallback m_ecb; |
| 150 |
| 151 private: |
| 152 ·· |
| 153 /// Start protocol operation |
| 154 void |
| 155 Start (); |
| 156 /// Queue packet untill we find a route |
| 157 void |
| 158 DeferredRouteOutput (Ptr<const Packet> p, const Ipv6Header & header, UnicastFo
rwardCallback ucb, ErrorCallback ecb); |
| 159 /// Look for any queued packets to send them out |
| 160 void |
| 161 LookForQueuedPackets (void); |
| 162 /** |
| 163 * Send packet from queue |
| 164 * \param dst - destination address to which we are sending the packet to |
| 165 * \param route - route identified for this packet |
| 166 */ |
| 167 void |
| 168 SendPacketFromQueue (Ipv6Address dst, Ptr<Ipv6Route> route); |
| 169 /// Find socket with local interface address iface |
| 170 Ptr<Socket> |
| 171 FindSocketWithInterfaceAddress (Ipv6InterfaceAddress iface) const; |
| 172 ·· |
| 173 // Receive dsdvipv6 control packets |
| 174 /// Receive and process dsdvipv6 control packet |
| 175 void |
| 176 RecvDsdv (Ptr<Socket> socket); |
| 177 |
| 178 void |
| 179 Send (Ptr<const NetDevice>, Ptr<Ipv6Route>, Ptr<const Packet>, const Ipv6Heade
r &); |
| 180 /// Create loopback route for given header |
| 181 Ptr<Ipv6Route> |
| 182 LoopbackRoute (const Ipv6Header & header, Ptr<NetDevice> oif) const; |
| 183 /** |
| 184 * Get settlingTime for a destination |
| 185 * \param dst - destination address |
| 186 * \return settlingTime for the destination if found |
| 187 */ |
| 188 Time |
| 189 GetSettlingTime (Ipv6Address dst); |
| 190 /// Sends trigger update from a node |
| 191 void |
| 192 SendTriggeredUpdate (); |
| 193 /// Broadcasts the entire routing table for every PeriodicUpdateInterval |
| 194 void |
| 195 SendPeriodicUpdate (); |
| 196 void |
| 197 MergeTriggerPeriodicUpdates (); |
| 198 /// Notify that packet is dropped for some reason |
| 199 void |
| 200 Drop (Ptr<const Packet>, const Ipv6Header &, Socket::SocketErrno); |
| 201 /// Timer to trigger periodic updates from a node |
| 202 Timer m_periodicUpdateTimer; |
| 203 /// Timer used by the trigger updates in case of Weighted Settling Time is use
d |
| 204 Timer m_triggeredExpireTimer; |
| 205 |
| 206 // / \{Sequence number divisor counter.\} |
| 207 uint32_t m_seqNumDivisorCounter; |
| 208 |
| 209 /// Provides uniform random variables. |
| 210 Ptr<UniformRandomVariable> m_uniformRandomVariable;·· |
| 211 }; |
| 212 |
| 213 } |
| 214 } |
| 215 |
| 216 #endif /* DSDV_ROUTING_PROTOCOL_H */ |
OLD | NEW |