author | Peter D. Barnes, Jr. <barnes26@llnl.gov> |
Wed, 03 Jul 2013 14:43:10 -0700 | |
changeset 9894 | ac4e52a91d5d |
parent 9266 | d26408b17360 |
permissions | -rw-r--r-- |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
2 |
/* |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
3 |
* Copyright 2007 University of Washington |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
4 |
* Copyright (C) 1999, 2000 Kunihiro Ishiguro, Toshiaki Takada |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
5 |
* |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
6 |
* This program is free software; you can redistribute it and/or modify |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
7 |
* it under the terms of the GNU General Public License version 2 as |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
8 |
* published by the Free Software Foundation; |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
9 |
* |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
14 |
* |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
16 |
* along with this program; if not, write to the Free Software |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
17 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
18 |
* |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
19 |
* Authors: Tom Henderson (tomhend@u.washington.edu) |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
20 |
* |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
21 |
* Kunihiro Ishigura, Toshiaki Takada (GNU Zebra) are attributed authors |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
22 |
* of the quagga 0.99.7/src/ospfd/ospf_spf.c code which was ported here |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
23 |
*/ |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
24 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
25 |
#include "ns3/test.h" |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
26 |
#include "ns3/global-route-manager-impl.h" |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
27 |
#include "ns3/candidate-queue.h" |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
28 |
#include "ns3/simulator.h" |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7256
diff
changeset
|
29 |
#include <cstdlib> // for rand() |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
30 |
|
9079
1e5921e6507d
Clean up core, network, internet, point-to-point tests that don't access private class attributes and methods in accordance to sample-test-suite.cc.
Vedran Miletić <rivanvx@gmail.com>
parents:
9063
diff
changeset
|
31 |
using namespace ns3; |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
32 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
33 |
class GlobalRouteManagerImplTestCase : public TestCase |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
34 |
{ |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
35 |
public: |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
36 |
GlobalRouteManagerImplTestCase(); |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7216
diff
changeset
|
37 |
virtual void DoRun (void); |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
38 |
}; |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
39 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
40 |
GlobalRouteManagerImplTestCase::GlobalRouteManagerImplTestCase() |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7216
diff
changeset
|
41 |
: TestCase ("GlobalRouteManagerImplTestCase") |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
42 |
{ |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
43 |
} |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
44 |
void |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7216
diff
changeset
|
45 |
GlobalRouteManagerImplTestCase::DoRun (void) |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
46 |
{ |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
47 |
CandidateQueue candidate; |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
48 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
49 |
for (int i = 0; i < 100; ++i) |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
50 |
{ |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
51 |
SPFVertex *v = new SPFVertex; |
9063
32755d0516f4
Bug 1237 - code cleanups related to includes
Vedran Miletić <rivanvx@gmail.com>
parents:
7256
diff
changeset
|
52 |
v->SetDistanceFromRoot (std::rand () % 100); |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
53 |
candidate.Push (v); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
54 |
} |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
55 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
56 |
for (int i = 0; i < 100; ++i) |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
57 |
{ |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
58 |
SPFVertex *v = candidate.Pop (); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
59 |
delete v; |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
60 |
v = 0; |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
61 |
} |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
62 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
63 |
// Build fake link state database; four routers (0-3), 3 point-to-point |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
64 |
// links |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
65 |
// |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
66 |
// n0 |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
67 |
// \ link 0 |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
68 |
// \ link 2 |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
69 |
// n2 -------------------------n3 |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
70 |
// / |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
71 |
// / link 1 |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
72 |
// n1 |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
73 |
// |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
74 |
// link0: 10.1.1.1/30, 10.1.1.2/30 |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
75 |
// link1: 10.1.2.1/30, 10.1.2.2/30 |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
76 |
// link2: 10.1.3.1/30, 10.1.3.2/30 |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
77 |
// |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
78 |
// Router 0 |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
79 |
GlobalRoutingLinkRecord* lr0 = new GlobalRoutingLinkRecord ( |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
80 |
GlobalRoutingLinkRecord::PointToPoint, |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
81 |
"0.0.0.2", // router ID 0.0.0.2 |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
82 |
"10.1.1.1", // local ID |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
83 |
1); // metric |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
84 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
85 |
GlobalRoutingLinkRecord* lr1 = new GlobalRoutingLinkRecord ( |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
86 |
GlobalRoutingLinkRecord::StubNetwork, |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
87 |
"10.1.1.1", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
88 |
"255.255.255.252", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
89 |
1); |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
90 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
91 |
GlobalRoutingLSA* lsa0 = new GlobalRoutingLSA (); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
92 |
lsa0->SetLSType (GlobalRoutingLSA::RouterLSA); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
93 |
lsa0->SetLinkStateId ("0.0.0.0"); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
94 |
lsa0->SetAdvertisingRouter ("0.0.0.0"); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
95 |
lsa0->AddLinkRecord (lr0); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
96 |
lsa0->AddLinkRecord (lr1); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
97 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
98 |
// Router 1 |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
99 |
GlobalRoutingLinkRecord* lr2 = new GlobalRoutingLinkRecord ( |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
100 |
GlobalRoutingLinkRecord::PointToPoint, |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
101 |
"0.0.0.2", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
102 |
"10.1.2.1", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
103 |
1); |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
104 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
105 |
GlobalRoutingLinkRecord* lr3 = new GlobalRoutingLinkRecord ( |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
106 |
GlobalRoutingLinkRecord::StubNetwork, |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
107 |
"10.1.2.1", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
108 |
"255.255.255.252", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
109 |
1); |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
110 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
111 |
GlobalRoutingLSA* lsa1 = new GlobalRoutingLSA (); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
112 |
lsa1->SetLSType (GlobalRoutingLSA::RouterLSA); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
113 |
lsa1->SetLinkStateId ("0.0.0.1"); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
114 |
lsa1->SetAdvertisingRouter ("0.0.0.1"); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
115 |
lsa1->AddLinkRecord (lr2); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
116 |
lsa1->AddLinkRecord (lr3); |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
117 |
|
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
118 |
// Router 2 |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
119 |
GlobalRoutingLinkRecord* lr4 = new GlobalRoutingLinkRecord ( |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
120 |
GlobalRoutingLinkRecord::PointToPoint, |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
121 |
"0.0.0.0", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
122 |
"10.1.1.2", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
123 |
1); |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
124 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
125 |
GlobalRoutingLinkRecord* lr5 = new GlobalRoutingLinkRecord ( |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
126 |
GlobalRoutingLinkRecord::StubNetwork, |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
127 |
"10.1.1.2", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
128 |
"255.255.255.252", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
129 |
1); |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
130 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
131 |
GlobalRoutingLinkRecord* lr6 = new GlobalRoutingLinkRecord ( |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
132 |
GlobalRoutingLinkRecord::PointToPoint, |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
133 |
"0.0.0.1", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
134 |
"10.1.2.2", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
135 |
1); |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
136 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
137 |
GlobalRoutingLinkRecord* lr7 = new GlobalRoutingLinkRecord ( |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
138 |
GlobalRoutingLinkRecord::StubNetwork, |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
139 |
"10.1.2.2", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
140 |
"255.255.255.252", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
141 |
1); |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
142 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
143 |
GlobalRoutingLinkRecord* lr8 = new GlobalRoutingLinkRecord ( |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
144 |
GlobalRoutingLinkRecord::PointToPoint, |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
145 |
"0.0.0.3", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
146 |
"10.1.3.2", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
147 |
1); |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
148 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
149 |
GlobalRoutingLinkRecord* lr9 = new GlobalRoutingLinkRecord ( |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
150 |
GlobalRoutingLinkRecord::StubNetwork, |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
151 |
"10.1.3.2", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
152 |
"255.255.255.252", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
153 |
1); |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
154 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
155 |
GlobalRoutingLSA* lsa2 = new GlobalRoutingLSA (); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
156 |
lsa2->SetLSType (GlobalRoutingLSA::RouterLSA); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
157 |
lsa2->SetLinkStateId ("0.0.0.2"); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
158 |
lsa2->SetAdvertisingRouter ("0.0.0.2"); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
159 |
lsa2->AddLinkRecord (lr4); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
160 |
lsa2->AddLinkRecord (lr5); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
161 |
lsa2->AddLinkRecord (lr6); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
162 |
lsa2->AddLinkRecord (lr7); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
163 |
lsa2->AddLinkRecord (lr8); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
164 |
lsa2->AddLinkRecord (lr9); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
165 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
166 |
// Router 3 |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
167 |
GlobalRoutingLinkRecord* lr10 = new GlobalRoutingLinkRecord ( |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
168 |
GlobalRoutingLinkRecord::PointToPoint, |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
169 |
"0.0.0.2", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
170 |
"10.1.2.1", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
171 |
1); |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
172 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
173 |
GlobalRoutingLinkRecord* lr11 = new GlobalRoutingLinkRecord ( |
7176
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
174 |
GlobalRoutingLinkRecord::StubNetwork, |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
175 |
"10.1.2.1", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
176 |
"255.255.255.252", |
9f2663992e99
internet coding style changes
Josh Pelkey <jpelkey@gatech.edu>
parents:
7119
diff
changeset
|
177 |
1); |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
178 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
179 |
GlobalRoutingLSA* lsa3 = new GlobalRoutingLSA (); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
180 |
lsa3->SetLSType (GlobalRoutingLSA::RouterLSA); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
181 |
lsa3->SetLinkStateId ("0.0.0.3"); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
182 |
lsa3->SetAdvertisingRouter ("0.0.0.3"); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
183 |
lsa3->AddLinkRecord (lr10); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
184 |
lsa3->AddLinkRecord (lr11); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
185 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
186 |
// Test the database |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
187 |
GlobalRouteManagerLSDB* srmlsdb = new GlobalRouteManagerLSDB (); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
188 |
srmlsdb->Insert (lsa0->GetLinkStateId (), lsa0); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
189 |
srmlsdb->Insert (lsa1->GetLinkStateId (), lsa1); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
190 |
srmlsdb->Insert (lsa2->GetLinkStateId (), lsa2); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
191 |
srmlsdb->Insert (lsa3->GetLinkStateId (), lsa3); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
192 |
NS_ASSERT (lsa2 == srmlsdb->GetLSA (lsa2->GetLinkStateId ())); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
193 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
194 |
// next, calculate routes based on the manually created LSDB |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
195 |
GlobalRouteManagerImpl* srm = new GlobalRouteManagerImpl (); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
196 |
srm->DebugUseLsdb (srmlsdb); // manually add in an LSDB |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
197 |
// Note-- this will succeed without any nodes in the topology |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
198 |
// because the NodeList is empty |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
199 |
srm->DebugSPFCalculate (lsa0->GetLinkStateId ()); // node n0 |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
200 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
201 |
Simulator::Run (); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
202 |
|
9894
ac4e52a91d5d
Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9266
diff
changeset
|
203 |
/// \todo here we should do some verification of the routes built |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
204 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
205 |
Simulator::Destroy (); |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
206 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
207 |
// This delete clears the srm, which deletes the LSDB, which clears |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
208 |
// all of the LSAs, which each destroys the attached LinkRecords. |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
209 |
delete srm; |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
210 |
|
9894
ac4e52a91d5d
Doxygenate todo's
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents:
9266
diff
changeset
|
211 |
/// \todo Testing |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
212 |
// No testing has actually been done other than making sure that this code |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
213 |
// does not crash |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
214 |
} |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
215 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
216 |
|
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
217 |
static class GlobalRouteManagerImplTestSuite : public TestSuite |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
218 |
{ |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
219 |
public: |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
220 |
GlobalRouteManagerImplTestSuite() |
7256
b04ba6772f8c
rerun check-style.py at default level to enforce space after function name
Tom Henderson <tomh@tomh.org>
parents:
7216
diff
changeset
|
221 |
: TestSuite ("global-route-manager-impl", UNIT) |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
222 |
{ |
9266
d26408b17360
bug 1563: get rid of default argument value in AddTestCase
Nicola Baldo <nbaldo@cttc.es>
parents:
9079
diff
changeset
|
223 |
AddTestCase (new GlobalRouteManagerImplTestCase (), TestCase::QUICK); |
6967
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
224 |
} |
51775b082612
Move tests from the internet module to its test library
Mitch Watrous <watrous@u.washington.edu>
parents:
diff
changeset
|
225 |
} g_globalRoutingManagerImplTestSuite; |