made GetNumLSAs cheap, added DiscoverLSAs as expensive call.
This commit is contained in:
@@ -102,8 +102,12 @@ StaticRouteManager::BuildStaticRoutingDatabase ()
|
||||
Ptr<StaticRouter> rtr =
|
||||
node->QueryInterface<StaticRouter> (StaticRouter::iid);
|
||||
NS_ASSERT_MSG(rtr, "QI for <StaticRouter> interface failed");
|
||||
|
||||
uint32_t numLSAs = rtr->GetNumLSAs();
|
||||
//
|
||||
// Should call DiscoverLSAs () before trying to use any routing info or to
|
||||
// update LSAs. Subsequently you may use GetNumLSAs(). If you call
|
||||
// GetNumLSAs () before calling DiscoverLSAs () will get zero as the number.
|
||||
//
|
||||
uint32_t numLSAs = rtr->DiscoverLSAs();
|
||||
NS_DEBUG_UNCOND ("Found " << numLSAs << " LSAs");
|
||||
|
||||
for (uint32_t j = 0; j < numLSAs; ++j)
|
||||
|
||||
@@ -184,12 +184,13 @@ StaticRouter::ClearLSAs ()
|
||||
}
|
||||
|
||||
//
|
||||
// Return the number of Link State Advertisements this node has to advertise.
|
||||
// Go out and discover any adjacent routers and build the Link State
|
||||
// Advertisements that reflect them and their associated networks.
|
||||
//
|
||||
uint32_t
|
||||
StaticRouter::GetNumLSAs (void)
|
||||
StaticRouter::DiscoverLSAs (void)
|
||||
{
|
||||
NS_DEBUG("StaticRouter::GetNumLSAs ()");
|
||||
NS_DEBUG("StaticRouter::DiscoverLSAs ()");
|
||||
NS_ASSERT_MSG(m_node, "<Node> interface not set");
|
||||
ClearLSAs ();
|
||||
//
|
||||
@@ -208,7 +209,7 @@ StaticRouter::GetNumLSAs (void)
|
||||
// a point-to-point channel.
|
||||
//
|
||||
uint32_t numDevices = m_node->GetNDevices();
|
||||
NS_DEBUG("StaticRouter::GetNumLSAs (): numDevices = " << numDevices);
|
||||
NS_DEBUG("StaticRouter::DiscoverLSAs (): numDevices = " << numDevices);
|
||||
//
|
||||
// Loop through the devices looking for those connected to a point-to-point
|
||||
// channel.
|
||||
@@ -219,11 +220,11 @@ StaticRouter::GetNumLSAs (void)
|
||||
|
||||
if (!ndLocal->IsPointToPoint ())
|
||||
{
|
||||
NS_DEBUG("StaticRouter::GetNumLSAs (): non-point-to-point device");
|
||||
NS_DEBUG("StaticRouter::DiscoverLSAs (): non-point-to-point device");
|
||||
continue;
|
||||
}
|
||||
|
||||
NS_DEBUG("StaticRouter::GetNumLSAs (): Point-to-point device");
|
||||
NS_DEBUG("StaticRouter::DiscoverLSAs (): Point-to-point device");
|
||||
//
|
||||
// Now, we have to find the Ipv4 interface whose netdevice is the one we
|
||||
// just found. This is still the IP on the local side of the channel. There
|
||||
@@ -304,6 +305,13 @@ StaticRouter::GetNumLSAs (void)
|
||||
return m_LSAs.size ();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
StaticRouter::GetNumLSAs (void)
|
||||
{
|
||||
NS_DEBUG("StaticRouter::GetNumLSAs ()");
|
||||
return m_LSAs.size ();
|
||||
}
|
||||
|
||||
//
|
||||
// Get the nth link state advertisement from this router.
|
||||
//
|
||||
|
||||
@@ -185,7 +185,7 @@ public:
|
||||
* Create a Static Router class and aggregate its interface onto the Node
|
||||
* provided.
|
||||
*
|
||||
* @param lsa The existing Node onto which this router will be aggregated.
|
||||
* @param node The existing Node onto which this router will be aggregated.
|
||||
*/
|
||||
StaticRouter (Ptr<Node> node);
|
||||
/**
|
||||
@@ -198,21 +198,35 @@ public:
|
||||
*/
|
||||
Ipv4Address GetRouterId(void);
|
||||
/**
|
||||
* Get the Number of Static Router Link State Advertisements that this
|
||||
* router can export.
|
||||
* Walk the connected channels, discover the adjacent routers and build
|
||||
* the associated number of Static Router Link State Advertisements that
|
||||
* this router can export.
|
||||
*
|
||||
* This is a fairly expensive operation in that every time it is called
|
||||
* the current list of LSAs is built by walking connected point-to-point
|
||||
* channels and peeking into adjacent IPV4 stacks to get address information.
|
||||
* This is done to allow for limited dymanics of the Static Routing
|
||||
* environment. By that we mean that you can discover new link state
|
||||
* advertisements after a network topology change by calling GetNumLSAs and
|
||||
* then by reading those advertisements.
|
||||
* advertisements after a network topology change by calling DiscoverLSAs
|
||||
* and then by reading those advertisements.
|
||||
*
|
||||
* @see StaticRouterLSA
|
||||
* @see StaticRouter::GetLSA ()
|
||||
* @returns The number of Static Router Link State Advertisements.
|
||||
*/
|
||||
uint32_t DiscoverLSAs (void);
|
||||
/**
|
||||
* Get the Number of Static Router Link State Advertisements that this
|
||||
* router can export. To get meaningful information you must have
|
||||
* previously called DiscoverLSAs. After you know how many LSAs are
|
||||
* present in the router, you may call GetLSA () to retrieve the actual
|
||||
* advertisement.
|
||||
*
|
||||
* @see StaticRouterLSA
|
||||
* @see StaticRouter::DiscoverLSAs ()
|
||||
* @see StaticRouter::GetLSA ()
|
||||
* @returns The number of Static Router Link State Advertisements.
|
||||
*/
|
||||
uint32_t GetNumLSAs (void);
|
||||
/**
|
||||
* Get a Static Router Link State Advertisements that this router has said
|
||||
|
||||
Reference in New Issue
Block a user