author | Tom Henderson <tomh@tomh.org> |
Sun, 30 Nov 2008 21:21:23 -0800 | |
changeset 3959 | ec65107df095 |
parent 3937 | 04f9377661b8 |
child 3960 | 34908804c029 |
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:
1121
diff
changeset
|
3 |
* Copyright 2007 University of Washington |
562a7017ed93
Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents:
1121
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:
1121
diff
changeset
|
17 |
* |
562a7017ed93
Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents:
1121
diff
changeset
|
18 |
* Authors: Craig Dowell (craigdo@ee.washington.edu) |
562a7017ed93
Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents:
1121
diff
changeset
|
19 |
* Tom Henderson (tomhend@u.washington.edu) |
1111 | 20 |
*/ |
21 |
||
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1111
diff
changeset
|
22 |
#ifndef GLOBAL_ROUTE_MANAGER_H |
1111 | 23 |
#define GLOBAL_ROUTE_MANAGER_H |
24 |
||
3937
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
25 |
#include "ns3/node-container.h" |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
26 |
|
1111 | 27 |
namespace ns3 { |
28 |
||
29 |
/** |
|
30 |
* @brief A global global router |
|
31 |
* |
|
32 |
* This singleton object can query interface each node in the system |
|
33 |
* for a GlobalRouter interface. For those nodes, it fetches one or |
|
34 |
* more Link State Advertisements and stores them in a local database. |
|
35 |
* Then, it can compute shortest paths on a per-node basis to all routers, |
|
36 |
* and finally configure each of the node's forwarding tables. |
|
37 |
* |
|
38 |
* The design is guided by OSPFv2 RFC 2328 section 16.1.1 and quagga ospfd. |
|
39 |
*/ |
|
40 |
class GlobalRouteManager |
|
41 |
{ |
|
42 |
public: |
|
43 |
/** |
|
44 |
* @brief Build a routing database and initialize the routing tables of |
|
3937
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
45 |
* the nodes in the simulation. Makes all nodes in the simulation into |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
46 |
* routers. |
1111 | 47 |
* |
3959
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
48 |
* All this function does is call the three private functions |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
49 |
* SelectRouterNodes (), BuildGlobalRoutingDatabase (), and |
1111 | 50 |
* InitializeRoutes (). |
51 |
* |
|
3959
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
52 |
* @see SelectRouterNodes (); |
1111 | 53 |
* @see BuildGlobalRoutingDatabase (); |
54 |
* @see InitializeRoutes (); |
|
55 |
*/ |
|
56 |
static void PopulateRoutingTables (); |
|
57 |
||
3959
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
58 |
/** |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
59 |
*@brief Remove all routes that were previously installed in a prior call |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
60 |
* to either PopulateRoutingTables() or RecomputeRoutingTables(), and |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
61 |
* add a new set of routes. |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
62 |
* |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
63 |
* This method does not change the set of nodes |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
64 |
* over which GlobalRouting is being used, but it will dynamically update |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
65 |
* its representation of the global topology before recomputing routes. |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
66 |
* Users must first call PopulateRoutingTables() and then may subsequently |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
67 |
* call RecomputeRoutingTables() at any later time in the simulation. |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
68 |
* |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
69 |
* @see DeleteGlobalRoutes (); |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
70 |
* @see BuildGlobalRoutingDatabase (); |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
71 |
* @see InitializeRoutes (); |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
72 |
*/ |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
73 |
static void RecomputeRoutingTables (); |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
74 |
|
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1111
diff
changeset
|
75 |
/** |
3937
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
76 |
* @brief Build a routing database and initialize the routing tables of |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
77 |
* the nodes in the simulation. Makes the nodes in the provided container |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
78 |
* into routers. |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
79 |
* |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
80 |
* All this function does is call BuildGlobalRoutingDatabase () and |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
81 |
* InitializeRoutes (). |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
82 |
* |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
83 |
* @see BuildGlobalRoutingDatabase (); |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
84 |
* @see InitializeRoutes (); |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
85 |
*/ |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
86 |
static void PopulateRoutingTables (NodeContainer c); |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
87 |
|
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
88 |
/** |
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1111
diff
changeset
|
89 |
* @brief Allocate a 32-bit router ID from monotonically increasing counter. |
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1111
diff
changeset
|
90 |
*/ |
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1111
diff
changeset
|
91 |
static uint32_t AllocateRouterId (); |
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1111
diff
changeset
|
92 |
|
1111 | 93 |
private: |
3959
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
94 |
|
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
95 |
/** |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
96 |
* @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
|
97 |
* GlobalRouterInterface |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
98 |
* |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
99 |
* 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
|
100 |
* 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
|
101 |
* @internal |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
102 |
*/ |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
103 |
static void DeleteGlobalRoutes (); |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3937
diff
changeset
|
104 |
|
1111 | 105 |
/** |
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1111
diff
changeset
|
106 |
* @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:
1111
diff
changeset
|
107 |
* aggregate the appropriate interfaces onto those nodes. |
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
108 |
* @internal |
1113
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1111
diff
changeset
|
109 |
* |
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1111
diff
changeset
|
110 |
*/ |
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1111
diff
changeset
|
111 |
static void SelectRouterNodes (); |
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1111
diff
changeset
|
112 |
|
5b63b39161e7
remove routing environment, move router interface creation to global-route-manager
Craig Dowell <craigdo@ee.washington.edu>
parents:
1111
diff
changeset
|
113 |
/** |
3937
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
114 |
* @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:
1457
diff
changeset
|
115 |
* 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:
1457
diff
changeset
|
116 |
* @internal |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
117 |
* |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
118 |
*/ |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
119 |
static void SelectRouterNodes (NodeContainer c); |
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
120 |
|
04f9377661b8
convince global routing not to crash in the presence of bridges
Craig Dowell <craigdo@ee.washington.edu>
parents:
1457
diff
changeset
|
121 |
/** |
1111 | 122 |
* @brief Build the routing database by gathering Link State Advertisements |
123 |
* from each node exporting a GlobalRouter interface. |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
124 |
* @internal |
1111 | 125 |
* |
126 |
*/ |
|
127 |
static void BuildGlobalRoutingDatabase (); |
|
128 |
||
129 |
/** |
|
130 |
* @brief Compute routes using a Dijkstra SPF computation and populate |
|
131 |
* per-node forwarding tables |
|
1114
4bf5d1262aae
doxygen update (@internal)
Craig Dowell <craigdo@ee.washington.edu>
parents:
1113
diff
changeset
|
132 |
* @internal |
1111 | 133 |
*/ |
134 |
static void InitializeRoutes (); |
|
135 |
||
136 |
/** |
|
137 |
* @brief Global Route Manager copy construction is disallowed. There's no |
|
138 |
* need for it and a compiler provided shallow copy would be wrong. |
|
139 |
* |
|
140 |
*/ |
|
141 |
GlobalRouteManager (GlobalRouteManager& srm); |
|
142 |
||
143 |
/** |
|
144 |
* @brief Global Router copy assignment operator is disallowed. There's no |
|
145 |
* need for it and a compiler provided shallow copy would be wrong. |
|
146 |
*/ |
|
147 |
GlobalRouteManager& operator= (GlobalRouteManager& srm); |
|
148 |
}; |
|
149 |
||
150 |
} // namespace ns3 |
|
151 |
||
152 |
#endif /* GLOBAL_ROUTE_MANAGER_H */ |