OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 The Georgia Institute of Technology· | 3 * Copyright (c) 2009 The Georgia Institute of Technology· |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 * Nix-vector routing protocol | 51 * Nix-vector routing protocol |
52 */ | 52 */ |
53 class Ipv4NixVectorRouting : public Ipv4RoutingProtocol | 53 class Ipv4NixVectorRouting : public Ipv4RoutingProtocol |
54 { | 54 { |
55 public: | 55 public: |
56 Ipv4NixVectorRouting (); | 56 Ipv4NixVectorRouting (); |
57 ~Ipv4NixVectorRouting (); | 57 ~Ipv4NixVectorRouting (); |
58 /** | 58 /** |
59 * @brief The Interface ID of the Global Router interface. | 59 * @brief The Interface ID of the Global Router interface. |
60 * | 60 * |
61 * @see Object::GetObject () | 61 * @return type ID |
62 */ | 62 */ |
63 static TypeId GetTypeId (void); | 63 static TypeId GetTypeId (void); |
64 /** | 64 /** |
65 * @brief Set the Node pointer of the node for which this | 65 * @brief Set the Node pointer of the node for which this |
66 * routing protocol is to be placed | 66 * routing protocol is to be placed |
67 * | 67 * |
68 * @param node Node pointer | 68 * @param node Node pointer |
69 */ | 69 */ |
70 void SetNode (Ptr<Node> node); | 70 void SetNode (Ptr<Node> node); |
71 | 71 |
72 /** | 72 /** |
73 * @brief Called when run-time link topology change occurs | 73 * @brief Called when run-time link topology change occurs |
74 * which iterates through the node list and flushes any | 74 * which iterates through the node list and flushes any |
75 * nix vector caches | 75 * nix vector caches |
76 * | 76 * |
77 * \internal | 77 * \internal |
78 * \c const is used here due to need to potentially flush the cache | 78 * \c const is used here due to need to potentially flush the cache |
79 * in const methods such as PrintRoutingTable. Caches are stored in | 79 * in const methods such as PrintRoutingTable. Caches are stored in |
80 * mutable variables and flushed in const methods. | 80 * mutable variables and flushed in const methods. |
81 */ | 81 */ |
82 void FlushGlobalNixRoutingCache (void) const; | 82 void FlushGlobalNixRoutingCache (void) const; |
83 | 83 |
84 private: | 84 private: |
85 | 85 |
86 /* flushes the cache which stores nix-vector based on | 86 /** flushes the cache which stores nix-vector based on |
87 * destination IP */ | 87 * destination IP */ |
88 void FlushNixCache (void) const; | 88 void FlushNixCache (void) const; |
89 | 89 |
90 /* flushes the cache which stores the Ipv4 route | 90 /** flushes the cache which stores the Ipv4 route |
91 * based on the destination IP */ | 91 * based on the destination IP */ |
92 void FlushIpv4RouteCache (void) const; | 92 void FlushIpv4RouteCache (void) const; |
93 | 93 |
94 /* upon a run-time topology change caches are | 94 /** upon a run-time topology change caches are |
95 * flushed and the total number of neighbors is | 95 * flushed and the total number of neighbors is |
96 * reset to zero */ | 96 * reset to zero */ |
97 void ResetTotalNeighbors (void); | 97 void ResetTotalNeighbors (void); |
98 | 98 |
99 /* takes in the source node and dest IP and calls GetNodeByIp, | 99 /** takes in the source node and dest IP and calls GetNodeByIp, |
100 * BFS, accounting for any output interface specified, and finally | 100 * BFS, accounting for any output interface specified, and finally |
101 * BuildNixVector to return the built nix-vector */ | 101 * BuildNixVector to return the built nix-vector· |
102 Ptr<NixVector> GetNixVector (Ptr<Node>, Ipv4Address, Ptr<NetDevice>); | 102 * |
| 103 * \param source is the source node |
| 104 * \param dest is the destination address |
| 105 * \param oif is the net device |
| 106 * \return Ptr<NixVector> |
| 107 */ |
| 108 Ptr<NixVector> GetNixVector (Ptr<Node> source, Ipv4Address dest, Ptr<NetDevice
> oif); |
103 | 109 |
104 /* checks the cache based on dest IP for the nix-vector */ | 110 /** checks the cache based on dest IP for the nix-vector */ |
105 Ptr<NixVector> GetNixVectorInCache (Ipv4Address); | 111 Ptr<NixVector> GetNixVectorInCache (Ipv4Address); |
106 | 112 |
107 /* checks the cache based on dest IP for the Ipv4Route */ | 113 /** checks the cache based on dest IP for the Ipv4Route */ |
108 Ptr<Ipv4Route> GetIpv4RouteInCache (Ipv4Address); | 114 Ptr<Ipv4Route> GetIpv4RouteInCache (Ipv4Address); |
109 | 115 |
110 /* given a net-device returns all the adjacent net-devices, | 116 /** given a net-device returns all the adjacent net-devices, |
111 * essentially getting the neighbors on that channel */ | 117 * essentially getting the neighbors on that channel */ |
112 void GetAdjacentNetDevices (Ptr<NetDevice>, Ptr<Channel>, NetDeviceContainer &
); | 118 void GetAdjacentNetDevices (Ptr<NetDevice>, Ptr<Channel>, NetDeviceContainer &
); |
113 | 119 |
114 /* iterates through the node list and finds the one | 120 /** iterates through the node list and finds the one |
115 * corresponding to the given Ipv4Address */ | 121 * corresponding to the given Ipv4Address */ |
116 Ptr<Node> GetNodeByIp (Ipv4Address); | 122 Ptr<Node> GetNodeByIp (Ipv4Address); |
117 | 123 |
118 /* Recurses the parent vector, created by BFS and actually builds the nixvecto
r */ | 124 /** Recurses the parent vector, created by BFS and actually builds the nixvect
or */ |
119 bool BuildNixVector (const std::vector< Ptr<Node> > & parentVector, uint32_t s
ource, uint32_t dest, Ptr<NixVector> nixVector); | 125 bool BuildNixVector (const std::vector< Ptr<Node> > & parentVector, uint32_t s
ource, uint32_t dest, Ptr<NixVector> nixVector); |
120 | 126 |
121 /* special variation of BuildNixVector for when a node is sending to itself */ | 127 /** special variation of BuildNixVector for when a node is sending to itself *
/ |
122 bool BuildNixVectorLocal (Ptr<NixVector> nixVector); | 128 bool BuildNixVectorLocal (Ptr<NixVector> nixVector); |
123 | 129 |
124 /* simple iterates through the nodes net-devices and determines | 130 /** simple iterates through the nodes net-devices and determines |
125 * how many neighbors it has */ | 131 * how many neighbors it has */ |
126 uint32_t FindTotalNeighbors (void); | 132 uint32_t FindTotalNeighbors (void); |
127 | 133 |
128 /* determine if the netdevice is bridged */ | 134 /** determine if the netdevice is bridged */ |
129 Ptr<BridgeNetDevice> NetDeviceIsBridged (Ptr<NetDevice> nd) const; | 135 Ptr<BridgeNetDevice> NetDeviceIsBridged (Ptr<NetDevice> nd) const; |
130 | 136 |
131 | 137 |
132 /* Nix index is with respect to the neighbors. The net-device index must be | 138 /** Nix index is with respect to the neighbors. The net-device index must be |
133 * derived from this */ | 139 * derived from this |
| 140 * |
| 141 * \param nodeIndex |
| 142 * \param gatewayIp |
| 143 * \returns net device |
| 144 */ |
134 uint32_t FindNetDeviceForNixIndex (uint32_t nodeIndex, Ipv4Address & gatewayIp
); | 145 uint32_t FindNetDeviceForNixIndex (uint32_t nodeIndex, Ipv4Address & gatewayIp
); |
135 | 146 |
136 /* Breadth first search algorithm | 147 /** Breadth first search algorithm |
137 * Param1: total number of nodes | 148 * \param numberOfNodes total number of nodes |
138 * Param2: Source Node | 149 * \param source Source Node |
139 * Param3: Dest Node | 150 * \param dest Dest Node |
140 * Param4: (returned) Parent vector for retracing routes | 151 * \param parentVector (returned) Parent vector for retracing routes |
141 * Param5: specific output interface to use from source node, if not null | 152 * \param oif specific output interface to use from source node, if not null |
142 * Returns: false if dest not found, true o.w. | 153 * \returns false if dest not found, true o.w. |
143 */ | 154 */ |
144 bool BFS (uint32_t numberOfNodes, | 155 bool BFS (uint32_t numberOfNodes, |
145 Ptr<Node> source, | 156 Ptr<Node> source, |
146 Ptr<Node> dest, | 157 Ptr<Node> dest, |
147 std::vector< Ptr<Node> > & parentVector, | 158 std::vector< Ptr<Node> > & parentVector, |
148 Ptr<NetDevice> oif); | 159 Ptr<NetDevice> oif); |
149 | 160 |
150 void DoDispose (void); | 161 void DoDispose (void); |
151 | 162 |
152 /* From Ipv4RoutingProtocol */ | 163 /** From Ipv4RoutingProtocol */ |
153 virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, P
tr<NetDevice> oif, Socket::SocketErrno &sockerr); | 164 virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, P
tr<NetDevice> oif, Socket::SocketErrno &sockerr); |
154 virtual bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<co
nst NetDevice> idev, | 165 virtual bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<co
nst NetDevice> idev, |
155 UnicastForwardCallback ucb, MulticastForwardCallback
mcb, | 166 UnicastForwardCallback ucb, MulticastForwardCallback
mcb, |
156 LocalDeliverCallback lcb, ErrorCallback ecb); | 167 LocalDeliverCallback lcb, ErrorCallback ecb); |
157 virtual void NotifyInterfaceUp (uint32_t interface); | 168 virtual void NotifyInterfaceUp (uint32_t interface); |
158 virtual void NotifyInterfaceDown (uint32_t interface); | 169 virtual void NotifyInterfaceDown (uint32_t interface); |
159 virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress addres
s); | 170 virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress addres
s); |
160 virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress add
ress); | 171 virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress add
ress); |
161 virtual void SetIpv4 (Ptr<Ipv4> ipv4); | 172 virtual void SetIpv4 (Ptr<Ipv4> ipv4); |
162 virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit un
it = Time::S) const; | 173 virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit un
it = Time::S) const; |
163 · | 174 · |
164 /*· | 175 /**· |
165 * Flushes routing caches if required. | 176 * Flushes routing caches if required. |
166 */ | 177 */ |
167 void CheckCacheStateAndFlush (void) const; | 178 void CheckCacheStateAndFlush (void) const; |
168 | 179 |
169 /*· | 180 /**· |
170 * Flag to mark when caches are dirty and need to be flushed.·· | 181 * Flag to mark when caches are dirty and need to be flushed.·· |
171 * Used for lazy cleanup of caches when there are many topology changes. | 182 * Used for lazy cleanup of caches when there are many topology changes. |
172 */ | 183 */ |
173 static bool g_isCacheDirty; | 184 static bool g_isCacheDirty; |
174 | 185 |
175 /* Cache stores nix-vectors based on destination ip */ | 186 /** Cache stores nix-vectors based on destination ip */ |
176 mutable NixMap_t m_nixCache; | 187 mutable NixMap_t m_nixCache; |
177 | 188 |
178 /* Cache stores Ipv4Routes based on destination ip */ | 189 /** Cache stores Ipv4Routes based on destination ip */ |
179 mutable Ipv4RouteMap_t m_ipv4RouteCache; | 190 mutable Ipv4RouteMap_t m_ipv4RouteCache; |
180 | 191 |
181 Ptr<Ipv4> m_ipv4; | 192 Ptr<Ipv4> m_ipv4; ///< IPv4 |
182 Ptr<Node> m_node; | 193 Ptr<Node> m_node; ///< node |
183 | 194 |
184 /* Total neighbors used for nix-vector to determine | 195 /** Total neighbors used for nix-vector to determine |
185 * number of bits */ | 196 * number of bits */ |
186 uint32_t m_totalNeighbors; | 197 uint32_t m_totalNeighbors; |
187 }; | 198 }; |
188 } // namespace ns3 | 199 } // namespace ns3 |
189 | 200 |
190 #endif /* IPV4_NIX_VECTOR_ROUTING_H */ | 201 #endif /* IPV4_NIX_VECTOR_ROUTING_H */ |
OLD | NEW |