author | Andrey Mazo <mazo@iitp.ru> |
Fri, 23 Apr 2010 15:09:31 +0400 | |
changeset 6273 | 8d70de29d514 |
parent 6113 | 0ce37bf4f1c1 |
child 6297 | d58f84b6191b |
permissions | -rw-r--r-- |
1111 | 1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
1457
562a7017ed93
Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents:
1421
diff
changeset
|
3 |
* Copyright 2007 University of Washington |
562a7017ed93
Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents:
1421
diff
changeset
|
4 |
* Copyright (C) 1999, 2000 Kunihiro Ishiguro, Toshiaki Takada |
562a7017ed93
Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents:
1421
diff
changeset
|
5 |
* |
1111 | 6 |
* This program is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License version 2 as |
|
8 |
* published by the Free Software Foundation; |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
1457
562a7017ed93
Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents:
1421
diff
changeset
|
18 |
* |
1505 | 19 |
* Authors: Tom Henderson (tomhend@u.washington.edu) |
1457
562a7017ed93
Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents:
1421
diff
changeset
|
20 |
* |
562a7017ed93
Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents:
1421
diff
changeset
|
21 |
* Kunihiro Ishigura, Toshiaki Takada (GNU Zebra) are attributed authors |
562a7017ed93
Copyrights/licenses for routing code
Tom Henderson <tomh@tomh.org>
parents:
1421
diff
changeset
|
22 |
* of the quagga 0.99.7/src/ospfd/ospf_spf.c code which was ported here |
1111 | 23 |
*/ |
24 |
||
25 |
#include <utility> |
|
26 |
#include <vector> |
|
27 |
#include <queue> |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
28 |
#include <algorithm> |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
29 |
#include <iostream> |
1111 | 30 |
#include "ns3/assert.h" |
31 |
#include "ns3/fatal-error.h" |
|
1505 | 32 |
#include "ns3/log.h" |
1111 | 33 |
#include "ns3/node-list.h" |
34 |
#include "ns3/ipv4.h" |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
35 |
#include "ns3/ipv4-routing-protocol.h" |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
36 |
#include "ns3/ipv4-list-routing.h" |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5935
diff
changeset
|
37 |
#include "ns3/mpi-interface.h" |
1111 | 38 |
#include "global-router-interface.h" |
39 |
#include "global-route-manager-impl.h" |
|
40 |
#include "candidate-queue.h" |
|
4527
7a1359808b0e
move global routing code into global routing directory
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4476
diff
changeset
|
41 |
#include "ipv4-global-routing.h" |
1111 | 42 |
|
1505 | 43 |
NS_LOG_COMPONENT_DEFINE ("GlobalRouteManager"); |
1111 | 44 |
|
45 |
namespace ns3 { |
|
46 |
||
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
47 |
std::ostream& |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
48 |
operator<< (std::ostream& os, const SPFVertex::NodeExit_t& exit) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
49 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
50 |
os << "(" << exit.first << " ," << exit.second << ")"; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
51 |
return os; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
52 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
53 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
54 |
std::ostream& |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
55 |
operator<< (std::ostream& os, const SPFVertex::ListOfSPFVertex_t& vs) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
56 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
57 |
typedef SPFVertex::ListOfSPFVertex_t::const_iterator CIter_t; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
58 |
os << "{"; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
59 |
for (CIter_t iter = vs.begin (); iter != vs.end ();) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
60 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
61 |
os << (*iter)->m_vertexId; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
62 |
if (++iter != vs.end ()) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
63 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
64 |
os << ", "; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
65 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
66 |
else |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
67 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
68 |
break; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
69 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
70 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
71 |
os << "}"; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
72 |
return os; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
73 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
74 |
|
1111 | 75 |
// --------------------------------------------------------------------------- |
76 |
// |
|
77 |
// SPFVertex Implementation |
|
78 |
// |
|
79 |
// --------------------------------------------------------------------------- |
|
80 |
||
81 |
SPFVertex::SPFVertex () : |
|
82 |
m_vertexType (VertexUnknown), |
|
83 |
m_vertexId ("255.255.255.255"), |
|
84 |
m_lsa (0), |
|
85 |
m_distanceFromRoot (SPF_INFINITY), |
|
86 |
m_rootOif (SPF_INFINITY), |
|
87 |
m_nextHop ("0.0.0.0"), |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
88 |
m_parents (), |
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
89 |
m_children (), |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
90 |
m_vertexProcessed (false) |
1111 | 91 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
92 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 93 |
} |
94 |
||
1278 | 95 |
SPFVertex::SPFVertex (GlobalRoutingLSA* lsa) : |
1111 | 96 |
m_vertexId (lsa->GetLinkStateId ()), |
97 |
m_lsa (lsa), |
|
98 |
m_distanceFromRoot (SPF_INFINITY), |
|
99 |
m_rootOif (SPF_INFINITY), |
|
100 |
m_nextHop ("0.0.0.0"), |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
101 |
m_parents (), |
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
102 |
m_children (), |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
103 |
m_vertexProcessed (false) |
1111 | 104 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
105 |
NS_LOG_FUNCTION_NOARGS (); |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
106 |
|
1278 | 107 |
if (lsa->GetLSType () == GlobalRoutingLSA::RouterLSA) |
108 |
{ |
|
1505 | 109 |
NS_LOG_LOGIC ("Setting m_vertexType to VertexRouter"); |
1278 | 110 |
m_vertexType = SPFVertex::VertexRouter; |
111 |
} |
|
112 |
else if (lsa->GetLSType () == GlobalRoutingLSA::NetworkLSA) |
|
113 |
{ |
|
1505 | 114 |
NS_LOG_LOGIC ("Setting m_vertexType to VertexNetwork"); |
1278 | 115 |
m_vertexType = SPFVertex::VertexNetwork; |
116 |
} |
|
1111 | 117 |
} |
118 |
||
119 |
SPFVertex::~SPFVertex () |
|
120 |
{ |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
121 |
NS_LOG_FUNCTION (m_vertexId); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
122 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
123 |
NS_LOG_LOGIC ("Children vertices - " << m_children); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
124 |
NS_LOG_LOGIC ("Parent verteices - " << m_parents); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
125 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
126 |
// find this node from all its parents and remove the entry of this node |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
127 |
// from all its parents |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
128 |
for (ListOfSPFVertex_t::iterator piter = m_parents.begin (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
129 |
piter != m_parents.end (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
130 |
piter++) |
1111 | 131 |
{ |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
132 |
// remove the current vertex from its parent's children list. Check |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
133 |
// if the size of the list is reduced, or the child<->parent relation |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
134 |
// is not bidirectional |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
135 |
uint32_t orgCount = (*piter)->m_children.size (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
136 |
(*piter)->m_children.remove (this); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
137 |
uint32_t newCount = (*piter)->m_children.size (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
138 |
if (orgCount > newCount) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
139 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
140 |
NS_ASSERT_MSG (orgCount > newCount, "Unable to find the current vertex from its parents --- impossible!"); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
141 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
142 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
143 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
144 |
// delete children |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
145 |
while (m_children.size () > 0) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
146 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
147 |
// pop out children one by one. Some children may disapper |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
148 |
// when deleting some other children in the list. As a result, |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
149 |
// it is necessary to use pop to walk through all children, instead |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
150 |
// of using iterator. |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
151 |
// |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
152 |
// Note that m_children.pop_front () is not necessary as this |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
153 |
// p is removed from the children list when p is deleted |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
154 |
SPFVertex* p = m_children.front (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
155 |
// 'p' == 0, this child is already deleted by its other parent |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
156 |
if (p == 0) continue; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
157 |
NS_LOG_LOGIC ("Parent vertex-" << m_vertexId << " deleting its child vertex-" << p->GetVertexId ()); |
1111 | 158 |
delete p; |
159 |
p = 0; |
|
160 |
} |
|
161 |
m_children.clear (); |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
162 |
// delete parents |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
163 |
m_parents.clear (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
164 |
// delete root exit direction |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
165 |
m_ecmpRootExits.clear (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
166 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
167 |
NS_LOG_LOGIC ("Vertex-" << m_vertexId << " completed deleted"); |
1111 | 168 |
} |
169 |
||
170 |
void |
|
171 |
SPFVertex::SetVertexType (SPFVertex::VertexType type) |
|
172 |
{ |
|
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
173 |
NS_LOG_FUNCTION (type); |
1111 | 174 |
m_vertexType = type; |
175 |
} |
|
176 |
||
177 |
SPFVertex::VertexType |
|
178 |
SPFVertex::GetVertexType (void) const |
|
179 |
{ |
|
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
180 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 181 |
return m_vertexType; |
182 |
} |
|
183 |
||
184 |
void |
|
185 |
SPFVertex::SetVertexId (Ipv4Address id) |
|
186 |
{ |
|
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
187 |
NS_LOG_FUNCTION (id); |
1111 | 188 |
m_vertexId = id; |
189 |
} |
|
190 |
||
191 |
Ipv4Address |
|
192 |
SPFVertex::GetVertexId (void) const |
|
193 |
{ |
|
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
194 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 195 |
return m_vertexId; |
196 |
} |
|
197 |
||
198 |
void |
|
1278 | 199 |
SPFVertex::SetLSA (GlobalRoutingLSA* lsa) |
1111 | 200 |
{ |
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
201 |
NS_LOG_FUNCTION (lsa); |
1111 | 202 |
m_lsa = lsa; |
203 |
} |
|
204 |
||
1278 | 205 |
GlobalRoutingLSA* |
1111 | 206 |
SPFVertex::GetLSA (void) const |
207 |
{ |
|
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
208 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 209 |
return m_lsa; |
210 |
} |
|
211 |
||
212 |
void |
|
213 |
SPFVertex::SetDistanceFromRoot (uint32_t distance) |
|
214 |
{ |
|
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
215 |
NS_LOG_FUNCTION (distance); |
1111 | 216 |
m_distanceFromRoot = distance; |
217 |
} |
|
218 |
||
219 |
uint32_t |
|
220 |
SPFVertex::GetDistanceFromRoot (void) const |
|
221 |
{ |
|
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
222 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 223 |
return m_distanceFromRoot; |
224 |
} |
|
225 |
||
226 |
void |
|
227 |
SPFVertex::SetParent (SPFVertex* parent) |
|
228 |
{ |
|
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
229 |
NS_LOG_FUNCTION (parent); |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
230 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
231 |
// always maintain only one parent when using setter/getter methods |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
232 |
m_parents.clear (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
233 |
m_parents.push_back (parent); |
1111 | 234 |
} |
235 |
||
236 |
SPFVertex* |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
237 |
SPFVertex::GetParent (uint32_t i) const |
1111 | 238 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
239 |
NS_LOG_FUNCTION_NOARGS (); |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
240 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
241 |
// If the index i is out-of-range, return 0 and do nothing |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
242 |
if (m_parents.size () <= i) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
243 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
244 |
NS_LOG_LOGIC ("Index to SPFVertex's parent is out-of-range."); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
245 |
return 0; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
246 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
247 |
ListOfSPFVertex_t::const_iterator iter = m_parents.begin (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
248 |
while (i-- > 0) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
249 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
250 |
iter++; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
251 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
252 |
return *iter; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
253 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
254 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
255 |
void |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
256 |
SPFVertex::MergeParent (const SPFVertex* v) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
257 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
258 |
NS_LOG_FUNCTION (v); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
259 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
260 |
NS_LOG_LOGIC ("Before merge, list of parents = " << m_parents); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
261 |
// combine the two lists first, and then remove any duplicated after |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
262 |
m_parents.insert (m_parents.end (), |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
263 |
v->m_parents.begin (), v->m_parents.end ()); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
264 |
// remove duplication |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
265 |
m_parents.sort (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
266 |
m_parents.unique (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
267 |
NS_LOG_LOGIC ("After merge, list of parents = " << m_parents); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
268 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
269 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
270 |
void |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
271 |
SPFVertex::SetRootExitDirection (Ipv4Address nextHop, int32_t id) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
272 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
273 |
NS_LOG_FUNCTION (nextHop << id); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
274 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
275 |
// always maintain only one root's exit |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
276 |
m_ecmpRootExits.clear (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
277 |
m_ecmpRootExits.push_back (NodeExit_t (nextHop, id)); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
278 |
// update the following in order to be backward compatitable with |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
279 |
// GetNextHop and GetOutgoingInterface methods |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
280 |
m_nextHop = nextHop; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
281 |
m_rootOif = id; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
282 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
283 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
284 |
void |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
285 |
SPFVertex::SetRootExitDirection (SPFVertex::NodeExit_t exit) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
286 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
287 |
NS_LOG_FUNCTION (exit); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
288 |
SetRootExitDirection (exit.first, exit.second); |
1111 | 289 |
} |
290 |
||
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
291 |
SPFVertex::NodeExit_t |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
292 |
SPFVertex::GetRootExitDirection (uint32_t i) const |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
293 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
294 |
NS_LOG_FUNCTION (i); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
295 |
typedef ListOfNodeExit_t::const_iterator CIter_t; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
296 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
297 |
NS_ASSERT_MSG (i < m_ecmpRootExits.size (), "Index out-of-range when accessing SPFVertex::m_ecmpRootExits!"); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
298 |
CIter_t iter = m_ecmpRootExits.begin (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
299 |
while (i-- > 0) {iter++;} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
300 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
301 |
return *iter; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
302 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
303 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
304 |
SPFVertex::NodeExit_t |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
305 |
SPFVertex::GetRootExitDirection () const |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
306 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
307 |
NS_LOG_FUNCTION_NOARGS (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
308 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
309 |
NS_ASSERT_MSG (m_ecmpRootExits.size () <= 1, "Assumed there is at most one exit from the root to this vertex"); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
310 |
return GetRootExitDirection (0); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
311 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
312 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
313 |
void |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
314 |
SPFVertex::MergeRootExitDirections (const SPFVertex* vertex) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
315 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
316 |
NS_LOG_FUNCTION (vertex); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
317 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
318 |
// obtain the external list of exit directions |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
319 |
// |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
320 |
// Append the external list into 'this' and remove duplication afterward |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
321 |
const ListOfNodeExit_t& extList = vertex->m_ecmpRootExits; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
322 |
m_ecmpRootExits.insert (m_ecmpRootExits.end (), |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
323 |
extList.begin(), extList.end ()); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
324 |
m_ecmpRootExits.sort (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
325 |
m_ecmpRootExits.unique (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
326 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
327 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
328 |
void |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
329 |
SPFVertex::InheritAllRootExitDirections (const SPFVertex* vertex) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
330 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
331 |
NS_LOG_FUNCTION (vertex); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
332 |
|
6273
8d70de29d514
spell check, mostly in comments.
Andrey Mazo <mazo@iitp.ru>
parents:
6113
diff
changeset
|
333 |
// discard all exit direction currently associated with this vertex, |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
334 |
// and copy all the exit directions from the given vertex |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
335 |
if (m_ecmpRootExits.size () > 0) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
336 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
337 |
NS_LOG_WARN ("x root exit directions in this vertex are going to be discarded"); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
338 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
339 |
m_ecmpRootExits.clear (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
340 |
m_ecmpRootExits.insert (m_ecmpRootExits.end (), |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
341 |
vertex->m_ecmpRootExits.begin (), vertex->m_ecmpRootExits.end ()); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
342 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
343 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
344 |
uint32_t |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
345 |
SPFVertex::GetNRootExitDirections () const |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
346 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
347 |
NS_LOG_FUNCTION_NOARGS (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
348 |
return m_ecmpRootExits.size (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
349 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
350 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
351 |
uint32_t |
1111 | 352 |
SPFVertex::GetNChildren (void) const |
353 |
{ |
|
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
354 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 355 |
return m_children.size (); |
356 |
} |
|
357 |
||
358 |
SPFVertex* |
|
359 |
SPFVertex::GetChild (uint32_t n) const |
|
360 |
{ |
|
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
361 |
NS_LOG_FUNCTION (n); |
1111 | 362 |
uint32_t j = 0; |
363 |
||
364 |
for ( ListOfSPFVertex_t::const_iterator i = m_children.begin (); |
|
365 |
i != m_children.end (); |
|
366 |
i++, j++) |
|
367 |
{ |
|
368 |
if (j == n) |
|
369 |
{ |
|
370 |
return *i; |
|
371 |
} |
|
372 |
} |
|
3947
756887a9bbea
disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents:
3946
diff
changeset
|
373 |
NS_ASSERT_MSG (false, "Index <n> out of range."); |
1111 | 374 |
return 0; |
375 |
} |
|
376 |
||
377 |
uint32_t |
|
378 |
SPFVertex::AddChild (SPFVertex* child) |
|
379 |
{ |
|
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
380 |
NS_LOG_FUNCTION (child); |
1111 | 381 |
m_children.push_back (child); |
382 |
return m_children.size (); |
|
383 |
} |
|
384 |
||
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
385 |
void |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
386 |
SPFVertex::SetVertexProcessed (bool value) |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
387 |
{ |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
388 |
m_vertexProcessed = value; |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
389 |
} |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
390 |
|
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
391 |
bool |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
392 |
SPFVertex::IsVertexProcessed (void) const |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
393 |
{ |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
394 |
return m_vertexProcessed; |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
395 |
} |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
396 |
|
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
397 |
void |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
398 |
SPFVertex::ClearVertexProcessed (void) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
399 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
400 |
for (uint32_t i = 0; i < this->GetNChildren (); i++) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
401 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
402 |
this->GetChild (i)->ClearVertexProcessed (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
403 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
404 |
this->SetVertexProcessed (false); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
405 |
} |
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
406 |
|
1111 | 407 |
// --------------------------------------------------------------------------- |
408 |
// |
|
409 |
// GlobalRouteManagerLSDB Implementation |
|
410 |
// |
|
411 |
// --------------------------------------------------------------------------- |
|
412 |
||
413 |
GlobalRouteManagerLSDB::GlobalRouteManagerLSDB () |
|
414 |
: |
|
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
415 |
m_database (), |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
416 |
m_extdatabase () |
1111 | 417 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
418 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 419 |
} |
420 |
||
421 |
GlobalRouteManagerLSDB::~GlobalRouteManagerLSDB () |
|
422 |
{ |
|
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
423 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 424 |
LSDBMap_t::iterator i; |
425 |
for (i= m_database.begin (); i!= m_database.end (); i++) |
|
426 |
{ |
|
1505 | 427 |
NS_LOG_LOGIC ("free LSA"); |
1278 | 428 |
GlobalRoutingLSA* temp = i->second; |
1111 | 429 |
delete temp; |
430 |
} |
|
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
431 |
for (uint32_t j = 0; j < m_extdatabase.size (); j++) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
432 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
433 |
NS_LOG_LOGIC ("free ASexternalLSA"); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
434 |
GlobalRoutingLSA* temp = m_extdatabase.at (j); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
435 |
delete temp; |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
436 |
} |
1505 | 437 |
NS_LOG_LOGIC ("clear map"); |
1111 | 438 |
m_database.clear (); |
439 |
} |
|
440 |
||
441 |
void |
|
442 |
GlobalRouteManagerLSDB::Initialize () |
|
443 |
{ |
|
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
444 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 445 |
LSDBMap_t::iterator i; |
446 |
for (i= m_database.begin (); i!= m_database.end (); i++) |
|
447 |
{ |
|
1278 | 448 |
GlobalRoutingLSA* temp = i->second; |
449 |
temp->SetStatus (GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED); |
|
1111 | 450 |
} |
451 |
} |
|
452 |
||
453 |
void |
|
1278 | 454 |
GlobalRouteManagerLSDB::Insert (Ipv4Address addr, GlobalRoutingLSA* lsa) |
1111 | 455 |
{ |
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
456 |
NS_LOG_FUNCTION (addr << lsa); |
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
457 |
if (lsa->GetLSType () == GlobalRoutingLSA::ASExternalLSAs) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
458 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
459 |
m_extdatabase.push_back (lsa); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
460 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
461 |
else |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
462 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
463 |
m_database.insert (LSDBPair_t (addr, lsa)); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
464 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
465 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
466 |
|
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
467 |
GlobalRoutingLSA* |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
468 |
GlobalRouteManagerLSDB::GetExtLSA (uint32_t index) const |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
469 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
470 |
return m_extdatabase.at (index); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
471 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
472 |
|
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
473 |
uint32_t |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
474 |
GlobalRouteManagerLSDB::GetNumExtLSAs () const |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
475 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
476 |
return m_extdatabase.size (); |
1111 | 477 |
} |
478 |
||
1278 | 479 |
GlobalRoutingLSA* |
1111 | 480 |
GlobalRouteManagerLSDB::GetLSA (Ipv4Address addr) const |
481 |
{ |
|
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
482 |
NS_LOG_FUNCTION (addr); |
1111 | 483 |
// |
484 |
// Look up an LSA by its address. |
|
485 |
// |
|
486 |
LSDBMap_t::const_iterator i; |
|
487 |
for (i= m_database.begin (); i!= m_database.end (); i++) |
|
488 |
{ |
|
489 |
if (i->first == addr) |
|
490 |
{ |
|
491 |
return i->second; |
|
492 |
} |
|
493 |
} |
|
494 |
return 0; |
|
495 |
} |
|
496 |
||
1278 | 497 |
GlobalRoutingLSA* |
498 |
GlobalRouteManagerLSDB::GetLSAByLinkData (Ipv4Address addr) const |
|
499 |
{ |
|
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
500 |
NS_LOG_FUNCTION (addr); |
1278 | 501 |
// |
502 |
// Look up an LSA by its address. |
|
503 |
// |
|
504 |
LSDBMap_t::const_iterator i; |
|
505 |
for (i= m_database.begin (); i!= m_database.end (); i++) |
|
506 |
{ |
|
507 |
GlobalRoutingLSA* temp = i->second; |
|
508 |
// Iterate among temp's Link Records |
|
509 |
for (uint32_t j = 0; j < temp->GetNLinkRecords (); j++) |
|
510 |
{ |
|
511 |
GlobalRoutingLinkRecord *lr = temp->GetLinkRecord (j); |
|
512 |
if ( lr->GetLinkType () == GlobalRoutingLinkRecord::TransitNetwork && |
|
513 |
lr->GetLinkData () == addr) |
|
514 |
{ |
|
515 |
return temp; |
|
516 |
} |
|
517 |
} |
|
518 |
} |
|
519 |
return 0; |
|
520 |
} |
|
521 |
||
1111 | 522 |
// --------------------------------------------------------------------------- |
523 |
// |
|
524 |
// GlobalRouteManagerImpl Implementation |
|
525 |
// |
|
526 |
// --------------------------------------------------------------------------- |
|
527 |
||
528 |
GlobalRouteManagerImpl::GlobalRouteManagerImpl () |
|
529 |
: |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
530 |
m_spfroot (0) |
1111 | 531 |
{ |
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
532 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 533 |
m_lsdb = new GlobalRouteManagerLSDB (); |
534 |
} |
|
535 |
||
536 |
GlobalRouteManagerImpl::~GlobalRouteManagerImpl () |
|
537 |
{ |
|
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
538 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 539 |
if (m_lsdb) |
540 |
{ |
|
541 |
delete m_lsdb; |
|
542 |
} |
|
543 |
} |
|
544 |
||
545 |
void |
|
546 |
GlobalRouteManagerImpl::DebugUseLsdb (GlobalRouteManagerLSDB* lsdb) |
|
547 |
{ |
|
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
548 |
NS_LOG_FUNCTION (lsdb); |
1111 | 549 |
if (m_lsdb) |
550 |
{ |
|
551 |
delete m_lsdb; |
|
552 |
} |
|
553 |
m_lsdb = lsdb; |
|
554 |
} |
|
555 |
||
3959
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
556 |
void |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
557 |
GlobalRouteManagerImpl::DeleteGlobalRoutes () |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
558 |
{ |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
559 |
NS_LOG_FUNCTION_NOARGS (); |
4758
0f9bcd407aff
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
Guillaume Seguin <guillaume.seguin@sophia.inria.fr>
parents:
4745
diff
changeset
|
560 |
NodeList::Iterator listEnd = NodeList::End (); |
0f9bcd407aff
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
Guillaume Seguin <guillaume.seguin@sophia.inria.fr>
parents:
4745
diff
changeset
|
561 |
for (NodeList::Iterator i = NodeList::Begin (); i != listEnd; i++) |
3959
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
562 |
{ |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
563 |
Ptr<Node> node = *i; |
4616
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
564 |
Ptr<GlobalRouter> router = node->GetObject<GlobalRouter> (); |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
565 |
if (router == 0) |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
566 |
{ |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
567 |
continue; |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
568 |
} |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
569 |
Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol (); |
3959
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
570 |
uint32_t j = 0; |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
571 |
uint32_t nRoutes = gr->GetNRoutes (); |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
572 |
NS_LOG_LOGIC ("Deleting " << gr->GetNRoutes ()<< " routes from node " << node->GetId ()); |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
573 |
// Each time we delete route 0, the route index shifts downward |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
574 |
// We can delete all routes if we delete the route numbered 0 |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
575 |
// nRoutes times |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
576 |
for (j = 0; j < nRoutes; j++) |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
577 |
{ |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
578 |
NS_LOG_LOGIC ("Deleting global route " << j << " from node " << node->GetId ()); |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
579 |
gr->RemoveRoute (0); |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
580 |
} |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
581 |
NS_LOG_LOGIC ("Deleted " << j << " global routes from node "<< node->GetId ()); |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
582 |
} |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
583 |
if (m_lsdb) |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
584 |
{ |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
585 |
NS_LOG_LOGIC ("Deleting LSDB, creating new one"); |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
586 |
delete m_lsdb; |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
587 |
m_lsdb = new GlobalRouteManagerLSDB (); |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
588 |
} |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
589 |
} |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
590 |
|
1111 | 591 |
// |
592 |
// In order to build the routing database, we need to walk the list of nodes |
|
593 |
// in the system and look for those that support the GlobalRouter interface. |
|
594 |
// These routers will export a number of Link State Advertisements (LSAs) |
|
595 |
// that describe the links and networks that are "adjacent" (i.e., that are |
|
596 |
// on the other side of a point-to-point link). We take these LSAs and put |
|
597 |
// add them to the Link State DataBase (LSDB) from which the routes will |
|
598 |
// ultimately be computed. |
|
599 |
// |
|
600 |
void |
|
601 |
GlobalRouteManagerImpl::BuildGlobalRoutingDatabase () |
|
602 |
{ |
|
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
603 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 604 |
// |
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
605 |
// Walk the list of nodes looking for the GlobalRouter Interface. Nodes with |
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
606 |
// global router interfaces are, not too surprisingly, our routers. |
1111 | 607 |
// |
4758
0f9bcd407aff
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
Guillaume Seguin <guillaume.seguin@sophia.inria.fr>
parents:
4745
diff
changeset
|
608 |
NodeList::Iterator listEnd = NodeList::End (); |
0f9bcd407aff
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
Guillaume Seguin <guillaume.seguin@sophia.inria.fr>
parents:
4745
diff
changeset
|
609 |
for (NodeList::Iterator i = NodeList::Begin (); i != listEnd; i++) |
1111 | 610 |
{ |
611 |
Ptr<Node> node = *i; |
|
612 |
||
3939
206f627bd5af
factor DiscoverLSAs into understandable modules
Craig Dowell <craigdo@ee.washington.edu>
parents:
3937
diff
changeset
|
613 |
Ptr<GlobalRouter> rtr = node->GetObject<GlobalRouter> (); |
1111 | 614 |
// |
615 |
// Ignore nodes that aren't participating in routing. |
|
616 |
// |
|
617 |
if (!rtr) |
|
618 |
{ |
|
619 |
continue; |
|
620 |
} |
|
621 |
// |
|
622 |
// You must call DiscoverLSAs () before trying to use any routing info or to |
|
623 |
// update LSAs. DiscoverLSAs () drives the process of discovering routes in |
|
624 |
// the GlobalRouter. Afterward, you may use GetNumLSAs (), which is a very |
|
625 |
// computationally inexpensive call. If you call GetNumLSAs () before calling |
|
626 |
// DiscoverLSAs () will get zero as the number since no routes have been |
|
627 |
// found. |
|
628 |
// |
|
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
629 |
Ptr<Ipv4GlobalRouting> grouting = rtr->GetRoutingProtocol (); |
1111 | 630 |
uint32_t numLSAs = rtr->DiscoverLSAs (); |
1505 | 631 |
NS_LOG_LOGIC ("Found " << numLSAs << " LSAs"); |
1111 | 632 |
|
633 |
for (uint32_t j = 0; j < numLSAs; ++j) |
|
634 |
{ |
|
1278 | 635 |
GlobalRoutingLSA* lsa = new GlobalRoutingLSA (); |
1111 | 636 |
// |
637 |
// This is the call to actually fetch a Link State Advertisement from the |
|
638 |
// router. |
|
639 |
// |
|
640 |
rtr->GetLSA (j, *lsa); |
|
1505 | 641 |
NS_LOG_LOGIC (*lsa); |
1111 | 642 |
// |
643 |
// Write the newly discovered link state advertisement to the database. |
|
644 |
// |
|
645 |
m_lsdb->Insert (lsa->GetLinkStateId (), lsa); |
|
646 |
} |
|
647 |
} |
|
648 |
} |
|
649 |
||
650 |
// |
|
651 |
// For each node that is a global router (which is determined by the presence |
|
652 |
// of an aggregated GlobalRouter interface), run the Dijkstra SPF calculation |
|
653 |
// on the database rooted at that router, and populate the node forwarding |
|
654 |
// tables. |
|
655 |
// |
|
656 |
// This function parallels RFC2328, Section 16.1.1, and quagga ospfd |
|
657 |
// |
|
658 |
// This calculation yields the set of intra-area routes associated |
|
659 |
// with an area (called hereafter Area A). A router calculates the |
|
660 |
// shortest-path tree using itself as the root. The formation |
|
661 |
// of the shortest path tree is done here in two stages. In the |
|
662 |
// first stage, only links between routers and transit networks are |
|
663 |
// considered. Using the Dijkstra algorithm, a tree is formed from |
|
664 |
// this subset of the link state database. In the second stage, |
|
665 |
// leaves are added to the tree by considering the links to stub |
|
666 |
// networks. |
|
667 |
// |
|
668 |
// The area's link state database is represented as a directed graph. |
|
669 |
// The graph's vertices are routers, transit networks and stub networks. |
|
670 |
// |
|
671 |
// The first stage of the procedure (i.e., the Dijkstra algorithm) |
|
672 |
// can now be summarized as follows. At each iteration of the |
|
673 |
// algorithm, there is a list of candidate vertices. Paths from |
|
674 |
// the root to these vertices have been found, but not necessarily |
|
675 |
// the shortest ones. However, the paths to the candidate vertex |
|
676 |
// that is closest to the root are guaranteed to be shortest; this |
|
677 |
// vertex is added to the shortest-path tree, removed from the |
|
678 |
// candidate list, and its adjacent vertices are examined for |
|
679 |
// possible addition to/modification of the candidate list. The |
|
680 |
// algorithm then iterates again. It terminates when the candidate |
|
681 |
// list becomes empty. |
|
682 |
// |
|
683 |
void |
|
684 |
GlobalRouteManagerImpl::InitializeRoutes () |
|
685 |
{ |
|
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
686 |
NS_LOG_FUNCTION_NOARGS (); |
1111 | 687 |
// |
688 |
// Walk the list of nodes in the system. |
|
689 |
// |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
690 |
NS_LOG_INFO ("About to start SPF calculation"); |
4758
0f9bcd407aff
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
Guillaume Seguin <guillaume.seguin@sophia.inria.fr>
parents:
4745
diff
changeset
|
691 |
NodeList::Iterator listEnd = NodeList::End (); |
0f9bcd407aff
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
Guillaume Seguin <guillaume.seguin@sophia.inria.fr>
parents:
4745
diff
changeset
|
692 |
for (NodeList::Iterator i = NodeList::Begin (); i != listEnd; i++) |
1111 | 693 |
{ |
694 |
Ptr<Node> node = *i; |
|
695 |
// |
|
696 |
// Look for the GlobalRouter interface that indicates that the node is |
|
697 |
// participating in routing. |
|
698 |
// |
|
699 |
Ptr<GlobalRouter> rtr = |
|
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2250
diff
changeset
|
700 |
node->GetObject<GlobalRouter> (); |
6113
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5935
diff
changeset
|
701 |
|
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5935
diff
changeset
|
702 |
// Ignore nodes that are not assigned to our systemId (distributed sim) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5935
diff
changeset
|
703 |
if (node->GetSystemId () != MpiInterface::GetSystemId ()) |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5935
diff
changeset
|
704 |
{ |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5935
diff
changeset
|
705 |
continue; |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5935
diff
changeset
|
706 |
} |
0ce37bf4f1c1
Merge distributed simulation code
Josh Pelkey <jpelkey@gatech.edu>
parents:
5935
diff
changeset
|
707 |
|
1111 | 708 |
// |
709 |
// if the node has a global router interface, then run the global routing |
|
710 |
// algorithms. |
|
711 |
// |
|
712 |
if (rtr && rtr->GetNumLSAs () ) |
|
713 |
{ |
|
714 |
SPFCalculate (rtr->GetRouterId ()); |
|
715 |
} |
|
716 |
} |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
717 |
NS_LOG_INFO ("Finished SPF calculation"); |
1111 | 718 |
} |
719 |
||
720 |
// |
|
721 |
// This method is derived from quagga ospf_spf_next (). See RFC2328 Section |
|
722 |
// 16.1 (2) for further details. |
|
723 |
// |
|
724 |
// We're passed a parameter <v> that is a vertex which is already in the SPF |
|
725 |
// tree. A vertex represents a router node. We also get a reference to the |
|
726 |
// SPF candidate queue, which is a priority queue containing the shortest paths |
|
727 |
// to the networks we know about. |
|
728 |
// |
|
729 |
// We examine the links in v's LSA and update the list of candidates with any |
|
730 |
// vertices not already on the list. If a lower-cost path is found to a |
|
731 |
// vertex already on the candidate list, store the new (lower) cost. |
|
732 |
// |
|
733 |
void |
|
734 |
GlobalRouteManagerImpl::SPFNext (SPFVertex* v, CandidateQueue& candidate) |
|
735 |
{ |
|
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
736 |
NS_LOG_FUNCTION (v << &candidate); |
1505 | 737 |
|
1111 | 738 |
SPFVertex* w = 0; |
1278 | 739 |
GlobalRoutingLSA* w_lsa = 0; |
740 |
GlobalRoutingLinkRecord *l = 0; |
|
1111 | 741 |
uint32_t distance = 0; |
1278 | 742 |
uint32_t numRecordsInVertex = 0; |
1505 | 743 |
// |
1278 | 744 |
// V points to a Router-LSA or Network-LSA |
745 |
// Loop over the links in router LSA or attached routers in Network LSA |
|
1505 | 746 |
// |
1278 | 747 |
if (v->GetVertexType () == SPFVertex::VertexRouter) |
1111 | 748 |
{ |
1278 | 749 |
numRecordsInVertex = v->GetLSA ()->GetNLinkRecords (); |
750 |
} |
|
751 |
if (v->GetVertexType () == SPFVertex::VertexNetwork) |
|
752 |
{ |
|
753 |
numRecordsInVertex = v->GetLSA ()->GetNAttachedRouters (); |
|
754 |
} |
|
755 |
||
756 |
for (uint32_t i = 0; i < numRecordsInVertex; i++) |
|
757 |
{ |
|
758 |
// Get w_lsa: In case of V is Router-LSA |
|
759 |
if (v->GetVertexType () == SPFVertex::VertexRouter) |
|
1111 | 760 |
{ |
1776
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1505
diff
changeset
|
761 |
NS_LOG_LOGIC ("Examining link " << i << " of " << |
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1505
diff
changeset
|
762 |
v->GetVertexId () << "'s " << |
1111 | 763 |
v->GetLSA ()->GetNLinkRecords () << " link records"); |
764 |
// |
|
765 |
// (a) If this is a link to a stub network, examine the next link in V's LSA. |
|
766 |
// Links to stub networks will be considered in the second stage of the |
|
767 |
// shortest path calculation. |
|
768 |
// |
|
1278 | 769 |
l = v->GetLSA ()->GetLinkRecord (i); |
770 |
if (l->GetLinkType () == GlobalRoutingLinkRecord::StubNetwork) |
|
771 |
{ |
|
1505 | 772 |
NS_LOG_LOGIC ("Found a Stub record to " << l->GetLinkId ()); |
1278 | 773 |
continue; |
774 |
} |
|
1111 | 775 |
// |
776 |
// (b) Otherwise, W is a transit vertex (router or transit network). Look up |
|
777 |
// the vertex W's LSA (router-LSA or network-LSA) in Area A's link state |
|
778 |
// database. |
|
779 |
// |
|
1278 | 780 |
if (l->GetLinkType () == GlobalRoutingLinkRecord::PointToPoint) |
781 |
{ |
|
1111 | 782 |
// |
783 |
// Lookup the link state advertisement of the new link -- we call it <w> in |
|
784 |
// the link state database. |
|
785 |
// |
|
1278 | 786 |
w_lsa = m_lsdb->GetLSA (l->GetLinkId ()); |
787 |
NS_ASSERT (w_lsa); |
|
1505 | 788 |
NS_LOG_LOGIC ("Found a P2P record from " << |
1278 | 789 |
v->GetVertexId () << " to " << w_lsa->GetLinkStateId ()); |
790 |
} |
|
791 |
else if (l->GetLinkType () == |
|
792 |
GlobalRoutingLinkRecord::TransitNetwork) |
|
793 |
{ |
|
794 |
w_lsa = m_lsdb->GetLSA (l->GetLinkId ()); |
|
795 |
NS_ASSERT (w_lsa); |
|
1505 | 796 |
NS_LOG_LOGIC ("Found a Transit record from " << |
1278 | 797 |
v->GetVertexId () << " to " << w_lsa->GetLinkStateId ()); |
798 |
} |
|
799 |
else |
|
800 |
{ |
|
801 |
NS_ASSERT_MSG (0, "illegal Link Type"); |
|
802 |
} |
|
803 |
} |
|
804 |
// Get w_lsa: In case of V is Network-LSA |
|
805 |
if (v->GetVertexType () == SPFVertex::VertexNetwork) |
|
806 |
{ |
|
807 |
w_lsa = m_lsdb->GetLSAByLinkData |
|
808 |
(v->GetLSA ()->GetAttachedRouter (i)); |
|
809 |
if (!w_lsa) |
|
810 |
{ |
|
811 |
continue; |
|
812 |
} |
|
1505 | 813 |
NS_LOG_LOGIC ("Found a Network LSA from " << |
1278 | 814 |
v->GetVertexId () << " to " << w_lsa->GetLinkStateId ()); |
815 |
} |
|
816 |
||
817 |
// Note: w_lsa at this point may be either RouterLSA or NetworkLSA |
|
1111 | 818 |
// |
819 |
// (c) If vertex W is already on the shortest-path tree, examine the next |
|
820 |
// link in the LSA. |
|
821 |
// |
|
822 |
// If the link is to a router that is already in the shortest path first tree |
|
823 |
// then we have it covered -- ignore it. |
|
824 |
// |
|
1278 | 825 |
if (w_lsa->GetStatus () == GlobalRoutingLSA::LSA_SPF_IN_SPFTREE) |
826 |
{ |
|
1505 | 827 |
NS_LOG_LOGIC ("Skipping -> LSA "<< |
1278 | 828 |
w_lsa->GetLinkStateId () << " already in SPF tree"); |
829 |
continue; |
|
830 |
} |
|
1111 | 831 |
// |
832 |
// (d) Calculate the link state cost D of the resulting path from the root to |
|
833 |
// vertex W. D is equal to the sum of the link state cost of the (already |
|
834 |
// calculated) shortest path to vertex V and the advertised cost of the link |
|
835 |
// between vertices V and W. |
|
836 |
// |
|
1278 | 837 |
if (v->GetLSA ()->GetLSType () == GlobalRoutingLSA::RouterLSA) |
838 |
{ |
|
839 |
distance = v->GetDistanceFromRoot () + l->GetMetric (); |
|
840 |
} |
|
841 |
else |
|
842 |
{ |
|
843 |
distance = v->GetDistanceFromRoot (); |
|
844 |
} |
|
1111 | 845 |
|
1505 | 846 |
NS_LOG_LOGIC ("Considering w_lsa " << w_lsa->GetLinkStateId ()); |
1278 | 847 |
|
848 |
// Is there already vertex w in candidate list? |
|
849 |
if (w_lsa->GetStatus () == GlobalRoutingLSA::LSA_SPF_NOT_EXPLORED) |
|
850 |
{ |
|
851 |
// Calculate nexthop to w |
|
1111 | 852 |
// We need to figure out how to actually get to the new router represented |
853 |
// by <w>. This will (among other things) find the next hop address to send |
|
854 |
// packets destined for this network to, and also find the outbound interface |
|
855 |
// used to forward the packets. |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
856 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
857 |
// prepare vertex w |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
858 |
w = new SPFVertex (w_lsa); |
1278 | 859 |
if (SPFNexthopCalculation (v, w, l, distance)) |
860 |
{ |
|
861 |
w_lsa->SetStatus (GlobalRoutingLSA::LSA_SPF_CANDIDATE); |
|
1111 | 862 |
// |
863 |
// Push this new vertex onto the priority queue (ordered by distance from the |
|
864 |
// root node). |
|
865 |
// |
|
1278 | 866 |
candidate.Push (w); |
1505 | 867 |
NS_LOG_LOGIC ("Pushing " << |
1278 | 868 |
w->GetVertexId () << ", parent vertexId: " << |
1776
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1505
diff
changeset
|
869 |
v->GetVertexId () << ", distance: " << |
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1505
diff
changeset
|
870 |
w->GetDistanceFromRoot ()); |
1278 | 871 |
} |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
872 |
else |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
873 |
NS_ASSERT_MSG (0, "SPFNexthopCalculation never " |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
874 |
<< "return false, but it does now!"); |
1278 | 875 |
} |
876 |
else if (w_lsa->GetStatus () == GlobalRoutingLSA::LSA_SPF_CANDIDATE) |
|
877 |
{ |
|
1111 | 878 |
// |
879 |
// We have already considered the link represented by <w>. What wse have to |
|
880 |
// do now is to decide if this new router represents a route with a shorter |
|
881 |
// distance metric. |
|
882 |
// |
|
883 |
// So, locate the vertex in the candidate queue and take a look at the |
|
884 |
// distance. |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
885 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
886 |
/* (quagga-0.98.6) W is already on the candidate list; call it cw. |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
887 |
* Compare the previously calculated cost (cw->distance) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
888 |
* with the cost we just determined (w->distance) to see |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
889 |
* if we've found a shorter path. |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
890 |
*/ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
891 |
SPFVertex* cw; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
892 |
cw = candidate.Find (w_lsa->GetLinkStateId ()); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
893 |
if (cw->GetDistanceFromRoot () < distance) |
1278 | 894 |
{ |
1111 | 895 |
// |
896 |
// This is not a shorter path, so don't do anything. |
|
897 |
// |
|
1278 | 898 |
continue; |
899 |
} |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
900 |
else if (cw->GetDistanceFromRoot () == distance) |
1278 | 901 |
{ |
1111 | 902 |
// |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
903 |
// This path is one with an equal cost. |
1111 | 904 |
// |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
905 |
NS_LOG_LOGIC ("Equal cost multiple paths found."); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
906 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
907 |
// At this point, there are two instances 'w' and 'cw' of the |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
908 |
// same vertex, the vertex that is currently being considered |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
909 |
// for adding into the shortest path tree. 'w' is the instance |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
910 |
// as seen from the root via vertex 'v', and 'cw' is the instance |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
911 |
// as seen from the root via some other vertices other than 'v'. |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
912 |
// These two instances are being merged in the following code. |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
913 |
// In particular, the parent nodes, the next hops, and the root's |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
914 |
// output interfaces of the two instances are being merged. |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
915 |
// |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
916 |
// Note that this is functionally equivalent to calling |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
917 |
// ospf_nexthop_merge (cw->nexthop, w->nexthop) in quagga-0.98.6 |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
918 |
// (ospf_spf.c::859), although the detail implementation |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
919 |
// is very different from quagga (blame ns3::GlobalRouteManagerImpl) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
920 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
921 |
// prepare vertex w |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
922 |
w = new SPFVertex (w_lsa); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
923 |
SPFNexthopCalculation (v, w, l, distance); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
924 |
cw->MergeRootExitDirections (w); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
925 |
cw->MergeParent (w); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
926 |
// SPFVertexAddParent (w) is necessary as the destructor of |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
927 |
// SPFVertex checks if the vertex and its parent is linked |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
928 |
// bidirectionally |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
929 |
SPFVertexAddParent (w); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
930 |
delete w; |
1278 | 931 |
} |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
932 |
else // cw->GetDistanceFromRoot () > w->GetDistanceFromRoot () |
1278 | 933 |
{ |
1111 | 934 |
// |
935 |
// this path represents a new, lower-cost path to <w> (the vertex we found in |
|
936 |
// the current link record of the link state advertisement of the current root |
|
937 |
// (vertex <v>) |
|
938 |
// |
|
939 |
// N.B. the nexthop_calculation is conditional, if it finds a valid nexthop |
|
940 |
// it will call spf_add_parents, which will flush the old parents |
|
941 |
// |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
942 |
if (SPFNexthopCalculation (v, cw, l, distance)) |
1278 | 943 |
{ |
1111 | 944 |
// |
945 |
// If we've changed the cost to get to the vertex represented by <w>, we |
|
946 |
// must reorder the priority queue keyed to that cost. |
|
947 |
// |
|
1278 | 948 |
candidate.Reorder (); |
949 |
} |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
950 |
} // new lower cost path found |
1278 | 951 |
} // end W is already on the candidate list |
952 |
} // end loop over the links in V's LSA |
|
1111 | 953 |
} |
954 |
||
955 |
// |
|
1776
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1505
diff
changeset
|
956 |
// This method is derived from quagga ospf_nexthop_calculation() 16.1.1. |
1111 | 957 |
// |
1278 | 958 |
// Calculate nexthop from root through V (parent) to vertex W (destination) |
959 |
// with given distance from root->W. |
|
960 |
// |
|
961 |
// As appropriate, set w's parent, distance, and nexthop information |
|
1111 | 962 |
// |
963 |
// For now, this is greatly simplified from the quagga code |
|
964 |
// |
|
965 |
int |
|
966 |
GlobalRouteManagerImpl::SPFNexthopCalculation ( |
|
967 |
SPFVertex* v, |
|
968 |
SPFVertex* w, |
|
1278 | 969 |
GlobalRoutingLinkRecord* l, |
1111 | 970 |
uint32_t distance) |
971 |
{ |
|
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
972 |
NS_LOG_FUNCTION (v << w << l << distance); |
1505 | 973 |
// |
1278 | 974 |
// If w is a NetworkVertex, l should be null |
975 |
/* |
|
976 |
if (w->GetVertexType () == SPFVertex::VertexNetwork && l) |
|
977 |
{ |
|
3947
756887a9bbea
disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents:
3946
diff
changeset
|
978 |
NS_ASSERT_MSG (0, "Error: SPFNexthopCalculation parameter problem"); |
1278 | 979 |
} |
980 |
*/ |
|
981 |
||
1111 | 982 |
// |
983 |
// The vertex m_spfroot is a distinguished vertex representing the node at |
|
984 |
// the root of the calculations. That is, it is the node for which we are |
|
985 |
// calculating the routes. |
|
986 |
// |
|
987 |
// There are two distinct cases for calculating the next hop information. |
|
988 |
// First, if we're considering a hop from the root to an "adjacent" network |
|
989 |
// (one that is on the other side of a point-to-point link connected to the |
|
990 |
// root), then we need to store the information needed to forward down that |
|
991 |
// link. The second case is if the network is not directly adjacent. In that |
|
992 |
// case we need to use the forwarding information from the vertex on the path |
|
993 |
// to the destination that is directly adjacent [node 1] in both cases of the |
|
994 |
// diagram below. |
|
995 |
// |
|
996 |
// (1) [root] -> [point-to-point] -> [node 1] |
|
997 |
// (2) [root] -> [point-to-point] -> [node 1] -> [point-to-point] -> [node 2] |
|
998 |
// |
|
999 |
// We call the propagation of next hop information down vertices of a path |
|
1000 |
// "inheriting" the next hop information. |
|
1001 |
// |
|
1002 |
// The point-to-point link information is only useful in this calculation when |
|
1003 |
// we are examining the root node. |
|
1004 |
// |
|
1005 |
if (v == m_spfroot) |
|
1006 |
{ |
|
1007 |
// |
|
1008 |
// In this case <v> is the root node, which means it is the starting point |
|
1009 |
// for the packets forwarded by that node. This also means that the next hop |
|
1010 |
// address of packets headed for some arbitrary off-network destination must |
|
1011 |
// be the destination at the other end of one of the links off of the root |
|
1012 |
// node if this root node is a router. We then need to see if this node <w> |
|
1013 |
// is a router. |
|
1014 |
// |
|
1015 |
if (w->GetVertexType () == SPFVertex::VertexRouter) |
|
1016 |
{ |
|
1017 |
// |
|
1018 |
// In the case of point-to-point links, the link data field (m_linkData) of a |
|
1019 |
// Global Router Link Record contains the local IP address. If we look at the |
|
1020 |
// link record describing the link from the perspecive of <w> (the remote |
|
1021 |
// node from the viewpoint of <v>) back to the root node, we can discover the |
|
1022 |
// IP address of the router to which <v> is adjacent. This is a distinguished |
|
1023 |
// address -- the next hop address to get from <v> to <w> and all networks |
|
1024 |
// accessed through that path. |
|
1025 |
// |
|
1026 |
// SPFGetNextLink () is a little odd. used in this way it is just going to |
|
1027 |
// return the link record describing the link from <w> to <v>. Think of it as |
|
1028 |
// SPFGetLink. |
|
1029 |
// |
|
3947
756887a9bbea
disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents:
3946
diff
changeset
|
1030 |
NS_ASSERT (l); |
1278 | 1031 |
GlobalRoutingLinkRecord *linkRemote = 0; |
1111 | 1032 |
linkRemote = SPFGetNextLink (w, v, linkRemote); |
1033 |
// |
|
1034 |
// At this point, <l> is the Global Router Link Record describing the point- |
|
1035 |
// to point link from <v> to <w> from the perspective of <v>; and <linkRemote> |
|
1036 |
// is the Global Router Link Record describing that same link from the |
|
1037 |
// perspective of <w> (back to <v>). Now we can just copy the next hop |
|
1038 |
// address from the m_linkData member variable. |
|
1039 |
// |
|
1040 |
// The next hop member variable we put in <w> has the sense "in order to get |
|
1041 |
// from the root node to the host represented by vertex <w>, you have to send |
|
1042 |
// the packet to the next hop address specified in w->m_nextHop. |
|
1043 |
// |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1044 |
Ipv4Address nextHop = linkRemote->GetLinkData (); |
1111 | 1045 |
// |
1046 |
// Now find the outgoing interface corresponding to the point to point link |
|
1047 |
// from the perspective of <v> -- remember that <l> is the link "from" |
|
1048 |
// <v> "to" <w>. |
|
1049 |
// |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1050 |
uint32_t outIf = FindOutgoingInterfaceId (l->GetLinkData ()); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1051 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1052 |
w->SetRootExitDirection (nextHop, outIf); |
1776
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1505
diff
changeset
|
1053 |
w->SetDistanceFromRoot (distance); |
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1505
diff
changeset
|
1054 |
w->SetParent (v); |
1505 | 1055 |
NS_LOG_LOGIC ("Next hop from " << |
1111 | 1056 |
v->GetVertexId () << " to " << w->GetVertexId () << |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1057 |
" goes through next hop " << nextHop << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1058 |
" via outgoing interface " << outIf << |
1776
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1505
diff
changeset
|
1059 |
" with distance " << distance); |
1278 | 1060 |
} // end W is a router vertes |
1061 |
else |
|
1062 |
{ |
|
1063 |
NS_ASSERT (w->GetVertexType () == SPFVertex::VertexNetwork); |
|
1064 |
// W is a directly connected network; no next hop is required |
|
1065 |
GlobalRoutingLSA* w_lsa = w->GetLSA (); |
|
1066 |
NS_ASSERT (w_lsa->GetLSType () == GlobalRoutingLSA::NetworkLSA); |
|
1067 |
// Find outgoing interface ID for this network |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1068 |
uint32_t outIf = FindOutgoingInterfaceId (w_lsa->GetLinkStateId (), |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1069 |
w_lsa->GetNetworkLSANetworkMask () ); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1070 |
// Set the next hop to 0.0.0.0 meaning "not exist" |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1071 |
Ipv4Address nextHop = Ipv4Address::GetZero (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1072 |
w->SetRootExitDirection (nextHop, outIf); |
1278 | 1073 |
w->SetDistanceFromRoot (distance); |
1074 |
w->SetParent (v); |
|
1505 | 1075 |
NS_LOG_LOGIC ("Next hop from " << |
1278 | 1076 |
v->GetVertexId () << " to network " << w->GetVertexId () << |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1077 |
" via outgoing interface " << outIf << |
1776
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1505
diff
changeset
|
1078 |
" with distance " << distance); |
1278 | 1079 |
return 1; |
1080 |
} |
|
1081 |
} // end v is the root |
|
1082 |
else if (v->GetVertexType () == SPFVertex::VertexNetwork) |
|
1083 |
{ |
|
1084 |
// See if any of v's parents are the root |
|
1085 |
if (v->GetParent () == m_spfroot) |
|
1086 |
{ |
|
1087 |
// 16.1.1 para 5. ...the parent vertex is a network that |
|
1088 |
// directly connects the calculating router to the destination |
|
1089 |
// router. The list of next hops is then determined by |
|
1090 |
// examining the destination's router-LSA... |
|
1091 |
NS_ASSERT (w->GetVertexType () == SPFVertex::VertexRouter); |
|
1092 |
GlobalRoutingLinkRecord *linkRemote = 0; |
|
1093 |
while ((linkRemote = SPFGetNextLink (w, v, linkRemote))) |
|
1094 |
{ |
|
1095 |
/* ...For each link in the router-LSA that points back to the |
|
1096 |
* parent network, the link's Link Data field provides the IP |
|
1097 |
* address of a next hop router. The outgoing interface to |
|
1098 |
* use can then be derived from the next hop IP address (or |
|
1099 |
* it can be inherited from the parent network). |
|
1100 |
*/ |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1101 |
Ipv4Address nextHop = linkRemote->GetLinkData (); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1102 |
uint32_t outIf = v->GetRootExitDirection ().second; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1103 |
w->SetRootExitDirection (nextHop, outIf); |
1505 | 1104 |
NS_LOG_LOGIC ("Next hop from " << |
1278 | 1105 |
v->GetVertexId () << " to " << w->GetVertexId () << |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1106 |
" goes through next hop " << nextHop << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1107 |
" via outgoing interface " << outIf); |
1278 | 1108 |
} |
1109 |
} |
|
1110 |
else |
|
1111 |
{ |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1112 |
w->SetRootExitDirection (v->GetRootExitDirection ()); |
1111 | 1113 |
} |
1114 |
} |
|
1115 |
else |
|
1116 |
{ |
|
1117 |
// |
|
1118 |
// If we're calculating the next hop information from a node (v) that is |
|
1119 |
// *not* the root, then we need to "inherit" the information needed to |
|
1120 |
// forward the packet from the vertex closer to the root. That is, we'll |
|
1121 |
// still send packets to the next hop address of the router adjacent to the |
|
1122 |
// root on the path toward <w>. |
|
1123 |
// |
|
1124 |
// Above, when we were considering the root node, we calculated the next hop |
|
1125 |
// address and outgoing interface required to get off of the root network. |
|
1126 |
// At this point, we are further away from the root network along one of the |
|
1127 |
// (shortest) paths. So the next hop and outoing interface remain the same |
|
1128 |
// (are inherited). |
|
1129 |
// |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1130 |
w->InheritAllRootExitDirections (v); |
1111 | 1131 |
} |
1132 |
// |
|
1133 |
// In all cases, we need valid values for the distance metric and a parent. |
|
1134 |
// |
|
1135 |
w->SetDistanceFromRoot (distance); |
|
1136 |
w->SetParent (v); |
|
1137 |
||
1138 |
return 1; |
|
1139 |
} |
|
1140 |
||
1141 |
// |
|
1142 |
// This method is derived from quagga ospf_get_next_link () |
|
1143 |
// |
|
1144 |
// First search the Global Router Link Records of vertex <v> for one |
|
1145 |
// representing a point-to point link to vertex <w>. |
|
1146 |
// |
|
1147 |
// What is done depends on prev_link. Contrary to appearances, prev_link just |
|
1148 |
// acts as a flag here. If prev_link is NULL, we return the first Global |
|
1149 |
// Router Link Record we find that describes a point-to-point link from <v> |
|
1150 |
// to <w>. If prev_link is not NULL, we return a Global Router Link Record |
|
1151 |
// representing a possible *second* link from <v> to <w>. |
|
1152 |
// |
|
1278 | 1153 |
GlobalRoutingLinkRecord* |
1111 | 1154 |
GlobalRouteManagerImpl::SPFGetNextLink ( |
1155 |
SPFVertex* v, |
|
1156 |
SPFVertex* w, |
|
1278 | 1157 |
GlobalRoutingLinkRecord* prev_link) |
1111 | 1158 |
{ |
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
1159 |
NS_LOG_FUNCTION (v << w << prev_link); |
1111 | 1160 |
|
1161 |
bool skip = true; |
|
1278 | 1162 |
bool found_prev_link = false; |
1163 |
GlobalRoutingLinkRecord* l; |
|
1111 | 1164 |
// |
1165 |
// If prev_link is 0, we are really looking for the first link, not the next |
|
1166 |
// link. |
|
1167 |
// |
|
1168 |
if (prev_link == 0) |
|
1169 |
{ |
|
1170 |
skip = false; |
|
1278 | 1171 |
found_prev_link = true; |
1111 | 1172 |
} |
1173 |
// |
|
1174 |
// Iterate through the Global Router Link Records advertised by the vertex |
|
1175 |
// <v> looking for records representing the point-to-point links off of this |
|
1176 |
// vertex. |
|
1177 |
// |
|
1178 |
for (uint32_t i = 0; i < v->GetLSA ()->GetNLinkRecords (); ++i) |
|
1179 |
{ |
|
1180 |
l = v->GetLSA ()->GetLinkRecord (i); |
|
1181 |
// |
|
1182 |
// The link ID of a link record representing a point-to-point link is set to |
|
1183 |
// the router ID of the neighboring router -- the router to which the link |
|
1184 |
// connects from the perspective of <v> in this case. The vertex ID is also |
|
1185 |
// set to the router ID (using the link state advertisement of a router node). |
|
1186 |
// We're just checking to see if the link <l> is actually the link from <v> to |
|
1187 |
// <w>. |
|
1188 |
// |
|
1278 | 1189 |
if (l->GetLinkId () == w->GetVertexId ()) |
1190 |
{ |
|
1191 |
if (!found_prev_link) |
|
1192 |
{ |
|
1505 | 1193 |
NS_LOG_LOGIC ("Skipping links before prev_link found"); |
1278 | 1194 |
found_prev_link = true; |
1195 |
continue; |
|
1196 |
} |
|
1197 |
||
1505 | 1198 |
NS_LOG_LOGIC ("Found matching link l: linkId = " << |
1111 | 1199 |
l->GetLinkId () << " linkData = " << l->GetLinkData ()); |
1200 |
// |
|
1201 |
// If skip is false, don't (not too surprisingly) skip the link found -- it's |
|
1202 |
// the one we're interested in. That's either because we didn't pass in a |
|
1203 |
// previous link, and we're interested in the first one, or because we've |
|
1204 |
// skipped a previous link and moved forward to the next (which is then the |
|
1205 |
// one we want). |
|
1206 |
// |
|
1207 |
if (skip == false) |
|
1208 |
{ |
|
1505 | 1209 |
NS_LOG_LOGIC ("Returning the found link"); |
1111 | 1210 |
return l; |
1211 |
} |
|
1212 |
else |
|
1213 |
{ |
|
1214 |
// |
|
1215 |
// Skip is true and we've found a link from <v> to <w>. We want the next one. |
|
1216 |
// Setting skip to false gets us the next point-to-point global router link |
|
1217 |
// record in the LSA from <v>. |
|
1218 |
// |
|
1505 | 1219 |
NS_LOG_LOGIC ("Skipping the found link"); |
1111 | 1220 |
skip = false; |
1221 |
continue; |
|
1222 |
} |
|
1223 |
} |
|
1224 |
} |
|
1225 |
return 0; |
|
1226 |
} |
|
1227 |
||
1228 |
// |
|
1229 |
// Used for unit tests. |
|
1230 |
// |
|
1231 |
void |
|
1232 |
GlobalRouteManagerImpl::DebugSPFCalculate (Ipv4Address root) |
|
1233 |
{ |
|
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
1234 |
NS_LOG_FUNCTION (root); |
1111 | 1235 |
SPFCalculate (root); |
1236 |
} |
|
1237 |
||
4628
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1238 |
// |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1239 |
// Used to test if a node is a stub, from an OSPF sense. |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1240 |
// If there is only one link of type 1 or 2, then a default route |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1241 |
// can safely be added to the next-hop router and SPF does not need |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1242 |
// to be run |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1243 |
// |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1244 |
bool |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1245 |
GlobalRouteManagerImpl::CheckForStubNode (Ipv4Address root) |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1246 |
{ |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1247 |
NS_LOG_FUNCTION (root); |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1248 |
GlobalRoutingLSA *rlsa = m_lsdb->GetLSA (root); |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1249 |
Ipv4Address myRouterId = rlsa->GetLinkStateId (); |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1250 |
int transits = 0; |
4630 | 1251 |
GlobalRoutingLinkRecord *transitLink = 0; |
4628
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1252 |
for (uint32_t i = 0; i < rlsa->GetNLinkRecords (); i++) |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1253 |
{ |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1254 |
GlobalRoutingLinkRecord *l = rlsa->GetLinkRecord (i); |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1255 |
if (l->GetLinkType () == GlobalRoutingLinkRecord::TransitNetwork) |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1256 |
{ |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1257 |
transits++; |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1258 |
transitLink = l; |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1259 |
} |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1260 |
else if (l->GetLinkType () == GlobalRoutingLinkRecord::PointToPoint) |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1261 |
{ |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1262 |
transits++; |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1263 |
transitLink = l; |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1264 |
} |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1265 |
} |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1266 |
if (transits == 0) |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1267 |
{ |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1268 |
// This router is not connected to any router. Probably, global |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1269 |
// routing should not be called for this node, but we can just raise |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1270 |
// a warning here and return true. |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1271 |
NS_LOG_WARN ("all nodes should have at least one transit link:" << root ); |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1272 |
return true; |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1273 |
} |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1274 |
if (transits == 1) |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1275 |
{ |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1276 |
if (transitLink->GetLinkType () == GlobalRoutingLinkRecord::TransitNetwork) |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1277 |
{ |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1278 |
// Install default route to next hop router |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1279 |
// What is the next hop? We need to check all neighbors on the link. |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1280 |
// If there is a single router that has two transit links, then |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1281 |
// that is the default next hop. If there are more than one |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1282 |
// routers on link with multiple transit links, return false. |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1283 |
// Not yet implemented, so simply return false |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1284 |
NS_LOG_LOGIC ("TBD: Would have inserted default for transit"); |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1285 |
return false; |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1286 |
} |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1287 |
else if (transitLink->GetLinkType () == GlobalRoutingLinkRecord::PointToPoint) |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1288 |
{ |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1289 |
// Install default route to next hop |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1290 |
// The link record LinkID is the router ID of the peer. |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1291 |
// The Link Data is the local IP interface address |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1292 |
GlobalRoutingLSA *w_lsa = m_lsdb->GetLSA (transitLink->GetLinkId ()); |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1293 |
uint32_t nLinkRecords = w_lsa->GetNLinkRecords (); |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1294 |
for (uint32_t j = 0; j < nLinkRecords; ++j) |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1295 |
{ |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1296 |
// |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1297 |
// We are only concerned about point-to-point links |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1298 |
// |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1299 |
GlobalRoutingLinkRecord *lr = w_lsa->GetLinkRecord (j); |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1300 |
if (lr->GetLinkType () != GlobalRoutingLinkRecord::PointToPoint) |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1301 |
{ |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1302 |
continue; |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1303 |
} |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1304 |
// Find the link record that corresponds to our routerId |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1305 |
if (lr->GetLinkId () == myRouterId) |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1306 |
{ |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1307 |
// Next hop is stored in the LinkID field of lr |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1308 |
Ptr<GlobalRouter> router = rlsa->GetNode ()->GetObject<GlobalRouter> (); |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1309 |
NS_ASSERT (router); |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1310 |
Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol (); |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1311 |
NS_ASSERT (gr); |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1312 |
gr->AddNetworkRouteTo (Ipv4Address ("0.0.0.0"), Ipv4Mask ("0.0.0.0"), lr->GetLinkData (), |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1313 |
FindOutgoingInterfaceId (transitLink->GetLinkData ())); |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1314 |
NS_LOG_LOGIC ("Inserting default route for node " << myRouterId << " to next hop " << |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1315 |
lr->GetLinkData () << " via interface " << |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1316 |
FindOutgoingInterfaceId(transitLink->GetLinkData())); |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1317 |
return true; |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1318 |
} |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1319 |
} |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1320 |
} |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1321 |
} |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1322 |
return false; |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1323 |
} |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1324 |
|
1111 | 1325 |
// quagga ospf_spf_calculate |
1326 |
void |
|
1327 |
GlobalRouteManagerImpl::SPFCalculate (Ipv4Address root) |
|
1328 |
{ |
|
2983
e3a416fe9dd5
NS_LOG_FUNCTION -> NS_LOG_FUNCTION_NOARGS and NS_LOG_PARAMS -> NS_LOG_FUNCTION
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2258
diff
changeset
|
1329 |
NS_LOG_FUNCTION (this << root); |
1111 | 1330 |
|
1331 |
SPFVertex *v; |
|
1332 |
// |
|
1333 |
// Initialize the Link State Database. |
|
1334 |
// |
|
1335 |
m_lsdb->Initialize (); |
|
1336 |
// |
|
1337 |
// The candidate queue is a priority queue of SPFVertex objects, with the top |
|
1338 |
// of the queue being the closest vertex in terms of distance from the root |
|
1339 |
// of the tree. Initially, this queue is empty. |
|
1340 |
// |
|
1341 |
CandidateQueue candidate; |
|
3947
756887a9bbea
disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents:
3946
diff
changeset
|
1342 |
NS_ASSERT (candidate.Size () == 0); |
1111 | 1343 |
// |
1344 |
// Initialize the shortest-path tree to only contain the router doing the |
|
1345 |
// calculation. Each router (and corresponding network) is a vertex in the |
|
1346 |
// shortest path first (SPF) tree. |
|
1347 |
// |
|
1348 |
v = new SPFVertex (m_lsdb->GetLSA (root)); |
|
1349 |
// |
|
1350 |
// This vertex is the root of the SPF tree and it is distance 0 from the root. |
|
1351 |
// We also mark this vertex as being in the SPF tree. |
|
1352 |
// |
|
1353 |
m_spfroot= v; |
|
1354 |
v->SetDistanceFromRoot (0); |
|
1278 | 1355 |
v->GetLSA ()->SetStatus (GlobalRoutingLSA::LSA_SPF_IN_SPFTREE); |
1776
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1505
diff
changeset
|
1356 |
NS_LOG_LOGIC ("Starting SPFCalculate for node " << root); |
1111 | 1357 |
|
4628
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1358 |
// |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1359 |
// Optimize SPF calculation, for ns-3. |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1360 |
// We do not need to calculate SPF for every node in the network if this |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1361 |
// node has only one interface through which another router can be |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1362 |
// reached. Instead, short-circuit this computation and just install |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1363 |
// a default route in the CheckForStubNode() method. |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1364 |
// |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1365 |
if (NodeList::GetNNodes () > 0 && CheckForStubNode (root)) |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1366 |
{ |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1367 |
NS_LOG_LOGIC ("SPFCalculate truncated for stub node " << root); |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1368 |
delete m_spfroot; |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1369 |
return; |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1370 |
} |
a5a8c44e4240
bug 521. Ipv4 global routing inefficient. Updated Tom's patch
Craig Dowell <craigdo@ee.washington.edu>
parents:
4616
diff
changeset
|
1371 |
|
1111 | 1372 |
for (;;) |
1373 |
{ |
|
1374 |
// |
|
1375 |
// The operations we need to do are given in the OSPF RFC which we reference |
|
1376 |
// as we go along. |
|
1377 |
// |
|
1378 |
// RFC2328 16.1. (2). |
|
1379 |
// |
|
1380 |
// We examine the Global Router Link Records in the Link State |
|
1381 |
// Advertisements of the current vertex. If there are any point-to-point |
|
1382 |
// links to unexplored adjacent vertices we add them to the tree and update |
|
1383 |
// the distance and next hop information on how to get there. We also add |
|
1384 |
// the new vertices to the candidate queue (the priority queue ordered by |
|
1385 |
// shortest path). If the new vertices represent shorter paths, we use them |
|
1386 |
// and update the path cost. |
|
1387 |
// |
|
1388 |
SPFNext (v, candidate); |
|
1389 |
// |
|
1390 |
// RFC2328 16.1. (3). |
|
1391 |
// |
|
1392 |
// If at this step the candidate list is empty, the shortest-path tree (of |
|
1393 |
// transit vertices) has been completely built and this stage of the |
|
1394 |
// procedure terminates. |
|
1395 |
// |
|
1396 |
if (candidate.Size () == 0) |
|
1397 |
{ |
|
1398 |
break; |
|
1399 |
} |
|
1400 |
// |
|
1401 |
// Choose the vertex belonging to the candidate list that is closest to the |
|
1402 |
// root, and add it to the shortest-path tree (removing it from the candidate |
|
1403 |
// list in the process). |
|
1404 |
// |
|
1405 |
// Recall that in the previous step, we created SPFVertex structures for each |
|
1406 |
// of the routers found in the Global Router Link Records and added tehm to |
|
1407 |
// the candidate list. |
|
1408 |
// |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1409 |
NS_LOG_LOGIC (candidate); |
1111 | 1410 |
v = candidate.Pop (); |
1505 | 1411 |
NS_LOG_LOGIC ("Popped vertex " << v->GetVertexId ()); |
1111 | 1412 |
// |
1413 |
// Update the status field of the vertex to indicate that it is in the SPF |
|
1414 |
// tree. |
|
1415 |
// |
|
1278 | 1416 |
v->GetLSA ()->SetStatus (GlobalRoutingLSA::LSA_SPF_IN_SPFTREE); |
1111 | 1417 |
// |
1418 |
// The current vertex has a parent pointer. By calling this rather oddly |
|
1419 |
// named method (blame quagga) we add the current vertex to the list of |
|
1420 |
// children of that parent vertex. In the next hop calculation called during |
|
1421 |
// SPFNext, the parent pointer was set but the vertex has been orphaned up |
|
1422 |
// to now. |
|
1423 |
// |
|
1424 |
SPFVertexAddParent (v); |
|
1425 |
// |
|
1426 |
// Note that when there is a choice of vertices closest to the root, network |
|
1427 |
// vertices must be chosen before router vertices in order to necessarily |
|
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1428 |
// find all equal-cost paths. |
1111 | 1429 |
// |
1430 |
// RFC2328 16.1. (4). |
|
1431 |
// |
|
1432 |
// This is the method that actually adds the routes. It'll walk the list |
|
1433 |
// of nodes in the system, looking for the node corresponding to the router |
|
1434 |
// ID of the root of the tree -- that is the router we're building the routes |
|
1435 |
// for. It looks for the Ipv4 interface of that node and remembers it. So |
|
1436 |
// we are only actually adding routes to that one node at the root of the SPF |
|
1437 |
// tree. |
|
1438 |
// |
|
1439 |
// We're going to pop of a pointer to every vertex in the tree except the |
|
1440 |
// root in order of distance from the root. For each of the vertices, we call |
|
1441 |
// SPFIntraAddRouter (). Down in SPFIntraAddRouter, we look at all of the |
|
1442 |
// point-to-point Global Router Link Records (the links to nodes adjacent to |
|
1443 |
// the node represented by the vertex). We add a route to the IP address |
|
1444 |
// specified by the m_linkData field of each of those link records. This will |
|
1445 |
// be the *local* IP address associated with the interface attached to the |
|
1446 |
// link. We use the outbound interface and next hop information present in |
|
1447 |
// the vertex <v> which have possibly been inherited from the root. |
|
1448 |
// |
|
1449 |
// To summarize, we're going to look at the node represented by <v> and loop |
|
1450 |
// through its point-to-point links, adding a *host* route to the local IP |
|
1451 |
// address (at the <v> side) for each of those links. |
|
1452 |
// |
|
1278 | 1453 |
if (v->GetVertexType () == SPFVertex::VertexRouter) |
1454 |
{ |
|
1455 |
SPFIntraAddRouter (v); |
|
1456 |
} |
|
1457 |
else if (v->GetVertexType () == SPFVertex::VertexNetwork) |
|
1458 |
{ |
|
1459 |
SPFIntraAddTransit (v); |
|
1460 |
} |
|
1461 |
else |
|
1462 |
{ |
|
3947
756887a9bbea
disallow routing on bridge devices with IP address, fix wifi-wired-bridging
Craig Dowell <craigdo@ee.washington.edu>
parents:
3946
diff
changeset
|
1463 |
NS_ASSERT_MSG (0, "illegal SPFVertex type"); |
1278 | 1464 |
} |
1111 | 1465 |
// |
1466 |
// RFC2328 16.1. (5). |
|
1467 |
// |
|
1468 |
// Iterate the algorithm by returning to Step 2 until there are no more |
|
1469 |
// candidate vertices. |
|
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1470 |
|
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1471 |
} // end for loop |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1472 |
|
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1473 |
// Second stage of SPF calculation procedure |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1474 |
SPFProcessStubs (m_spfroot); |
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1475 |
for (uint32_t i = 0; i < m_lsdb->GetNumExtLSAs (); i++) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1476 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1477 |
m_spfroot->ClearVertexProcessed (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1478 |
GlobalRoutingLSA *extlsa = m_lsdb->GetExtLSA (i); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1479 |
NS_LOG_LOGIC ("Processing External LSA with id " << extlsa->GetLinkStateId ()); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1480 |
ProcessASExternals (m_spfroot, extlsa); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1481 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1482 |
|
1111 | 1483 |
// |
1484 |
// We're all done setting the routing information for the node at the root of |
|
1485 |
// the SPF tree. Delete all of the vertices and corresponding resources. Go |
|
1486 |
// possibly do it again for the next router. |
|
1487 |
// |
|
1488 |
delete m_spfroot; |
|
1489 |
m_spfroot = 0; |
|
1490 |
} |
|
1491 |
||
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1492 |
void |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1493 |
GlobalRouteManagerImpl::ProcessASExternals (SPFVertex* v, GlobalRoutingLSA* extlsa) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1494 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1495 |
NS_LOG_FUNCTION_NOARGS (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1496 |
NS_LOG_LOGIC ("Processing external for destination " << |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1497 |
extlsa->GetLinkStateId () << |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1498 |
", for router " << v->GetVertexId () << |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1499 |
", advertised by " << extlsa->GetAdvertisingRouter ()); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1500 |
if (v->GetVertexType () == SPFVertex::VertexRouter) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1501 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1502 |
GlobalRoutingLSA *rlsa = v->GetLSA (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1503 |
NS_LOG_LOGIC ("Processing router LSA with id " << rlsa->GetLinkStateId ()); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1504 |
if ((rlsa->GetLinkStateId ()) == (extlsa->GetAdvertisingRouter ())) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1505 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1506 |
NS_LOG_LOGIC ("Found advertising router to destination"); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1507 |
SPFAddASExternal(extlsa,v); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1508 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1509 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1510 |
for (uint32_t i = 0; i < v->GetNChildren (); i++) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1511 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1512 |
if (!v->GetChild (i)->IsVertexProcessed ()) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1513 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1514 |
NS_LOG_LOGIC ("Vertex's child " << i << " not yet processed, processing..."); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1515 |
ProcessASExternals (v->GetChild (i), extlsa); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1516 |
v->GetChild (i)->SetVertexProcessed (true); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1517 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1518 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1519 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1520 |
|
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1521 |
// |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1522 |
// Adding external routes to routing table - modeled after |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1523 |
// SPFAddIntraAddStub() |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1524 |
// |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1525 |
|
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1526 |
void |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1527 |
GlobalRouteManagerImpl::SPFAddASExternal (GlobalRoutingLSA *extlsa, SPFVertex *v) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1528 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1529 |
NS_LOG_FUNCTION_NOARGS (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1530 |
|
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1531 |
NS_ASSERT_MSG (m_spfroot, "GlobalRouteManagerImpl::SPFAddASExternal (): Root pointer not set"); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1532 |
// Two cases to consider: We are advertising the external ourselves |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1533 |
// => No need to add anything |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1534 |
// OR find best path to the advertising router |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1535 |
if (v->GetVertexId () == m_spfroot->GetVertexId ()) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1536 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1537 |
NS_LOG_LOGIC ("External is on local host: " |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1538 |
<< v->GetVertexId () << "; returning"); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1539 |
return; |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1540 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1541 |
NS_LOG_LOGIC ("External is on remote host: " |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1542 |
<< extlsa->GetAdvertisingRouter () << "; installing"); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1543 |
|
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1544 |
Ipv4Address routerId = m_spfroot->GetVertexId (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1545 |
|
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1546 |
NS_LOG_LOGIC ("Vertex ID = " << routerId); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1547 |
// |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1548 |
// We need to walk the list of nodes looking for the one that has the router |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1549 |
// ID corresponding to the root vertex. This is the one we're going to write |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1550 |
// the routing information to. |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1551 |
// |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1552 |
NodeList::Iterator i = NodeList::Begin (); |
4758
0f9bcd407aff
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
Guillaume Seguin <guillaume.seguin@sophia.inria.fr>
parents:
4745
diff
changeset
|
1553 |
NodeList::Iterator listEnd = NodeList::End (); |
0f9bcd407aff
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
Guillaume Seguin <guillaume.seguin@sophia.inria.fr>
parents:
4745
diff
changeset
|
1554 |
for (; i != listEnd; i++) |
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1555 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1556 |
Ptr<Node> node = *i; |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1557 |
// |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1558 |
// The router ID is accessible through the GlobalRouter interface, so we need |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1559 |
// to QI for that interface. If there's no GlobalRouter interface, the node |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1560 |
// in question cannot be the router we want, so we continue. |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1561 |
// |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1562 |
Ptr<GlobalRouter> rtr = node->GetObject<GlobalRouter> (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1563 |
|
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1564 |
if (rtr == 0) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1565 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1566 |
NS_LOG_LOGIC ("No GlobalRouter interface on node " << node->GetId ()); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1567 |
continue; |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1568 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1569 |
// |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1570 |
// If the router ID of the current node is equal to the router ID of the |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1571 |
// root of the SPF tree, then this node is the one for which we need to |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1572 |
// write the routing tables. |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1573 |
// |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1574 |
NS_LOG_LOGIC ("Considering router " << rtr->GetRouterId ()); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1575 |
|
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1576 |
if (rtr->GetRouterId () == routerId) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1577 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1578 |
NS_LOG_LOGIC ("Setting routes for node " << node->GetId ()); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1579 |
// |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1580 |
// Routing information is updated using the Ipv4 interface. We need to QI |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1581 |
// for that interface. If the node is acting as an IP version 4 router, it |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1582 |
// should absolutely have an Ipv4 interface. |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1583 |
// |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1584 |
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1585 |
NS_ASSERT_MSG (ipv4, |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1586 |
"GlobalRouteManagerImpl::SPFIntraAddRouter (): " |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1587 |
"QI for <Ipv4> interface failed"); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1588 |
// |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1589 |
// Get the Global Router Link State Advertisement from the vertex we're |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1590 |
// adding the routes to. The LSA will have a number of attached Global Router |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1591 |
// Link Records corresponding to links off of that vertex / node. We're going |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1592 |
// to be interested in the records corresponding to point-to-point links. |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1593 |
// |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1594 |
NS_ASSERT_MSG (v->GetLSA (), |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1595 |
"GlobalRouteManagerImpl::SPFIntraAddRouter (): " |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1596 |
"Expected valid LSA in SPFVertex* v"); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1597 |
Ipv4Mask tempmask = extlsa->GetNetworkLSANetworkMask (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1598 |
Ipv4Address tempip = extlsa->GetLinkStateId (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1599 |
tempip = tempip.CombineMask (tempmask); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1600 |
|
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1601 |
// |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1602 |
// Here's why we did all of that work. We're going to add a host route to the |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1603 |
// host address found in the m_linkData field of the point-to-point link |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1604 |
// record. In the case of a point-to-point link, this is the local IP address |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1605 |
// of the node connected to the link. Each of these point-to-point links |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1606 |
// will correspond to a local interface that has an IP address to which |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1607 |
// the node at the root of the SPF tree can send packets. The vertex <v> |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1608 |
// (corresponding to the node that has these links and interfaces) has |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1609 |
// an m_nextHop address precalculated for us that is the address to which the |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1610 |
// root node should send packets to be forwarded to these IP addresses. |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1611 |
// Similarly, the vertex <v> has an m_rootOif (outbound interface index) to |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1612 |
// which the packets should be send for forwarding. |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1613 |
// |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1614 |
Ptr<GlobalRouter> router = node->GetObject<GlobalRouter> (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1615 |
if (router == 0) |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1616 |
{ |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1617 |
continue; |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1618 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1619 |
Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol (); |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1620 |
NS_ASSERT (gr); |
5934
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1621 |
// walk through all next-hop-IPs and out-going-interfaces for reaching |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1622 |
// the stub network gateway 'v' from the root node |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1623 |
for (uint32_t i = 0; i < v->GetNRootExitDirections (); i++) |
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1624 |
{ |
5934
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1625 |
SPFVertex::NodeExit_t exit = v->GetRootExitDirection (i); |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1626 |
Ipv4Address nextHop = exit.first; |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1627 |
int32_t outIf = exit.second; |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1628 |
if (outIf >= 0) |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1629 |
{ |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1630 |
gr->AddASExternalRouteTo (tempip, tempmask, nextHop, outIf); |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1631 |
NS_LOG_LOGIC ("(Route " << i << ") Node " << node->GetId () << |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1632 |
" add external network route to " << tempip << |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1633 |
" using next hop " << nextHop << |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1634 |
" via interface " << outIf); |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1635 |
} |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1636 |
else |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1637 |
{ |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1638 |
NS_LOG_LOGIC ("(Route " << i << ") Node " << node->GetId () << |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1639 |
" NOT able to add network route to " << tempip << |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1640 |
" using next hop " << nextHop << |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1641 |
" since outgoing interface id is negative"); |
71a3dd5e7a08
[bug 789] Globalrouting externalroutes to use the new GetRootExitDirections()
Antti M?kel? <zarhan@cc.hut.fi>
parents:
5858
diff
changeset
|
1642 |
} |
4745
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1643 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1644 |
return; |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1645 |
} // if |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1646 |
} // for |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1647 |
} |
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1648 |
|
a0e27af57c8d
Allow injection of routes to Ipv4GlobalRouting
Antti Makela <zarhan@cc.hut.fi>
parents:
4630
diff
changeset
|
1649 |
|
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1650 |
// Processing logic from RFC 2328, page 166 and quagga ospf_spf_process_stubs () |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1651 |
// stub link records will exist for point-to-point interfaces and for |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1652 |
// broadcast interfaces for which no neighboring router can be found |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1653 |
void |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1654 |
GlobalRouteManagerImpl::SPFProcessStubs (SPFVertex* v) |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1655 |
{ |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1656 |
NS_LOG_FUNCTION_NOARGS (); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1657 |
NS_LOG_LOGIC ("Processing stubs for " << v->GetVertexId ()); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1658 |
if (v->GetVertexType () == SPFVertex::VertexRouter) |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1659 |
{ |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1660 |
GlobalRoutingLSA *rlsa = v->GetLSA (); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1661 |
NS_LOG_LOGIC ("Processing router LSA with id " << rlsa->GetLinkStateId ()); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1662 |
for (uint32_t i = 0; i < rlsa->GetNLinkRecords (); i++) |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1663 |
{ |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1664 |
NS_LOG_LOGIC ("Examining link " << i << " of " << |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1665 |
v->GetVertexId () << "'s " << |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1666 |
v->GetLSA ()->GetNLinkRecords () << " link records"); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1667 |
GlobalRoutingLinkRecord *l = v->GetLSA ()->GetLinkRecord (i); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1668 |
if (l->GetLinkType () == GlobalRoutingLinkRecord::StubNetwork) |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1669 |
{ |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1670 |
NS_LOG_LOGIC ("Found a Stub record to " << l->GetLinkId ()); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1671 |
SPFIntraAddStub (l, v); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1672 |
continue; |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1673 |
} |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1674 |
} |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1675 |
} |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1676 |
for (uint32_t i = 0; i < v->GetNChildren (); i++) |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1677 |
{ |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1678 |
if (!v->GetChild (i)->IsVertexProcessed ()) |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1679 |
{ |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1680 |
SPFProcessStubs (v->GetChild (i)); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1681 |
v->GetChild (i)->SetVertexProcessed (true); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1682 |
} |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1683 |
} |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1684 |
} |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1685 |
|
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1686 |
// RFC2328 16.1. second stage. |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1687 |
void |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1688 |
GlobalRouteManagerImpl::SPFIntraAddStub (GlobalRoutingLinkRecord *l, SPFVertex* v) |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1689 |
{ |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1690 |
NS_LOG_FUNCTION_NOARGS (); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1691 |
|
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1692 |
NS_ASSERT_MSG (m_spfroot, |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1693 |
"GlobalRouteManagerImpl::SPFIntraAddStub (): Root pointer not set"); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1694 |
|
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1695 |
// XXX simplifed logic for the moment. There are two cases to consider: |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1696 |
// 1) the stub network is on this router; do nothing for now |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1697 |
// (already handled above) |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1698 |
// 2) the stub network is on a remote router, so I should use the |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1699 |
// same next hop that I use to get to vertex v |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1700 |
if (v->GetVertexId () == m_spfroot->GetVertexId ()) |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1701 |
{ |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1702 |
NS_LOG_LOGIC ("Stub is on local host: " << v->GetVertexId () << "; returning"); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1703 |
return; |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1704 |
} |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1705 |
NS_LOG_LOGIC ("Stub is on remote host: " << v->GetVertexId () << "; installing"); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1706 |
// |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1707 |
// The root of the Shortest Path First tree is the router to which we are |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1708 |
// going to write the actual routing table entries. The vertex corresponding |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1709 |
// to this router has a vertex ID which is the router ID of that node. We're |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1710 |
// going to use this ID to discover which node it is that we're actually going |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1711 |
// to update. |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1712 |
// |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1713 |
Ipv4Address routerId = m_spfroot->GetVertexId (); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1714 |
|
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1715 |
NS_LOG_LOGIC ("Vertex ID = " << routerId); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1716 |
// |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1717 |
// We need to walk the list of nodes looking for the one that has the router |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1718 |
// ID corresponding to the root vertex. This is the one we're going to write |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1719 |
// the routing information to. |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1720 |
// |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1721 |
NodeList::Iterator i = NodeList::Begin (); |
4758
0f9bcd407aff
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
Guillaume Seguin <guillaume.seguin@sophia.inria.fr>
parents:
4745
diff
changeset
|
1722 |
NodeList::Iterator listEnd = NodeList::End (); |
0f9bcd407aff
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
Guillaume Seguin <guillaume.seguin@sophia.inria.fr>
parents:
4745
diff
changeset
|
1723 |
for (; i != listEnd; i++) |
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1724 |
{ |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1725 |
Ptr<Node> node = *i; |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1726 |
// |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1727 |
// The router ID is accessible through the GlobalRouter interface, so we need |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1728 |
// to QI for that interface. If there's no GlobalRouter interface, the node |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1729 |
// in question cannot be the router we want, so we continue. |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1730 |
// |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1731 |
Ptr<GlobalRouter> rtr = |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1732 |
node->GetObject<GlobalRouter> (); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1733 |
|
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1734 |
if (rtr == 0) |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1735 |
{ |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1736 |
NS_LOG_LOGIC ("No GlobalRouter interface on node " << |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1737 |
node->GetId ()); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1738 |
continue; |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1739 |
} |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1740 |
// |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1741 |
// If the router ID of the current node is equal to the router ID of the |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1742 |
// root of the SPF tree, then this node is the one for which we need to |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1743 |
// write the routing tables. |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1744 |
// |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1745 |
NS_LOG_LOGIC ("Considering router " << rtr->GetRouterId ()); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1746 |
|
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1747 |
if (rtr->GetRouterId () == routerId) |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1748 |
{ |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1749 |
NS_LOG_LOGIC ("Setting routes for node " << node->GetId ()); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1750 |
// |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1751 |
// Routing information is updated using the Ipv4 interface. We need to QI |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1752 |
// for that interface. If the node is acting as an IP version 4 router, it |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1753 |
// should absolutely have an Ipv4 interface. |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1754 |
// |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1755 |
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> (); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1756 |
NS_ASSERT_MSG (ipv4, |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1757 |
"GlobalRouteManagerImpl::SPFIntraAddRouter (): " |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1758 |
"QI for <Ipv4> interface failed"); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1759 |
// |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1760 |
// Get the Global Router Link State Advertisement from the vertex we're |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1761 |
// adding the routes to. The LSA will have a number of attached Global Router |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1762 |
// Link Records corresponding to links off of that vertex / node. We're going |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1763 |
// to be interested in the records corresponding to point-to-point links. |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1764 |
// |
3969 | 1765 |
NS_ASSERT_MSG (v->GetLSA (), |
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1766 |
"GlobalRouteManagerImpl::SPFIntraAddRouter (): " |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1767 |
"Expected valid LSA in SPFVertex* v"); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1768 |
Ipv4Mask tempmask ("255.255.255.0"); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1769 |
Ipv4Address tempip = l->GetLinkId (); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1770 |
tempip = tempip.CombineMask (tempmask); |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1771 |
// |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1772 |
// Here's why we did all of that work. We're going to add a host route to the |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1773 |
// host address found in the m_linkData field of the point-to-point link |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1774 |
// record. In the case of a point-to-point link, this is the local IP address |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1775 |
// of the node connected to the link. Each of these point-to-point links |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1776 |
// will correspond to a local interface that has an IP address to which |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1777 |
// the node at the root of the SPF tree can send packets. The vertex <v> |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1778 |
// (corresponding to the node that has these links and interfaces) has |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1779 |
// an m_nextHop address precalculated for us that is the address to which the |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1780 |
// root node should send packets to be forwarded to these IP addresses. |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1781 |
// Similarly, the vertex <v> has an m_rootOif (outbound interface index) to |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1782 |
// which the packets should be send for forwarding. |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1783 |
// |
4616
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
1784 |
|
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
1785 |
Ptr<GlobalRouter> router = node->GetObject<GlobalRouter> (); |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
1786 |
if (router == 0) |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
1787 |
{ |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
1788 |
continue; |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
1789 |
} |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
1790 |
Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol (); |
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1791 |
NS_ASSERT (gr); |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1792 |
// walk through all next-hop-IPs and out-going-interfaces for reaching |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1793 |
// the stub network gateway 'v' from the root node |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1794 |
for (uint32_t i = 0; i < v->GetNRootExitDirections (); i++) |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1795 |
{ |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1796 |
SPFVertex::NodeExit_t exit = v->GetRootExitDirection (i); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1797 |
Ipv4Address nextHop = exit.first; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1798 |
int32_t outIf = exit.second; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1799 |
if (outIf >= 0) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1800 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1801 |
gr->AddNetworkRouteTo (tempip, tempmask, nextHop, outIf); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1802 |
NS_LOG_LOGIC ("(Route " << i << ") Node " << node->GetId () << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1803 |
" add network route to " << tempip << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1804 |
" using next hop " << nextHop << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1805 |
" via interface " << outIf); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1806 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1807 |
else |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1808 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1809 |
NS_LOG_LOGIC ("(Route " << i << ") Node " << node->GetId () << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1810 |
" NOT able to add network route to " << tempip << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1811 |
" using next hop " << nextHop << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1812 |
" since outgoing interface id is negative"); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
1813 |
} |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1814 |
} |
3960
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1815 |
return; |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1816 |
} // if |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1817 |
} // for |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1818 |
} |
34908804c029
Add processing logic for stub links in global routing code
Tom Henderson <tomh@tomh.org>
parents:
3959
diff
changeset
|
1819 |
|
1111 | 1820 |
// |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1821 |
// Return the interface number corresponding to a given IP address and mask |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1822 |
// This is a wrapper around GetInterfaceForPrefix(), but we first |
1316
f357c6a2bb37
Provide two new Ipv4 convenience functions: GetIfIndexByIpv4Address() and GetIpv4RouteToDestination (), and align global routing code to use the first function
Tom Henderson <tomh@tomh.org>
parents:
1302
diff
changeset
|
1823 |
// have to find the right node pointer to pass to that function. |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1824 |
// If no such interface is found, return -1 (note: unit test framework |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1825 |
// for routing assumes -1 to be a legal return value) |
1278 | 1826 |
// |
4476 | 1827 |
int32_t |
4297
d8501bae8be1
Fix a previous regexp substitution that went too far
Tom Henderson <tomh@tomh.org>
parents:
3969
diff
changeset
|
1828 |
GlobalRouteManagerImpl::FindOutgoingInterfaceId (Ipv4Address a, Ipv4Mask amask) |
1278 | 1829 |
{ |
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
1830 |
NS_LOG_FUNCTION (a << amask); |
1278 | 1831 |
// |
1832 |
// We have an IP address <a> and a vertex ID of the root of the SPF tree. |
|
1833 |
// The question is what interface index does this address correspond to. |
|
1834 |
// The answer is a little complicated since we have to find a pointer to |
|
1835 |
// the node corresponding to the vertex ID, find the Ipv4 interface on that |
|
1836 |
// node in order to iterate the interfaces and find the one corresponding to |
|
1837 |
// the address in question. |
|
1838 |
// |
|
1839 |
Ipv4Address routerId = m_spfroot->GetVertexId (); |
|
1840 |
// |
|
1841 |
// Walk the list of nodes in the system looking for the one corresponding to |
|
1842 |
// the node at the root of the SPF tree. This is the node for which we are |
|
1843 |
// building the routing table. |
|
1844 |
// |
|
1302
7dd6ea991e80
use more NodeList::Iterator types
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1301
diff
changeset
|
1845 |
NodeList::Iterator i = NodeList::Begin (); |
4758
0f9bcd407aff
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
Guillaume Seguin <guillaume.seguin@sophia.inria.fr>
parents:
4745
diff
changeset
|
1846 |
NodeList::Iterator listEnd = NodeList::End (); |
0f9bcd407aff
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
Guillaume Seguin <guillaume.seguin@sophia.inria.fr>
parents:
4745
diff
changeset
|
1847 |
for (; i != listEnd; i++) |
1278 | 1848 |
{ |
1849 |
Ptr<Node> node = *i; |
|
1850 |
||
1851 |
Ptr<GlobalRouter> rtr = |
|
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2250
diff
changeset
|
1852 |
node->GetObject<GlobalRouter> (); |
1278 | 1853 |
// |
1854 |
// If the node doesn't have a GlobalRouter interface it can't be the one |
|
1855 |
// we're interested in. |
|
1856 |
// |
|
1857 |
if (rtr == 0) |
|
1858 |
{ |
|
1859 |
continue; |
|
1860 |
} |
|
1861 |
||
1862 |
if (rtr->GetRouterId () == routerId) |
|
1863 |
{ |
|
1864 |
// |
|
1865 |
// This is the node we're building the routing table for. We're going to need |
|
1866 |
// the Ipv4 interface to look for the ipv4 interface index. Since this node |
|
1867 |
// is participating in routing IP version 4 packets, it certainly must have |
|
1868 |
// an Ipv4 interface. |
|
1869 |
// |
|
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2250
diff
changeset
|
1870 |
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> (); |
1278 | 1871 |
NS_ASSERT_MSG (ipv4, |
4297
d8501bae8be1
Fix a previous regexp substitution that went too far
Tom Henderson <tomh@tomh.org>
parents:
3969
diff
changeset
|
1872 |
"GlobalRouteManagerImpl::FindOutgoingInterfaceId (): " |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1873 |
"GetObject for <Ipv4> interface failed"); |
1278 | 1874 |
// |
1875 |
// Look through the interfaces on this node for one that has the IP address |
|
1876 |
// we're looking for. If we find one, return the corresponding interface |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1877 |
// index, or -1 if not found. |
1278 | 1878 |
// |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1879 |
int32_t interface = ipv4->GetInterfaceForPrefix (a, amask); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1880 |
|
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1881 |
#if 0 |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1882 |
if (interface < 0) |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1883 |
{ |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1884 |
NS_FATAL_ERROR ("GlobalRouteManagerImpl::FindOutgoingInterfaceId(): " |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1885 |
"Expected an interface associated with address a:" << a); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1886 |
} |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1887 |
#endif |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1888 |
return interface; |
1278 | 1889 |
} |
1890 |
} |
|
1891 |
// |
|
1892 |
// Couldn't find it. |
|
1893 |
// |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1894 |
NS_LOG_LOGIC ("FindOutgoingInterfaceId():Can't find root node " << routerId); |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1895 |
return -1; |
1278 | 1896 |
} |
1897 |
||
1898 |
// |
|
1111 | 1899 |
// This method is derived from quagga ospf_intra_add_router () |
1900 |
// |
|
1901 |
// This is where we are actually going to add the host routes to the routing |
|
1902 |
// tables of the individual nodes. |
|
1903 |
// |
|
1904 |
// The vertex passed as a parameter has just been added to the SPF tree. |
|
1905 |
// This vertex must have a valid m_root_oid, corresponding to the outgoing |
|
1906 |
// interface on the root router of the tree that is the first hop on the path |
|
1907 |
// to the vertex. The vertex must also have a next hop address, corresponding |
|
1908 |
// to the next hop on the path to the vertex. The vertex has an m_lsa field |
|
1909 |
// that has some number of link records. For each point to point link record, |
|
1910 |
// the m_linkData is the local IP address of the link. This corresponds to |
|
1911 |
// a destination IP address, reachable from the root, to which we add a host |
|
1912 |
// route. |
|
1913 |
// |
|
1914 |
void |
|
1915 |
GlobalRouteManagerImpl::SPFIntraAddRouter (SPFVertex* v) |
|
1916 |
{ |
|
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
1917 |
NS_LOG_FUNCTION (v); |
1111 | 1918 |
|
1919 |
NS_ASSERT_MSG (m_spfroot, |
|
1920 |
"GlobalRouteManagerImpl::SPFIntraAddRouter (): Root pointer not set"); |
|
1921 |
// |
|
1922 |
// The root of the Shortest Path First tree is the router to which we are |
|
1923 |
// going to write the actual routing table entries. The vertex corresponding |
|
1924 |
// to this router has a vertex ID which is the router ID of that node. We're |
|
1925 |
// going to use this ID to discover which node it is that we're actually going |
|
1926 |
// to update. |
|
1927 |
// |
|
1928 |
Ipv4Address routerId = m_spfroot->GetVertexId (); |
|
1929 |
||
1505 | 1930 |
NS_LOG_LOGIC ("Vertex ID = " << routerId); |
1111 | 1931 |
// |
1932 |
// We need to walk the list of nodes looking for the one that has the router |
|
1933 |
// ID corresponding to the root vertex. This is the one we're going to write |
|
1934 |
// the routing information to. |
|
1935 |
// |
|
1302
7dd6ea991e80
use more NodeList::Iterator types
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1301
diff
changeset
|
1936 |
NodeList::Iterator i = NodeList::Begin (); |
4758
0f9bcd407aff
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
Guillaume Seguin <guillaume.seguin@sophia.inria.fr>
parents:
4745
diff
changeset
|
1937 |
NodeList::Iterator listEnd = NodeList::End (); |
0f9bcd407aff
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
Guillaume Seguin <guillaume.seguin@sophia.inria.fr>
parents:
4745
diff
changeset
|
1938 |
for (; i != listEnd; i++) |
1111 | 1939 |
{ |
1940 |
Ptr<Node> node = *i; |
|
1941 |
// |
|
1942 |
// The router ID is accessible through the GlobalRouter interface, so we need |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1943 |
// to GetObject for that interface. If there's no GlobalRouter interface, |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1944 |
// the node in question cannot be the router we want, so we continue. |
1111 | 1945 |
// |
1946 |
Ptr<GlobalRouter> rtr = |
|
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2250
diff
changeset
|
1947 |
node->GetObject<GlobalRouter> (); |
1111 | 1948 |
|
1949 |
if (rtr == 0) |
|
1950 |
{ |
|
1505 | 1951 |
NS_LOG_LOGIC ("No GlobalRouter interface on node " << |
1952 |
node->GetId ()); |
|
1111 | 1953 |
continue; |
1954 |
} |
|
1955 |
// |
|
1956 |
// If the router ID of the current node is equal to the router ID of the |
|
1957 |
// root of the SPF tree, then this node is the one for which we need to |
|
1958 |
// write the routing tables. |
|
1959 |
// |
|
1505 | 1960 |
NS_LOG_LOGIC ("Considering router " << rtr->GetRouterId ()); |
1111 | 1961 |
|
1962 |
if (rtr->GetRouterId () == routerId) |
|
1963 |
{ |
|
1505 | 1964 |
NS_LOG_LOGIC ("Setting routes for node " << node->GetId ()); |
1111 | 1965 |
// |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1966 |
// Routing information is updated using the Ipv4 interface. We need to |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1967 |
// GetObject for that interface. If the node is acting as an IP version 4 |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1968 |
// router, it should absolutely have an Ipv4 interface. |
1111 | 1969 |
// |
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2250
diff
changeset
|
1970 |
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> (); |
1111 | 1971 |
NS_ASSERT_MSG (ipv4, |
1972 |
"GlobalRouteManagerImpl::SPFIntraAddRouter (): " |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
1973 |
"GetObject for <Ipv4> interface failed"); |
1111 | 1974 |
// |
1975 |
// Get the Global Router Link State Advertisement from the vertex we're |
|
1976 |
// adding the routes to. The LSA will have a number of attached Global Router |
|
1977 |
// Link Records corresponding to links off of that vertex / node. We're going |
|
1978 |
// to be interested in the records corresponding to point-to-point links. |
|
1979 |
// |
|
1278 | 1980 |
GlobalRoutingLSA *lsa = v->GetLSA (); |
1111 | 1981 |
NS_ASSERT_MSG (lsa, |
1982 |
"GlobalRouteManagerImpl::SPFIntraAddRouter (): " |
|
1983 |
"Expected valid LSA in SPFVertex* v"); |
|
1984 |
||
1985 |
uint32_t nLinkRecords = lsa->GetNLinkRecords (); |
|
1986 |
// |
|
1987 |
// Iterate through the link records on the vertex to which we're going to add |
|
1988 |
// routes. To make sure we're being clear, we're going to add routing table |
|
1989 |
// entries to the tables on the node corresping to the root of the SPF tree. |
|
1990 |
// These entries will have routes to the IP addresses we find from looking at |
|
1991 |
// the local side of the point-to-point links found on the node described by |
|
1992 |
// the vertex <v>. |
|
1993 |
// |
|
3959
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
1994 |
NS_LOG_LOGIC (" Node " << node->GetId () << |
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
1995 |
" found " << nLinkRecords << " link records in LSA " << lsa << "with LinkStateId "<< lsa->GetLinkStateId ()); |
3091 | 1996 |
for (uint32_t j = 0; j < nLinkRecords; ++j) |
1111 | 1997 |
{ |
1998 |
// |
|
1999 |
// We are only concerned about point-to-point links |
|
2000 |
// |
|
1278 | 2001 |
GlobalRoutingLinkRecord *lr = lsa->GetLinkRecord (j); |
2002 |
if (lr->GetLinkType () != GlobalRoutingLinkRecord::PointToPoint) |
|
1111 | 2003 |
{ |
2004 |
continue; |
|
2005 |
} |
|
2006 |
// |
|
2007 |
// Here's why we did all of that work. We're going to add a host route to the |
|
2008 |
// host address found in the m_linkData field of the point-to-point link |
|
2009 |
// record. In the case of a point-to-point link, this is the local IP address |
|
2010 |
// of the node connected to the link. Each of these point-to-point links |
|
2011 |
// will correspond to a local interface that has an IP address to which |
|
2012 |
// the node at the root of the SPF tree can send packets. The vertex <v> |
|
2013 |
// (corresponding to the node that has these links and interfaces) has |
|
2014 |
// an m_nextHop address precalculated for us that is the address to which the |
|
2015 |
// root node should send packets to be forwarded to these IP addresses. |
|
2016 |
// Similarly, the vertex <v> has an m_rootOif (outbound interface index) to |
|
2017 |
// which the packets should be send for forwarding. |
|
2018 |
// |
|
4616
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
2019 |
Ptr<GlobalRouter> router = node->GetObject<GlobalRouter> (); |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
2020 |
if (router == 0) |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
2021 |
{ |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
2022 |
continue; |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
2023 |
} |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
2024 |
Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol (); |
3959
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
2025 |
NS_ASSERT (gr); |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2026 |
// walk through all available exit directions due to ECMP, |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2027 |
// and add host route for each of the exit direction toward |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2028 |
// the vertex 'v' |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2029 |
for (uint32_t i = 0; i < v->GetNRootExitDirections (); i++) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2030 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2031 |
SPFVertex::NodeExit_t exit = v->GetRootExitDirection (i); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2032 |
Ipv4Address nextHop = exit.first; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2033 |
int32_t outIf = exit.second; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2034 |
if (outIf >= 0) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2035 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2036 |
gr->AddHostRouteTo (lr->GetLinkData (), nextHop, |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2037 |
outIf); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2038 |
NS_LOG_LOGIC ("(Route " << i << ") Node " << node->GetId () << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2039 |
" adding host route to " << lr->GetLinkData () << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2040 |
" using next hop " << nextHop << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2041 |
" and outgoing interface " << outIf); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2042 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2043 |
else |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2044 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2045 |
NS_LOG_LOGIC ("(Route " << i << ") Node " << node->GetId () << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2046 |
" NOT able to add host route to " << lr->GetLinkData () << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2047 |
" using next hop " << nextHop << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2048 |
" since outgoing interface id is negative " << outIf); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2049 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2050 |
} // for all routes from the root the vertex 'v' |
1111 | 2051 |
} |
2052 |
// |
|
2053 |
// Done adding the routes for the selected node. |
|
2054 |
// |
|
2055 |
return; |
|
2056 |
} |
|
2057 |
} |
|
2058 |
} |
|
1278 | 2059 |
void |
2060 |
GlobalRouteManagerImpl::SPFIntraAddTransit (SPFVertex* v) |
|
2061 |
{ |
|
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
2062 |
NS_LOG_FUNCTION (v); |
1278 | 2063 |
|
2064 |
NS_ASSERT_MSG (m_spfroot, |
|
2065 |
"GlobalRouteManagerImpl::SPFIntraAddTransit (): Root pointer not set"); |
|
2066 |
// |
|
2067 |
// The root of the Shortest Path First tree is the router to which we are |
|
2068 |
// going to write the actual routing table entries. The vertex corresponding |
|
2069 |
// to this router has a vertex ID which is the router ID of that node. We're |
|
2070 |
// going to use this ID to discover which node it is that we're actually going |
|
2071 |
// to update. |
|
2072 |
// |
|
2073 |
Ipv4Address routerId = m_spfroot->GetVertexId (); |
|
2074 |
||
1505 | 2075 |
NS_LOG_LOGIC ("Vertex ID = " << routerId); |
1278 | 2076 |
// |
2077 |
// We need to walk the list of nodes looking for the one that has the router |
|
2078 |
// ID corresponding to the root vertex. This is the one we're going to write |
|
2079 |
// the routing information to. |
|
2080 |
// |
|
1302
7dd6ea991e80
use more NodeList::Iterator types
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1301
diff
changeset
|
2081 |
NodeList::Iterator i = NodeList::Begin (); |
4758
0f9bcd407aff
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
Guillaume Seguin <guillaume.seguin@sophia.inria.fr>
parents:
4745
diff
changeset
|
2082 |
NodeList::Iterator listEnd = NodeList::End (); |
0f9bcd407aff
Don't recompute NodeList::End () at every loop in GlobalRouteManagerImpl
Guillaume Seguin <guillaume.seguin@sophia.inria.fr>
parents:
4745
diff
changeset
|
2083 |
for (; i != listEnd; i++) |
1278 | 2084 |
{ |
2085 |
Ptr<Node> node = *i; |
|
2086 |
// |
|
2087 |
// The router ID is accessible through the GlobalRouter interface, so we need |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
2088 |
// to GetObject for that interface. If there's no GlobalRouter interface, |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
2089 |
// the node in question cannot be the router we want, so we continue. |
1278 | 2090 |
// |
2091 |
Ptr<GlobalRouter> rtr = |
|
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2250
diff
changeset
|
2092 |
node->GetObject<GlobalRouter> (); |
1278 | 2093 |
|
2094 |
if (rtr == 0) |
|
2095 |
{ |
|
1505 | 2096 |
NS_LOG_LOGIC ("No GlobalRouter interface on node " << |
2097 |
node->GetId ()); |
|
1278 | 2098 |
continue; |
2099 |
} |
|
2100 |
// |
|
2101 |
// If the router ID of the current node is equal to the router ID of the |
|
2102 |
// root of the SPF tree, then this node is the one for which we need to |
|
2103 |
// write the routing tables. |
|
2104 |
// |
|
1505 | 2105 |
NS_LOG_LOGIC ("Considering router " << rtr->GetRouterId ()); |
1278 | 2106 |
|
2107 |
if (rtr->GetRouterId () == routerId) |
|
2108 |
{ |
|
1505 | 2109 |
NS_LOG_LOGIC ("setting routes for node " << node->GetId ()); |
1278 | 2110 |
// |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
2111 |
// Routing information is updated using the Ipv4 interface. We need to |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
2112 |
// GetObject for that interface. If the node is acting as an IP version 4 |
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
2113 |
// router, it should absolutely have an Ipv4 interface. |
1278 | 2114 |
// |
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2250
diff
changeset
|
2115 |
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> (); |
1278 | 2116 |
NS_ASSERT_MSG (ipv4, |
2117 |
"GlobalRouteManagerImpl::SPFIntraAddTransit (): " |
|
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
2118 |
"GetObject for <Ipv4> interface failed"); |
1278 | 2119 |
// |
2120 |
// Get the Global Router Link State Advertisement from the vertex we're |
|
2121 |
// adding the routes to. The LSA will have a number of attached Global Router |
|
2122 |
// Link Records corresponding to links off of that vertex / node. We're going |
|
2123 |
// to be interested in the records corresponding to point-to-point links. |
|
2124 |
// |
|
2125 |
GlobalRoutingLSA *lsa = v->GetLSA (); |
|
2126 |
NS_ASSERT_MSG (lsa, |
|
2127 |
"GlobalRouteManagerImpl::SPFIntraAddTransit (): " |
|
2128 |
"Expected valid LSA in SPFVertex* v"); |
|
1279
03ab1b7ad2d0
fix optimized build; remove old comment
Tom Henderson <tomh@tomh.org>
parents:
1278
diff
changeset
|
2129 |
Ipv4Mask tempmask = lsa->GetNetworkLSANetworkMask (); |
03ab1b7ad2d0
fix optimized build; remove old comment
Tom Henderson <tomh@tomh.org>
parents:
1278
diff
changeset
|
2130 |
Ipv4Address tempip = lsa->GetLinkStateId (); |
1278 | 2131 |
tempip = tempip.CombineMask (tempmask); |
4616
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
2132 |
Ptr<GlobalRouter> router = node->GetObject<GlobalRouter> (); |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
2133 |
if (router == 0) |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
2134 |
{ |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
2135 |
continue; |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
2136 |
} |
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4560
diff
changeset
|
2137 |
Ptr<Ipv4GlobalRouting> gr = router->GetRoutingProtocol (); |
3959
ec65107df095
Segregate Ipv4GlobalRouting from Ipv4StaticRouting; add API for deleting and recomputing global routes
Tom Henderson <tomh@tomh.org>
parents:
3947
diff
changeset
|
2138 |
NS_ASSERT (gr); |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2139 |
// walk through all available exit directions due to ECMP, |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2140 |
// and add host route for each of the exit direction toward |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2141 |
// the vertex 'v' |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2142 |
for (uint32_t i = 0; i < v->GetNRootExitDirections (); i++) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2143 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2144 |
SPFVertex::NodeExit_t exit = v->GetRootExitDirection (i); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2145 |
Ipv4Address nextHop = exit.first; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2146 |
int32_t outIf = exit.second; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2147 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2148 |
if (outIf >= 0) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2149 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2150 |
gr->AddNetworkRouteTo (tempip, tempmask, nextHop, outIf); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2151 |
NS_LOG_LOGIC ("(Route " << i << ") Node " << node->GetId () << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2152 |
" add network route to " << tempip << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2153 |
" using next hop " << nextHop << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2154 |
" via interface " << outIf); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2155 |
} |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2156 |
else |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2157 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2158 |
NS_LOG_LOGIC ("(Route " << i << ") Node " << node->GetId () << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2159 |
" NOT able to add network route to " << tempip << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2160 |
" using next hop " << nextHop << |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2161 |
" since outgoing interface id is negative " << outIf); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2162 |
} |
4472
e20a31541404
src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents:
4372
diff
changeset
|
2163 |
} |
1278 | 2164 |
} |
2165 |
} |
|
2166 |
} |
|
1111 | 2167 |
|
2168 |
// Derived from quagga ospf_vertex_add_parents () |
|
2169 |
// |
|
2170 |
// This is a somewhat oddly named method (blame quagga). Although you might |
|
2171 |
// expect it to add a parent *to* something, it actually adds a vertex |
|
2172 |
// to the list of children *in* each of its parents. |
|
2173 |
// |
|
2174 |
// Given a pointer to a vertex, it links back to the vertex's parent that it |
|
2175 |
// already has set and adds itself to that vertex's list of children. |
|
2176 |
// |
|
2177 |
void |
|
2178 |
GlobalRouteManagerImpl::SPFVertexAddParent (SPFVertex* v) |
|
2179 |
{ |
|
3946
6a20c485ddb5
document wifi-wired-bridging a little and add aborts if bridged net devices with IP addresses found
Craig Dowell <craigdo@ee.washington.edu>
parents:
3939
diff
changeset
|
2180 |
NS_LOG_FUNCTION (v); |
5858
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2181 |
|
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2182 |
for (uint32_t i=0;;) |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2183 |
{ |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2184 |
SPFVertex* parent; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2185 |
// check if all parents of vertex v |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2186 |
if ((parent = v->GetParent (i++)) == 0) break; |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2187 |
parent->AddChild (v); |
afb51c7f34c2
bug 667: Add equal-cost multipath routing (ECMP) to IPv4 global routing
Wilson Thong <wilsonwk@ee.cityu.edu.hk>
parents:
5324
diff
changeset
|
2188 |
} |
1111 | 2189 |
} |
2190 |
||
2191 |
} // namespace ns3 |
|
2192 |
||
2193 |
||
2194 |
#include "ns3/test.h" |
|
1200
ae6244482a59
fix memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1121
diff
changeset
|
2195 |
#include "ns3/simulator.h" |
5282
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2196 |
#include <stdlib.h> // for rand() |
1111 | 2197 |
|
2198 |
namespace ns3 { |
|
2199 |
||
5282
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2200 |
class GlobalRouteManagerImplTestCase : public TestCase |
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2201 |
{ |
1111 | 2202 |
public: |
5282
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2203 |
GlobalRouteManagerImplTestCase(); |
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2204 |
virtual bool DoRun(void); |
1111 | 2205 |
}; |
2206 |
||
5282
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2207 |
GlobalRouteManagerImplTestCase::GlobalRouteManagerImplTestCase() |
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2208 |
: TestCase("GlobalRouteManagerImplTestCase") |
1111 | 2209 |
{} |
5282
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2210 |
bool |
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2211 |
GlobalRouteManagerImplTestCase::DoRun(void) |
1111 | 2212 |
{ |
2213 |
CandidateQueue candidate; |
|
2214 |
||
2215 |
for (int i = 0; i < 100; ++i) |
|
2216 |
{ |
|
2217 |
SPFVertex *v = new SPFVertex; |
|
2218 |
v->SetDistanceFromRoot (rand () % 100); |
|
2219 |
candidate.Push (v); |
|
2220 |
} |
|
2221 |
||
2222 |
uint32_t lastDistance = 0; |
|
2223 |
||
2224 |
for (int i = 0; i < 100; ++i) |
|
2225 |
{ |
|
2226 |
SPFVertex *v = candidate.Pop (); |
|
2227 |
if (v->GetDistanceFromRoot () < lastDistance) |
|
2228 |
{ |
|
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5282
diff
changeset
|
2229 |
// XXX does nothing. |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5282
diff
changeset
|
2230 |
UpdateErrorStatus (false); |
1111 | 2231 |
} |
2232 |
lastDistance = v->GetDistanceFromRoot (); |
|
2233 |
delete v; |
|
2234 |
v = 0; |
|
2235 |
} |
|
2236 |
||
2237 |
// Build fake link state database; four routers (0-3), 3 point-to-point |
|
2238 |
// links |
|
2239 |
// |
|
2240 |
// n0 |
|
2241 |
// \ link 0 |
|
2242 |
// \ link 2 |
|
2243 |
// n2 -------------------------n3 |
|
2244 |
// / |
|
2245 |
// / link 1 |
|
2246 |
// n1 |
|
2247 |
// |
|
2248 |
// link0: 10.1.1.1/30, 10.1.1.2/30 |
|
2249 |
// link1: 10.1.2.1/30, 10.1.2.2/30 |
|
2250 |
// link2: 10.1.3.1/30, 10.1.3.2/30 |
|
2251 |
// |
|
2252 |
// Router 0 |
|
1278 | 2253 |
GlobalRoutingLinkRecord* lr0 = new GlobalRoutingLinkRecord ( |
2254 |
GlobalRoutingLinkRecord::PointToPoint, |
|
1111 | 2255 |
"0.0.0.2", // router ID 0.0.0.2 |
2256 |
"10.1.1.1", // local ID |
|
2257 |
1); // metric |
|
2258 |
||
1278 | 2259 |
GlobalRoutingLinkRecord* lr1 = new GlobalRoutingLinkRecord ( |
2260 |
GlobalRoutingLinkRecord::StubNetwork, |
|
1111 | 2261 |
"10.1.1.1", |
2262 |
"255.255.255.252", |
|
2263 |
1); |
|
2264 |
||
1278 | 2265 |
GlobalRoutingLSA* lsa0 = new GlobalRoutingLSA (); |
1282 | 2266 |
lsa0->SetLSType (GlobalRoutingLSA::RouterLSA); |
1111 | 2267 |
lsa0->SetLinkStateId ("0.0.0.0"); |
2268 |
lsa0->SetAdvertisingRouter ("0.0.0.0"); |
|
2269 |
lsa0->AddLinkRecord (lr0); |
|
2270 |
lsa0->AddLinkRecord (lr1); |
|
2271 |
||
2272 |
// Router 1 |
|
1278 | 2273 |
GlobalRoutingLinkRecord* lr2 = new GlobalRoutingLinkRecord ( |
2274 |
GlobalRoutingLinkRecord::PointToPoint, |
|
1111 | 2275 |
"0.0.0.2", |
2276 |
"10.1.2.1", |
|
2277 |
1); |
|
2278 |
||
1278 | 2279 |
GlobalRoutingLinkRecord* lr3 = new GlobalRoutingLinkRecord ( |
2280 |
GlobalRoutingLinkRecord::StubNetwork, |
|
1111 | 2281 |
"10.1.2.1", |
2282 |
"255.255.255.252", |
|
2283 |
1); |
|
2284 |
||
1278 | 2285 |
GlobalRoutingLSA* lsa1 = new GlobalRoutingLSA (); |
1282 | 2286 |
lsa1->SetLSType (GlobalRoutingLSA::RouterLSA); |
1111 | 2287 |
lsa1->SetLinkStateId ("0.0.0.1"); |
2288 |
lsa1->SetAdvertisingRouter ("0.0.0.1"); |
|
2289 |
lsa1->AddLinkRecord (lr2); |
|
2290 |
lsa1->AddLinkRecord (lr3); |
|
2291 |
||
2292 |
// Router 2 |
|
1278 | 2293 |
GlobalRoutingLinkRecord* lr4 = new GlobalRoutingLinkRecord ( |
2294 |
GlobalRoutingLinkRecord::PointToPoint, |
|
1111 | 2295 |
"0.0.0.0", |
2296 |
"10.1.1.2", |
|
2297 |
1); |
|
2298 |
||
1278 | 2299 |
GlobalRoutingLinkRecord* lr5 = new GlobalRoutingLinkRecord ( |
2300 |
GlobalRoutingLinkRecord::StubNetwork, |
|
1111 | 2301 |
"10.1.1.2", |
2302 |
"255.255.255.252", |
|
2303 |
1); |
|
2304 |
||
1278 | 2305 |
GlobalRoutingLinkRecord* lr6 = new GlobalRoutingLinkRecord ( |
2306 |
GlobalRoutingLinkRecord::PointToPoint, |
|
1111 | 2307 |
"0.0.0.1", |
2308 |
"10.1.2.2", |
|
2309 |
1); |
|
2310 |
||
1278 | 2311 |
GlobalRoutingLinkRecord* lr7 = new GlobalRoutingLinkRecord ( |
2312 |
GlobalRoutingLinkRecord::StubNetwork, |
|
1111 | 2313 |
"10.1.2.2", |
2314 |
"255.255.255.252", |
|
2315 |
1); |
|
2316 |
||
1278 | 2317 |
GlobalRoutingLinkRecord* lr8 = new GlobalRoutingLinkRecord ( |
2318 |
GlobalRoutingLinkRecord::PointToPoint, |
|
1111 | 2319 |
"0.0.0.3", |
2320 |
"10.1.3.2", |
|
2321 |
1); |
|
2322 |
||
1278 | 2323 |
GlobalRoutingLinkRecord* lr9 = new GlobalRoutingLinkRecord ( |
2324 |
GlobalRoutingLinkRecord::StubNetwork, |
|
1111 | 2325 |
"10.1.3.2", |
2326 |
"255.255.255.252", |
|
2327 |
1); |
|
2328 |
||
1278 | 2329 |
GlobalRoutingLSA* lsa2 = new GlobalRoutingLSA (); |
1282 | 2330 |
lsa2->SetLSType (GlobalRoutingLSA::RouterLSA); |
1111 | 2331 |
lsa2->SetLinkStateId ("0.0.0.2"); |
2332 |
lsa2->SetAdvertisingRouter ("0.0.0.2"); |
|
2333 |
lsa2->AddLinkRecord (lr4); |
|
2334 |
lsa2->AddLinkRecord (lr5); |
|
2335 |
lsa2->AddLinkRecord (lr6); |
|
2336 |
lsa2->AddLinkRecord (lr7); |
|
2337 |
lsa2->AddLinkRecord (lr8); |
|
2338 |
lsa2->AddLinkRecord (lr9); |
|
2339 |
||
2340 |
// Router 3 |
|
1278 | 2341 |
GlobalRoutingLinkRecord* lr10 = new GlobalRoutingLinkRecord ( |
2342 |
GlobalRoutingLinkRecord::PointToPoint, |
|
1111 | 2343 |
"0.0.0.2", |
2344 |
"10.1.2.1", |
|
2345 |
1); |
|
2346 |
||
1278 | 2347 |
GlobalRoutingLinkRecord* lr11 = new GlobalRoutingLinkRecord ( |
2348 |
GlobalRoutingLinkRecord::StubNetwork, |
|
1111 | 2349 |
"10.1.2.1", |
2350 |
"255.255.255.252", |
|
2351 |
1); |
|
2352 |
||
1278 | 2353 |
GlobalRoutingLSA* lsa3 = new GlobalRoutingLSA (); |
1282 | 2354 |
lsa3->SetLSType (GlobalRoutingLSA::RouterLSA); |
1111 | 2355 |
lsa3->SetLinkStateId ("0.0.0.3"); |
2356 |
lsa3->SetAdvertisingRouter ("0.0.0.3"); |
|
2357 |
lsa3->AddLinkRecord (lr10); |
|
2358 |
lsa3->AddLinkRecord (lr11); |
|
2359 |
||
2360 |
// Test the database |
|
2361 |
GlobalRouteManagerLSDB* srmlsdb = new GlobalRouteManagerLSDB (); |
|
2362 |
srmlsdb->Insert (lsa0->GetLinkStateId (), lsa0); |
|
2363 |
srmlsdb->Insert (lsa1->GetLinkStateId (), lsa1); |
|
2364 |
srmlsdb->Insert (lsa2->GetLinkStateId (), lsa2); |
|
2365 |
srmlsdb->Insert (lsa3->GetLinkStateId (), lsa3); |
|
2366 |
NS_ASSERT (lsa2 == srmlsdb->GetLSA (lsa2->GetLinkStateId ())); |
|
2367 |
||
2368 |
// next, calculate routes based on the manually created LSDB |
|
2369 |
GlobalRouteManagerImpl* srm = new GlobalRouteManagerImpl (); |
|
2370 |
srm->DebugUseLsdb (srmlsdb); // manually add in an LSDB |
|
2371 |
// Note-- this will succeed without any nodes in the topology |
|
2372 |
// because the NodeList is empty |
|
2373 |
srm->DebugSPFCalculate (lsa0->GetLinkStateId ()); // node n0 |
|
2374 |
||
1200
ae6244482a59
fix memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1121
diff
changeset
|
2375 |
Simulator::Run (); |
1316
f357c6a2bb37
Provide two new Ipv4 convenience functions: GetIfIndexByIpv4Address() and GetIpv4RouteToDestination (), and align global routing code to use the first function
Tom Henderson <tomh@tomh.org>
parents:
1302
diff
changeset
|
2376 |
|
f357c6a2bb37
Provide two new Ipv4 convenience functions: GetIfIndexByIpv4Address() and GetIpv4RouteToDestination (), and align global routing code to use the first function
Tom Henderson <tomh@tomh.org>
parents:
1302
diff
changeset
|
2377 |
// XXX here we should do some verification of the routes built |
f357c6a2bb37
Provide two new Ipv4 convenience functions: GetIfIndexByIpv4Address() and GetIpv4RouteToDestination (), and align global routing code to use the first function
Tom Henderson <tomh@tomh.org>
parents:
1302
diff
changeset
|
2378 |
|
1200
ae6244482a59
fix memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1121
diff
changeset
|
2379 |
Simulator::Destroy (); |
ae6244482a59
fix memory leak
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1121
diff
changeset
|
2380 |
|
1111 | 2381 |
// This delete clears the srm, which deletes the LSDB, which clears |
2382 |
// all of the LSAs, which each destroys the attached LinkRecords. |
|
2383 |
delete srm; |
|
2384 |
||
5282
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2385 |
// XXX |
5324
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5282
diff
changeset
|
2386 |
// No testing has actually been done other than making sure that this code |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5282
diff
changeset
|
2387 |
// does not crash |
0ba73cdd2a43
Refalgamize test framework to allow multiple test failures
Craig Dowell <craigdo@ee.washington.edu>
parents:
5282
diff
changeset
|
2388 |
return GetErrorStatus (); |
1111 | 2389 |
} |
2390 |
||
5282
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2391 |
|
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2392 |
static class GlobalRouteManagerImplTestSuite : public TestSuite |
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2393 |
{ |
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2394 |
public: |
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2395 |
GlobalRouteManagerImplTestSuite() |
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2396 |
: TestSuite("global-route-manager-impl", UNIT) |
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2397 |
{ |
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2398 |
AddTestCase(new GlobalRouteManagerImplTestCase()); |
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2399 |
} |
2b8d4ebd2254
Bug 675: convert unit tests to new test framework
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4758
diff
changeset
|
2400 |
} g_globalRoutingManagerImplTestSuite; |
1111 | 2401 |
|
2402 |
} // namespace ns3 |