src/routing/static-route-manager.cc
author Craig Dowell <craigdo@ee.washington.edu>
Fri, 13 Jul 2007 14:05:12 -0700
changeset 1089 5ad63c15b7e4
parent 1088 488db5bf22c0
child 1092 a5d807363dec
permissions -rw-r--r--
fix merge problem that lost candidate queue changes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     2
/*
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     3
 * This program is free software; you can redistribute it and/or modify
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     4
 * it under the terms of the GNU General Public License version 2 as
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     5
 * published by the Free Software Foundation;
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     6
 *
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     7
 * This program is distributed in the hope that it will be useful,
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
     9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    10
 * GNU General Public License for more details.
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    11
 *
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    12
 * You should have received a copy of the GNU General Public License
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    13
 * along with this program; if not, write to the Free Software
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    15
 */
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    16
#include <utility>
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    17
#include <vector>
1062
ea9b7839421d SPFVertex constructor
Tom Henderson <tomh@tomh.org>
parents: 1059
diff changeset
    18
#include <queue>
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    19
#include "ns3/assert.h"
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    20
#include "ns3/fatal-error.h"
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    21
#include "ns3/debug.h"
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    22
#include "ns3/node-list.h"
1084
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
    23
#include "ns3/ipv4.h"
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    24
#include "static-router.h"
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    25
#include "static-route-manager.h"
1077
ee75a75b51b3 Replace SPFVertexPriorityQueue with CandidateQueue
Tom Henderson <tomh@tomh.org>
parents: 1076
diff changeset
    26
#include "candidate-queue.h"
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    27
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    28
NS_DEBUG_COMPONENT_DEFINE ("StaticRouteManager");
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    29
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
    30
