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 */ |
| 32 #ifndef DSDVROUTINGPROTOCOL_H_ |
| 33 #define DSDVROUTINGPROTOCOL_H_ |
| 34 |
| 35 #include "dsdv-rtable.h" |
| 36 #include "dsdv-packet-queue.h" |
| 37 #include "dsdv-packet.h" |
| 38 #include "ns3/node.h" |
| 39 #include "ns3/ipv4-routing-protocol.h" |
| 40 #include "ns3/ipv4-interface.h" |
| 41 #include "ns3/ipv4-l3-protocol.h" |
| 42 #include "ns3/output-stream-wrapper.h" |
| 43 |
| 44 namespace ns3 { |
| 45 namespace dsdv { |
| 46 |
| 47 /** |
| 48 * \ingroup dsdv |
| 49 * \brief DSDV routing protocol. |
| 50 */ |
| 51 class RoutingProtocol : public Ipv4RoutingProtocol |
| 52 { |
| 53 public: |
| 54 static TypeId |
| 55 GetTypeId (void); |
| 56 static const uint32_t DSDV_PORT; |
| 57 |
| 58 // / c-tor |
| 59 RoutingProtocol (); |
| 60 virtual |
| 61 ~RoutingProtocol (); |
| 62 virtual void |
| 63 DoDispose (); |
| 64 |
| 65 // /\name From Ipv4RoutingProtocol |
| 66 // \{ |
| 67 Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDe
vice> oif, Socket::SocketErrno &sockerr); |
| 68 bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetD
evice> idev, UnicastForwardCallback ucb, |
| 69 MulticastForwardCallback mcb, LocalDeliverCallback lcb, Error
Callback ecb); |
| 70 virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const; |
| 71 virtual void NotifyInterfaceUp (uint32_t interface); |
| 72 virtual void NotifyInterfaceDown (uint32_t interface); |
| 73 virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress addres
s); |
| 74 virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress add
ress); |
| 75 virtual void SetIpv4 (Ptr<Ipv4> ipv4); |
| 76 // \} |
| 77 // /\name Methods to handle protocol parameters |
| 78 // \{ |
| 79 void SetEnableBufferFlag (bool f); |
| 80 bool GetEnableBufferFlag () const; |
| 81 void SetWSTFlag (bool f); |
| 82 bool GetWSTFlag () const; |
| 83 void SetEnableRAFlag (bool f); |
| 84 bool GetEnableRAFlag () const; |
| 85 // \} |
| 86 |
| 87 private: |
| 88 // /\name Protocol parameters. |
| 89 // \{ |
| 90 // / \{Holdtimes is the multiplicative factor of PeriodicUpdateInterval for wh
ich the node waits since the last update |
| 91 // / before flushing a route from the routing table. If PeriodicUpdateInterval
is 8s and Holdtimes is 3, the node |
| 92 // / waits for 24s since the last update to flush this route from its routing
table. \} |
| 93 uint32_t Holdtimes; |
| 94 // / \{PeriodicUpdateInterval specifies the periodic time interval between whi
ch the a node broadcasts |
| 95 // / its entire routing table.\} |
| 96 Time m_periodicUpdateInterval; |
| 97 // /\{ SettlingTime specifies the time for which a node waits before propagati
ng an update. |
| 98 // / It waits for this time interval in hope of receiving an update with a bet
ter metric. |
| 99 // /\} |
| 100 Time m_settlingTime; |
| 101 // /Nodes IP address |
| 102 Ipv4Address m_mainAddress; |
| 103 // / IP protocol |
| 104 Ptr<Ipv4> m_ipv4; |
| 105 // / Raw socket per each IP interface, map socket -> iface address (IP + mask) |
| 106 std::map<Ptr<Socket>, Ipv4InterfaceAddress> m_socketAddresses; |
| 107 // / Loopback device used to defer route requests until a route is found |
| 108 Ptr<NetDevice> m_lo; |
| 109 // / Main Routing table for the node |
| 110 RoutingTable m_routingTable; |
| 111 // / Advertised Routing table for the node |
| 112 RoutingTable m_advRoutingTable; |
| 113 // / The maximum number of packets that we allow a routing protocol to buffer. |
| 114 uint32_t m_maxQueueLen; |
| 115 // / The maximum number of packets that we allow per destination to buffer. |
| 116 uint32_t m_maxQueuedPacketsPerDst; |
| 117 // /< The maximum period of time that a routing protocol is allowed to buffer
a packet for. |
| 118 Time m_maxQueueTime; |
| 119 // / A "drop front on full" queue used by the routing layer to buffer packets
to which it does not have a route. |
| 120 PacketQueue m_queue; |
| 121 // / Flag that is used to enable or disable buffering |
| 122 bool EnableBuffering; |
| 123 // / Flag that is used to enable or disable Weighted Settling Time |
| 124 bool EnableWST; |
| 125 // / This is the wighted factor to determine the weighted settling time |
| 126 double m_weightedFactor; |
| 127 // / This is a flag to enable route aggregation. Route aggregation will aggreg
ate all routes for |
| 128 // / 'RouteAggregationTime' from the time an update is received by a node and
sends them as a single update . |
| 129 bool EnableRouteAggregation; |
| 130 // / Parameter that holds the route aggregation time interval |
| 131 Time m_routeAggregationTime; |
| 132 // / Unicast callback for own packets |
| 133 UnicastForwardCallback m_scb; |
| 134 // / Error callback for own packets |
| 135 ErrorCallback m_ecb; |
| 136 // /\} |
| 137 |
| 138 private: |
| 139 // / Start protocol operation |
| 140 void |
| 141 Start (); |
| 142 // / Queue packet untill we find a route |
| 143 void |
| 144 DeferredRouteOutput (Ptr<const Packet> p, const Ipv4Header & header, UnicastFo
rwardCallback ucb, ErrorCallback ecb); |
| 145 // / Look for any queued packets to send them out |
| 146 void |
| 147 LookForQueuedPackets (void); |
| 148 /** |
| 149 * Send packet from queue |
| 150 * \param dst - destination address to which we are sending the packet to |
| 151 * \param route - route identified for this packet |
| 152 */ |
| 153 void |
| 154 SendPacketFromQueue (Ipv4Address dst, Ptr<Ipv4Route> route); |
| 155 // / Find socket with local interface address iface |
| 156 Ptr<Socket> |
| 157 FindSocketWithInterfaceAddress (Ipv4InterfaceAddress iface) const; |
| 158 // /\name Receive dsdv control packets |
| 159 // \{ |
| 160 // / Receive and process dsdv control packet |
| 161 void |
| 162 RecvDsdv (Ptr<Socket> socket); |
| 163 // \} |
| 164 void |
| 165 Send (Ptr<Ipv4Route>, Ptr<const Packet>, const Ipv4Header &); |
| 166 // / Create loopback route for given header |
| 167 Ptr<Ipv4Route> |
| 168 LoopbackRoute (const Ipv4Header & header, Ptr<NetDevice> oif) const; |
| 169 /** |
| 170 * Get settlingTime for a destination |
| 171 * \param dst - destination address |
| 172 * \return settlingTime for the destination if found |
| 173 */ |
| 174 Time |
| 175 GetSettlingTime (Ipv4Address dst); |
| 176 // / Sends trigger update from a node |
| 177 void |
| 178 SendTriggeredUpdate (); |
| 179 // / Broadcasts the entire routing table for every PeriodicUpdateInterval |
| 180 void |
| 181 SendPeriodicUpdate (); |
| 182 void |
| 183 MergeTriggerPeriodicUpdates (); |
| 184 // / Notify that packet is dropped for some reason |
| 185 void |
| 186 Drop (Ptr<const Packet>, const Ipv4Header &, Socket::SocketErrno); |
| 187 // / Timer to trigger periodic updates from a node |
| 188 Timer m_periodicUpdateTimer; |
| 189 // / Timer used by the trigger updates in case of Weighted Settling Time is us
ed |
| 190 Timer m_triggeredExpireTimer; |
| 191 }; |
| 192 |
| 193 } |
| 194 } |
| 195 #endif /* DSDVROUTINGPROTOCOL_H_ */ |
OLD | NEW |