author | Tom Henderson <tomh@tomh.org> |
Sun, 30 Nov 2008 23:37:12 -0800 | |
changeset 3960 | 34908804c029 |
parent 3959 | ec65107df095 |
child 4297 | d8501bae8be1 |
permissions | -rw-r--r-- |
1111 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
1457
562a7017ed93
Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents:
1316
diff
changeset
|
3 |
* Copyright 2007 University of Washington |
562a7017ed93
Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents:
1316
diff
changeset
|
4 |
* |
1111 | 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 |
|
1457
562a7017ed93
Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents:
1316
diff
changeset
|
17 |
* |
562a7017ed93
Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents:
1316
diff
changeset
|
18 |
* Authors: Craig Dowell (craigdo@ee.washington.edu) |
562a7017ed93
Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents:
1316
diff
changeset
|
19 |
* Tom Henderson (tomhend@u.washington.edu) |
1111 | 20 |
*/ |
1112 | 21 |
|
1111 | 22 |
#ifndef GLOBAL_ROUTE_MANAGER_IMPL_H |
23 |
#define GLOBAL_ROUTE_MANAGER_IMPL_H |
|
24 |
||
25 |
#include <stdint.h> |
|
26 |
#include <list> |
|
27 |
#include <queue> |
|
28 |
#include <map> |
|
29 |
#include "ns3/object.h" |
|
30 |
#include "ns3/ptr.h" |
|
31 |
#include "ns3/ipv4-address.h" |
|
3937
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
2250
diff
changeset
|
32 |
#include "ns3/node-container.h" |
1111 | 33 |
#include "global-router-interface.h" |
34 |
||
35 |
namespace ns3 { |
|
36 |
||
37 |
const uint32_t SPF_INFINITY = 0xffffffff; |
|
38 |
||
39 |
class CandidateQueue; |
|
3959
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
40 |
class Ipv4GlobalRouting; |
1111 | 41 |
|
42 |
/** |
|
43 |
* @brief Vertex used in shortest path first (SPF) computations. See RFC 2328, |
|
44 |
* Section 16. |
|
45 |
* |
|
46 |
* Each router in the simulation is associated with an SPFVertex object. When |
|
47 |
* calculating routes, each of these routers is, in turn, chosen as the "root" |
|
48 |
* of the calculation and routes to all of the other routers are eventually |
|
49 |
* saved in the routing tables of each of the chosen nodes. Each of these |
|
50 |
* routers in the calculation has an associated SPFVertex. |
|
51 |
* |
|
52 |
* The "Root" vertex is the SPFVertex representing the router that is having |
|
53 |
* its routing tables set. The SPFVertex objects representing other routers |
|
54 |
* or networks in the simulation are arranged in the SPF tree. It is this |
|
55 |
* tree that represents the Shortest Paths to the other networks. |
|
56 |
* |
|
57 |
* Each SPFVertex has a pointer to the Global Router Link State Advertisement |
|
58 |
* (LSA) that its underlying router has exported. Within these LSAs are |
|
59 |
* Global Router Link Records that describe the point to point links from the |
|
60 |
* underlying router to other nodes (represented by other SPFVertex objects) |
|
61 |
* in the simulation topology. The combination of the arrangement of the |
|
62 |
* SPFVertex objects in the SPF tree, along with the details of the link |
|
63 |
* records that connect them provide the information required to construct the |
|
64 |
* required routes. |
|
65 |
*/ |
|
66 |
class SPFVertex |
|
67 |
{ |
|
68 |
public: |
|
69 |
/** |
|
70 |
* @brief Enumeration of the possible types of SPFVertex objects. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
71 |
* @internal |
1111 | 72 |
* |
73 |
* Currently we use VertexRouter to identify objects that represent a router |
|
74 |
* in the simulation topology, and VertexNetwork to identify objects that |
|
75 |
* represent a network. |
|
76 |
*/ |
|
77 |
enum VertexType { |
|
78 |
VertexUnknown = 0, /**< Uninitialized Link Record */ |
|
79 |
VertexRouter, /**< Vertex representing a router in the topology */ |
|
80 |
VertexNetwork /**< Vertex representing a network in the topology */ |
|
81 |
}; |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
82 |
|
1111 | 83 |
/** |
84 |
* @brief Construct an empty ("uninitialized") SPFVertex (Shortest Path First |
|
85 |
* Vertex). |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
86 |
* @internal |
1111 | 87 |
* |
88 |
* The Vertex Type is set to VertexUnknown, the Vertex ID is set to |
|
89 |
* 255.255.255.255, and the distance from root is set to infinity |
|
90 |
* (UINT32_MAX). The referenced Link State Advertisement (LSA) is set to |
|
91 |
* null as is the parent SPFVertex. The outgoing interface index is set to |
|
92 |
* infinity, the next hop address is set to 0.0.0.0 and the list of children |
|
93 |
* of the SPFVertex is initialized to empty. |
|
94 |
* |
|
95 |
* @see VertexType |
|
96 |
*/ |
|
97 |
SPFVertex(); |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
98 |
|
1111 | 99 |
/** |
100 |
* @brief Construct an initialized SPFVertex (Shortest Path First Vertex). |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
101 |
* @internal |
1111 | 102 |
* |
103 |
* The Vertex Type is initialized to VertexRouter and the Vertex ID is found |
|
104 |
* from the Link State ID of the Link State Advertisement (LSA) passed as a |
|
105 |
* parameter. The Link State ID is set to the Router ID of the advertising |
|
106 |
* router. The referenced LSA (m_lsa) is set to the given LSA. Other than |
|
107 |
* these members, initialization is as in the default constructor. |
|
108 |
* of the SPFVertex is initialized to empty. |
|
109 |
* |
|
110 |
* @see SPFVertex::SPFVertex () |
|
111 |
* @see VertexType |
|
1278 | 112 |
* @see GlobalRoutingLSA |
1111 | 113 |
* @param lsa The Link State Advertisement used for finding initial values. |
114 |
*/ |
|
1278 | 115 |
SPFVertex(GlobalRoutingLSA* lsa); |
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
116 |
|
1111 | 117 |
/** |
118 |
* @brief Destroy an SPFVertex (Shortest Path First Vertex). |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
119 |
* @internal |
1111 | 120 |
* |
121 |
* The children vertices of the SPFVertex are recursively deleted. |
|
122 |
* |
|
123 |
* @see SPFVertex::SPFVertex () |
|
124 |
*/ |
|
125 |
~SPFVertex(); |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
126 |
|
1111 | 127 |
/** |
128 |
* @brief Get the Vertex Type field of a SPFVertex object. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
129 |
* @internal |
1111 | 130 |
* |
131 |
* The Vertex Type describes the kind of simulation object a given SPFVertex |
|
132 |
* represents. |
|
133 |
* |
|
134 |
* @see VertexType |
|
135 |
* @returns The VertexType of the current SPFVertex object. |
|
136 |
*/ |
|
137 |
VertexType GetVertexType (void) const; |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
138 |
|
1111 | 139 |
/** |
140 |
* @brief Set the Vertex Type field of a SPFVertex object. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
141 |
* @internal |
1111 | 142 |
* |
143 |
* The Vertex Type describes the kind of simulation object a given SPFVertex |
|
144 |
* represents. |
|
145 |
* |
|
146 |
* @see VertexType |
|
147 |
* @param type The new VertexType for the current SPFVertex object. |
|
148 |
*/ |
|
149 |
void SetVertexType (VertexType type); |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
150 |
|
1111 | 151 |
/** |
152 |
* @brief Get the Vertex ID field of a SPFVertex object. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
153 |
* @internal |
1111 | 154 |
* |
155 |
* The Vertex ID uniquely identifies the simulation object a given SPFVertex |
|
156 |
* represents. Typically, this is the Router ID for SPFVertex objects |
|
157 |
* representing routers, and comes from the Link State Advertisement of a |
|
158 |
* router aggregated to a node in the simulation. These IDs are allocated |
|
159 |
* automatically by the routing environment and look like IP addresses |
|
160 |
* beginning at 0.0.0.0 and monotonically increasing as new routers are |
|
161 |
* instantiated. |
|
162 |
* |
|
163 |
* @returns The Ipv4Address Vertex ID of the current SPFVertex object. |
|
164 |
*/ |
|
165 |
Ipv4Address GetVertexId (void) const; |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
166 |
|
1111 | 167 |
/** |
168 |
* @brief Set the Vertex ID field of a SPFVertex object. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
169 |
* @internal |
1111 | 170 |
* |
171 |
* The Vertex ID uniquely identifies the simulation object a given SPFVertex |
|
172 |
* represents. Typically, this is the Router ID for SPFVertex objects |
|
173 |
* representing routers, and comes from the Link State Advertisement of a |
|
174 |
* router aggregated to a node in the simulation. These IDs are allocated |
|
175 |
* automatically by the routing environment and look like IP addresses |
|
176 |
* beginning at 0.0.0.0 and monotonically increase as new routers are |
|
177 |
* instantiated. This method is an explicit override of the automatically |
|
178 |
* generated value. |
|
179 |
* |
|
180 |
* @param id The new Ipv4Address Vertex ID for the current SPFVertex object. |
|
181 |
*/ |
|
182 |
void SetVertexId (Ipv4Address id); |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
183 |
|
1111 | 184 |
/** |
185 |
* @brief Get the Global Router Link State Advertisement returned by the |
|
186 |
* Global Router represented by this SPFVertex during the route discovery |
|
187 |
* process. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
188 |
* @internal |
1111 | 189 |
* |
190 |
* @see GlobalRouter |
|
1278 | 191 |
* @see GlobalRoutingLSA |
1111 | 192 |
* @see GlobalRouter::DiscoverLSAs () |
1278 | 193 |
* @returns A pointer to the GlobalRoutingLSA found by the router represented |
1111 | 194 |
* by this SPFVertex object. |
195 |
*/ |
|
1278 | 196 |
GlobalRoutingLSA* GetLSA (void) const; |
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
197 |
|
1111 | 198 |
/** |
199 |
* @brief Set the Global Router Link State Advertisement returned by the |
|
200 |
* Global Router represented by this SPFVertex during the route discovery |
|
201 |
* process. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
202 |
* @internal |
1111 | 203 |
* |
204 |
* @see SPFVertex::GetLSA () |
|
205 |
* @see GlobalRouter |
|
1278 | 206 |
* @see GlobalRoutingLSA |
1111 | 207 |
* @see GlobalRouter::DiscoverLSAs () |
208 |
* @warning Ownership of the LSA is transferred to the "this" SPFVertex. You |
|
209 |
* must not delete the LSA after calling this method. |
|
1278 | 210 |
* @param lsa A pointer to the GlobalRoutingLSA. |
1111 | 211 |
*/ |
1278 | 212 |
void SetLSA (GlobalRoutingLSA* lsa); |
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
213 |
|
1111 | 214 |
/** |
215 |
* @brief Get the distance from the root vertex to "this" SPFVertex object. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
216 |
* @internal |
1111 | 217 |
* |
218 |
* Each router in the simulation is associated with an SPFVertex object. When |
|
219 |
* calculating routes, each of these routers is, in turn, chosen as the "root" |
|
220 |
* of the calculation and routes to all of the other routers are eventually |
|
221 |
* saved in the routing tables of each of the chosen nodes. Each of these |
|
222 |
* routers in the calculation has an associated SPFVertex. |
|
223 |
* |
|
224 |
* The "Root" vertex is then the SPFVertex representing the router that is |
|
225 |
* having its routing tables set. The "this" SPFVertex is the vertex to which |
|
226 |
* a route is being calculated from the root. The distance from the root that |
|
227 |
* we're asking for is the number of hops from the root vertex to the vertex |
|
228 |
* in question. |
|
229 |
* |
|
230 |
* The distance is calculated during route discovery and is stored in a |
|
231 |
* member variable. This method simply fetches that value. |
|
232 |
* |
|
233 |
* @returns The distance, in hops, from the root SPFVertex to "this" SPFVertex. |
|
234 |
*/ |
|
235 |
uint32_t GetDistanceFromRoot (void) const; |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
236 |
|
1111 | 237 |
/** |
238 |
* @brief Set the distance from the root vertex to "this" SPFVertex object. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
239 |
* @internal |
1111 | 240 |
* |
241 |
* Each router in the simulation is associated with an SPFVertex object. When |
|
242 |
* calculating routes, each of these routers is, in turn, chosen as the "root" |
|
243 |
* of the calculation and routes to all of the other routers are eventually |
|
244 |
* saved in the routing tables of each of the chosen nodes. Each of these |
|
245 |
* routers in the calculation has an associated SPFVertex. |
|
246 |
* |
|
247 |
* The "Root" vertex is then the SPFVertex representing the router that is |
|
248 |
* having its routing tables set. The "this" SPFVertex is the vertex to which |
|
249 |
* a route is being calculated from the root. The distance from the root that |
|
250 |
* we're asking for is the number of hops from the root vertex to the vertex |
|
251 |
* in question. |
|
252 |
* |
|
253 |
* @param distance The distance, in hops, from the root SPFVertex to "this" |
|
254 |
* SPFVertex. |
|
255 |
*/ |
|
256 |
void SetDistanceFromRoot (uint32_t distance); |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
257 |
|
1111 | 258 |
/** |
259 |
* @brief Get the interface ID that should be used to begin forwarding packets |
|
260 |
* from the root SPFVertex to "this" SPFVertex. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
261 |
* @internal |
1111 | 262 |
* |
263 |
* Each router node in the simulation is associated with an SPFVertex object. |
|
264 |
* When calculating routes, each of these routers is, in turn, chosen as the |
|
265 |
* "root" of the calculation and routes to all of the other routers are |
|
266 |
* eventually saved in the routing tables of each of the chosen nodes. |
|
267 |
* |
|
268 |
* The "Root" vertex is then the SPFVertex representing the router that is |
|
269 |
* having its routing tables set. The "this" SPFVertex is the vertex that |
|
270 |
* represents the host or network to which a route is being calculated from |
|
271 |
* the root. The outgoing interface that we're asking for is the interface |
|
272 |
* index on the root node that should be used to start packets along the |
|
273 |
* path to "this" vertex. |
|
274 |
* |
|
275 |
* When initializing the root SPFVertex, the interface ID is determined by |
|
276 |
* examining the Global Router Link Records of the Link State Advertisement |
|
277 |
* generated by the root node's GlobalRouter. These interfaces are used to |
|
278 |
* forward packets off of the root's network down those links. As other |
|
279 |
* vertices are discovered which are further away from the root, they will |
|
280 |
* be accessible down one of the paths begun by a Global Router Link Record. |
|
281 |
* |
|
282 |
* To forward packets to these hosts or networks, the root node must begin |
|
283 |
* the forwarding process by sending the packets to the interface of that |
|
284 |
* first hop. This means that the first hop address and interface ID must |
|
285 |
* be the same for all downstream SPFVertices. We call this "inheriting" |
|
286 |
* the interface and next hop. |
|
287 |
* |
|
288 |
* In this method, the root node is asking, "which of my local interfaces |
|
289 |
* should I use to get a packet to the network or host represented by 'this' |
|
290 |
* SPFVertex." |
|
291 |
* |
|
292 |
* @see GlobalRouter |
|
1278 | 293 |
* @see GlobalRoutingLSA |
294 |
* @see GlobalRoutingLinkRecord |
|
1111 | 295 |
* @returns The interface index to use when forwarding packets to the host |
296 |
* or network represented by "this" SPFVertex. |
|
297 |
*/ |
|
2250
18f432098389
InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1457
diff
changeset
|
298 |
uint32_t GetOutgoingTypeId (void) const; |
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
299 |
|
1111 | 300 |
/** |
301 |
* @brief Set the interface ID that should be used to begin forwarding packets |
|
302 |
* from the root SPFVertex to "this" SPFVertex. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
303 |
* @internal |
1111 | 304 |
* |
305 |
* Each router node in the simulation is associated with an SPFVertex object. |
|
306 |
* When calculating routes, each of these routers is, in turn, chosen as the |
|
307 |
* "root" of the calculation and routes to all of the other routers are |
|
308 |
* eventually saved in the routing tables of each of the chosen nodes. |
|
309 |
* |
|
310 |
* The "Root" vertex is then the SPFVertex representing the router that is |
|
311 |
* having its routing tables set. The "this" SPFVertex is the vertex that |
|
312 |
* represents the host or network to which a route is being calculated from |
|
313 |
* the root. The outgoing interface that we're asking for is the interface |
|
314 |
* index on the root node that should be used to start packets along the |
|
315 |
* path to "this" vertex. |
|
316 |
* |
|
317 |
* When initializing the root SPFVertex, the interface ID is determined by |
|
318 |
* examining the Global Router Link Records of the Link State Advertisement |
|
319 |
* generated by the root node's GlobalRouter. These interfaces are used to |
|
320 |
* forward packets off of the root's network down those links. As other |
|
321 |
* vertices are discovered which are further away from the root, they will |
|
322 |
* be accessible down one of the paths begun by a Global Router Link Record. |
|
323 |
* |
|
324 |
* To forward packets to these hosts or networks, the root node must begin |
|
325 |
* the forwarding process by sending the packets to the interface of that |
|
326 |
* first hop. This means that the first hop address and interface ID must |
|
327 |
* be the same for all downstream SPFVertices. We call this "inheriting" |
|
328 |
* the interface and next hop. |
|
329 |
* |
|
330 |
* In this method, we are letting the root node know which of its local |
|
331 |
* interfaces it should use to get a packet to the network or host represented |
|
332 |
* by "this" SPFVertex. |
|
333 |
* |
|
334 |
* @see GlobalRouter |
|
1278 | 335 |
* @see GlobalRoutingLSA |
336 |
* @see GlobalRoutingLinkRecord |
|
1111 | 337 |
* @param id The interface index to use when forwarding packets to the host or |
338 |
* network represented by "this" SPFVertex. |
|
339 |
*/ |
|
2250
18f432098389
InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1457
diff
changeset
|
340 |
void SetOutgoingTypeId (uint32_t id); |
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
341 |
|
1111 | 342 |
/** |
343 |
* @brief Get the IP address that should be used to begin forwarding packets |
|
344 |
* from the root SPFVertex to "this" SPFVertex. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
345 |
* @internal |
1111 | 346 |
* |
347 |
* Each router node in the simulation is associated with an SPFVertex object. |
|
348 |
* When calculating routes, each of these routers is, in turn, chosen as the |
|
349 |
* "root" of the calculation and routes to all of the other routers are |
|
350 |
* eventually saved in the routing tables of each of the chosen nodes. |
|
351 |
* |
|
352 |
* The "Root" vertex is then the SPFVertex representing the router that is |
|
353 |
* having its routing tables set. The "this" SPFVertex is the vertex that |
|
354 |
* represents the host or network to which a route is being calculated from |
|
355 |
* the root. The IP address that we're asking for is the address on the |
|
356 |
* remote side of a link off of the root node that should be used as the |
|
357 |
* destination for packets along the path to "this" vertex. |
|
358 |
* |
|
359 |
* When initializing the root SPFVertex, the IP address used when forwarding |
|
360 |
* packets is determined by examining the Global Router Link Records of the |
|
361 |
* Link State Advertisement generated by the root node's GlobalRouter. This |
|
362 |
* address is used to forward packets off of the root's network down those |
|
363 |
* links. As other vertices / nodes are discovered which are further away |
|
364 |
* from the root, they will be accessible down one of the paths via a link |
|
365 |
* described by one of these Global Router Link Records. |
|
366 |
* |
|
367 |
* To forward packets to these hosts or networks, the root node must begin |
|
368 |
* the forwarding process by sending the packets to a first hop router down |
|
369 |
* an interface. This means that the first hop address and interface ID must |
|
370 |
* be the same for all downstream SPFVertices. We call this "inheriting" |
|
371 |
* the interface and next hop. |
|
372 |
* |
|
373 |
* In this method, the root node is asking, "which router should I send a |
|
374 |
* packet to in order to get that packet to the network or host represented |
|
375 |
* by 'this' SPFVertex." |
|
376 |
* |
|
377 |
* @see GlobalRouter |
|
1278 | 378 |
* @see GlobalRoutingLSA |
379 |
* @see GlobalRoutingLinkRecord |
|
1111 | 380 |
* @returns The IP address to use when forwarding packets to the host |
381 |
* or network represented by "this" SPFVertex. |
|
382 |
*/ |
|
383 |
Ipv4Address GetNextHop (void) const; |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
384 |
|
1111 | 385 |
/** |
386 |
* @brief Set the IP address that should be used to begin forwarding packets |
|
387 |
* from the root SPFVertex to "this" SPFVertex. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
388 |
* @internal |
1111 | 389 |
* |
390 |
* Each router node in the simulation is associated with an SPFVertex object. |
|
391 |
* When calculating routes, each of these routers is, in turn, chosen as the |
|
392 |
* "root" of the calculation and routes to all of the other routers are |
|
393 |
* eventually saved in the routing tables of each of the chosen nodes. |
|
394 |
* |
|
395 |
* The "Root" vertex is then the SPFVertex representing the router that is |
|
396 |
* having its routing tables set. The "this" SPFVertex is the vertex that |
|
397 |
* represents the host or network to which a route is being calculated from |
|
398 |
* the root. The IP address that we're asking for is the address on the |
|
399 |
* remote side of a link off of the root node that should be used as the |
|
400 |
* destination for packets along the path to "this" vertex. |
|
401 |
* |
|
402 |
* When initializing the root SPFVertex, the IP address used when forwarding |
|
403 |
* packets is determined by examining the Global Router Link Records of the |
|
404 |
* Link State Advertisement generated by the root node's GlobalRouter. This |
|
405 |
* address is used to forward packets off of the root's network down those |
|
406 |
* links. As other vertices / nodes are discovered which are further away |
|
407 |
* from the root, they will be accessible down one of the paths via a link |
|
408 |
* described by one of these Global Router Link Records. |
|
409 |
* |
|
410 |
* To forward packets to these hosts or networks, the root node must begin |
|
411 |
* the forwarding process by sending the packets to a first hop router down |
|
412 |
* an interface. This means that the first hop address and interface ID must |
|
413 |
* be the same for all downstream SPFVertices. We call this "inheriting" |
|
414 |
* the interface and next hop. |
|
415 |
* |
|
416 |
* In this method we are telling the root node which router it should send |
|
417 |
* should I send a packet to in order to get that packet to the network or |
|
418 |
* host represented by 'this' SPFVertex." |
|
419 |
* |
|
420 |
* @see GlobalRouter |
|
1278 | 421 |
* @see GlobalRoutingLSA |
422 |
* @see GlobalRoutingLinkRecord |
|
1111 | 423 |
* @param nextHop The IP address to use when forwarding packets to the host |
424 |
* or network represented by "this" SPFVertex. |
|
425 |
*/ |
|
426 |
void SetNextHop (Ipv4Address nextHop); |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
427 |
|
1111 | 428 |
/** |
429 |
* @brief Get a pointer to the SPFVector that is the parent of "this" |
|
430 |
* SPFVertex. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
431 |
* @internal |
1111 | 432 |
* |
433 |
* Each router node in the simulation is associated with an SPFVertex object. |
|
434 |
* When calculating routes, each of these routers is, in turn, chosen as the |
|
435 |
* "root" of the calculation and routes to all of the other routers are |
|
436 |
* eventually saved in the routing tables of each of the chosen nodes. |
|
437 |
* |
|
438 |
* The "Root" vertex is then the SPFVertex representing the router that is |
|
439 |
* having its routing tables set and is the root of the SPF tree. |
|
440 |
* |
|
441 |
* This method returns a pointer to the parent node of "this" SPFVertex |
|
442 |
* (both of which reside in that SPF tree). |
|
443 |
* |
|
444 |
* @returns A pointer to the SPFVertex that is the parent of "this" SPFVertex |
|
445 |
* in the SPF tree. |
|
446 |
*/ |
|
447 |
SPFVertex* GetParent (void) const; |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
448 |
|
1111 | 449 |
/** |
450 |
* @brief Set the pointer to the SPFVector that is the parent of "this" |
|
451 |
* SPFVertex. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
452 |
* @internal |
1111 | 453 |
* |
454 |
* Each router node in the simulation is associated with an SPFVertex object. |
|
455 |
* When calculating routes, each of these routers is, in turn, chosen as the |
|
456 |
* "root" of the calculation and routes to all of the other routers are |
|
457 |
* eventually saved in the routing tables of each of the chosen nodes. |
|
458 |
* |
|
459 |
* The "Root" vertex is then the SPFVertex representing the router that is |
|
460 |
* having its routing tables set and is the root of the SPF tree. |
|
461 |
* |
|
462 |
* This method sets the parent pointer of "this" SPFVertex (both of which |
|
463 |
* reside in that SPF tree). |
|
464 |
* |
|
465 |
* @param parent A pointer to the SPFVertex that is the parent of "this" |
|
466 |
* SPFVertex* in the SPF tree. |
|
467 |
*/ |
|
468 |
void SetParent (SPFVertex* parent); |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
469 |
|
1111 | 470 |
/** |
471 |
* @brief Get the number of children of "this" SPFVertex. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
472 |
* @internal |
1111 | 473 |
* |
474 |
* Each router node in the simulation is associated with an SPFVertex object. |
|
475 |
* When calculating routes, each of these routers is, in turn, chosen as the |
|
476 |
* "root" of the calculation and routes to all of the other routers are |
|
477 |
* eventually saved in the routing tables of each of the chosen nodes. |
|
478 |
* |
|
479 |
* The "Root" vertex is then the SPFVertex representing the router that is |
|
480 |
* having its routing tables set and is the root of the SPF tree. Each vertex |
|
481 |
* in the SPF tree can have a number of children that represent host or |
|
482 |
* network routes available via that vertex. |
|
483 |
* |
|
484 |
* This method returns the number of children of "this" SPFVertex (which |
|
485 |
* reside in the SPF tree). |
|
486 |
* |
|
487 |
* @returns The number of children of "this" SPFVertex (which reside in the |
|
488 |
* SPF tree). |
|
489 |
*/ |
|
490 |
uint32_t GetNChildren (void) const; |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
491 |
|
1111 | 492 |
/** |
493 |
* @brief Get a borrowed SPFVertex pointer to the specified child of "this" |
|
494 |
* SPFVertex. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
495 |
* @internal |
1111 | 496 |
* |
497 |
* Each router node in the simulation is associated with an SPFVertex object. |
|
498 |
* When calculating routes, each of these routers is, in turn, chosen as the |
|
499 |
* "root" of the calculation and routes to all of the other routers are |
|
500 |
* eventually saved in the routing tables of each of the chosen nodes. |
|
501 |
* |
|
502 |
* The "Root" vertex is then the SPFVertex representing the router that is |
|
503 |
* having its routing tables set and is the root of the SPF tree. Each vertex |
|
504 |
* in the SPF tree can have a number of children that represent host or |
|
505 |
* network routes available via that vertex. |
|
506 |
* |
|
507 |
* This method the number of children of "this" SPFVertex (which reside in |
|
508 |
* the SPF tree. |
|
509 |
* |
|
510 |
* @see SPFVertex::GetNChildren |
|
511 |
* @param n The index (from 0 to the number of children minus 1) of the |
|
512 |
* child SPFVertex to return. |
|
513 |
* @warning The pointer returned by GetChild () is a borrowed pointer. You |
|
514 |
* do not have any ownership of the underlying object and must not delete |
|
515 |
* that object. |
|
516 |
* @returns A pointer to the specified child SPFVertex (which resides in the |
|
517 |
* SPF tree). |
|
518 |
*/ |
|
519 |
SPFVertex* GetChild (uint32_t n) const; |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
520 |
|
1111 | 521 |
/** |
522 |
* @brief Get a borrowed SPFVertex pointer to the specified child of "this" |
|
523 |
* SPFVertex. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
524 |
* @internal |
1111 | 525 |
* |
526 |
* Each router node in the simulation is associated with an SPFVertex object. |
|
527 |
* When calculating routes, each of these routers is, in turn, chosen as the |
|
528 |
* "root" of the calculation and routes to all of the other routers are |
|
529 |
* eventually saved in the routing tables of each of the chosen nodes. |
|
530 |
* |
|
531 |
* The "Root" vertex is then the SPFVertex representing the router that is |
|
532 |
* having its routing tables set and is the root of the SPF tree. Each vertex |
|
533 |
* in the SPF tree can have a number of children that represent host or |
|
534 |
* network routes available via that vertex. |
|
535 |
* |
|
536 |
* This method the number of children of "this" SPFVertex (which reside in |
|
537 |
* the SPF tree. |
|
538 |
* |
|
539 |
* @see SPFVertex::GetNChildren |
|
540 |
* @warning Ownership of the pointer added to the children of "this" |
|
541 |
* SPFVertex is transferred to the "this" SPFVertex. You must not delete the |
|
542 |
* (now) child SPFVertex after calling this method. |
|
543 |
* @param child A pointer to the SPFVertex (which resides in the SPF tree) to |
|
544 |
* be added to the list of children of "this" SPFVertex. |
|
545 |
* @returns The number of children of "this" SPFVertex after the addition of |
|
546 |
* the new child. |
|
547 |
*/ |
|
548 |
uint32_t AddChild (SPFVertex* child); |
|
549 |
||
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
550 |
/** |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
551 |
* @brief Set the value of the VertexProcessed flag |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
552 |
* |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
553 |
* Flag to note whether vertex has been processed in stage two of |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
554 |
* SPF computation |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
555 |
* @param value boolean value to set the flag |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
556 |
*/ |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
557 |
void SetVertexProcessed (bool value); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
558 |
|
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
559 |
/** |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
560 |
* @brief Check the value of the VertexProcessed flag |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
561 |
* |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
562 |
* Flag to note whether vertex has been processed in stage two of |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
563 |
* SPF computation |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
564 |
* @returns value of underlying flag |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
565 |
*/ |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
566 |
bool IsVertexProcessed (void) const; |
1111 | 567 |
private: |
568 |
VertexType m_vertexType; |
|
569 |
Ipv4Address m_vertexId; |
|
1278 | 570 |
GlobalRoutingLSA* m_lsa; |
1111 | 571 |
uint32_t m_distanceFromRoot; |
572 |
uint32_t m_rootOif; |
|
573 |
Ipv4Address m_nextHop; |
|
574 |
SPFVertex* m_parent; |
|
575 |
typedef std::list<SPFVertex*> ListOfSPFVertex_t; |
|
576 |
ListOfSPFVertex_t m_children; |
|
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
577 |
bool m_vertexProcessed; |
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
578 |
|
1111 | 579 |
/** |
580 |
* @brief The SPFVertex copy construction is disallowed. There's no need for |
|
581 |
* it and a compiler provided shallow copy would be wrong. |
|
582 |
*/ |
|
583 |
SPFVertex (SPFVertex& v); |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
584 |
|
1111 | 585 |
/** |
586 |
* @brief The SPFVertex copy assignment operator is disallowed. There's no |
|
587 |
* need for it and a compiler provided shallow copy would be wrong. |
|
588 |
*/ |
|
589 |
SPFVertex& operator= (SPFVertex& v); |
|
590 |
}; |
|
591 |
||
592 |
/** |
|
593 |
* @brief The Link State DataBase (LSDB) of the Global Route Manager. |
|
594 |
* |
|
595 |
* Each node in the simulation participating in global routing has a |
|
596 |
* GlobalRouter interface. The primary job of this interface is to export |
|
597 |
* Global Router Link State Advertisements (LSAs). These advertisements in |
|
598 |
* turn contain a number of Global Router Link Records that describe the |
|
599 |
* point to point links from the underlying node to other nodes (that will |
|
600 |
* also export their own LSAs. |
|
601 |
* |
|
602 |
* This class implements a searchable database of LSAs gathered from every |
|
603 |
* router in the simulation. |
|
604 |
*/ |
|
605 |
class GlobalRouteManagerLSDB |
|
606 |
{ |
|
607 |
public: |
|
608 |
/** |
|
609 |
* @brief Construct an empty Global Router Manager Link State Database. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
610 |
* @internal |
1111 | 611 |
* |
612 |
* The database map composing the Link State Database is initialized in |
|
613 |
* this constructor. |
|
614 |
*/ |
|
615 |
GlobalRouteManagerLSDB (); |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
616 |
|
1111 | 617 |
/** |
618 |
* @brief Destroy an empty Global Router Manager Link State Database. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
619 |
* @internal |
1111 | 620 |
* |
621 |
* The database map is walked and all of the Link State Advertisements stored |
|
622 |
* in the database are freed; then the database map itself is clear ()ed to |
|
623 |
* release any remaining resources. |
|
624 |
*/ |
|
625 |
~GlobalRouteManagerLSDB (); |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
626 |
|
1111 | 627 |
/** |
628 |
* @brief Insert an IP address / Link State Advertisement pair into the Link |
|
629 |
* State Database. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
630 |
* @internal |
1111 | 631 |
* |
1278 | 632 |
* The IPV4 address and the GlobalRoutingLSA given as parameters are converted |
1111 | 633 |
* to an STL pair and are inserted into the database map. |
634 |
* |
|
1278 | 635 |
* @see GlobalRoutingLSA |
1111 | 636 |
* @see Ipv4Address |
637 |
* @param addr The IP address associated with the LSA. Typically the Router |
|
638 |
* ID. |
|
639 |
* @param lsa A pointer to the Link State Advertisement for the router. |
|
640 |
*/ |
|
1278 | 641 |
void Insert(Ipv4Address addr, GlobalRoutingLSA* lsa); |
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
642 |
|
1111 | 643 |
/** |
644 |
* @brief Look up the Link State Advertisement associated with the given |
|
1278 | 645 |
* link state ID (address). |
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
646 |
* @internal |
1111 | 647 |
* |
648 |
* The database map is searched for the given IPV4 address and corresponding |
|
1278 | 649 |
* GlobalRoutingLSA is returned. |
1111 | 650 |
* |
1278 | 651 |
* @see GlobalRoutingLSA |
1111 | 652 |
* @see Ipv4Address |
653 |
* @param addr The IP address associated with the LSA. Typically the Router |
|
654 |
* ID. |
|
655 |
* @returns A pointer to the Link State Advertisement for the router specified |
|
656 |
* by the IP address addr. |
|
657 |
*/ |
|
1278 | 658 |
GlobalRoutingLSA* GetLSA (Ipv4Address addr) const; |
659 |
/** |
|
660 |
* @brief Look up the Link State Advertisement associated with the given |
|
661 |
* link state ID (address). This is a variation of the GetLSA call |
|
662 |
* to allow the LSA to be found by matching addr with the LinkData field |
|
663 |
* of the TransitNetwork link record. |
|
664 |
* @internal |
|
665 |
* |
|
666 |
* @see GetLSA |
|
667 |
* @param addr The IP address associated with the LSA. Typically the Router |
|
668 |
* @returns A pointer to the Link State Advertisement for the router specified |
|
669 |
* by the IP address addr. |
|
670 |
* ID. |
|
671 |
*/ |
|
672 |
GlobalRoutingLSA* GetLSAByLinkData (Ipv4Address addr) const; |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
673 |
|
1111 | 674 |
/** |
675 |
* @brief Set all LSA flags to an initialized state, for SPF computation |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
676 |
* @internal |
1111 | 677 |
* |
678 |
* This function walks the database and resets the status flags of all of the |
|
679 |
* contained Link State Advertisements to LSA_SPF_NOT_EXPLORED. This is done |
|
680 |
* prior to each SPF calculation to reset the state of the SPFVertex structures |
|
681 |
* that will reference the LSAs during the calculation. |
|
682 |
* |
|
1278 | 683 |
* @see GlobalRoutingLSA |
1111 | 684 |
* @see SPFVertex |
685 |
*/ |
|
686 |
void Initialize (); |
|
687 |
||
688 |
private: |
|
1278 | 689 |
typedef std::map<Ipv4Address, GlobalRoutingLSA*> LSDBMap_t; |
690 |
typedef std::pair<Ipv4Address, GlobalRoutingLSA*> LSDBPair_t; |
|
1111 | 691 |
|
692 |
LSDBMap_t m_database; |
|
693 |
/** |
|
694 |
* @brief GlobalRouteManagerLSDB copy construction is disallowed. There's no |
|
695 |
* need for it and a compiler provided shallow copy would be wrong. |
|
696 |
*/ |
|
697 |
GlobalRouteManagerLSDB (GlobalRouteManagerLSDB& lsdb); |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
698 |
|
1111 | 699 |
/** |
700 |
* @brief The SPFVertex copy assignment operator is disallowed. There's no |
|
701 |
* need for it and a compiler provided shallow copy would be wrong. |
|
702 |
*/ |
|
703 |
GlobalRouteManagerLSDB& operator= (GlobalRouteManagerLSDB& lsdb); |
|
704 |
}; |
|
705 |
||
706 |
/** |
|
707 |
* @brief A global router implementation. |
|
708 |
* |
|
709 |
* This singleton object can query interface each node in the system |
|
710 |
* for a GlobalRouter interface. For those nodes, it fetches one or |
|
711 |
* more Link State Advertisements and stores them in a local database. |
|
712 |
* Then, it can compute shortest paths on a per-node basis to all routers, |
|
713 |
* and finally configure each of the node's forwarding tables. |
|
714 |
* |
|
715 |
* The design is guided by OSPFv2 RFC 2328 section 16.1.1 and quagga ospfd. |
|
716 |
*/ |
|
717 |
class GlobalRouteManagerImpl |
|
718 |
{ |
|
719 |
public: |
|
720 |
GlobalRouteManagerImpl (); |
|
721 |
virtual ~GlobalRouteManagerImpl (); |
|
722 |
/** |
|
3959
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
723 |
* @brief Delete all static routes on all nodes that have a |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
724 |
* GlobalRouterInterface |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
725 |
* |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
726 |
* TODO: separate manually assigned static routes from static routes that |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
727 |
* the global routing code injects, and only delete the latter |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
728 |
* @internal |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
729 |
* |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
730 |
*/ |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
731 |
virtual void DeleteGlobalRoutes (); |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
732 |
/** |
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
733 |
* @brief Select which nodes in the system are to be router nodes and |
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
734 |
* aggregate the appropriate interfaces onto those nodes. |
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
735 |
* @internal |
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
736 |
* |
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
737 |
*/ |
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
738 |
virtual void SelectRouterNodes (); |
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
739 |
|
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
740 |
/** |
3937
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
2250
diff
changeset
|
741 |
* @brief Select which nodes in the system are to be router nodes and |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
2250
diff
changeset
|
742 |
* aggregate the appropriate interfaces onto those nodes. |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
2250
diff
changeset
|
743 |
* @internal |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
2250
diff
changeset
|
744 |
* |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
2250
diff
changeset
|
745 |
*/ |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
2250
diff
changeset
|
746 |
virtual void SelectRouterNodes (NodeContainer c); |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
2250
diff
changeset
|
747 |
|
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
2250
diff
changeset
|
748 |
/** |
1111 | 749 |
* @brief Build the routing database by gathering Link State Advertisements |
750 |
* from each node exporting a GlobalRouter interface. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
751 |
* @internal |
1111 | 752 |
*/ |
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
753 |
virtual void BuildGlobalRoutingDatabase (); |
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
754 |
|
1111 | 755 |
/** |
756 |
* @brief Compute routes using a Dijkstra SPF computation and populate |
|
757 |
* per-node forwarding tables |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
758 |
* @internal |
1111 | 759 |
*/ |
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
760 |
virtual void InitializeRoutes (); |
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
761 |
|
1111 | 762 |
/** |
763 |
* @brief Debugging routine; allow client code to supply a pre-built LSDB |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
764 |
* @internal |
1111 | 765 |
*/ |
766 |
void DebugUseLsdb (GlobalRouteManagerLSDB*); |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
767 |
|
1111 | 768 |
/** |
769 |
* @brief Debugging routine; call the core SPF from the unit tests |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
770 |
* @internal |
1111 | 771 |
*/ |
772 |
void DebugSPFCalculate (Ipv4Address root); |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
773 |
|
1111 | 774 |
private: |
775 |
/** |
|
776 |
* @brief GlobalRouteManagerImpl copy construction is disallowed. |
|
777 |
* There's no need for it and a compiler provided shallow copy would be |
|
778 |
* wrong. |
|
779 |
*/ |
|
780 |
GlobalRouteManagerImpl (GlobalRouteManagerImpl& srmi); |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
781 |
|
1111 | 782 |
/** |
783 |
* @brief Global Route Manager Implementation assignment operator is |
|
784 |
* disallowed. There's no need for it and a compiler provided shallow copy |
|
785 |
* would be hopelessly wrong. |
|
786 |
*/ |
|
787 |
GlobalRouteManagerImpl& operator= (GlobalRouteManagerImpl& srmi); |
|
788 |
||
789 |
SPFVertex* m_spfroot; |
|
790 |
GlobalRouteManagerLSDB* m_lsdb; |
|
791 |
void SPFCalculate (Ipv4Address root); |
|
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
792 |
void SPFProcessStubs (SPFVertex* v); |
1111 | 793 |
void SPFNext (SPFVertex*, CandidateQueue&); |
794 |
int SPFNexthopCalculation (SPFVertex* v, SPFVertex* w, |
|
1278 | 795 |
GlobalRoutingLinkRecord* l, uint32_t distance); |
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
796 |
void SPFVertexAddParent (SPFVertex* v); |
1278 | 797 |
GlobalRoutingLinkRecord* SPFGetNextLink (SPFVertex* v, SPFVertex* w, |
798 |
GlobalRoutingLinkRecord* prev_link); |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1112
diff
changeset
|
799 |
void SPFIntraAddRouter (SPFVertex* v); |
1278 | 800 |
void SPFIntraAddTransit (SPFVertex* v); |
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
801 |
void SPFIntraAddStub (GlobalRoutingLinkRecord *l, SPFVertex* v); |
2250
18f432098389
InterfaceId -> TypeId
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1457
diff
changeset
|
802 |
uint32_t FindOutgoingTypeId (Ipv4Address a, |
1316
f357c6a2bb37
Provide two new Ipv4 convenience functions: GetIfIndexByIpv4Address() and GetIpv4RouteToDestination (), and align global routing code to use the first function
Tom Henderson <tomh@tomh.org>
parents:
1278
diff
changeset
|
803 |
Ipv4Mask amask = Ipv4Mask("255.255.255.255")); |
3959
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
804 |
|
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
805 |
// Local cache of the Ipv4GlobalRouting objects, indexed by nodeId |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
806 |
typedef std::list< std::pair< uint32_t, Ptr<Ipv4GlobalRouting> > > Ipv4GlobalRoutingList; |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
807 |
void AddGlobalRoutingProtocol (uint32_t nodeId, Ptr<Ipv4GlobalRouting> proto); |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
808 |
Ptr<Ipv4GlobalRouting> GetGlobalRoutingProtocol (uint32_t nodeId); |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
809 |
Ipv4GlobalRoutingList m_routingProtocols; |
1111 | 810 |
}; |
811 |
||
812 |
} // namespace ns3 |
|
813 |
||
814 |
#endif /* GLOBAL_ROUTE_MANAGER_IMPL_H */ |