namespace ns3 {
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
    31
1062
ea9b7839421d SPFVertex constructor
Tom Henderson <tomh@tomh.org>
parents: 1059
diff changeset
    32
SPFVertex::SPFVertex () : 
ea9b7839421d SPFVertex constructor
Tom Henderson <tomh@tomh.org>
parents: 1059
diff changeset
    33
  m_vertexType(VertexUnknown), 
ea9b7839421d SPFVertex constructor
Tom Henderson <tomh@tomh.org>
parents: 1059
diff changeset
    34
  m_vertexId("255.255.255.255"), 
ea9b7839421d SPFVertex constructor
Tom Henderson <tomh@tomh.org>
parents: 1059
diff changeset
    35
  m_lsa(0),
1082
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
    36
  m_parent(0),
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
    37
  m_children(),
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
    38
  m_distanceFromRoot(SPF_INFINITY), 
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
    39
  m_rootOif(SPF_INFINITY),
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
    40
  m_nextHop("0.0.0.0")
1062
ea9b7839421d SPFVertex constructor
Tom Henderson <tomh@tomh.org>
parents: 1059
diff changeset
    41
{
ea9b7839421d SPFVertex constructor
Tom Henderson <tomh@tomh.org>
parents: 1059
diff changeset
    42
}
ea9b7839421d SPFVertex constructor
Tom Henderson <tomh@tomh.org>
parents: 1059
diff changeset
    43
1079
89b08d079fb6 Non-default constructor for SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1078
diff changeset
    44
SPFVertex::SPFVertex (StaticRouterLSA* lsa) : 
89b08d079fb6 Non-default constructor for SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1078
diff changeset
    45
  m_vertexType(VertexRouter), 
89b08d079fb6 Non-default constructor for SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1078
diff changeset
    46
  m_vertexId(lsa->m_linkStateId),
89b08d079fb6 Non-default constructor for SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1078
diff changeset
    47
  m_lsa(lsa),
1082
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
    48
  m_parent(0),
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
    49
  m_children(),
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
    50
  m_distanceFromRoot(SPF_INFINITY), 
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
    51
  m_rootOif(SPF_INFINITY),
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
    52
  m_nextHop("0.0.0.0")
1079
89b08d079fb6 Non-default constructor for SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1078
diff changeset
    53
{
89b08d079fb6 Non-default constructor for SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1078
diff changeset
    54
}
89b08d079fb6 Non-default constructor for SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1078
diff changeset
    55
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
    56
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
    57
SPFVertex::~SPFVertex ()
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
    58
{
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
    59
}
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
    60
1053
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
    61
StaticRouteManagerLSDB::~StaticRouteManagerLSDB()
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
    62
{
1055
e9580901878f Add LSDB destructor
Tom Henderson <tomh@tomh.org>
parents: 1053
diff changeset
    63
  NS_DEBUG("StaticRouteManagerLSDB::~StaticRouteManagerLSDB ()");
1053
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
    64
1055
e9580901878f Add LSDB destructor
Tom Henderson <tomh@tomh.org>
parents: 1053
diff changeset
    65
  LSDBMap_t::iterator i;
e9580901878f Add LSDB destructor
Tom Henderson <tomh@tomh.org>
parents: 1053
diff changeset
    66
  for (i= m_database.begin(); i!= m_database.end(); i++)
1063
98fe4e27c65a Initialize LSDB for SPF runs
Tom Henderson <tomh@tomh.org>
parents: 1062
diff changeset
    67
    {
1076
1fa07692b5ca Make LSDB back into a storage for LSAs
Tom Henderson <tomh@tomh.org>
parents: 1072
diff changeset
    68
      NS_DEBUG("StaticRouteManagerLSDB::~StaticRouteManagerLSDB():free LSA");
1fa07692b5ca Make LSDB back into a storage for LSAs
Tom Henderson <tomh@tomh.org>
parents: 1072
diff changeset
    69
      StaticRouterLSA* temp = i->second;
1055
e9580901878f Add LSDB destructor
Tom Henderson <tomh@tomh.org>
parents: 1053
diff changeset
    70
      delete temp;
1053
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
    71
    }
1055
e9580901878f Add LSDB destructor
Tom Henderson <tomh@tomh.org>
parents: 1053
diff changeset
    72
  NS_DEBUG("StaticRouteManagerLSDB::~StaticRouteManagerLSDB ():  clear map");
e9580901878f Add LSDB destructor
Tom Henderson <tomh@tomh.org>
parents: 1053
diff changeset
    73
  m_database.clear();
1053
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
    74
}
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
    75
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
    76
void
1063
98fe4e27c65a Initialize LSDB for SPF runs
Tom Henderson <tomh@tomh.org>
parents: 1062
diff changeset
    77
StaticRouteManagerLSDB::Initialize()
98fe4e27c65a Initialize LSDB for SPF runs
Tom Henderson <tomh@tomh.org>
parents: 1062
diff changeset
    78
{
98fe4e27c65a Initialize LSDB for SPF runs
Tom Henderson <tomh@tomh.org>
parents: 1062
diff changeset
    79
  NS_DEBUG("StaticRouteManagerLSDB::Initialize ()");
98fe4e27c65a Initialize LSDB for SPF runs
Tom Henderson <tomh@tomh.org>
parents: 1062
diff changeset
    80
98fe4e27c65a Initialize LSDB for SPF runs
Tom Henderson <tomh@tomh.org>
parents: 1062
diff changeset
    81
  LSDBMap_t::iterator i;
98fe4e27c65a Initialize LSDB for SPF runs
Tom Henderson <tomh@tomh.org>
parents: 1062
diff changeset
    82
  for (i= m_database.begin(); i!= m_database.end(); i++)
98fe4e27c65a Initialize LSDB for SPF runs
Tom Henderson <tomh@tomh.org>
parents: 1062
diff changeset
    83
    {
1076
1fa07692b5ca Make LSDB back into a storage for LSAs
Tom Henderson <tomh@tomh.org>
parents: 1072
diff changeset
    84
      StaticRouterLSA* temp = i->second;
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
    85
      temp->m_stat = StaticRouterLSA::LSA_SPF_NOT_EXPLORED;
1063
98fe4e27c65a Initialize LSDB for SPF runs
Tom Henderson <tomh@tomh.org>
parents: 1062
diff changeset
    86
    }
98fe4e27c65a Initialize LSDB for SPF runs
Tom Henderson <tomh@tomh.org>
parents: 1062
diff changeset
    87
}
98fe4e27c65a Initialize LSDB for SPF runs
Tom Henderson <tomh@tomh.org>
parents: 1062
diff changeset
    88
98fe4e27c65a Initialize LSDB for SPF runs
Tom Henderson <tomh@tomh.org>
parents: 1062
diff changeset
    89
void
1067
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
    90
StaticRouteManagerLSDB::Insert(Ipv4Address addr, StaticRouterLSA* lsa)
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
    91
{
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
    92
  NS_DEBUG("StaticRouteManagerLSDB::Insert ()");
1085
c12d61407468 delete vertices, fix candidate queue pop/top semantics
Craig Dowell <craigdo@ee.washington.edu>
parents: 1084
diff changeset
    93
  m_database.insert(LSDBPair_t(addr, lsa));
1067
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
    94
}
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
    95
1076
1fa07692b5ca Make LSDB back into a storage for LSAs
Tom Henderson <tomh@tomh.org>
parents: 1072
diff changeset
    96
StaticRouterLSA*
1fa07692b5ca Make LSDB back into a storage for LSAs
Tom Henderson <tomh@tomh.org>
parents: 1072
diff changeset
    97
StaticRouteManagerLSDB::GetLSA (Ipv4Address addr)
1053
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
    98
{
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
    99
  NS_DEBUG("StaticRouteManagerLSDB::GetLSA ()");
1053
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
   100
  // Look up an LSA by its address
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
   101
  LSDBMap_t::iterator i;
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
   102
  for (i= m_database.begin(); i!= m_database.end(); i++)
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
   103
  {
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
   104
    if (i->first == addr)
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
   105
    {
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
   106
      return i->second;
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
   107
    }
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
   108
  }
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
   109
  return 0;
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
   110
}
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   111
1082
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   112
StaticRouteManager::StaticRouteManager () : m_spfroot(0) 
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   113
{
1059
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   114
  m_lsdb = new StaticRouteManagerLSDB ();
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   115
}
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   116
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   117
StaticRouteManager::~StaticRouteManager ()
1059
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   118
{
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   119
  NS_DEBUG("StaticRouteManager::~StaticRouteManager ()");
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   120
1059
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   121
  if (m_lsdb)
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   122
    delete m_lsdb;
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   123
}
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   124
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   125
void
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   126
StaticRouteManager::DebugUseLsdb (StaticRouteManagerLSDB* lsdb)
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   127
{
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   128
  if (m_lsdb)
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   129
    delete m_lsdb;
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   130
  m_lsdb = lsdb;
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   131
}
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   132
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   133
void
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   134
StaticRouteManager::BuildStaticRoutingDatabase () 
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   135
{
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   136
  NS_DEBUG("StaticRouteManager::BuildStaticRoutingDatabase()");
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   137
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   138
  // Walk the list of nodes.  QI for StaticRouter interface.
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   139
  // if node has a StaticRouter interface, grab the LSAs 
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   140
  // from it and stick them in the LSDB
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   141
  typedef std::vector < Ptr<Node> >::iterator Iterator;
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   142
  for (Iterator i = NodeList::Begin(); i != NodeList::End(); i++)
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   143
    {
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   144
      Ptr<Node> node = *i;
1048
9bbf68fe9c09 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 1045
diff changeset
   145
9bbf68fe9c09 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 1045
diff changeset
   146
      Ptr<StaticRouter> rtr = 
9bbf68fe9c09 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 1045
diff changeset
   147
        node->QueryInterface<StaticRouter> (StaticRouter::iid);
9bbf68fe9c09 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 1045
diff changeset
   148
      NS_ASSERT_MSG(rtr, "QI for <StaticRouter> interface failed");
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   149
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   150
      // You must call DiscoverLSAs () before trying to use any 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   151
      // routing info or to update LSAs.  Subsequently you may use 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   152
      // GetNumLSAs().  If you call GetNumLSAs () before calling 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   153
      // DiscoverLSAs () will get zero as the number.
1061
007ef746ec4d made GetNumLSAs cheap, added DiscoverLSAs as expensive call.
Craig Dowell <craigdo@ee.washington.edu>
parents: 1059
diff changeset
   154
      uint32_t numLSAs = rtr->DiscoverLSAs();
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   155
      NS_DEBUG ("Discover LSAs:  Found " << numLSAs << " LSAs");
1056
dc7924932154 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 1055
diff changeset
   156
dc7924932154 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 1055
diff changeset
   157
      for (uint32_t j = 0; j < numLSAs; ++j)
dc7924932154 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 1055
diff changeset
   158
        {
1067
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   159
          StaticRouterLSA* lsa = new StaticRouterLSA ();
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   160
          rtr->GetLSA(j, *lsa);
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   161
          NS_DEBUG ("LSA " << j);
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   162
          NS_DEBUG ("----------------------------");
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   163
          NS_DEBUG (*lsa);
1067
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   164
          m_lsdb->Insert (lsa->m_linkStateId, lsa); 
1056
dc7924932154 checkpoint
Craig Dowell <craigdo@ee.washington.edu>
parents: 1055
diff changeset
   165
        }
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   166
    }
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   167
}
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   168
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   169
// For each node that is a static router (which can be determined by
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   170
// the presence of StaticRouter interface), run Dijkstra SPF calculation
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   171
// on the database rooted at that router, and populate the node
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   172
// forwarding tables
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   173
void
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   174
StaticRouteManager::InitializeRoutes ()
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   175
{
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   176
  NS_DEBUG("StaticRouteManager::InitializeRoutes ()");
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   177
  //    This function parallels RFC2328, Section 16.1.1, and quagga ospfd
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   178
  //
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   179
  //      This calculation yields the set of intra-area routes associated
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   180
  //      with an area (called hereafter Area A).  A router calculates the
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   181
  //      shortest-path tree using itself as the root.  The formation
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   182
  //      of the shortest path tree is done here in two stages.  In the
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   183
  //      first stage, only links between routers and transit networks are
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   184
  //      considered.  Using the Dijkstra algorithm, a tree is formed from
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   185
  //      this subset of the link state database.  In the second stage,
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   186
  //      leaves are added to the tree by considering the links to stub
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   187
  //      networks.
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   188
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   189
  //      The area's link state database is represented as a directed graph.  
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   190
  //      The graph's vertices are routers, transit networks and stub networks.  
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   191
  //      The first stage of the procedure (i.e., the Dijkstra algorithm)
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   192
  //      can now be summarized as follows. At each iteration of the
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   193
  //      algorithm, there is a list of candidate vertices.  Paths from
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   194
  //      the root to these vertices have been found, but not necessarily
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   195
  //      the shortest ones.  However, the paths to the candidate vertex
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   196
  //      that is closest to the root are guaranteed to be shortest; this
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   197
  //      vertex is added to the shortest-path tree, removed from the
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   198
  //      candidate list, and its adjacent vertices are examined for
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   199
  //      possible addition to/modification of the candidate list.  The
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   200
  //      algorithm then iterates again.  It terminates when the candidate
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   201
  //      list becomes empty. 
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   202
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   203
  // Iterate for each node that is a router in the topology
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   204
  typedef std::vector < Ptr<Node> >::iterator Iterator;
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   205
  for (Iterator i = NodeList::Begin(); i != NodeList::End(); i++)
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   206
    {
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   207
      Ptr<Node> node = *i;
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   208
      
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   209
      Ptr<StaticRouter> rtr = 
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   210
        node->QueryInterface<StaticRouter> (StaticRouter::iid);
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   211
      NS_ASSERT_MSG(rtr, "QI for <StaticRouter> interface failed");
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   212
      if (rtr && rtr->GetNumLSAs () )
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   213
        {
1059
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   214
          SPFCalculate(rtr->GetRouterId ());
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   215
        }
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   216
    }
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   217
}
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   218
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   219
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   220
// Derived from quagga ospf_spf_next()
1067
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   221
// RFC2328 Section 16.1 (2).
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   222
// v is on the SPF tree.  Examine the links in v's LSA.  Update the list
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   223
// of candidates with any vertices not already on the list.  If a lower-cost
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   224
// path is found to a vertex already on the candidate list, store the new cost.
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   225
void
1077
ee75a75b51b3 Replace SPFVertexPriorityQueue with CandidateQueue
Tom Henderson <tomh@tomh.org>
parents: 1076
diff changeset
   226
StaticRouteManager::SPFNext(SPFVertex* v, CandidateQueue& candidate)
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   227
{
1080
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   228
  SPFVertex* w = 0;
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   229
  StaticRouterLSA* w_lsa = 0;
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   230
  uint32_t distance = 0;
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   231
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   232
  NS_DEBUG("StaticRouteManager::SPFNext ()");
1067
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   233
  if (v->m_vertexType == SPFVertex::VertexRouter) 
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   234
    {
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   235
      // Always true for now, since all our LSAs are RouterLSAs
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   236
      if (true)
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   237
        {
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   238
          NS_DEBUG ("SPFNext: Examining " << v->m_vertexId << "'s " <<
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   239
            v->m_lsa->m_linkRecords.size() << " link records");
1067
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   240
          for ( StaticRouterLSA::ListOfLinkRecords_t::iterator i = 
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   241
                v->m_lsa->m_linkRecords.begin();
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   242
                i != v->m_lsa->m_linkRecords.end();
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   243
                i++ )
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   244
            {
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   245
              // (a) If this is a link to a stub network, examine the next
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   246
              // link in V's LSA.  Links to stub networks will be
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   247
              // considered in the second stage of the shortest path
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   248
              // calculation. 
1080
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   249
              StaticRouterLinkRecord* l = *i;
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   250
              if (l->m_linkType == StaticRouterLinkRecord::StubNetwork)
1067
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   251
                {
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   252
                  NS_DEBUG("SPFNext: Found a Stub record to " 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   253
                    << l->m_linkId);
1067
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   254
                  continue;
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   255
                }
1069
5a396452fe65 end of day checkin
Tom Henderson <tomh@tomh.org>
parents: 1068
diff changeset
   256
                // (b) Otherwise, W is a transit vertex (router or transit
5a396452fe65 end of day checkin
Tom Henderson <tomh@tomh.org>
parents: 1068
diff changeset
   257
                // network).  Look up the vertex W's LSA (router-LSA or
5a396452fe65 end of day checkin
Tom Henderson <tomh@tomh.org>
parents: 1068
diff changeset
   258
                // network-LSA) in Area A's link state database. 
1080
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   259
              if (l->m_linkType == StaticRouterLinkRecord::PointToPoint)
1067
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   260
                {
1078
8d38eebf74e5 move m_stat flag to LSA
Tom Henderson <tomh@tomh.org>
parents: 1077
diff changeset
   261
                  // Lookup the vertex W's LSA 
1080
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   262
                  w_lsa = m_lsdb->GetLSA(l->m_linkId);
1076
1fa07692b5ca Make LSDB back into a storage for LSAs
Tom Henderson <tomh@tomh.org>
parents: 1072
diff changeset
   263
                  NS_ASSERT(w_lsa);
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   264
                  NS_DEBUG("SPFNext:  Found a P2P record from " << 
1076
1fa07692b5ca Make LSDB back into a storage for LSAs
Tom Henderson <tomh@tomh.org>
parents: 1072
diff changeset
   265
                    v->m_vertexId << " to " << w_lsa->m_linkStateId);
1069
5a396452fe65 end of day checkin
Tom Henderson <tomh@tomh.org>
parents: 1068
diff changeset
   266
                  // (c) If vertex W is already on the shortest-path tree, 
5a396452fe65 end of day checkin
Tom Henderson <tomh@tomh.org>
parents: 1068
diff changeset
   267
                  //  examine the next link in the LSA. 
1078
8d38eebf74e5 move m_stat flag to LSA
Tom Henderson <tomh@tomh.org>
parents: 1077
diff changeset
   268
                  if (w_lsa->m_stat == StaticRouterLSA::LSA_SPF_IN_SPFTREE) 
1069
5a396452fe65 end of day checkin
Tom Henderson <tomh@tomh.org>
parents: 1068
diff changeset
   269
                    {
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   270
                      NS_DEBUG("SPFNext: Skipping->  LSA "<< 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   271
                        w_lsa->m_linkStateId << " already in SPF tree");
1069
5a396452fe65 end of day checkin
Tom Henderson <tomh@tomh.org>
parents: 1068
diff changeset
   272
                      continue;
5a396452fe65 end of day checkin
Tom Henderson <tomh@tomh.org>
parents: 1068
diff changeset
   273
                    }
5a396452fe65 end of day checkin
Tom Henderson <tomh@tomh.org>
parents: 1068
diff changeset
   274
                  // (d) Calculate the link state cost D of the resulting path
5a396452fe65 end of day checkin
Tom Henderson <tomh@tomh.org>
parents: 1068
diff changeset
   275
                  // from the root to vertex W.  D is equal to the sum of 
5a396452fe65 end of day checkin
Tom Henderson <tomh@tomh.org>
parents: 1068
diff changeset
   276
                  // the link state cost of the (already calculated) 
5a396452fe65 end of day checkin
Tom Henderson <tomh@tomh.org>
parents: 1068
diff changeset
   277
                  // shortest path to vertex V and the advertised cost of 
5a396452fe65 end of day checkin
Tom Henderson <tomh@tomh.org>
parents: 1068
diff changeset
   278
                  // the link between vertices V and W.  
1080
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   279
                  distance = v->m_distanceFromRoot + l->m_metric;
1069
5a396452fe65 end of day checkin
Tom Henderson <tomh@tomh.org>
parents: 1068
diff changeset
   280
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   281
                  NS_DEBUG("SPFNext: Considering w_lsa " << 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   282
                    w_lsa->m_linkStateId);
1069
5a396452fe65 end of day checkin
Tom Henderson <tomh@tomh.org>
parents: 1068
diff changeset
   283
                  // Here, W is either already in candidate list or not
1078
8d38eebf74e5 move m_stat flag to LSA
Tom Henderson <tomh@tomh.org>
parents: 1077
diff changeset
   284
                  if (w_lsa->m_stat == StaticRouterLSA::LSA_SPF_NOT_EXPLORED)
8d38eebf74e5 move m_stat flag to LSA
Tom Henderson <tomh@tomh.org>
parents: 1077
diff changeset
   285
                    {
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   286
                        w = new SPFVertex(w_lsa);
1080
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   287
                      // Calculate nexthop to W
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   288
                      if (SPFNexthopCalculation(v, w, l, distance))
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   289
                        {
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   290
                          w_lsa->m_stat = StaticRouterLSA::LSA_SPF_CANDIDATE;
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   291
                          candidate.Push(w);
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   292
                          NS_DEBUG("SPFNext:  Pushing " << w->m_vertexId
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   293
                            << ", parent vertexId: " << v->m_vertexId);
1080
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   294
                        }
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   295
                    }
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   296
                  } else if (w_lsa->m_stat == 
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   297
                             StaticRouterLSA::LSA_SPF_CANDIDATE)
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   298
                    {
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   299
                      //Get the vertex from candidates
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   300
                      w = candidate.Find(w_lsa->m_linkStateId);
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   301
                      if (w->m_distanceFromRoot < distance)
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   302
                        {
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   303
                          continue; // not a shorter path
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   304
                        }
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   305
                       // equal to
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   306
                       else if (w->m_distanceFromRoot == distance)
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   307
                         {
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   308
                           // Do nothing-- not doing equal-cost multipath
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   309
                         }
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   310
                       else
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   311
                         {
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   312
                          // Found a lower-cost path to W.
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   313
                          // nexthop_calculation is conditional, if it finds
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   314
                          // valid nexthop it will call spf_add_parents, which
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   315
                          // will flush the old parents
1080
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   316
                           if (SPFNexthopCalculation(v, w, l, distance))
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   317
                             {
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   318
                               // Decrease the key of the node in the heap,
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   319
                               // re-sort the heap. 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   320
                               candidate.Reorder();
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   321
                             }
1080
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   322
                          }    
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   323
                }  // point-to-point
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   324
            } // for loop
1067
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   325
        } 
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   326
     }
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   327
}
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   328
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   329
// Derived from quagga ospf_next_hop_calculation()
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   330
// 16.1.1.  Calculate nexthop from root through V (parent) to
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   331
// vertex W (destination), with given distance from root->W.
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   332
//
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   333
// For now, this is greatly simplified from the quagga code
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   334
//                  
1080
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   335
int
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   336
StaticRouteManager::SPFNexthopCalculation (
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   337
  SPFVertex* v, 
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   338
  SPFVertex* w,
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   339
  StaticRouterLinkRecord* l,
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   340
  uint32_t distance)
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   341
{
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   342
  NS_DEBUG("StaticRouteManager::SPFNexthopCalculation ()");
1082
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   343
  if (v == m_spfroot)
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   344
    {
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   345
      // parent of w is the root itself
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   346
      // calculate the interfaceid of the router that corresponds
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   347
      // to link l between v and w and store it in w->m_rootOif
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   348
      // This rootOif is then used when installing host routes for the
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   349
      // destinations covered by this vertex.  Store also the next hop
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   350
      // IP address.
1083
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   351
      //
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   352
      // Find the outgoing interface on v corresponding to the link l
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   353
      // between v and w
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   354
      if (w->m_vertexType == SPFVertex::VertexRouter) 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   355
        {
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   356
          // l is a link from v to w
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   357
          // l2 will be a link from w to v
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   358
          StaticRouterLinkRecord *l2 = 0;
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   359
          l2 = SPFGetNextLink(w,v,l2);
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   360
          w->m_nextHop = l2->m_linkData;
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   361
          // Find interface corresponding to link's IP address
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   362
          w->m_rootOif = FindOutgoingInterfaceId(l->m_linkData); 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   363
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   364
          NS_DEBUG("SPFNexthopCalculation: Next hop from " << 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   365
            v->m_vertexId << " to " << w->m_vertexId << 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   366
            " goes through next hop " << w->m_nextHop <<
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   367
            " via outgoing interface " << w->m_rootOif);
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   368
        }
1082
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   369
    }
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   370
  else 
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   371
    {
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   372
       // Inherit the rootOif and nextHop from the current parent
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   373
       w->m_rootOif = v->m_rootOif;
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   374
       w->m_nextHop = v->m_nextHop;
1082
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   375
    }
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   376
  w->m_distanceFromRoot = distance;
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   377
  w->m_parent = v;
1080
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   378
  return 1;
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   379
}
82a244f82f80 finish SPFNext logic; add declaration for NexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1079
diff changeset
   380
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   381
// Derived from quagga ospf_get_next_link
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   382
// Find the next link after prev_link from v to w.  If prev_link is
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   383
// NULL, return the first link from v to w.  Ignore stub and virtual links;
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   384
// these link types will never be returned.
1084
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   385
//
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   386
StaticRouterLinkRecord* 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   387
StaticRouteManager::SPFGetNextLink(
1083
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   388
  SPFVertex* v,
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   389
  SPFVertex* w,
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   390
  StaticRouterLinkRecord* prev_link
1083
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   391
  ) 
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   392
{
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   393
  NS_DEBUG("StaticRouteManager::SPFGetNextLink ()");
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   394
  bool skip = true;
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   395
  StaticRouterLinkRecord* l;
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   396
  if (prev_link == 0)
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   397
    {
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   398
      skip = false;
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   399
    }
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   400
  
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   401
  for ( StaticRouterLSA::ListOfLinkRecords_t::iterator i = 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   402
        v->m_lsa->m_linkRecords.begin();
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   403
        i != v->m_lsa->m_linkRecords.end();
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   404
        i++ )
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   405
    {
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   406
        l = *i;
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   407
        if (l->m_linkType != StaticRouterLinkRecord::PointToPoint)
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   408
          {
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   409
            continue;
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   410
          }
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   411
        if (l->m_linkId == w->m_vertexId) {
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   412
          NS_DEBUG("SPFGetNextLink: Found matching link l:  linkId=" <<
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   413
            l->m_linkId << " linkData=" << l->m_linkData);
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   414
          if (skip == false) 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   415
            {
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   416
              NS_DEBUG("SPFGetNextLink: Returning the found link");
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   417
              return l;
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   418
            }
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   419
          else
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   420
            {
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   421
              NS_DEBUG("SPFGetNextLink: Skipping the found link");
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   422
              skip = false;
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   423
              continue;
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   424
            }
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   425
        }
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   426
    }
1083
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   427
  return 0;
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   428
}
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   429
  
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   430
1059
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   431
// quagga ospf_spf_calculate
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   432
void
1059
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   433
StaticRouteManager::DebugSPFCalculate(Ipv4Address root)
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   434
{
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   435
  SPFCalculate(root);
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   436
}
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   437
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   438
// quagga ospf_spf_calculate
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   439
void
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   440
StaticRouteManager::SPFCalculate(Ipv4Address root)
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   441
{
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   442
  NS_DEBUG("StaticRouteManager::SPFCalculate ()");
1063
98fe4e27c65a Initialize LSDB for SPF runs
Tom Henderson <tomh@tomh.org>
parents: 1062
diff changeset
   443
1082
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   444
  SPFVertex *v;
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   445
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   446
  m_lsdb->Initialize ();
1063
98fe4e27c65a Initialize LSDB for SPF runs
Tom Henderson <tomh@tomh.org>
parents: 1062
diff changeset
   447
1072
7002990baec9 Add candidate list (priority queue)
Tom Henderson <tomh@tomh.org>
parents: 1069
diff changeset
   448
  // The candidate queue is a priority queue of SPFVertex objects, with
7002990baec9 Add candidate list (priority queue)
Tom Henderson <tomh@tomh.org>
parents: 1069
diff changeset
   449
  // the top of the queue being the closest vertex in terms of 
7002990baec9 Add candidate list (priority queue)
Tom Henderson <tomh@tomh.org>
parents: 1069
diff changeset
   450
  // distanceFromRoot.  Initially, this queue is empty.
1064
25e962f8ac4c Initialize SPFCalculate
Tom Henderson <tomh@tomh.org>
parents: 1063
diff changeset
   451
  //
1077
ee75a75b51b3 Replace SPFVertexPriorityQueue with CandidateQueue
Tom Henderson <tomh@tomh.org>
parents: 1076
diff changeset
   452
  CandidateQueue candidate;
ee75a75b51b3 Replace SPFVertexPriorityQueue with CandidateQueue
Tom Henderson <tomh@tomh.org>
parents: 1076
diff changeset
   453
  NS_ASSERT(candidate.Size() == 0);
1064
25e962f8ac4c Initialize SPFCalculate
Tom Henderson <tomh@tomh.org>
parents: 1063
diff changeset
   454
  //
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   455
  // Initialize the shortest-path tree to only the router doing the 
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   456
  // calculation.
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   457
  //
1079
89b08d079fb6 Non-default constructor for SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1078
diff changeset
   458
  v= new SPFVertex(m_lsdb->GetLSA(root));
89b08d079fb6 Non-default constructor for SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1078
diff changeset
   459
  // This vertex is the root of the SPF tree
1064
25e962f8ac4c Initialize SPFCalculate
Tom Henderson <tomh@tomh.org>
parents: 1063
diff changeset
   460
  v->m_distanceFromRoot = 0;
1082
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   461
  m_spfroot= v;  
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   462
  v->m_lsa->m_stat = StaticRouterLSA::LSA_SPF_IN_SPFTREE;
1067
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   463
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   464
  for (;;)
704eb2583865 Iterate link records (16.1(2))
Tom Henderson <tomh@tomh.org>
parents: 1066
diff changeset
   465
    {
1069
5a396452fe65 end of day checkin
Tom Henderson <tomh@tomh.org>
parents: 1068
diff changeset
   466
      // RFC2328 16.1. (2). 
1072
7002990baec9 Add candidate list (priority queue)
Tom Henderson <tomh@tomh.org>
parents: 1069
diff changeset
   467
      SPFNext(v , candidate);
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   468
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   469
      // RFC2328 16.1. (3). 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   470
      // If at this step the candidate list is empty, the shortest-
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   471
      // path tree (of transit vertices) has been completely built and
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   472
      // this stage of the procedure terminates. 
1082
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   473
      if (candidate.Size() == 0)
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   474
        break;
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   475
      // Otherwise, choose the vertex belonging to the candidate list
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   476
      // that is closest to the root, and add it to the shortest-path
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   477
      // tree (removing it from the candidate list in the 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   478
      // process). 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   479
      // Extract from the candidates the node with the lower key. 
1089
5ad63c15b7e4 fix merge problem that lost candidate queue changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 1088
diff changeset
   480
      v = candidate.Pop();
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   481
      // Update stat field in vertex. 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   482
      NS_DEBUG("SPFCalculate: Popping vertex" << v->m_vertexId);
1082
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   483
      v->m_lsa->m_stat = StaticRouterLSA::LSA_SPF_IN_SPFTREE;
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   484
      SPFVertexAddParent(v);
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   485
      // Note that when there is a choice of vertices closest to the
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   486
      // root, network vertices must be chosen before router vertices
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   487
      // in order to necessarily find all equal-cost paths. 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   488
      // We don't do this at this moment, we should add the treatment
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   489
      // above codes. -- kunihiro. 
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   490
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   491
      // RFC2328 16.1. (4). 
1083
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   492
      SPFIntraAddRouter (v);
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   493
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   494
      // RFC2328 16.1. (5). 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   495
      // Iterate the algorithm by returning to Step 2.
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   496
    } // end loop until no more candidate vertices 
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   497
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   498
  // Second stage of SPF calculation procedure's  
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   499
  // NOTYET:  ospf_spf_process_stubs (area, area->spf, new_table);
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   500
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   501
  DeleteSPFVertexChain(m_spfroot);  
1082
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   502
  m_spfroot = 0;
1058
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   503
}
de579b1ff195 convert LSDB to class SPFVertex
Tom Henderson <tomh@tomh.org>
parents: 1057
diff changeset
   504
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   505
// XXX this should probably be a method on Ipv4
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   506
uint32_t
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   507
StaticRouteManager::FindOutgoingInterfaceId(Ipv4Address a)
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   508
{
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   509
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   510
  Ipv4Address routerId = m_spfroot->m_vertexId;
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   511
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   512
  std::vector<Ptr<Node> >::iterator i = NodeList::Begin(); 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   513
  for (; i != NodeList::End(); i++)
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   514
    {
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   515
      Ptr<Node> node = *i;
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   516
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   517
      Ptr<StaticRouter> rtr = 
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   518
        node->QueryInterface<StaticRouter> (StaticRouter::iid);
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   519
      NS_ASSERT_MSG(rtr, 
1087
003d90c0b8e4 merge probs
Craig Dowell <craigdo@ee.washington.edu>
parents: 1086
diff changeset
   520
        "StaticRouteManager::FindOutgoingInterfaceId (): "
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   521
        "QI for <StaticRouter> interface failed");
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   522
      if (rtr->GetRouterId () == routerId)
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   523
        {
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   524
          Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   525
          NS_ASSERT_MSG(ipv4, 
1087
003d90c0b8e4 merge probs
Craig Dowell <craigdo@ee.washington.edu>
parents: 1086
diff changeset
   526
            "StaticRouteManager::FindOutgoingInterfaceId (): "
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   527
            "QI for <Ipv4> interface failed");
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   528
          for (uint32_t i = 0; i < ipv4->GetNInterfaces(); i++)
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   529
            {
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   530
              if (ipv4->GetAddress (i) == a) {
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   531
                NS_DEBUG("FindOutgoingInterfaceId: Interface match for " << a);
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   532
                return i;
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   533
              }
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   534
            }
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   535
        }
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   536
     }
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   537
  return 0;
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   538
}
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   539
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   540
// derived from quagga ospf_intra_add_router()
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   541
//
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   542
// This is where we add host routes to the routing tables
1083
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   543
void
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   544
StaticRouteManager::SPFIntraAddRouter(SPFVertex* v)
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   545
{
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   546
   // This vertex has just been added to the SPF tree
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   547
   // - the vertex should have a valid m_root_oid corresponding
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   548
   //   to the outgoing interface on the root router of the tree
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   549
   //   that corresponds to the path to it
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   550
   // - the vertex has an m_lsa field that has a number of link
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   551
   //   records.  For each point to point record, the m_linkData
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   552
   //   is a destination IP address to which we add a host route
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   553
   //
1084
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   554
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   555
  NS_ASSERT_MSG(m_spfroot, 
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   556
    "StaticRouteManager::SPFIntraAddRouter (): Root pointer not set");
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   557
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   558
  Ipv4Address routerId = m_spfroot->m_vertexId;
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   559
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   560
  std::vector<Ptr<Node> >::iterator i = NodeList::Begin(); 
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   561
  for (; i != NodeList::End(); i++)
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   562
    {
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   563
      Ptr<Node> node = *i;
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   564
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   565
      Ptr<StaticRouter> rtr = 
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   566
        node->QueryInterface<StaticRouter> (StaticRouter::iid);
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   567
      NS_ASSERT_MSG(rtr, 
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   568
        "StaticRouteManager::SPFIntraAddRouter (): "
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   569
        "QI for <StaticRouter> interface failed");
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   570
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   571
      if (rtr->GetRouterId () == routerId)
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   572
        {
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   573
          NS_DEBUG("StaticRouteManager::SPFIntraAddRouter (): "
1084
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   574
            "setting routes for node " << node->GetId ());
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   575
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   576
          Ptr<Ipv4> ipv4 = node->QueryInterface<Ipv4> (Ipv4::iid);
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   577
          NS_ASSERT_MSG(ipv4, 
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   578
            "StaticRouteManager::SPFIntraAddRouter (): "
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   579
            "QI for <Ipv4> interface failed");
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   580
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   581
          StaticRouterLSA *lsa = v->m_lsa;
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   582
          NS_ASSERT_MSG(lsa, 
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   583
            "StaticRouteManager::SPFIntraAddRouter (): "
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   584
            "Expected valid LSA in SPFVertex* v");
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   585
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   586
          uint32_t nLinkRecords = lsa->GetNLinkRecords ();
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   587
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   588
          NS_ASSERT_MSG((nLinkRecords & 1) == 0,
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   589
            "StaticRouteManager::SPFIntraAddRouter (): "
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   590
            "Expected exen number of Link Records");
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   591
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   592
          for (uint32_t j = 0; j < nLinkRecords; j += 2)
1084
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   593
            {
1087
003d90c0b8e4 merge probs
Craig Dowell <craigdo@ee.washington.edu>
parents: 1086
diff changeset
   594
              StaticRouterLinkRecord *lr = lsa->GetLinkRecord (j);
003d90c0b8e4 merge probs
Craig Dowell <craigdo@ee.washington.edu>
parents: 1086
diff changeset
   595
              if (lr->m_linkType != StaticRouterLinkRecord::PointToPoint)
003d90c0b8e4 merge probs
Craig Dowell <craigdo@ee.washington.edu>
parents: 1086
diff changeset
   596
                {
003d90c0b8e4 merge probs
Craig Dowell <craigdo@ee.washington.edu>
parents: 1086
diff changeset
   597
                  continue;
003d90c0b8e4 merge probs
Craig Dowell <craigdo@ee.washington.edu>
parents: 1086
diff changeset
   598
                }
1084
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   599
1088
488db5bf22c0 remove debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents: 1087
diff changeset
   600
              NS_DEBUG("StaticRouteManager::SPFIntraAddRouter (): "
1087
003d90c0b8e4 merge probs
Craig Dowell <craigdo@ee.washington.edu>
parents: 1086
diff changeset
   601
                "Add route to " << lr->m_linkData <<
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   602
                " using next hop " << v->m_nextHop <<
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   603
                " via interface " << v->m_rootOif);
1084
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   604
1087
003d90c0b8e4 merge probs
Craig Dowell <craigdo@ee.washington.edu>
parents: 1086
diff changeset
   605
              ipv4->AddHostRouteTo(lr->m_linkData, v->m_nextHop,
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   606
                v->m_rootOif);
1084
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   607
            }
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   608
        }
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   609
    }
1083
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   610
}
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   611
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   612
// Derived from quagga ospf_vertex_add_parents()
1082
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   613
// Add a vertex to the list of children in each of its parents. 
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   614
void
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   615
StaticRouteManager::SPFVertexAddParent(SPFVertex* v)
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   616
{
1083
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   617
  // For now, only one parent (not doing equal-cost multipath)
33b6a589141d Finish function prototypes
Tom Henderson <tomh@tomh.org>
parents: 1082
diff changeset
   618
  v->m_parent->m_children.push_back(v);
1082
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   619
}
a4ab78763094 Initial logic for SPFNexthopCalculation
Tom Henderson <tomh@tomh.org>
parents: 1080
diff changeset
   620
1086
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   621
void
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   622
StaticRouteManager::DeleteSPFVertexChain(SPFVertex* spfroot)
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   623
{
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   624
  // spfroot is the root of all SPFVertex created during the SPF process
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   625
  // each vertex has a list of children
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   626
  // Recursively, delete all of the SPFVertex children of each SPFVertex
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   627
  // then delete root itself
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   628
}
43ea23238ce8 Debugged; works
Tom Henderson <tomh@tomh.org>
parents: 1085
diff changeset
   629
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   630
} // namespace ns3
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   631
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   632
#ifdef RUN_SELF_TESTS
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   633
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   634
#include "ns3/test.h"
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   635
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   636
namespace ns3 {
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   637
1066
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   638
class StaticRouterTestNode : public Node
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   639
{
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   640
public:
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   641
  StaticRouterTestNode();
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   642
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   643
private:
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   644
  virtual void DoAddDevice (Ptr<NetDevice> device) const {};
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   645
  virtual TraceResolver *DoCreateTraceResolver (TraceContext const &context);
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   646
};
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   647
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   648
StaticRouterTestNode::StaticRouterTestNode ()
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   649
{
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   650
//  Ptr<Ipv4L3Protocol> ipv4 = Create<Ipv4L3Protocol> (this);
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   651
}
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   652
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   653
TraceResolver*
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   654
StaticRouterTestNode::DoCreateTraceResolver (TraceContext const &context)
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   655
{
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   656
  return 0;
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   657
}
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   658
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   659
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   660
class StaticRouteManagerTest : public Test {
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   661
public:
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   662
  StaticRouteManagerTest ();
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   663
  virtual ~StaticRouteManagerTest ();
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   664
  virtual bool RunTests (void);
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   665
};
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   666
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   667
StaticRouteManagerTest::StaticRouteManagerTest ()
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   668
  : Test ("StaticRouteManager")
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   669
{
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   670
}
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   671
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   672
StaticRouteManagerTest::~StaticRouteManagerTest ()
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   673
{}
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   674
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   675
bool
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   676
StaticRouteManagerTest::RunTests (void)
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   677
{
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   678
  bool ok = true;
1049
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   679
1084
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   680
  CandidateQueue candidate;
1068
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   681
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   682
  for (int i = 0; i < 100; ++i)
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   683
    {
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   684
      SPFVertex *v = new SPFVertex;
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   685
      v->m_distanceFromRoot = rand () % 100;
1084
0be920a99cc4 implement SPFIntraAddRouter
Craig Dowell <craigdo@ee.washington.edu>
parents: 1083
diff changeset
   686
      candidate.Push (v);
1068
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   687
    }
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   688
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   689
  uint32_t lastDistance = 0;
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   690
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   691
  for (int i = 0; i < 100; ++i)
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   692
    {
1089
5ad63c15b7e4 fix merge problem that lost candidate queue changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 1088
diff changeset
   693
      SPFVertex *v = candidate.Pop ();
1068
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   694
      if (v->m_distanceFromRoot < lastDistance)
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   695
        {
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   696
          ok = false;
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   697
        }
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   698
      lastDistance = v->m_distanceFromRoot;
1089
5ad63c15b7e4 fix merge problem that lost candidate queue changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 1088
diff changeset
   699
      delete v;
5ad63c15b7e4 fix merge problem that lost candidate queue changes
Craig Dowell <craigdo@ee.washington.edu>
parents: 1088
diff changeset
   700
      v = 0;
1068
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   701
    }
019229673fb4 SPFVertex Priority Queue
Craig Dowell <craigdo@ee.washington.edu>
parents: 1067
diff changeset
   702
1049
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   703
  // Build fake link state database; four routers (0-3), 3 point-to-point
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   704
  // links
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   705
  //
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   706
  //   n0
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   707
  //      \ link 0
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   708
  //       \          link 2
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   709
  //        n2 -------------------------n3
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   710
  //       /
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   711
  //      / link 1
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   712
  //    n1
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   713
  //
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   714
  //  link0:  10.1.1.1/30, 10.1.1.2/30
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   715
  //  link1:  10.1.2.1/30, 10.1.2.2/30
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   716
  //  link2:  10.1.3.1/30, 10.1.3.2/30
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   717
  //
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   718
  // Router 0
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   719
  StaticRouterLinkRecord* lr0 = new StaticRouterLinkRecord();
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   720
  lr0->m_linkId.Set(2);  // router ID 0.0.0.2
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   721
  lr0->m_linkData.Set("10.1.1.1");
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   722
  lr0->m_linkType = StaticRouterLinkRecord::PointToPoint;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   723
  lr0->m_metric = 1;
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   724
  StaticRouterLinkRecord* lr1 = new StaticRouterLinkRecord();
1049
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   725
  lr1->m_linkId.Set("10.1.1.1");  
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   726
  lr1->m_linkData.Set("255.255.255.252");
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   727
  lr1->m_linkType = StaticRouterLinkRecord::StubNetwork;
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   728
  lr1->m_metric = 1;
1049
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   729
  StaticRouterLSA* lsa0 = new StaticRouterLSA();
1055
e9580901878f Add LSDB destructor
Tom Henderson <tomh@tomh.org>
parents: 1053
diff changeset
   730
  lsa0->m_linkStateId.Set("0.0.0.0");
e9580901878f Add LSDB destructor
Tom Henderson <tomh@tomh.org>
parents: 1053
diff changeset
   731
  lsa0->m_advertisingRtr.Set("0.0.0.0");
1049
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   732
  lsa0->AddLinkRecord(lr0);
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   733
  lsa0->AddLinkRecord(lr1);
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   734
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   735
  // Router 1
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   736
  StaticRouterLinkRecord* lr2 = new StaticRouterLinkRecord();
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   737
  lr2->m_linkId.Set(2);  // router ID 0.0.0.2
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   738
  lr2->m_linkData.Set("10.1.2.1");
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   739
  lr2->m_linkType = StaticRouterLinkRecord::PointToPoint;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   740
  lr2->m_metric = 1;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   741
  StaticRouterLinkRecord* lr3 = new StaticRouterLinkRecord();
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   742
  lr3->m_linkId.Set("10.1.2.1");  
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   743
  lr3->m_linkData.Set("255.255.255.252");
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   744
  lr3->m_linkType = StaticRouterLinkRecord::StubNetwork;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   745
  lr3->m_metric = 1;
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   746
  StaticRouterLSA* lsa1 = new StaticRouterLSA();
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   747
  lsa1->m_linkStateId.Set(1);
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   748
  lsa1->m_advertisingRtr.Set(1);
1049
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   749
  lsa1->AddLinkRecord(lr2);
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   750
  lsa1->AddLinkRecord(lr3);
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   751
  
1049
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   752
  // Router 2 
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   753
  StaticRouterLinkRecord* lr4 = new StaticRouterLinkRecord();
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   754
  lr4->m_linkId.Set("0.0.0.0");
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   755
  lr4->m_linkData.Set("10.1.1.2");
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   756
  lr4->m_linkType = StaticRouterLinkRecord::PointToPoint;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   757
  lr4->m_metric = 1;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   758
  StaticRouterLinkRecord* lr5 = new StaticRouterLinkRecord();
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   759
  lr5->m_linkId.Set("10.1.1.2");  
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   760
  lr5->m_linkData.Set("255.255.255.252");
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   761
  lr5->m_linkType = StaticRouterLinkRecord::StubNetwork;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   762
  lr5->m_metric = 1;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   763
  StaticRouterLinkRecord* lr6 = new StaticRouterLinkRecord();
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   764
  lr6->m_linkId.Set(1);  
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   765
  lr6->m_linkData.Set("10.1.2.2");
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   766
  lr6->m_linkType = StaticRouterLinkRecord::PointToPoint;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   767
  lr6->m_metric = 1;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   768
  StaticRouterLinkRecord* lr7 = new StaticRouterLinkRecord();
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   769
  lr7->m_linkId.Set("10.1.2.2");  
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   770
  lr7->m_linkData.Set("255.255.255.252");
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   771
  lr7->m_linkType = StaticRouterLinkRecord::StubNetwork;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   772
  lr7->m_metric = 1;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   773
  StaticRouterLinkRecord* lr8 = new StaticRouterLinkRecord();
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   774
  lr8->m_linkId.Set(3);  
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   775
  lr8->m_linkData.Set("10.1.3.2");
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   776
  lr8->m_linkType = StaticRouterLinkRecord::PointToPoint;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   777
  lr8->m_metric = 1;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   778
  StaticRouterLinkRecord* lr9 = new StaticRouterLinkRecord();
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   779
  lr9->m_linkId.Set("10.1.3.2");  
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   780
  lr9->m_linkData.Set("255.255.255.252");
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   781
  lr9->m_linkType = StaticRouterLinkRecord::StubNetwork;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   782
  lr9->m_metric = 1;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   783
  StaticRouterLSA* lsa2 = new StaticRouterLSA();
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   784
  lsa2->m_linkStateId.Set(2);
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   785
  lsa2->m_advertisingRtr.Set(2);
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   786
  lsa2->AddLinkRecord(lr4);
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   787
  lsa2->AddLinkRecord(lr5);
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   788
  lsa2->AddLinkRecord(lr6);
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   789
  lsa2->AddLinkRecord(lr7);
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   790
  lsa2->AddLinkRecord(lr8);
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   791
  lsa2->AddLinkRecord(lr9);
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   792
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   793
  // Router 3
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   794
  StaticRouterLinkRecord* lr10 = new StaticRouterLinkRecord();
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   795
  lr10->m_linkId.Set(2);  // router ID 0.0.0.2
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   796
  lr10->m_linkData.Set("10.1.2.1");
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   797
  lr10->m_linkType = StaticRouterLinkRecord::PointToPoint;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   798
  lr10->m_metric = 1;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   799
  StaticRouterLinkRecord* lr11 = new StaticRouterLinkRecord();
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   800
  lr11->m_linkId.Set("10.1.2.1");  
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   801
  lr11->m_linkData.Set("255.255.255.252");
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   802
  lr11->m_linkType = StaticRouterLinkRecord::StubNetwork;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   803
  lr11->m_metric = 1;
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   804
  StaticRouterLSA* lsa3 = new StaticRouterLSA();
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   805
  lsa3->m_linkStateId.Set(3);
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   806
  lsa3->m_advertisingRtr.Set(3);
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   807
  lsa3->AddLinkRecord(lr2);
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   808
  lsa3->AddLinkRecord(lr3);
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   809
1053
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
   810
  // Test the database 
57341f5736a7 Add LSDB functions
Tom Henderson <tomh@tomh.org>
parents: 1049
diff changeset
   811
  StaticRouteManagerLSDB* srmlsdb = new StaticRouteManagerLSDB();
1076
1fa07692b5ca Make LSDB back into a storage for LSAs
Tom Henderson <tomh@tomh.org>
parents: 1072
diff changeset
   812
  srmlsdb->Insert(lsa0->m_linkStateId, lsa0);
1fa07692b5ca Make LSDB back into a storage for LSAs
Tom Henderson <tomh@tomh.org>
parents: 1072
diff changeset
   813
  srmlsdb->Insert(lsa1->m_linkStateId, lsa1);
1fa07692b5ca Make LSDB back into a storage for LSAs
Tom Henderson <tomh@tomh.org>
parents: 1072
diff changeset
   814
  srmlsdb->Insert(lsa2->m_linkStateId, lsa2);
1fa07692b5ca Make LSDB back into a storage for LSAs
Tom Henderson <tomh@tomh.org>
parents: 1072
diff changeset
   815
  srmlsdb->Insert(lsa3->m_linkStateId, lsa3);
1fa07692b5ca Make LSDB back into a storage for LSAs
Tom Henderson <tomh@tomh.org>
parents: 1072
diff changeset
   816
  NS_ASSERT(lsa2 == srmlsdb->GetLSA(lsa2->m_linkStateId));
1049
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   817
1066
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   818
  // We need a dummy node to populate the routing tables
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   819
  Ptr<StaticRouterTestNode> n2 = Create<StaticRouterTestNode> ();
f19baa3a0cb5 Dummy test node for unit testing
Tom Henderson <tomh@tomh.org>
parents: 1065
diff changeset
   820
1059
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   821
  // XXX next, calculate routes based on the manually created LSDB
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   822
  StaticRouteManager* srm = new StaticRouteManager();
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   823
  srm->DebugUseLsdb (srmlsdb);
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   824
  srm->DebugSPFCalculate(lsa0->m_linkStateId);  // node n0
1055
e9580901878f Add LSDB destructor
Tom Henderson <tomh@tomh.org>
parents: 1053
diff changeset
   825
1059
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   826
  // This delete clears the srm, which deletes the LSDB, which clears 
1076
1fa07692b5ca Make LSDB back into a storage for LSAs
Tom Henderson <tomh@tomh.org>
parents: 1072
diff changeset
   827
  // all of the LSAs, which each destroys the attached LinkRecords.
1059
2ebd3bb3da3e more plumbing around SPFCalculate()
Tom Henderson <tomh@tomh.org>
parents: 1058
diff changeset
   828
  delete srm;
1049
b572b65faba3 Fill out self-tests example
Tom Henderson <tomh@tomh.org>
parents: 1048
diff changeset
   829
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   830
  return ok;
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   831
}
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   832
1055
e9580901878f Add LSDB destructor
Tom Henderson <tomh@tomh.org>
parents: 1053
diff changeset
   833
// Instantiate this class for the unit tests
1045
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   834
static StaticRouteManagerTest g_staticRouteManagerTest;
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   835
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   836
} // namespace ns3
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   837
c2c43e021fb7 Add ctor/dtor to StaticRouterLSA, add the Add() method to add link records, misc. cleanup
Tom Henderson <tomh@tomh.org>
parents:
diff changeset
   838
#endif