00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright 2007 University of Washington 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Authors: Craig Dowell (craigdo@ee.washington.edu) 00019 * Tom Henderson (tomhend@u.washington.edu) 00020 */ 00021 00022 #ifndef GLOBAL_ROUTE_MANAGER_H 00023 #define GLOBAL_ROUTE_MANAGER_H 00024 00025 #include "ns3/node-container.h" 00026 00027 namespace ns3 { 00028 00029 /** 00030 * @brief A global global router 00031 * 00032 * This singleton object can query interface each node in the system 00033 * for a GlobalRouter interface. For those nodes, it fetches one or 00034 * more Link State Advertisements and stores them in a local database. 00035 * Then, it can compute shortest paths on a per-node basis to all routers, 00036 * and finally configure each of the node's forwarding tables. 00037 * 00038 * The design is guided by OSPFv2 RFC 2328 section 16.1.1 and quagga ospfd. 00039 */ 00040 class GlobalRouteManager 00041 { 00042 public: 00043 /** 00044 * @brief Build a routing database and initialize the routing tables of 00045 * the nodes in the simulation. Makes all nodes in the simulation into 00046 * routers. 00047 * 00048 * All this function does is call the three functions 00049 * SelectRouterNodes (), BuildGlobalRoutingDatabase (), and 00050 * InitializeRoutes (). 00051 * 00052 * @see SelectRouterNodes (); 00053 * @see BuildGlobalRoutingDatabase (); 00054 * @see InitializeRoutes (); 00055 */ 00056 static void PopulateRoutingTables (); 00057 00058 /** 00059 * @brief Build a routing database and initialize the routing tables of 00060 * the nodes in the simulation. Makes the nodes in the provided container 00061 * into routers. 00062 * 00063 * All this function does is call the three functions 00064 * SelectRouterNodes (), BuildGlobalRoutingDatabase (), and 00065 * InitializeRoutes (). 00066 * 00067 * @see SelectRouterNodes (Node Container c); 00068 * @see BuildGlobalRoutingDatabase (); 00069 * @see InitializeRoutes (); 00070 */ 00071 static void PopulateRoutingTables (NodeContainer c); 00072 00073 /** 00074 *@brief Remove all routes that were previously installed in a prior call 00075 * to either PopulateRoutingTables() or RecomputeRoutingTables(), and 00076 * add a new set of routes. 00077 * 00078 * This method does not change the set of nodes 00079 * over which GlobalRouting is being used, but it will dynamically update 00080 * its representation of the global topology before recomputing routes. 00081 * Users must first call PopulateRoutingTables() and then may subsequently 00082 * call RecomputeRoutingTables() at any later time in the simulation. 00083 * 00084 * @see DeleteGlobalRoutes (); 00085 * @see BuildGlobalRoutingDatabase (); 00086 * @see InitializeRoutes (); 00087 */ 00088 static void RecomputeRoutingTables (); 00089 00090 /** 00091 * @brief Delete all static routes on all nodes that have a 00092 * GlobalRouterInterface 00093 * 00094 */ 00095 static void DeleteGlobalRoutes (); 00096 00097 /** 00098 * @brief Select which nodes in the system are to be router nodes and 00099 * aggregate the appropriate interfaces onto those nodes. 00100 * @internal 00101 * 00102 */ 00103 static void SelectRouterNodes (); 00104 00105 /** 00106 * @brief Select which nodes in the system are to be router nodes and 00107 * aggregate the appropriate interfaces onto those nodes. 00108 * @internal 00109 * 00110 */ 00111 static void SelectRouterNodes (NodeContainer c); 00112 00113 /** 00114 * @brief Allocate a 32-bit router ID from monotonically increasing counter. 00115 */ 00116 static uint32_t AllocateRouterId (); 00117 00118 private: 00119 00120 /** 00121 * @brief Build the routing database by gathering Link State Advertisements 00122 * from each node exporting a GlobalRouter interface. 00123 * @internal 00124 * 00125 */ 00126 static void BuildGlobalRoutingDatabase (); 00127 00128 /** 00129 * @brief Compute routes using a Dijkstra SPF computation and populate 00130 * per-node forwarding tables 00131 * @internal 00132 */ 00133 static void InitializeRoutes (); 00134 00135 /** 00136 * @brief Global Route Manager copy construction is disallowed. There's no 00137 * need for it and a compiler provided shallow copy would be wrong. 00138 * 00139 */ 00140 GlobalRouteManager (GlobalRouteManager& srm); 00141 00142 /** 00143 * @brief Global Router copy assignment operator is disallowed. There's no 00144 * need for it and a compiler provided shallow copy would be wrong. 00145 */ 00146 GlobalRouteManager& operator= (GlobalRouteManager& srm); 00147 }; 00148 00149 } // namespace ns3 00150 00151 #endif /* GLOBAL_ROUTE_MANAGER_H */