# HG changeset patch # User Craig Dowell # Date 1184803074 25200 # Node ID 4aeb2eaa21a7fd8c79cbf3328430086914cb2840 # Parent 1e97c5a86b2420c3f8869d4048dfc27a18d08ca9 general cleanup of routing diff -r 1e97c5a86b24 -r 4aeb2eaa21a7 SConstruct --- a/SConstruct Wed Jul 18 14:35:06 2007 -0700 +++ b/SConstruct Wed Jul 18 16:57:54 2007 -0700 @@ -503,13 +503,6 @@ sample_component_manager.add_deps(['core']) sample_component_manager.add_source('main-component-manager.cc') -sample_candidate_queue = build.Ns3Module('sample-candidate-queue', 'samples') -sample_candidate_queue.set_executable() -ns3.add(sample_candidate_queue) -sample_candidate_queue.add_deps(['core']) -sample_candidate_queue.add_deps(['routing']) -sample_candidate_queue.add_source('main-candidate-queue.cc') - # examples example_simple_p2p = build.Ns3Module('simple-p2p', 'examples') example_simple_p2p.set_executable() diff -r 1e97c5a86b24 -r 4aeb2eaa21a7 samples/main-candidate-queue.cc --- a/samples/main-candidate-queue.cc Wed Jul 18 14:35:06 2007 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation; - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "ns3/debug.h" -#include "ns3/assert.h" -#include "ns3/candidate-queue.h" - -using namespace ns3; - - int -main (int argc, char *argv[]) -{ - NS_DEBUG_UNCOND("Candidate Queue Test"); - -#if 0 - DebugComponentEnable("CandidateQueue"); -#endif - - CandidateQueue candidate; - NS_ASSERT(candidate.Size () == 0); - - for (int i = 0; i < 100; ++i) - { - SPFVertex *v = new SPFVertex; - v->m_distanceFromRoot = rand () % 100; - candidate.Push (v); - } - - uint32_t lastDistance = 0; - bool ok = true; - - for (int i = 0; i < 100; ++i) - { - SPFVertex *v = candidate.Top (); - candidate.Pop (); - if (v->m_distanceFromRoot < lastDistance) - { - ok = false; - NS_ASSERT(0); - } - lastDistance = v->m_distanceFromRoot; - } - - for (int i = 0; i < 100; ++i) - { - SPFVertex *v = new SPFVertex; - v->m_distanceFromRoot = rand () % 100; - candidate.Push (v); - } - -#if 0 - for (int i = 0; i < 100; ++i) - { - SPFVertex *v = candidate.Find (i); - if (v) { - v->m_distanceFromRoot = rand () % 100; - } - } -#endif - - candidate.Reorder (); - - lastDistance = 0; - - for (int i = 0; i < 100; ++i) - { - SPFVertex *v = candidate.Top (); - candidate.Pop (); - if (v->m_distanceFromRoot < lastDistance) - { - ok = false; - NS_ASSERT(0); - } - lastDistance = v->m_distanceFromRoot; - } - - NS_ASSERT(candidate.Size () == 0); - - return 0; -} diff -r 1e97c5a86b24 -r 4aeb2eaa21a7 src/routing/candidate-queue.cc --- a/src/routing/candidate-queue.cc Wed Jul 18 14:35:06 2007 -0700 +++ b/src/routing/candidate-queue.cc Wed Jul 18 16:57:54 2007 -0700 @@ -57,7 +57,7 @@ for (; i != m_candidates.end (); i++) { SPFVertex *v = *i; - if (vNew->m_distanceFromRoot < v->m_distanceFromRoot) + if (vNew->GetDistanceFromRoot () < v->GetDistanceFromRoot ()) { break; } @@ -119,7 +119,7 @@ for (; i != m_candidates.end (); i++) { SPFVertex *v = *i; - if (v->m_vertexId == addr) + if (v->GetVertexId() == addr) { return v; } diff -r 1e97c5a86b24 -r 4aeb2eaa21a7 src/routing/static-route-manager.cc --- a/src/routing/static-route-manager.cc Wed Jul 18 14:35:06 2007 -0700 +++ b/src/routing/static-route-manager.cc Wed Jul 18 16:57:54 2007 -0700 @@ -34,11 +34,11 @@ m_vertexType (VertexUnknown), m_vertexId ("255.255.255.255"), m_lsa (0), - m_parent (0), - m_children (), m_distanceFromRoot (SPF_INFINITY), m_rootOif (SPF_INFINITY), - m_nextHop ("0.0.0.0") + m_nextHop ("0.0.0.0"), + m_parent (0), + m_children () { } @@ -46,19 +46,19 @@ m_vertexType (VertexRouter), m_vertexId (lsa->GetLinkStateId ()), m_lsa (lsa), - m_parent (0), - m_children (), m_distanceFromRoot (SPF_INFINITY), m_rootOif (SPF_INFINITY), - m_nextHop ("0.0.0.0") + m_nextHop ("0.0.0.0"), + m_parent (0), + m_children () { } SPFVertex::~SPFVertex () { - for ( t_listOfSPFVertex::iterator i = m_children.begin (); - i != m_children.end (); - i++) + for ( ListOfSPFVertex_t::iterator i = m_children.begin (); + i != m_children.end (); + i++) { SPFVertex *p = *i; delete p; @@ -68,6 +68,128 @@ m_children.clear (); } + void +SPFVertex::SetVertexType (SPFVertex::VertexType type) +{ + m_vertexType = type; +} + + SPFVertex::VertexType +SPFVertex::GetVertexType (void) const +{ + return m_vertexType; +} + + void +SPFVertex::SetVertexId (Ipv4Address id) +{ + m_vertexId = id; +} + + Ipv4Address +SPFVertex::GetVertexId (void) const +{ + return m_vertexId; +} + + void +SPFVertex::SetLSA (StaticRouterLSA* lsa) +{ + m_lsa = lsa; +} + + StaticRouterLSA* +SPFVertex::GetLSA (void) const +{ + return m_lsa; +} + + void +SPFVertex::SetDistanceFromRoot (uint32_t distance) +{ + m_distanceFromRoot = distance; +} + + uint32_t +SPFVertex::GetDistanceFromRoot (void) const +{ + return m_distanceFromRoot; +} + + void +SPFVertex::SetOutgoingInterfaceId (uint32_t id) +{ + m_rootOif = id; +} + + uint32_t +SPFVertex::GetOutgoingInterfaceId (void) const +{ + return m_rootOif; +} + + void +SPFVertex::SetNextHop (Ipv4Address nextHop) +{ + m_nextHop = nextHop; +} + + Ipv4Address +SPFVertex::GetNextHop (void) const +{ + return m_nextHop; +} + + void +SPFVertex::SetParent (SPFVertex* parent) +{ + m_parent = parent; +} + + SPFVertex* +SPFVertex::GetParent (void) const +{ + return m_parent; +} + + uint32_t +SPFVertex::GetNChildren (void) const +{ + return m_children.size (); +} + + SPFVertex* +SPFVertex::GetChild (uint32_t n) const +{ + uint32_t j = 0; + + for ( ListOfSPFVertex_t::const_iterator i = m_children.begin (); + i != m_children.end (); + i++, j++) + { + if (j == n) + { + return *i; + } + } + NS_ASSERT_MSG(false, "Index out of range."); + return 0; +} + + uint32_t +SPFVertex::AddChild (SPFVertex* child) +{ + m_children.push_back (child); + return m_children.size (); +} + +StaticRouteManagerLSDB::StaticRouteManagerLSDB () +: + m_database () +{ + NS_DEBUG ("StaticRouteManagerLSDB::StaticRouteManagerLSDB ()"); +} + StaticRouteManagerLSDB::~StaticRouteManagerLSDB () { NS_DEBUG ("StaticRouteManagerLSDB::~StaticRouteManagerLSDB ()"); @@ -286,24 +408,24 @@ // // Always true for now, since all our LSAs are RouterLSAs. // - if (v->m_vertexType == SPFVertex::VertexRouter) + if (v->GetVertexType () == SPFVertex::VertexRouter) { if (true) { - NS_DEBUG ("SPFNext: Examining " << v->m_vertexId << "'s " << - v->m_lsa->GetNLinkRecords () << " link records"); + NS_DEBUG ("SPFNext: Examining " << v->GetVertexId () << "'s " << + v->GetLSA ()->GetNLinkRecords () << " link records"); // // Walk the list of link records in the link state advertisement associated // with the "current" router (represented by vertex ). // - for (uint32_t i = 0; i < v->m_lsa->GetNLinkRecords (); ++i) + for (uint32_t i = 0; i < v->GetLSA ()->GetNLinkRecords (); ++i) { // // (a) If this is a link to a stub network, examine the next link in V's LSA. // Links to stub networks will be considered in the second stage of the // shortest path calculation. // - StaticRouterLinkRecord *l = v->m_lsa->GetLinkRecord (i); + StaticRouterLinkRecord *l = v->GetLSA ()->GetLinkRecord (i); if (l->GetLinkType () == StaticRouterLinkRecord::StubNetwork) { NS_DEBUG ("SPFNext: Found a Stub record to " << @@ -324,7 +446,7 @@ w_lsa = m_lsdb->GetLSA (l->GetLinkId ()); NS_ASSERT (w_lsa); NS_DEBUG ("SPFNext: Found a P2P record from " << - v->m_vertexId << " to " << w_lsa->GetLinkStateId ()); + v->GetVertexId () << " to " << w_lsa->GetLinkStateId ()); // // (c) If vertex W is already on the shortest-path tree, examine the next // link in the LSA. @@ -347,7 +469,7 @@ // calculated) shortest path to vertex V and the advertised cost of the link // between vertices V and W. // - distance = v->m_distanceFromRoot + l->GetMetric (); + distance = v->GetDistanceFromRoot () + l->GetMetric (); NS_DEBUG ("SPFNext: Considering w_lsa " << w_lsa->GetLinkStateId ()); @@ -375,8 +497,9 @@ // root node). // candidate.Push (w); - NS_DEBUG ("SPFNext: Pushing " << w->m_vertexId - << ", parent vertexId: " << v->m_vertexId); + NS_DEBUG ("SPFNext: Pushing " << + w->GetVertexId () << ", parent vertexId: " << + v->GetVertexId ()); } } } else if (w_lsa->GetStatus () == @@ -390,22 +513,22 @@ // So, locate the vertex in the candidate queue and take a look at the // distance. w = candidate.Find (w_lsa->GetLinkStateId ()); - if (w->m_distanceFromRoot < distance) + if (w->GetDistanceFromRoot () < distance) { // // This is not a shorter path, so don't do anything. // continue; } - else if (w->m_distanceFromRoot == distance) - { + else if (w->GetDistanceFromRoot () == distance) + { // // This path is one with an equal cost. Do nothing for now -- we're not doing // equal-cost multipath cases yet. // - } - else - { + } + else + { // // this path represents a new, lower-cost path to (the vertex we found in // the current link record of the link state advertisement of the current root @@ -414,15 +537,15 @@ // N.B. the nexthop_calculation is conditional, if it finds a valid nexthop // it will call spf_add_parents, which will flush the old parents // - if (SPFNexthopCalculation (v, w, l, distance)) - { + if (SPFNexthopCalculation (v, w, l, distance)) + { // // If we've changed the cost to get to the vertex represented by , we // must reorder the priority queue keyed to that cost. // - candidate.Reorder (); - } - } + candidate.Reorder (); + } + } } // point-to-point } // for loop } @@ -479,7 +602,7 @@ // node if this root node is a router. We then need to see if this node // is a router. // - if (w->m_vertexType == SPFVertex::VertexRouter) + if (w->GetVertexType () == SPFVertex::VertexRouter) { // // In the case of point-to-point links, the link data field (m_linkData) of a @@ -507,18 +630,19 @@ // from the root node to the host represented by vertex , you have to send // the packet to the next hop address specified in w->m_nextHop. // - w->m_nextHop = linkRemote->GetLinkData (); + w->SetNextHop(linkRemote->GetLinkData ()); // // Now find the outgoing interface corresponding to the point to point link // from the perspective of -- remember that is the link "from" // "to" . // - w->m_rootOif = FindOutgoingInterfaceId (l->GetLinkData ()); + w->SetOutgoingInterfaceId ( + FindOutgoingInterfaceId (l->GetLinkData ())); NS_DEBUG ("SPFNexthopCalculation: Next hop from " << - v->m_vertexId << " to " << w->m_vertexId << - " goes through next hop " << w->m_nextHop << - " via outgoing interface " << w->m_rootOif); + v->GetVertexId () << " to " << w->GetVertexId () << + " goes through next hop " << w->GetNextHop () << + " via outgoing interface " << w->GetOutgoingInterfaceId ()); } } else @@ -536,14 +660,14 @@ // (shortest) paths. So the next hop and outoing interface remain the same // (are inherited). // - w->m_nextHop = v->m_nextHop; - w->m_rootOif = v->m_rootOif; + w->SetNextHop (v->GetNextHop ()); + w->SetOutgoingInterfaceId (v->GetOutgoingInterfaceId ()); } // // In all cases, we need valid values for the distance metric and a parent. // - w->m_distanceFromRoot = distance; - w->m_parent = v; + w->SetDistanceFromRoot (distance); + w->SetParent (v); return 1; } @@ -587,9 +711,9 @@ // looking for records representing the point-to-point links off of this // vertex. // - for (uint32_t i = 0; i < v->m_lsa->GetNLinkRecords (); ++i) + for (uint32_t i = 0; i < v->GetLSA ()->GetNLinkRecords (); ++i) { - l = v->m_lsa->GetLinkRecord (i); + l = v->GetLSA ()->GetLinkRecord (i); if (l->GetLinkType () != StaticRouterLinkRecord::PointToPoint) { continue; @@ -602,7 +726,7 @@ // We're just checking to see if the link is actually the link from to // . // - if (l->GetLinkId () == w->m_vertexId) { + if (l->GetLinkId () == w->GetVertexId ()) { NS_DEBUG ("SPFGetNextLink: Found matching link l: linkId = " << l->GetLinkId () << " linkData = " << l->GetLinkData ()); // @@ -672,8 +796,8 @@ // We also mark this vertex as being in the SPF tree. // m_spfroot= v; - v->m_distanceFromRoot = 0; - v->m_lsa->SetStatus (StaticRouterLSA::LSA_SPF_IN_SPFTREE); + v->SetDistanceFromRoot (0); + v->GetLSA ()->SetStatus (StaticRouterLSA::LSA_SPF_IN_SPFTREE); for (;;) { @@ -713,12 +837,12 @@ // the candidate list. // v = candidate.Pop (); - NS_DEBUG ("SPFCalculate: Popped vertex " << v->m_vertexId); + NS_DEBUG ("SPFCalculate: Popped vertex " << v->GetVertexId ()); // // Update the status field of the vertex to indicate that it is in the SPF // tree. // - v->m_lsa->SetStatus (StaticRouterLSA::LSA_SPF_IN_SPFTREE); + v->GetLSA ()->SetStatus (StaticRouterLSA::LSA_SPF_IN_SPFTREE); // // The current vertex has a parent pointer. By calling this rather oddly // named method (blame quagga) we add the current vertex to the list of @@ -792,7 +916,7 @@ // node in order to iterate the interfaces and find the one corresponding to // the address in question. // - Ipv4Address routerId = m_spfroot->m_vertexId; + Ipv4Address routerId = m_spfroot->GetVertexId (); // // Walk the list of nodes in the system looking for the one corresponding to // the node at the root of the SPF tree. This is the node for which we are @@ -878,7 +1002,7 @@ // going to use this ID to discover which node it is that we're actually going // to update. // - Ipv4Address routerId = m_spfroot->m_vertexId; + Ipv4Address routerId = m_spfroot->GetVertexId (); NS_DEBUG ("StaticRouteManager::SPFIntraAddRouter ():" "Vertex ID = " << routerId); @@ -927,7 +1051,7 @@ // Link Records corresponding to links off of that vertex / node. We're going // to be interested in the records corresponding to point-to-point links. // - StaticRouterLSA *lsa = v->m_lsa; + StaticRouterLSA *lsa = v->GetLSA (); NS_ASSERT_MSG (lsa, "StaticRouteManager::SPFIntraAddRouter (): " "Expected valid LSA in SPFVertex* v"); @@ -955,8 +1079,8 @@ NS_DEBUG ("StaticRouteManager::SPFIntraAddRouter (): " " Node " << node->GetId () << " add route to " << lr->GetLinkData () << - " using next hop " << v->m_nextHop << - " via interface " << v->m_rootOif); + " using next hop " << v->GetNextHop () << + " via interface " << v->GetOutgoingInterfaceId ()); // // Here's why we did all of that work. We're going to add a host route to the // host address found in the m_linkData field of the point-to-point link @@ -970,8 +1094,8 @@ // Similarly, the vertex has an m_rootOif (outbound interface index) to // which the packets should be send for forwarding. // - ipv4->AddHostRouteTo (lr->GetLinkData (), v->m_nextHop, - v->m_rootOif); + ipv4->AddHostRouteTo (lr->GetLinkData (), v->GetNextHop (), + v->GetOutgoingInterfaceId ()); } } // @@ -994,8 +1118,10 @@ void StaticRouteManager::SPFVertexAddParent (SPFVertex* v) { - // For now, only one parent (not doing equal-cost multipath) - v->m_parent->m_children.push_back (v); +// +// For now, only one parent (not doing equal-cost multipath) +// + v->GetParent ()->AddChild (v); } } // namespace ns3 @@ -1052,7 +1178,7 @@ for (int i = 0; i < 100; ++i) { SPFVertex *v = new SPFVertex; - v->m_distanceFromRoot = rand () % 100; + v->SetDistanceFromRoot (rand () % 100); candidate.Push (v); } @@ -1061,11 +1187,11 @@ for (int i = 0; i < 100; ++i) { SPFVertex *v = candidate.Pop (); - if (v->m_distanceFromRoot < lastDistance) + if (v->GetDistanceFromRoot () < lastDistance) { ok = false; } - lastDistance = v->m_distanceFromRoot; + lastDistance = v->GetDistanceFromRoot (); delete v; v = 0; } diff -r 1e97c5a86b24 -r 4aeb2eaa21a7 src/routing/static-route-manager.h --- a/src/routing/static-route-manager.h Wed Jul 18 14:35:06 2007 -0700 +++ b/src/routing/static-route-manager.h Wed Jul 18 16:57:54 2007 -0700 @@ -47,23 +47,58 @@ VertexUnknown = 0, VertexRouter, VertexNetwork - } m_vertexType; + }; + + void SetVertexType (VertexType type); + VertexType GetVertexType (void) const; - Ipv4Address m_vertexId; // router id + void SetVertexId (Ipv4Address idV); + Ipv4Address GetVertexId (void) const; - StaticRouterLSA* m_lsa; // This pointer owns LSA for mem. mgmt purposes + void SetLSA (StaticRouterLSA* lsa); + StaticRouterLSA* GetLSA (void) const; + + void SetDistanceFromRoot (uint32_t distance); + uint32_t GetDistanceFromRoot (void) const; - // need to keep track of current parent vertex - SPFVertex* m_parent; - // m_children lists the leaves from your SPF tree - typedef std::list t_listOfSPFVertex; - t_listOfSPFVertex m_children; - t_listOfSPFVertex::iterator m_SPFVertexIter; + void SetOutgoingInterfaceId (uint32_t id); + uint32_t GetOutgoingInterfaceId (void) const; + + void SetNextHop (Ipv4Address nextHop); + Ipv4Address GetNextHop (void) const; + + void SetParent (SPFVertex* parent); + SPFVertex* GetParent (void) const; + uint32_t GetNChildren (void) const; + SPFVertex* GetChild (uint32_t n) const; + + uint32_t AddChild (SPFVertex* child); + +private: + VertexType m_vertexType; + Ipv4Address m_vertexId; // router id + StaticRouterLSA* m_lsa; // This pointer owns LSA for mem. mgmt purposes uint32_t m_distanceFromRoot; uint32_t m_rootOif; Ipv4Address m_nextHop; + // need to keep track of current parent vertex + SPFVertex* m_parent; + + // m_children lists the leaves from your SPF tree + typedef std::list ListOfSPFVertex_t; + ListOfSPFVertex_t m_children; +/** + * The SPFVertex copy construction is disallowed. There's no need for + * it and a compiler provided shallow copy would be wrong. + */ + SPFVertex (SPFVertex& v); +/** + * The SPFVertex copy assignment operator is disallowed. There's no need for + * it and a compiler provided shallow copy would be wrong. + */ + SPFVertex& operator= (SPFVertex& v); }; /** @@ -72,6 +107,7 @@ class StaticRouteManagerLSDB { public: + StaticRouteManagerLSDB (); ~StaticRouteManagerLSDB (); void Insert(Ipv4Address addr, StaticRouterLSA* lsa); StaticRouterLSA* GetLSA (Ipv4Address addr); @@ -83,6 +119,17 @@ typedef std::map LSDBMap_t; typedef std::pair LSDBPair_t; LSDBMap_t m_database; +private: +/** + * StaticRouteManagerLSDB copy construction is disallowed. There's no + * need for it and a compiler provided shallow copy would be hopelessly wrong. + */ + StaticRouteManagerLSDB (StaticRouteManagerLSDB& lsdb); +/** + * The SPFVertex copy assignment operator is disallowed. There's no need for + * it and a compiler provided shallow copy would be wrong. + */ + StaticRouteManagerLSDB& operator= (StaticRouteManagerLSDB& lsdb); }; /** @@ -126,6 +173,18 @@ protected: private: +/** + * Static Route Manager copy construction is disallowed. There's no need for + * it and a compiler provided shallow copy would be hopelessly wrong. + * + */ + StaticRouteManager (StaticRouteManager& srm); +/** + * Static Router copy assignment operator is disallowed. There's no need for + * it and a compiler provided shallow copy would be hopelessly wrong. + */ + StaticRouteManager& operator= (StaticRouteManager& srm); + SPFVertex* m_spfroot; StaticRouteManagerLSDB* m_lsdb; void SPFCalculate (Ipv4Address root); diff -r 1e97c5a86b24 -r 4aeb2eaa21a7 src/routing/static-router.h --- a/src/routing/static-router.h Wed Jul 18 14:35:06 2007 -0700 +++ b/src/routing/static-router.h Wed Jul 18 16:57:54 2007 -0700 @@ -39,11 +39,11 @@ class StaticRouterLinkRecord { public: - /** - * Enumeration of the possible types of Static Router Link Records. These - * are defined in the OSPF spec. We currently only use PointToPoint and - * StubNetwork types. - */ +/** + * Enumeration of the possible types of Static Router Link Records. These + * are defined in the OSPF spec. We currently only use PointToPoint and + * StubNetwork types. + */ enum LinkType { Unknown = 0, /**< Uninitialized Link Record */ PointToPoint, /**< Record representing a point to point channel */ @@ -51,148 +51,151 @@ StubNetwork, /**< Record represents a leaf node network */ VirtualLink /**< Unused -- for future OSPF compatibility */ }; - /** - * Construct an empty ("uninitialized") Static Router Link Record. - * - * The Link ID and Link Data Ipv4 addresses are set to "0.0.0.0"; - * The Link Type is set to Unknown; - * The metric is set to 0. - */ +/** + * Construct an empty ("uninitialized") Static Router Link Record. + * + * The Link ID and Link Data Ipv4 addresses are set to "0.0.0.0"; + * The Link Type is set to Unknown; + * The metric is set to 0. + */ StaticRouterLinkRecord (); - /** - * Construct a fully uninitialized Static Router Link Record. - * - * @param linkType The type of link record to construct. - * @param linkId The link ID for the record. - * @param linkData The link data field for the record. - * @param metric The metric field for the record. - * @see LinkType - * @see SetLinkId - * @see SetLinkData - */ +/** + * Construct a fully uninitialized Static Router Link Record. + * + * @param linkType The type of link record to construct. + * @param linkId The link ID for the record. + * @param linkData The link data field for the record. + * @param metric The metric field for the record. + * @see LinkType + * @see SetLinkId + * @see SetLinkData + */ StaticRouterLinkRecord ( LinkType linkType, Ipv4Address linkId, Ipv4Address linkData, uint32_t metric); - /** - * Destroy a Static Router Link Record. - * - * Currently does nothing. Here as a placeholder only. - */ +/** + * Destroy a Static Router Link Record. + * + * Currently does nothing. Here as a placeholder only. + */ ~StaticRouterLinkRecord (); - /** - * Get the Link ID field of the Static Router Link Record. - * - * For an OSPF type 1 link (PointToPoint) the Link ID will be the Router ID - * of the neighboring router. - * - * For an OSPF type 3 link (StubNetwork), the Link ID will be the adjacent - * neighbor's IP address - */ +/** + * Get the Link ID field of the Static Router Link Record. + * + * For an OSPF type 1 link (PointToPoint) the Link ID will be the Router ID + * of the neighboring router. + * + * For an OSPF type 3 link (StubNetwork), the Link ID will be the adjacent + * neighbor's IP address + */ Ipv4Address GetLinkId(void) const; - /** - * Set the Link ID field of the Static Router Link Record. - * - * For an OSPF type 1 link (PointToPoint) the Link ID must be the Router ID - * of the neighboring router. - * - * For an OSPF type 3 link (StubNetwork), the Link ID must be the adjacent - * neighbor's IP address - */ +/** + * Set the Link ID field of the Static Router Link Record. + * + * For an OSPF type 1 link (PointToPoint) the Link ID must be the Router ID + * of the neighboring router. + * + * For an OSPF type 3 link (StubNetwork), the Link ID must be the adjacent + * neighbor's IP address + */ void SetLinkId(Ipv4Address addr); - /** - * Get the Link Data field of the Static Router Link Record. - * - * For an OSPF type 1 link (PointToPoint) the Link Data will be the IP - * address of the node of the local side of the link. - * - * For an OSPF type 3 link (StubNetwork), the Link Data will be the - * network mask - */ +/** + * Get the Link Data field of the Static Router Link Record. + * + * For an OSPF type 1 link (PointToPoint) the Link Data will be the IP + * address of the node of the local side of the link. + * + * For an OSPF type 3 link (StubNetwork), the Link Data will be the + * network mask + */ Ipv4Address GetLinkData(void) const; - /** - * Set the Link Data field of the Static Router Link Record. - * - * For an OSPF type 1 link (PointToPoint) the Link Data must be the IP - * address of the node of the local side of the link. - * - * For an OSPF type 3 link (StubNetwork), the Link Data must be set to the - * network mask - */ +/** + * Set the Link Data field of the Static Router Link Record. + * + * For an OSPF type 1 link (PointToPoint) the Link Data must be the IP + * address of the node of the local side of the link. + * + * For an OSPF type 3 link (StubNetwork), the Link Data must be set to the + * network mask + */ void SetLinkData(Ipv4Address addr); - /** - * Get the Link Type field of the Static Router Link Record. - * - * The Link Type describes the kind of link a given record represents. The - * values are defined by OSPF. - * - * @see LinkType - */ +/** + * Get the Link Type field of the Static Router Link Record. + * + * The Link Type describes the kind of link a given record represents. The + * values are defined by OSPF. + * + * @see LinkType + */ LinkType GetLinkType(void) const; - /** - * Set the Link Type field of the Static Router Link Record. - * - * The Link Type describes the kind of link a given record represents. The - * values are defined by OSPF. - * - * @see LinkType - */ +/** + * Set the Link Type field of the Static Router Link Record. + * + * The Link Type describes the kind of link a given record represents. The + * values are defined by OSPF. + * + * @see LinkType + */ void SetLinkType(LinkType linkType); - /** - * Get the Metric Data field of the Static Router Link Record. - * - * The metric is an abstract cost associated with forwarding a packet across - * a link. A sum of metrics must have a well-defined meaning. That is, you - * shouldn't use bandwidth as a metric (how does the sum of the bandwidth of - * two hops relate to the cost of sending a packet); rather you should use - * something like delay. - */ +/** + * Get the Metric Data field of the Static Router Link Record. + * + * The metric is an abstract cost associated with forwarding a packet across + * a link. A sum of metrics must have a well-defined meaning. That is, you + * shouldn't use bandwidth as a metric (how does the sum of the bandwidth of + * two hops relate to the cost of sending a packet); rather you should use + * something like delay. + */ uint32_t GetMetric(void) const; - /** - * Set the Metric Data field of the Static Router Link Record. - * - * The metric is an abstract cost associated with forwarding a packet across - * a link. A sum of metrics must have a well-defined meaning. That is, you - * shouldn't use bandwidth as a metric (how does the sum of the bandwidth of - * two hops relate to the cost of sending a packet); rather you should use - * something like delay. - */ +/** + * Set the Metric Data field of the Static Router Link Record. + * + * The metric is an abstract cost associated with forwarding a packet across + * a link. A sum of metrics must have a well-defined meaning. That is, you + * shouldn't use bandwidth as a metric (how does the sum of the bandwidth of + * two hops relate to the cost of sending a packet); rather you should use + * something like delay. + */ void SetMetric(uint32_t metric); private: - /** - * m_linkId and m_linkData are defined by OSPF to have different meanings - * depending on the type of link a given link records represents. They work - * together. - * - * For Type 1 link (PointToPoint), set m_linkId to Router ID of - * neighboring router. - * - * For Type 3 link (Stub), set m_linkId to neighbor's IP address - */ +/** + * m_linkId and m_linkData are defined by OSPF to have different meanings + * depending on the type of link a given link records represents. They work + * together. + * + * For Type 1 link (PointToPoint), set m_linkId to Router ID of + * neighboring router. + * + * For Type 3 link (Stub), set m_linkId to neighbor's IP address + */ Ipv4Address m_linkId; - /** - * m_linkId and m_linkData are defined by OSPF to have different meanings - * depending on the type of link a given link records represents. They work - * together. - * - * For Type 1 link (PointToPoint), set m_linkData to local IP address - * - * For Type 3 link (Stub), set m_linkData to mask - */ +/** + * m_linkId and m_linkData are defined by OSPF to have different meanings + * depending on the type of link a given link records represents. They work + * together. + * + * For Type 1 link (PointToPoint), set m_linkData to local IP address + * + * For Type 3 link (Stub), set m_linkData to mask + */ Ipv4Address m_linkData; // for links to RouterLSA, - +/** + * The type of the Static Router Link Record. Defined in the OSPF spec. + * We currently only use PointToPoint and StubNetwork types. + */ LinkType m_linkType; - /** - * The metric for a given link. - * - * A metric is abstract cost associated with forwarding a packet across a - * link. A sum of metrics must have a well-defined meaning. That is, you - * shouldn't use bandwidth as a metric (how does the sum of the bandwidth - * of two hops relate to the cost of sending a packet); rather you should - * use something like delay. - */ +/** + * The metric for a given link. + * + * A metric is abstract cost associated with forwarding a packet across a + * link. A sum of metrics must have a well-defined meaning. That is, you + * shouldn't use bandwidth as a metric (how does the sum of the bandwidth + * of two hops relate to the cost of sending a packet); rather you should + * use something like delay. + */ uint32_t m_metric; }; @@ -405,79 +408,79 @@ class StaticRouter : public Object { public: - /** - * The Interface ID of the Static Router interface. - * - * @see Object::QueryInterface () - */ +/** + * The Interface ID of the Static Router interface. + * + * @see Object::QueryInterface () + */ static const InterfaceId iid; - /** - * Create a Static Router class and aggregate its interface onto the Node - * provided. - * - * @param node The existing Node onto which this router will be aggregated. - */ +/** + * Create a Static Router class and aggregate its interface onto the Node + * provided. + * + * @param node The existing Node onto which this router will be aggregated. + */ StaticRouter (Ptr node); - /** - * Get the Router ID associated with this Static Router. The Router IDs - * are allocated in the RoutingEnvironment -- one per Router, starting at - * 0.0.0.1 and incrementing with each instantiation of a router. - * - * @see RoutingEnvironment::AllocateRouterId () - * @returns The Router ID associated with the Static Router. - */ +/** + * Get the Router ID associated with this Static Router. The Router IDs + * are allocated in the RoutingEnvironment -- one per Router, starting at + * 0.0.0.1 and incrementing with each instantiation of a router. + * + * @see RoutingEnvironment::AllocateRouterId () + * @returns The Router ID associated with the Static Router. + */ Ipv4Address GetRouterId (void) const; - /** - * 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 DiscoverLSAs - * and then by reading those advertisements. - * - * @see StaticRouterLSA - * @see StaticRouter::GetLSA () - * @returns The number of Static Router Link State Advertisements. - */ +/** + * 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 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. - */ +/** + * 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) const; - /** - * Get a Static Router Link State Advertisements that this router has said - * that it can export. - * - * This is a fairly inexpensive expensive operation in that the hard work - * was done in GetNumLSAs. We just copy the indicated Static Router Link - * State Advertisement into the requested StaticRouterLSA object. - * - * You must call StaticRouter::GetNumLSAs before calling this method in - * order to discover the adjacent routers and build the advertisements. - * GetNumLSAs will return the number of LSAs this router advertises. - * The parameter n (requested LSA number) must be in the range 0 to - * GetNumLSAs() - 1. - * - * @see StaticRouterLSA - * @see StaticRouter::GetNumLSAs () - * @param n The index number of the LSA you want to read. - * @param lsa The StaticRouterLSA class to receive the LSA information. - * @returns The number of Static Router Link State Advertisements. - */ +/** + * Get a Static Router Link State Advertisements that this router has said + * that it can export. + * + * This is a fairly inexpensive expensive operation in that the hard work + * was done in GetNumLSAs. We just copy the indicated Static Router Link + * State Advertisement into the requested StaticRouterLSA object. + * + * You must call StaticRouter::GetNumLSAs before calling this method in + * order to discover the adjacent routers and build the advertisements. + * GetNumLSAs will return the number of LSAs this router advertises. + * The parameter n (requested LSA number) must be in the range 0 to + * GetNumLSAs() - 1. + * + * @see StaticRouterLSA + * @see StaticRouter::GetNumLSAs () + * @param n The index number of the LSA you want to read. + * @param lsa The StaticRouterLSA class to receive the LSA information. + * @returns The number of Static Router Link State Advertisements. + */ bool GetLSA (uint32_t n, StaticRouterLSA &lsa) const; protected: @@ -495,13 +498,13 @@ Ipv4Address m_routerId; private: - /** - * Static Router copy construction is disallowed. - */ +/** + * Static Router copy construction is disallowed. + */ StaticRouter (StaticRouter& sr); - /** - * Static Router copy assignment operator is disallowed. - */ +/** + * Static Router copy assignment operator is disallowed. + */ StaticRouter& operator= (StaticRouter& sr); };