A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
global-route-manager-impl-test-suite.cc
Go to the documentation of this file.
1/*
2 * Copyright 2007 University of Washington
3 * Copyright (C) 1999, 2000 Kunihiro Ishiguro, Toshiaki Takada
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Authors: Tom Henderson (tomhend@u.washington.edu)
8 *
9 * Modified By: Shashwat Patni (shashwatpatni25@gmail.com)
10 *
11 * Kunihiro Ishigura, Toshiaki Takada (GNU Zebra) are attributed authors
12 * of the quagga 0.99.7/src/ospfd/ospf_spf.c code which was ported here
13 */
14
15#include "ns3/candidate-queue.h"
16#include "ns3/config.h"
17#include "ns3/global-route-manager-impl.h"
18#include "ns3/global-routing.h"
19#include "ns3/internet-module.h"
20#include "ns3/internet-stack-helper.h"
21#include "ns3/ipv4-global-routing-helper.h"
22#include "ns3/ipv6-global-routing-helper.h"
23#include "ns3/network-module.h"
24#include "ns3/node-container.h"
25#include "ns3/rng-seed-manager.h"
26#include "ns3/simple-net-device-helper.h"
27#include "ns3/simulator.h"
28#include "ns3/test.h"
29
30#include <cstdlib> // for rand()
31using namespace ns3;
32
33NS_LOG_COMPONENT_DEFINE("GlobalRouteManagerImplTestSuite");
34
35//
36// This test suite is designed to check the Working of the GlobalRouteManagerImpl
37// For that reason, the tests in this suite manually build LSAs for each topology
38// we manually call DebugSPFCalculate() to fill routing tables of the node we are interested in.
39//
40// TestCase 1: LinkRoutesTestCase
41// This test case tests that:
42// - GLobalRouteManagerLSDB stores the LSAs with key as the correct link state ID
43// - GlobalRouteManagerImpl checks for stubnodes and computes default routes for them
44// - HostRoutes are computed correctly for point-to-point links
45//
46// TestCase 2: LanRoutesTestCase
47// This test case tests that:
48// - Network LSAs are handled by the GlobalRouteManagerImpl
49// - GlobalRouteManagerImpl computes the routes correctly for a LAN topology
50//
51// TestCase 3: RandomEcmpRoutesTestCase
52// This test case tests that:
53// - GlobalRouteManagerImpl computes ECMP routes correctly.
54// - Those random routes are in fact used by the GlobalRouting protocol
55//
56
57/**
58 * @ingroup internet
59 * @ingroup tests
60 * @defgroup internet-test internet module tests
61 */
62
63/**
64 * @ingroup internet-test
65 *
66 * @brief Global Route Manager Test
67 */
69{
70 public:
72 void DoSetup() override;
73 void DoRun() override;
74
75 private:
76 /**
77 *@brief Builds the LSAs for the topology. These LSAs are manually created and inserted into the
78 * GlobalRouteManagerLSDB.Each node exports a router LSA.
79 */
80 void BuildLsav4();
81
82 /**
83 *@brief Builds the LSAs for the topology. These LSAs are manually created and inserted into the
84 * GlobalRouteManagerLSDB.Each node exports a router LSA.
85 */
86 void BuildLsav6();
87
88 /**
89 * @brief Checks the Routing Table Entries for the expected output.
90 * @param globalroutingprotocol The routing protocol for the node whose routing table is to be
91 * checked.
92 * @param dests The expected destinations.
93 * @param gws The expected gateways.
94 */
95 void CheckRoutesv4(Ptr<Ipv4GlobalRouting>& globalroutingprotocol,
96 std::vector<Ipv4Address>& dests,
97 std::vector<Ipv4Address>& gws);
98
99 /**
100 * @brief Checks the Routing Table Entries for the expected output.
101 * @param globalroutingprotocol The routing protocol for the node whose routing table is to be
102 * checked.
103 * @param dests The expected destinations.
104 * @param gws The expected gateways.
105 */
106 void CheckRoutesv6(Ptr<Ipv6GlobalRouting>& globalroutingprotocol,
107 std::vector<Ipv6Address>& dests,
108 std::vector<Ipv6Address>& gws);
109
110 NodeContainer nodes; //!< NodeContainer to hold the nodes in the topology
111 std::vector<GlobalRoutingLSA<Ipv4Manager>*> m_lsasv4; //!< The LSAs for the topology
112 std::vector<GlobalRoutingLSA<Ipv6Manager>*> m_lsasv6; //!< The LSAs for the topology
113};
114
116 : TestCase("LinkRoutesTestCase")
117{
118}
119
120void
122 std::vector<Ipv4Address>& dests,
123 std::vector<Ipv4Address>& gws)
124{
125 // check each individual Routing Table Entry for its destination and gateway
126 for (uint32_t i = 0; i < globalroutingprotocol->GetNRoutes(); i++)
127 {
128 Ipv4RoutingTableEntry* route = globalroutingprotocol->GetRoute(i);
129 NS_LOG_DEBUG("dest " << route->GetDest() << " gw " << route->GetGateway());
130 NS_TEST_ASSERT_MSG_EQ(route->GetDest(), dests[i], "Error-- wrong destination");
131 NS_TEST_ASSERT_MSG_EQ(route->GetGateway(), gws[i], "Error-- wrong gateway");
132 }
133}
134
135void
137 std::vector<Ipv6Address>& dests,
138 std::vector<Ipv6Address>& gws)
139{
140 // check each individual Routing Table Entry for its destination and gateway
141 for (uint32_t i = 0; i < globalroutingprotocol->GetNRoutes(); i++)
142 {
143 Ipv6RoutingTableEntry* route = globalroutingprotocol->GetRoute(i);
144 NS_LOG_DEBUG("dest " << route->GetDest() << " gw " << route->GetGateway());
145 NS_TEST_ASSERT_MSG_EQ(route->GetDest(), dests[i], "Error-- wrong destination");
146 NS_TEST_ASSERT_MSG_EQ(route->GetGateway(), gws[i], "Error-- wrong gateway");
147 }
148}
149
150void
152{
153 // Simple p2p links. n0,n1 and n3 are stub nodes
154 //
155 //
156 // n0
157 // \ link 0
158 // \ link 2
159 // n2 -------------------------n3
160 // /
161 // / link 1
162 // n1
163 //
164 // link0: n0->10.1.1.1/30, n2-> 10.1.1.2/30
165 // link1: n1-> 10.1.2.1/30, n2->10.1.2.2/30
166 // link2: n2->10.1.3.1/30, n3-> 10.1.3.2/30
167 //
168 //
169 //
170
171 nodes.Create(4);
172
173 Ipv4GlobalRoutingHelper globalhelperv4;
174 Ipv6GlobalRoutingHelper globalhelperv6;
176 stack.SetRoutingHelper(globalhelperv4);
177 stack.SetRoutingHelper(globalhelperv6);
178 stack.Install(nodes);
179
180 SimpleNetDeviceHelper devHelper;
181 devHelper.SetNetDevicePointToPointMode(true);
183 NetDeviceContainer d02 = devHelper.Install(nodes.Get(0), channel1);
184 d02.Add(devHelper.Install(nodes.Get(2), channel1));
186 NetDeviceContainer d12 = devHelper.Install(nodes.Get(1), channel2);
187 d12.Add(devHelper.Install(nodes.Get(2), channel2));
189 NetDeviceContainer d23 = devHelper.Install(nodes.Get(2), channel3);
190 d23.Add(devHelper.Install(nodes.Get(3), channel3));
191
192 // Assign IP addresses to the devices
193 Ipv4AddressHelper address;
194 address.SetBase("10.1.1.0", "255.255.255.252");
195 Ipv4InterfaceContainer i02 = address.Assign(d02);
196 address.SetBase("10.1.2.0", "255.255.255.252");
197 Ipv4InterfaceContainer i12 = address.Assign(d12);
198 address.SetBase("10.1.3.0", "255.255.255.252");
199 Ipv4InterfaceContainer i23 = address.Assign(d23);
200
201 Ipv6AddressHelper addressv6;
202 addressv6.SetBase("2001:1::", Ipv6Prefix(64));
203 Ipv6InterfaceContainer i02v6 = addressv6.Assign(d02);
204 addressv6.SetBase("2001:2::", Ipv6Prefix(64));
205 Ipv6InterfaceContainer i12v6 = addressv6.Assign(d12);
206 addressv6.SetBase("2001:3::", Ipv6Prefix(64));
207 Ipv6InterfaceContainer i23v6 = addressv6.Assign(d23);
208}
209
210void
212{
213 // Manually build the link state database; four routers (0-3), 3 point-to-point
214 // links
215
216 // Router 0
219 "0.0.0.2", // link id -> router ID 0.0.0.2
220 "10.1.1.1", // link data -> Local IP address of router 0
221 1); // metric
222
225 "10.1.1.2", // link id ->adjacent neighbor's IP address
226 "255.255.255.252",
227 1);
228
229 auto lsa0 = new GlobalRoutingLSA<Ipv4Manager>();
231 lsa0->SetLinkStateId("0.0.0.0");
232 lsa0->SetAdvertisingRouter("0.0.0.0");
233 lsa0->SetNode(nodes.Get(0));
234 lsa0->AddLinkRecord(lr0);
235 lsa0->AddLinkRecord(lr1);
236 m_lsasv4.push_back(lsa0);
237
238 // Router 1
239 auto lr2 =
241 "0.0.0.2",
242 "10.1.2.1",
243 1);
244
245 auto lr3 =
247 "10.1.2.2",
248 "255.255.255.252",
249 1);
250
251 auto lsa1 = new GlobalRoutingLSA<Ipv4Manager>();
253 lsa1->SetLinkStateId("0.0.0.1");
254 lsa1->SetAdvertisingRouter("0.0.0.1");
255 lsa1->AddLinkRecord(lr2);
256 lsa1->AddLinkRecord(lr3);
257 lsa1->SetNode(nodes.Get(1));
258 m_lsasv4.push_back(lsa1);
259
260 // Router 2
261 auto lr4 =
263 "0.0.0.0",
264 "10.1.1.2",
265 1);
266
267 auto lr5 =
269 "10.1.1.1",
270 "255.255.255.252",
271 1);
272
273 auto lr6 =
275 "0.0.0.1",
276 "10.1.2.2",
277 1);
278
279 auto lr7 =
281 "10.1.2.2",
282 "255.255.255.252",
283 1);
284
285 auto lr8 =
287 "0.0.0.3",
288 "10.1.3.1",
289 1);
290
291 auto lr9 =
293 "10.1.3.2",
294 "255.255.255.252",
295 1);
296
297 auto lsa2 = new GlobalRoutingLSA<Ipv4Manager>();
299 lsa2->SetLinkStateId("0.0.0.2");
300 lsa2->SetAdvertisingRouter("0.0.0.2");
301 lsa2->AddLinkRecord(lr4);
302 lsa2->AddLinkRecord(lr5);
303 lsa2->AddLinkRecord(lr6);
304 lsa2->AddLinkRecord(lr7);
305 lsa2->AddLinkRecord(lr8);
306 lsa2->AddLinkRecord(lr9);
307 lsa2->SetNode(nodes.Get(2));
308 m_lsasv4.push_back(lsa2);
309
310 // Router 3
311 auto lr10 =
313 "0.0.0.2",
314 "10.1.3.2",
315 1);
316
317 auto lr11 =
319 "10.1.3.1",
320 "255.255.255.252",
321 1);
322
323 auto lsa3 = new GlobalRoutingLSA<Ipv4Manager>();
325 lsa3->SetLinkStateId("0.0.0.3");
326 lsa3->SetAdvertisingRouter("0.0.0.3");
327 lsa3->AddLinkRecord(lr10);
328 lsa3->AddLinkRecord(lr11);
329 lsa3->SetNode(nodes.Get(3));
330 m_lsasv4.push_back(lsa3);
331}
332
333void
335{
336 // Manually build the link state database; four routers (0-3), 3 point-to-point
337 // links
338
339 // Router 0
342 "::ffff:0.0.0.2", // link id -> router ID 0.0.0.2
343 "2001:1::200:ff:fe00:1", // link data -> Local GlobalUnicast IP address of router 0
344 "fe80::200:ff:fe00:1", // Local Link Local IP address of router 0
345 1); // metric
346
347 // only need to do this once for prefix of 64 bits
348 uint8_t buf[16];
349 auto prefix = Ipv6Prefix(64);
350 prefix.GetBytes(buf); // frown
351
354 "2001:1::200:ff:fe00:2", // link id ->adjacent neighbor's IP address
355 Ipv6Address(buf), // Link Data -> Prefix converted to Ipv6Address associated with neighbours
356 // Ip address
357 1);
358
359 auto lsa0 = new GlobalRoutingLSA<Ipv6Manager>();
361 lsa0->SetLinkStateId("::ffff:0.0.0.0");
362 lsa0->SetAdvertisingRouter("::ffff:0.0.0.0");
363 lsa0->SetNode(nodes.Get(0));
364 lsa0->AddLinkRecord(lr0);
365 lsa0->AddLinkRecord(lr1);
366 m_lsasv6.push_back(lsa0);
367
368 // Router 1
371 "::ffff:0.0.0.2", // link id -> router ID
372 "2001:2::200:ff:fe00:3", // link data -> Local Global Unicast IP address of router 1
373 "fe80::200:ff:fe00:3", // link loc data -> Local Link Local IP address of router 1
374 1);
375
378 "2001:2::200:ff:fe00:4", // link id ->adjacent neighbor's IP address
379 Ipv6Address(buf), // Link Data -> Prefix converted to Ipv6Address associated with neighbours
380 // Ip address
381 1);
382
383 auto lsa1 = new GlobalRoutingLSA<Ipv6Manager>();
385 lsa1->SetLinkStateId("::ffff:0.0.0.1");
386 lsa1->SetAdvertisingRouter("::ffff:0.0.0.1");
387 lsa1->AddLinkRecord(lr2);
388 lsa1->AddLinkRecord(lr3);
389 lsa1->SetNode(nodes.Get(1));
390 m_lsasv6.push_back(lsa1);
391
392 // Router 2
395 "::ffff:0.0.0.0", // link id -> router ID
396 "2001:1::200:ff:fe00:2", // link data -> Local Global Unicast IP address of router 2
397 "fe80::200:ff:fe00:2", // link loc data -> Local Link Local IP address of router 2
398 1);
399
402 "2001:1::200:ff:fe00:1", // link id ->adjacent neighbor's IP address
403 Ipv6Address(buf), // Link Data -> Prefix converted to Ipv6Address associated with neighbours
404 // Ip address
405 1);
406
407 auto lr6 =
409 "::ffff:0.0.0.1",
410 "2001:2::200:ff:fe00:4",
411 "fe80::200:ff:fe00:4",
412 1);
413
414 auto lr7 =
416 "2001:2::200:ff:fe00:3",
417 Ipv6Address(buf),
418 1);
419
420 auto lr8 =
422 "::ffff:0.0.0.3",
423 "2001:3::200:ff:fe00:5",
424 "fe80::200:ff:fe00:5",
425 1);
426
427 auto lr9 =
429 "2001:3::200:ff:fe00:6",
430 Ipv6Address(buf),
431 1);
432
433 auto lsa2 = new GlobalRoutingLSA<Ipv6Manager>();
435 lsa2->SetLinkStateId("::ffff:0.0.0.2");
436 lsa2->SetAdvertisingRouter("::ffff:0.0.0.2");
437 lsa2->AddLinkRecord(lr4);
438 lsa2->AddLinkRecord(lr5);
439 lsa2->AddLinkRecord(lr6);
440 lsa2->AddLinkRecord(lr7);
441 lsa2->AddLinkRecord(lr8);
442 lsa2->AddLinkRecord(lr9);
443 lsa2->SetNode(nodes.Get(2));
444 m_lsasv6.push_back(lsa2);
445
446 // Router 3
447 auto lr10 =
449 "::ffff:0.0.0.2",
450 "2001:3::200:ff:fe00:6",
451 "fe80::200:ff:fe00:6",
452 1);
453
454 auto lr11 =
456 "2001:3::200:ff:fe00:5",
457 Ipv6Address(buf),
458 1);
459
460 auto lsa3 = new GlobalRoutingLSA<Ipv6Manager>();
462 lsa3->SetLinkStateId("::ffff:0.0.0.3");
463 lsa3->SetAdvertisingRouter("::ffff:0.0.0.3");
464 lsa3->AddLinkRecord(lr10);
465 lsa3->AddLinkRecord(lr11);
466 lsa3->SetNode(nodes.Get(3));
467 m_lsasv6.push_back(lsa3);
468}
469
470void
472{
473 // This test is for checking the individual working of GlobalRouteManagerImpl
474 // and GlobalRouteManagerLSDB, so we will not use the GlobalRoutingHelper
475 // to create the routing tables, but instead we will manually create the LSAs
476 // and insert them into the GlobalRouteManagerLSDB, and then use the
477 // GlobalRouteManagerImpl to calculate the routes based on the LSDB.
478 // This is a manual setup of the LSAs, which would normally be done by the
479 // GlobalRoutingHelper.
480
481 BuildLsav4();
482
483 // Test the database
484 auto srmlsdb = new GlobalRouteManagerLSDB<Ipv4Manager>();
485 srmlsdb->Insert(m_lsasv4[0]->GetLinkStateId(), m_lsasv4[0]);
486 srmlsdb->Insert(m_lsasv4[1]->GetLinkStateId(), m_lsasv4[1]);
487 srmlsdb->Insert(m_lsasv4[2]->GetLinkStateId(), m_lsasv4[2]);
488 srmlsdb->Insert(m_lsasv4[3]->GetLinkStateId(), m_lsasv4[3]);
489
491 m_lsasv4[2],
492 srmlsdb->GetLSA(m_lsasv4[2]->GetLinkStateId()),
493 "The Ipv4Address is not stored as the link state ID"); // LSAs are mapped by router id as
494 // key here we check that they are
495 // indeed getting the right lsa for
496 // the right key
497
498 // next, calculate routes based on the manually created LSDB
500 srm->DebugUseLsdb(srmlsdb); // manually add in an LSDB
501
502 srm->DebugSPFCalculate(m_lsasv4[0]->GetLinkStateId()); // fill routing table for node n0
503
504 srm->DebugSPFCalculate(m_lsasv4[1]->GetLinkStateId()); // fill routing table for node n1
505
506 srm->DebugSPFCalculate(m_lsasv4[2]->GetLinkStateId()); // fill routing table for node n2
507
508 srm->DebugSPFCalculate(m_lsasv4[3]->GetLinkStateId()); // fill routing table for node n3
509
510 BuildLsav6();
511
512 // Test the database
513 auto srmlsdbv6 = new GlobalRouteManagerLSDB<Ipv6Manager>();
514 srmlsdbv6->Insert(m_lsasv6[0]->GetLinkStateId(), m_lsasv6[0]);
515 srmlsdbv6->Insert(m_lsasv6[1]->GetLinkStateId(), m_lsasv6[1]);
516 srmlsdbv6->Insert(m_lsasv6[2]->GetLinkStateId(), m_lsasv6[2]);
517 srmlsdbv6->Insert(m_lsasv6[3]->GetLinkStateId(), m_lsasv6[3]);
518
520 m_lsasv6[2],
521 srmlsdbv6->GetLSA(m_lsasv6[2]->GetLinkStateId()),
522 "The Ipv6Address is not stored as the link state ID"); // LSAs are mapped by router id as
523 // key here we check that they are
524 // indeed getting the right lsa for
525 // the right key
526
527 // next, calculate routes based on the manually created LSDB
528 auto srmv6 = new GlobalRouteManagerImpl<Ipv6Manager>();
529 srmv6->DebugUseLsdb(srmlsdbv6); // manually add in an LSDB
530
531 srmv6->DebugSPFCalculate(m_lsasv6[0]->GetLinkStateId()); // fill ipv6 routing table for node n0
532
533 srmv6->DebugSPFCalculate(m_lsasv6[1]->GetLinkStateId()); // fill ipv6 routing table for node n1
534
535 srmv6->DebugSPFCalculate(m_lsasv6[2]->GetLinkStateId()); // fill ipv6 routing table for node n2
536
537 srmv6->DebugSPFCalculate(m_lsasv6[3]->GetLinkStateId()); // fill ipv6 routing table for node n3
538
539 //-----------------Now the tests for Ipv4------------------
540 // Test 1: Check if the SPF calculate Sets default routes for Stub nodes
541 Ptr<Ipv4L3Protocol> ip0 = nodes.Get(0)->GetObject<Ipv4L3Protocol>();
542 NS_TEST_ASSERT_MSG_NE(ip0, nullptr, "Error-- no Ipv4 object at node 0");
543 Ptr<Ipv4RoutingProtocol> routing0 = ip0->GetRoutingProtocol();
544 NS_TEST_ASSERT_MSG_NE(routing0, nullptr, "Error-- no Ipv4 routing protocol object at node 0");
545 Ptr<Ipv4GlobalRouting> globalRouting0 = routing0->GetObject<Ipv4GlobalRouting>();
546 NS_TEST_ASSERT_MSG_NE(globalRouting0, nullptr, "Error-- no Ipv4GlobalRouting object at node 0");
547
548 // Check that the right number of entries are in the routing table
549 uint32_t nRoutes0 = globalRouting0->GetNRoutes();
550 NS_TEST_ASSERT_MSG_EQ(nRoutes0, 1, "Error-- default route not found for stub node");
551
552 Ipv4RoutingTableEntry* route = nullptr;
553 route = globalRouting0->GetRoute(0);
554 // the only route is the default route on this node
556 Ipv4Address("0.0.0.0"),
557 "Error-- wrong destination for default route");
558 NS_TEST_ASSERT_MSG_EQ(route->GetGateway(), Ipv4Address("10.1.1.2"), "Error-- wrong gateway");
559
560 // Test 2: Check if SPFCalculate sets the correct routes for node 2
561 Ptr<Ipv4L3Protocol> ip2 = nodes.Get(2)->GetObject<Ipv4L3Protocol>();
562 NS_TEST_ASSERT_MSG_NE(ip2, nullptr, "Error-- no Ipv4 object at node 2");
563 Ptr<Ipv4RoutingProtocol> routing2 = ip2->GetRoutingProtocol();
564 NS_TEST_ASSERT_MSG_NE(routing2, nullptr, "Error-- no Ipv4 routing protocol object at node 2");
565 Ptr<Ipv4GlobalRouting> globalRouting2 = routing2->GetObject<Ipv4GlobalRouting>();
566 NS_TEST_ASSERT_MSG_NE(globalRouting2, nullptr, "Error-- no Ipv4GlobalRouting object at node 2");
567
568 // check that the correct number of routes were built
569 uint32_t nRoutes2 = globalRouting2->GetNRoutes();
570 NS_LOG_DEBUG("LinkRoutesTest nRoutes2 " << nRoutes2);
571 NS_TEST_ASSERT_MSG_EQ(nRoutes2, 6, "Error--- Incorrect number of routes found on node 2");
572
573 // check that all the routes in the routing table are correct for node 2
574 std::vector<Ipv4Address> expecteddests;
575 std::vector<Ipv4Address> expectedgws;
576 expecteddests.emplace_back("10.1.1.1");
577 expecteddests.emplace_back("10.1.2.1");
578 expecteddests.emplace_back("10.1.3.2");
579 expecteddests.emplace_back("10.1.1.0");
580 expecteddests.emplace_back("10.1.2.0");
581 expecteddests.emplace_back("10.1.3.0");
582
583 expectedgws.emplace_back("10.1.1.1");
584 expectedgws.emplace_back("10.1.2.1");
585 expectedgws.emplace_back("10.1.3.2");
586 expectedgws.emplace_back("10.1.1.1");
587 expectedgws.emplace_back("10.1.2.1");
588 expectedgws.emplace_back("10.1.3.2");
589
590 CheckRoutesv4(globalRouting2, expecteddests, expectedgws);
591
592 //-----------------Now the tests for Ipv6------------------
593 // Test 1: Check if the SPF calculate Sets default routes for Stub nodes
594 Ptr<Ipv6L3Protocol> ip0v6 = nodes.Get(0)->GetObject<Ipv6L3Protocol>();
595 NS_TEST_ASSERT_MSG_NE(ip0v6, nullptr, "Error-- no Ipv6 object at node 0");
596 Ptr<Ipv6RoutingProtocol> routing0v6 = ip0v6->GetRoutingProtocol();
597 NS_TEST_ASSERT_MSG_NE(routing0v6, nullptr, "Error-- no Ipv6 routing protocol object at node 0");
598 Ptr<Ipv6GlobalRouting> globalRouting0v6 = routing0v6->GetObject<Ipv6GlobalRouting>();
599 NS_TEST_ASSERT_MSG_NE(globalRouting0v6,
600 nullptr,
601 "Error-- no Ipv6GlobalRouting object at node 0");
602
603 // Check that the right number of entries are in the routing table
604 uint32_t nRoutes0v6 = globalRouting0v6->GetNRoutes();
605 NS_TEST_ASSERT_MSG_EQ(nRoutes0v6, 1, "Error-- default route not found for stub node");
606
607 Ipv6RoutingTableEntry* routev6 = nullptr;
608 routev6 = globalRouting0v6->GetRoute(0);
609 // the only route is the default route on this node
611 Ipv6Address("::"),
612 "Error-- wrong destination for default route");
614 Ipv6Address("fe80::200:ff:fe00:2"),
615 "Error-- wrong gateway");
616
617 // Test 2: Check if SPFCalculate sets the correct routes for node 2
618 Ptr<Ipv6L3Protocol> ip2v6 = nodes.Get(2)->GetObject<Ipv6L3Protocol>();
619 NS_TEST_ASSERT_MSG_NE(ip2v6, nullptr, "Error-- no Ipv6 object at node 2");
620 Ptr<Ipv6RoutingProtocol> routing2v6 = ip2v6->GetRoutingProtocol();
621 NS_TEST_ASSERT_MSG_NE(routing2v6, nullptr, "Error-- no Ipv6 routing protocol object at node 2");
622 Ptr<Ipv6GlobalRouting> globalRouting2v6 = routing2v6->GetObject<Ipv6GlobalRouting>();
623 NS_TEST_ASSERT_MSG_NE(globalRouting2v6,
624 nullptr,
625 "Error-- no Ipv6GlobalRouting object at node 2");
626
627 // check that the correct number of routes were built
628 uint32_t nRoutes2v6 = globalRouting2v6->GetNRoutes();
629 NS_LOG_DEBUG("LinkRoutesTest nRoutes2 " << nRoutes2v6);
630 NS_TEST_ASSERT_MSG_EQ(nRoutes2v6, 6, "Error--- Incorrect number of routes found on node 2");
631
632 // check that all the routes in the routing table are correct for node 2
633 std::vector<Ipv6Address> expecteddestsv6;
634 std::vector<Ipv6Address> expectedgwsv6;
635 expecteddestsv6.emplace_back("2001:1::200:ff:fe00:1");
636 expecteddestsv6.emplace_back("2001:2::200:ff:fe00:3");
637 expecteddestsv6.emplace_back("2001:3::200:ff:fe00:6");
638 expecteddestsv6.emplace_back("2001:1::");
639 expecteddestsv6.emplace_back("2001:2::");
640 expecteddestsv6.emplace_back("2001:3::");
641
642 expectedgwsv6.emplace_back("fe80::200:ff:fe00:1");
643 expectedgwsv6.emplace_back("fe80::200:ff:fe00:3");
644 expectedgwsv6.emplace_back("fe80::200:ff:fe00:6");
645 expectedgwsv6.emplace_back("fe80::200:ff:fe00:1");
646 expectedgwsv6.emplace_back("fe80::200:ff:fe00:3");
647 expectedgwsv6.emplace_back("fe80::200:ff:fe00:6");
648
649 CheckRoutesv6(globalRouting2v6, expecteddestsv6, expectedgwsv6);
650
652
655
656 // This delete clears the srm, which deletes the LSDB, which clears
657 // all of the LSAs, which each destroys the attached LinkRecords.
658 delete srm;
659 delete srmv6;
660 // reset the router ID counter to zero so that it does not affect other tests
661 // that may run after this one in the same program run.
664}
665
666/**
667 * @ingroup internet-test
668 *
669 * @brief This test case is to check if NetworkRoutes are being built correctly, i.e if route
670 * computation works for a LAN Topology.
671 */
673{
674 public:
676 void DoSetup() override;
677 void DoRun() override;
678
679 private:
680 /**
681 *@brief Builds the ipv4 LSAs for the topology. These LSAs are manually created and inserted
682 *into the GlobalRouteManagerLSDB.Each node exports a router LSA. In addition,the designated
683 *router also Exports the Network LSA.
684 */
685 void BuildLsav4();
686
687 /**
688 *@brief Builds the ipv6 LSAs for the topology. These LSAs are manually created and inserted
689 *into the GlobalRouteManagerLSDB.Each node exports a router LSA. In addition,the designated
690 *router also Exports the Network LSA.
691 */
692 void BuildLsav6();
693
694 NodeContainer nodes; //!< NodeContainer to hold the nodes in the topology
695 std::vector<GlobalRoutingLSA<Ipv4Manager>*> m_lsasv4; //!< The ipv4 LSAs for the topology
696 std::vector<GlobalRoutingLSA<Ipv6Manager>*> m_lsasv6; //!< The ipv6 LSAs for the topology
697};
698
700 : TestCase("LanRoutesTestCase")
701{
702}
703
704void
706{
707 // Simple Csma Network with three nodes
708 //
709 // n0 n1
710 // | (shared csma/cd) |
711 // -------------------------
712 // |
713 // n2
714 //
715 // n0:10.1.1.1/29
716 // n1:10.1.1.2/29
717 // n2:10.1.1.3/29
718 nodes.Create(3);
719 Ipv4GlobalRoutingHelper globalhelperv4;
720 Ipv6GlobalRoutingHelper globalhelperv6;
722 stack.SetRoutingHelper(globalhelperv4);
723 stack.SetRoutingHelper(globalhelperv6);
724 stack.Install(nodes);
725 SimpleNetDeviceHelper devHelper;
727 NetDeviceContainer d012 = devHelper.Install(nodes.Get(0), channel);
728 d012.Add(devHelper.Install(nodes.Get(1), channel));
729 d012.Add(devHelper.Install(nodes.Get(2), channel));
730
731 // assign IP addresses to the devices
732 Ipv4AddressHelper address;
733 address.SetBase("10.1.1.0", "255.255.255.248");
734 Ipv4InterfaceContainer i012 = address.Assign(d012);
735
736 Ipv6AddressHelper addressv6;
737 addressv6.SetBase("2001:1::", Ipv6Prefix(64));
738 Ipv6InterfaceContainer i012v6 = addressv6.Assign(d012);
739}
740
741void
743{
744 // we manually create the link state database, we could have used BuildRoutingTables() but this
745 // way testing the GlobalRouteManagerImpl without the involvement of GLobalRouter makes it
746 // easier to debug each individually
747
748 // router 0
751 "10.1.1.1",
752 "10.1.1.1",
753 1);
754 auto lsa0 = new GlobalRoutingLSA<Ipv4Manager>();
756 lsa0->AddLinkRecord(lr0);
757 lsa0->SetLinkStateId("0.0.0.0");
758 lsa0->SetAdvertisingRouter("0.0.0.0");
759 lsa0->SetNode(nodes.Get(0));
760 m_lsasv4.push_back(lsa0);
761
762 // router 1
765 "10.1.1.1",
766 "10.1.1.2",
767 1);
768 auto lsa1 = new GlobalRoutingLSA<Ipv4Manager>();
770 lsa1->AddLinkRecord(lr1);
771 lsa1->SetLinkStateId("0.0.0.1");
772 lsa1->SetAdvertisingRouter("0.0.0.1");
773 lsa1->SetNode(nodes.Get(1));
774 m_lsasv4.push_back(lsa1);
775
776 // router 2
779 "10.1.1.1",
780 "10.1.1.3",
781 1);
782 auto lsa2 = new GlobalRoutingLSA<Ipv4Manager>();
784 lsa2->AddLinkRecord(lr2);
785 lsa2->SetLinkStateId("0.0.0.2");
786 lsa2->SetAdvertisingRouter("0.0.0.2");
787 lsa2->SetNode(nodes.Get(2));
788 m_lsasv4.push_back(lsa2);
789
790 // router0 is the designated router for the LAN. it also exports the network LSA
791 auto lsa0network = new GlobalRoutingLSA<Ipv4Manager>();
792 lsa0network->SetLSType(GlobalRoutingLSA<Ipv4Manager>::NetworkLSA);
793 lsa0network->SetLinkStateId("10.1.1.1");
794 lsa0network->SetAdvertisingRouter("0.0.0.0");
795 lsa0network->AddAttachedRouter("10.1.1.1");
796 lsa0network->AddAttachedRouter("10.1.1.2");
797 lsa0network->AddAttachedRouter("10.1.1.3");
798 lsa0network->SetNetworkLSANetworkMask("255.255.255.248");
799 m_lsasv4.push_back(lsa0network); // note the index of the network lsa
800}
801
802void
804{
805 // we manually create the link state database, we could have used BuildRoutingTables() but this
806 // way testing the GlobalRouteManagerImpl without the involvement of GLobalRouter makes it
807 // easier to debug each individually
808
809 // router 0
812 "2001:1::200:ff:fe00:1", // link id -> Link ID is the ip address of the designated router
813 "2001:1::200:ff:fe00:1", // link data is this routers own Global Unicast ip address
814 "fe80::200:ff:fe00:1", // the link local data is the link local address of this router for
815 // this link
816 1);
817 auto lsa0 = new GlobalRoutingLSA<Ipv6Manager>();
819 lsa0->AddLinkRecord(lr0);
820 lsa0->SetLinkStateId("::ffff:0.0.0.0");
821 lsa0->SetAdvertisingRouter("::ffff:0.0.0.0");
822 lsa0->SetNode(nodes.Get(0));
823 m_lsasv6.push_back(lsa0);
824
825 // router 1
828 "2001:1::200:ff:fe00:1", // link id -> Link ID is the ip address of the designated router
829 "2001:1::200:ff:fe00:2", // link data is this routers own Global Unicast ip address
830 "fe80::200:ff:fe00:2", // the link local data is the link local address of this router for
831 // this link
832 1);
833 auto lsa1 = new GlobalRoutingLSA<Ipv6Manager>();
835 lsa1->AddLinkRecord(lr1);
836 lsa1->SetLinkStateId("::ffff:0.0.0.1");
837 lsa1->SetAdvertisingRouter("::ffff:0.0.0.1");
838 lsa1->SetNode(nodes.Get(1));
839 m_lsasv6.push_back(lsa1);
840
841 // router 2
844 "2001:1::200:ff:fe00:1",
845 "2001:1::200:ff:fe00:3",
846 "fe80::200:ff:fe00:3",
847 1);
848 auto lsa2 = new GlobalRoutingLSA<Ipv6Manager>();
850 lsa2->AddLinkRecord(lr2);
851 lsa2->SetLinkStateId("::ffff:0.0.0.2");
852 lsa2->SetAdvertisingRouter("::ffff:0.0.0.2");
853 lsa2->SetNode(nodes.Get(2));
854 m_lsasv6.push_back(lsa2);
855
856 // router0 is the designated router for the LAN. it also exports the network LSA
857 auto lsa0network = new GlobalRoutingLSA<Ipv6Manager>();
858 lsa0network->SetLSType(GlobalRoutingLSA<Ipv6Manager>::NetworkLSA);
859 lsa0network->SetLinkStateId("2001:1::200:ff:fe00:1");
860 lsa0network->SetAdvertisingRouter("::ffff:0.0.0.0");
861 lsa0network->AddAttachedRouter("2001:1::200:ff:fe00:1");
862 lsa0network->AddAttachedRouter("2001:1::200:ff:fe00:2");
863 lsa0network->AddAttachedRouter("2001:1::200:ff:fe00:3");
864
865 lsa0network->SetNetworkLSANetworkMask(Ipv6Prefix(64));
866 m_lsasv6.push_back(lsa0network); // note the index of the network lsa
867}
868
869void
871{
872 BuildLsav4();
873 // insert the LSAs into the GlobalRouteManagerLSDB
874 auto srmlsdb = new GlobalRouteManagerLSDB<Ipv4Manager>();
875
876 srmlsdb->Insert(m_lsasv4[0]->GetLinkStateId(), m_lsasv4[0]);
877 srmlsdb->Insert(m_lsasv4[1]->GetLinkStateId(), m_lsasv4[1]);
878 srmlsdb->Insert(m_lsasv4[2]->GetLinkStateId(), m_lsasv4[2]);
879 srmlsdb->Insert(m_lsasv4[3]->GetLinkStateId(), m_lsasv4[3]);
880
881 // create the GlobalRouteManagerImpl
882 auto srmv4 = new GlobalRouteManagerImpl<Ipv4Manager>();
883 srmv4->DebugUseLsdb(srmlsdb);
884
885 srmv4->DebugSPFCalculate(m_lsasv4[0]->GetLinkStateId()); // fill the routing table for node 0
886
887 // now for ipv6
888 BuildLsav6();
889 // insert the LSAs into the GlobalRouteManagerLSDB
890 auto srmlsdbv6 = new GlobalRouteManagerLSDB<Ipv6Manager>();
891
892 srmlsdbv6->Insert(m_lsasv6[0]->GetLinkStateId(), m_lsasv6[0]);
893 srmlsdbv6->Insert(m_lsasv6[1]->GetLinkStateId(), m_lsasv6[1]);
894 srmlsdbv6->Insert(m_lsasv6[2]->GetLinkStateId(), m_lsasv6[2]);
895 srmlsdbv6->Insert(m_lsasv6[3]->GetLinkStateId(), m_lsasv6[3]);
896
897 // create the GlobalRouteManagerImpl
898 auto srmv6 = new GlobalRouteManagerImpl<Ipv6Manager>();
899 srmv6->DebugUseLsdb(srmlsdbv6);
900
901 srmv6->DebugSPFCalculate(m_lsasv6[0]->GetLinkStateId()); // fill the routing table for node 0
902
903 // now the tests for IPv4-----------------------
904
905 Ptr<Ipv4L3Protocol> ip0 = nodes.Get(0)->GetObject<Ipv4L3Protocol>();
906 NS_TEST_ASSERT_MSG_NE(ip0, nullptr, "Error-- no Ipv4 object at node 0");
907 Ptr<Ipv4RoutingProtocol> routing0 = ip0->GetRoutingProtocol();
908 NS_TEST_ASSERT_MSG_NE(routing0, nullptr, "Error-- no Ipv4 routing protocol object at node 0");
909 Ptr<Ipv4GlobalRouting> globalRouting0 = routing0->GetObject<Ipv4GlobalRouting>();
910 NS_TEST_ASSERT_MSG_NE(globalRouting0, nullptr, "Error-- no Ipv4GlobalRouting object at node 0");
911
912 // The only route to check is the network route
913 uint32_t nRoutes0 = globalRouting0->GetNRoutes();
914 NS_TEST_ASSERT_MSG_EQ(nRoutes0, 1, "Error-- Network route not found for node 0");
915 Ipv4RoutingTableEntry* route = globalRouting0->GetRoute(0);
917 Ipv4Address("10.1.1.0"),
918 "Error-- wrong destination for network route");
920 Ipv4Address("0.0.0.0"),
921 "Error-- wrong gateway for network route");
922
923 // now the tests for IPv6-----------------------
924
925 Ptr<Ipv6L3Protocol> ip0v6 = nodes.Get(0)->GetObject<Ipv6L3Protocol>();
926 NS_TEST_ASSERT_MSG_NE(ip0v6, nullptr, "Error-- no Ipv6 object at node 0");
927 Ptr<Ipv6RoutingProtocol> routing0v6 = ip0v6->GetRoutingProtocol();
928 NS_TEST_ASSERT_MSG_NE(routing0v6, nullptr, "Error-- no Ipv6 routing protocol object at node 0");
929 Ptr<Ipv6GlobalRouting> globalRouting0v6 = routing0v6->GetObject<Ipv6GlobalRouting>();
930 NS_TEST_ASSERT_MSG_NE(globalRouting0v6,
931 nullptr,
932 "Error-- no Ipv6GlobalRouting object at node 0");
933
934 // The only route to check is the network route
935 uint32_t nRoutes0v6 = globalRouting0v6->GetNRoutes();
936 NS_TEST_ASSERT_MSG_EQ(nRoutes0v6, 1, "Error-- Network route not found for node 0");
937 Ipv6RoutingTableEntry* routev6 = globalRouting0v6->GetRoute(0);
939 Ipv6Address("2001:1::"),
940 "Error-- wrong destination for network route");
942 Ipv6Address("::"),
943 "Error-- wrong gateway for network route");
944
946
949 // This delete clears the srm, which deletes the LSDB, which clears
950 // all of the LSAs, which each destroys the attached LinkRecords.
951 delete srmv4;
952 delete srmv6;
955}
956
957/**
958 * @ingroup internet-test
959 *
960 * @brief The purpose of this test is to check if Equal Cost MultiPath (ECMP) Routes are being built
961 * and used correctly.
962 */
964{
965 public:
967
968 void DoSetup() override;
969 void DoRun() override;
970
971 private:
972 /**
973 *@brief Builds the LSAs for the topology. These LSAs are manually created and inserted into the
974 * GlobalRouteManagerLSDB.Each node exports a router LSA.
975 */
976 void BuildLsav4();
977
978 /**
979 *@brief Builds the LSAs for the topology. These LSAs are manually created and inserted into the
980 * GlobalRouteManagerLSDB.Each node exports a router LSA.
981 */
982 void BuildLsav6();
983
984 /**
985 * @brief Helper function that checks the output of the routing path
986 * and increments the corresponding route counter.
987 * @param route The routing path to check
988 */
989 void IncrementCountv4(Ptr<Ipv4Route>& route);
990
991 /**
992 * @brief Helper function that checks the output of the routing path
993 * and increments the corresponding route counter.
994 * @param route The routing path to check
995 */
996 void IncrementCountv6(Ptr<Ipv6Route>& route);
997 /**
998 * @brief function that checks the routing table entries for the expected output.
999 * @param globalroutingprotocol The routing protocol for the node whose routing table is to be
1000 * checked.
1001 * @param dests The expected destinations.
1002 * @param gws The expected gateways.
1003 */
1004 void CheckRoutesv4(Ptr<Ipv4GlobalRouting>& globalroutingprotocol,
1005 std::vector<Ipv4Address>& dests,
1006 std::vector<Ipv4Address>& gws);
1007
1008 /**
1009 * @brief function that checks the routing table entries for the expected output.
1010 * @param globalroutingprotocol The routing protocol for the node whose routing table is to be
1011 * checked.
1012 * @param dests The expected destinations.
1013 * @param gws The expected gateways.
1014 */
1015 void CheckRoutesv6(Ptr<Ipv6GlobalRouting>& globalroutingprotocol,
1016 std::vector<Ipv6Address>& dests,
1017 std::vector<Ipv6Address>& gws);
1018 uint32_t route1v4 = 0; //!< Counter to keep track of the number of times route1 is used for ipv4
1019 uint32_t route2v4 = 0; //!< Counter to keep track of the number of times route2 is used for ipv4
1020 uint32_t route1v6 = 0; //!< Counter to keep track of the number of times route1 is used for ipv6
1021 uint32_t route2v6 = 0; //!< Counter to keep track of the number of times route2 is used for ipv6
1022 NodeContainer nodes; //!< NodeContainer to hold the nodes in the topology
1023 std::vector<GlobalRoutingLSA<Ipv4Manager>*> m_lsasv4; //!< The LSAs for the topology
1024 std::vector<GlobalRoutingLSA<Ipv6Manager>*> m_lsasv6; //!< The LSAs for the topology
1025};
1026
1028 : TestCase("RandomEcmpTestCase")
1029{
1030}
1031
1032void
1034{
1035 Config::SetDefault("ns3::Ipv4GlobalRouting::RandomEcmpRouting", BooleanValue(true));
1036 Config::SetDefault("ns3::Ipv6GlobalRouting::RandomEcmpRouting", BooleanValue(true));
1037
1038 /*
1039 // Creating a Simple topology with 4 nodes and 3 links
1040 //
1041 //
1042 //
1043 // ------n1------
1044 // / \
1045 // / \
1046 // n0 n3
1047 // \ /
1048 // \ /
1049 // ------n2------
1050 //
1051 // Link n0-n1: 10.1.1.1/30,10.1.1.2/30
1052 // Link n0-n2: 10.1.2.1/30,10.1.2.2/30
1053 // Link n1-n3: 10.1.3.1/30,10.1.3.2/30
1054 // Link n2-n3: 10.1.4.1/30,10.1.4.2/30
1055 */
1056 nodes.Create(4);
1057
1058 Ipv4GlobalRoutingHelper globalhelper;
1059 Ipv6GlobalRoutingHelper globalhelperv6;
1060 InternetStackHelper stack;
1061 stack.SetRoutingHelper(globalhelper);
1062 stack.SetRoutingHelper(globalhelperv6);
1063 stack.Install(nodes);
1064 SimpleNetDeviceHelper devHelper;
1065 devHelper.SetNetDevicePointToPointMode(true);
1067 NetDeviceContainer d01 = devHelper.Install(nodes.Get(0), channel1);
1068 d01.Add(devHelper.Install(nodes.Get(1), channel1));
1070 NetDeviceContainer d23 = devHelper.Install(nodes.Get(2), channel2);
1071 d23.Add(devHelper.Install(nodes.Get(3), channel2));
1073 NetDeviceContainer d02 = devHelper.Install(nodes.Get(0), channel3);
1074 d02.Add(devHelper.Install(nodes.Get(2), channel3));
1076 NetDeviceContainer d13 = devHelper.Install(nodes.Get(1), channel4);
1077 d13.Add(devHelper.Install(nodes.Get(3), channel4));
1078
1079 // Assign IP addresses to the devices
1080 Ipv4AddressHelper address;
1081 address.SetBase("10.1.1.0", "255.255.255.252");
1082 Ipv4InterfaceContainer i01 = address.Assign(d01);
1083
1084 address.SetBase("10.1.2.0", "255.255.255.252");
1085 Ipv4InterfaceContainer i02 = address.Assign(d02);
1086
1087 address.SetBase("10.1.3.0", "255.255.255.252");
1088 Ipv4InterfaceContainer i13 = address.Assign(d13);
1089
1090 address.SetBase("10.1.4.0", "255.255.255.252");
1091 Ipv4InterfaceContainer i23 = address.Assign(d23);
1092
1093 Ipv6AddressHelper addressv6;
1094 addressv6.SetBase("2001:1::", Ipv6Prefix(64));
1095 Ipv6InterfaceContainer i01v6 = addressv6.Assign(d01);
1096 addressv6.SetBase("2001:2::", Ipv6Prefix(64));
1097 Ipv6InterfaceContainer i02v6 = addressv6.Assign(d02);
1098 addressv6.SetBase("2001:3::", Ipv6Prefix(64));
1099 Ipv6InterfaceContainer i13v6 = addressv6.Assign(d13);
1100 addressv6.SetBase("2001:4::", Ipv6Prefix(64));
1101 Ipv6InterfaceContainer i23v6 = addressv6.Assign(d23);
1102}
1103
1104void
1106 std::vector<Ipv4Address>& dests,
1107 std::vector<Ipv4Address>& gws)
1108{
1109 // check each individual routes destination and gateway
1110 for (uint32_t i = 0; i < globalroutingprotocol->GetNRoutes(); i++)
1111 {
1112 Ipv4RoutingTableEntry* route = globalroutingprotocol->GetRoute(i);
1113 NS_LOG_DEBUG("dest " << route->GetDest() << " gw " << route->GetGateway());
1114 NS_TEST_ASSERT_MSG_EQ(route->GetDest(), dests[i], "Error-- wrong destination");
1115 NS_TEST_ASSERT_MSG_EQ(route->GetGateway(), gws[i], "Error-- wrong gateway");
1116 }
1117}
1118
1119void
1121 std::vector<Ipv6Address>& dests,
1122 std::vector<Ipv6Address>& gws)
1123{
1124 // check each individual routes destination and gateway
1125 for (uint32_t i = 0; i < globalroutingprotocol->GetNRoutes(); i++)
1126 {
1127 Ipv6RoutingTableEntry* route = globalroutingprotocol->GetRoute(i);
1128 NS_LOG_DEBUG("dest " << route->GetDest() << " gw " << route->GetGateway());
1129 NS_TEST_ASSERT_MSG_EQ(route->GetDest(), dests[i], "Error-- wrong destination");
1130 NS_TEST_ASSERT_MSG_EQ(route->GetGateway(), gws[i], "Error-- wrong gateway");
1131 }
1132}
1133
1134void
1136{
1137 if (route->GetGateway() == Ipv4Address("10.1.1.2"))
1138 {
1139 route1v4++;
1140 }
1141 else if (route->GetGateway() == Ipv4Address("10.1.2.2"))
1142 {
1143 route2v4++;
1144 }
1145}
1146
1147void
1149{
1150 if (route->GetGateway() == Ipv6Address("fe80::200:ff:fe00:2"))
1151 {
1152 route1v6++;
1153 }
1154 else if (route->GetGateway() == Ipv6Address("fe80::200:ff:fe00:6"))
1155 {
1156 route2v6++;
1157 }
1158}
1159
1160void
1162{
1163 // we manually create the link state database, we could have used BuildRoutingTables() but this
1164 // way testing the GlobalRouteManagerImpl without the involvement of GLobalRouter makes it
1165 // easier to debug each individually
1166
1167 // router 0
1168 auto lr0 =
1170 "0.0.0.1",
1171 "10.1.1.1",
1172 1);
1173 auto lr1 =
1175 "10.1.1.2",
1176 "255.255.255.252",
1177 1);
1178
1179 auto lr2 =
1181 "0.0.0.2",
1182 "10.1.2.1",
1183 1);
1184 auto lr3 =
1186 "10.1.2.2",
1187 "255.255.255.252",
1188 1);
1189
1190 auto lsa0 = new GlobalRoutingLSA<Ipv4Manager>();
1193 lsa0->SetLinkStateId("0.0.0.0");
1194 lsa0->SetAdvertisingRouter("0.0.0.0");
1195 lsa0->SetNode(nodes.Get(0));
1196 lsa0->AddLinkRecord(lr0);
1197 lsa0->AddLinkRecord(lr1);
1198 lsa0->AddLinkRecord(lr2);
1199 lsa0->AddLinkRecord(lr3);
1200 m_lsasv4.push_back(lsa0);
1201
1202 // router 1
1203 auto lr4 =
1205 "0.0.0.0",
1206 "10.1.1.2",
1207 1);
1208 auto lr5 =
1210 "10.1.1.1",
1211 "255.255.255.252",
1212 1);
1213
1214 auto lr6 =
1216 "0.0.0.3",
1217 "10.1.3.1",
1218 1);
1219 auto lr7 =
1221 "10.1.3.2",
1222 "255.255.255.252",
1223 1);
1224
1225 auto lsa1 = new GlobalRoutingLSA<Ipv4Manager>();
1228 lsa1->SetLinkStateId("0.0.0.1");
1229 lsa1->SetAdvertisingRouter("0.0.0.1");
1230 lsa1->SetNode(nodes.Get(1));
1231 lsa1->AddLinkRecord(lr4);
1232 lsa1->AddLinkRecord(lr5);
1233 lsa1->AddLinkRecord(lr6);
1234 lsa1->AddLinkRecord(lr7);
1235 m_lsasv4.push_back(lsa1);
1236
1237 // router 2
1238 auto lr8 =
1240 "0.0.0.0",
1241 "10.1.2.2",
1242 1);
1243 auto lr9 =
1245 "10.1.2.1",
1246 "255.255.255.252",
1247 1);
1248 auto lr10 =
1250 "0.0.0.3",
1251 "10.1.4.1",
1252 1);
1253 auto lr11 =
1255 "10.1.4.2",
1256 "255.255.255.252",
1257 1);
1258
1259 auto lsa2 = new GlobalRoutingLSA<Ipv4Manager>();
1262 lsa2->SetLinkStateId("0.0.0.2");
1263 lsa2->SetAdvertisingRouter("0.0.0.2");
1264 lsa2->SetNode(nodes.Get(2));
1265 lsa2->AddLinkRecord(lr8);
1266 lsa2->AddLinkRecord(lr9);
1267 lsa2->AddLinkRecord(lr10);
1268 lsa2->AddLinkRecord(lr11);
1269 m_lsasv4.push_back(lsa2);
1270
1271 // router 3
1272 auto lr12 =
1274 "0.0.0.1",
1275 "10.1.3.2",
1276 1);
1277 auto lr13 =
1279 "10.1.3.1",
1280 "255.255.255.252",
1281 1);
1282 auto lr14 =
1284 "0.0.0.2",
1285 "10.1.4.2",
1286 1);
1287 auto lr15 =
1289 "10.1.4.1",
1290 "255.255.255.252",
1291 1);
1292
1293 auto lsa3 = new GlobalRoutingLSA<Ipv4Manager>();
1296 lsa3->SetLinkStateId("0.0.0.3");
1297 lsa3->SetAdvertisingRouter("0.0.0.3");
1298 lsa3->SetNode(nodes.Get(3));
1299 lsa3->AddLinkRecord(lr12);
1300 lsa3->AddLinkRecord(lr13);
1301 lsa3->AddLinkRecord(lr14);
1302 lsa3->AddLinkRecord(lr15);
1303 m_lsasv4.push_back(lsa3);
1304}
1305
1306void
1308{
1309 // we manually create the link state database, we could have used BuildRoutingTables() but this
1310 // way testing the GlobalRouteManagerImpl without the involvement of GLobalRouter makes it
1311 // easier to debug each individually
1312
1313 // router 0
1314 auto lr0 =
1316 "::ffff:0.0.0.1",
1317 "2001:1::200:ff:fe00:1",
1318 "fe80::200:ff:fe00:1",
1319 1);
1320 // only need to do this once for prefix of 64 bits
1321 uint8_t buf[16];
1322 auto prefix = Ipv6Prefix(64);
1323 prefix.GetBytes(buf); // frown
1324
1325 auto lr1 =
1327 "2001:1::200:ff:fe00:2",
1328 Ipv6Address(buf),
1329 1);
1330 auto lr2 =
1332 "::ffff:0.0.0.2",
1333 "2001:2::200:ff:fe00:5",
1334 "fe80::200:ff:fe00:5",
1335 1);
1336 auto lr3 =
1338 "2001:2::200:ff:fe00:6",
1339 Ipv6Address(buf),
1340 1);
1341
1342 auto lsa0 = new GlobalRoutingLSA<Ipv6Manager>();
1345 lsa0->SetLinkStateId("::ffff:0.0.0.0");
1346 lsa0->SetAdvertisingRouter("::ffff:0.0.0.0");
1347 lsa0->SetNode(nodes.Get(0));
1348 lsa0->AddLinkRecord(lr0);
1349 lsa0->AddLinkRecord(lr1);
1350 lsa0->AddLinkRecord(lr2);
1351 lsa0->AddLinkRecord(lr3);
1352 m_lsasv6.push_back(lsa0);
1353
1354 // router 1
1355 auto lr4 =
1357 "::ffff:0.0.0.0",
1358 "2001:1::200:ff:fe00:2",
1359 "fe80::200:ff:fe00:2",
1360 1);
1361 auto lr5 =
1363 "2001:1::200:ff:fe00:1",
1364 Ipv6Address(buf),
1365 1);
1366
1367 auto lr6 =
1369 "::ffff:0.0.0.3",
1370 "2001:3::200:ff:fe00:7",
1371 "fe80::200:ff:fe00:7",
1372 1);
1373 auto lr7 =
1375 "2001:3::200:ff:fe00:8",
1376 Ipv6Address(buf),
1377 1);
1378
1379 auto lsa1 = new GlobalRoutingLSA<Ipv6Manager>();
1382 lsa1->SetLinkStateId("::ffff:0.0.0.1");
1383 lsa1->SetAdvertisingRouter("::ffff:0.0.0.1");
1384 lsa1->SetNode(nodes.Get(1));
1385 lsa1->AddLinkRecord(lr4);
1386 lsa1->AddLinkRecord(lr5);
1387 lsa1->AddLinkRecord(lr6);
1388 lsa1->AddLinkRecord(lr7);
1389 m_lsasv6.push_back(lsa1);
1390
1391 // router 2
1392 auto lr8 =
1394 "::ffff:0.0.0.0",
1395 "2001:2::200:ff:fe00:6",
1396 "fe80::200:ff:fe00:6",
1397 1);
1398 auto lr9 =
1400 "2001:2::200:ff:fe00:5",
1401 Ipv6Address(buf),
1402 1);
1403 auto lr10 =
1405 "::ffff:0.0.0.3",
1406 "2001:4::200:ff:fe00:3",
1407 "fe80::200:ff:fe00:3",
1408 1);
1409 auto lr11 =
1411 "2001:4::200:ff:fe00:4",
1412 Ipv6Address(buf),
1413 1);
1414
1415 auto lsa2 = new GlobalRoutingLSA<Ipv6Manager>();
1418 lsa2->SetLinkStateId("::ffff:0.0.0.2");
1419 lsa2->SetAdvertisingRouter("::ffff:0.0.0.2");
1420 lsa2->SetNode(nodes.Get(2));
1421 lsa2->AddLinkRecord(lr8);
1422 lsa2->AddLinkRecord(lr9);
1423 lsa2->AddLinkRecord(lr10);
1424 lsa2->AddLinkRecord(lr11);
1425 m_lsasv6.push_back(lsa2);
1426
1427 // router 3
1428 auto lr12 =
1430 "::ffff:0.0.0.1",
1431 "2001:3::200:ff:fe00:8",
1432 "fe80::200:ff:fe00:8",
1433 1);
1434 auto lr13 =
1436 "2001:3::200:ff:fe00:7",
1437 Ipv6Address(buf),
1438 1);
1439 auto lr14 =
1441 "::ffff:0.0.0.2",
1442 "2001:4::200:ff:fe00:4",
1443 "fe80::200:ff:fe00:4",
1444 1);
1445 auto lr15 =
1447 "2001:4::200:ff:fe00:3",
1448 Ipv6Address(buf),
1449 1);
1450
1451 auto lsa3 = new GlobalRoutingLSA<Ipv6Manager>();
1454 lsa3->SetLinkStateId("::ffff:0.0.0.3");
1455 lsa3->SetAdvertisingRouter("::ffff:0.0.0.3");
1456 lsa3->SetNode(nodes.Get(3));
1457 lsa3->AddLinkRecord(lr12);
1458 lsa3->AddLinkRecord(lr13);
1459 lsa3->AddLinkRecord(lr14);
1460 lsa3->AddLinkRecord(lr15);
1461 m_lsasv6.push_back(lsa3);
1462}
1463
1464void
1466{
1467 // We need a deterministic output to pass the test. So we set a fixed seed and run for our
1468 // UniformRandomVariable
1473
1474 BuildLsav4();
1475
1476 // insert the LSAs into the GlobalRouteManagerLSDB
1477 auto srmlsdbv4 = new GlobalRouteManagerLSDB<Ipv4Manager>();
1478 srmlsdbv4->Insert(m_lsasv4[0]->GetLinkStateId(), m_lsasv4[0]);
1479 srmlsdbv4->Insert(m_lsasv4[1]->GetLinkStateId(), m_lsasv4[1]);
1480 srmlsdbv4->Insert(m_lsasv4[2]->GetLinkStateId(), m_lsasv4[2]);
1481 srmlsdbv4->Insert(m_lsasv4[3]->GetLinkStateId(), m_lsasv4[3]);
1482
1483 // create the GlobalRouteManagerImpl
1484 auto srmv4 = new GlobalRouteManagerImpl<Ipv4Manager>();
1485 srmv4->DebugUseLsdb(srmlsdbv4);
1486
1487 // we manually call the DebugSPFCalculate to fill the routing tables for node 0
1488 srmv4->DebugSPFCalculate(m_lsasv4[0]->GetLinkStateId());
1489
1490 // now for ipv6
1491 BuildLsav6();
1492
1493 // insert the LSAs into the GlobalRouteManagerLSDB
1494 auto srmlsdbv6 = new GlobalRouteManagerLSDB<Ipv6Manager>();
1495 srmlsdbv6->Insert(m_lsasv6[0]->GetLinkStateId(), m_lsasv6[0]);
1496 srmlsdbv6->Insert(m_lsasv6[1]->GetLinkStateId(), m_lsasv6[1]);
1497 srmlsdbv6->Insert(m_lsasv6[2]->GetLinkStateId(), m_lsasv6[2]);
1498 srmlsdbv6->Insert(m_lsasv6[3]->GetLinkStateId(), m_lsasv6[3]);
1499
1500 // create the GlobalRouteManagerImpl
1501 auto srmv6 = new GlobalRouteManagerImpl<Ipv6Manager>();
1502 srmv6->DebugUseLsdb(srmlsdbv6);
1503 // we manually call the DebugSPFCalculate to fill the routing tables for node 0
1504 srmv6->DebugSPFCalculate(m_lsasv6[0]->GetLinkStateId());
1505
1506 // now the tests-----------------------
1507
1508 Ptr<Ipv4L3Protocol> ip0 = nodes.Get(0)->GetObject<Ipv4L3Protocol>();
1509 NS_TEST_ASSERT_MSG_NE(ip0, nullptr, "Error-- no Ipv4 object at node 0");
1510 Ptr<Ipv4RoutingProtocol> routing0 = ip0->GetRoutingProtocol();
1511 NS_TEST_ASSERT_MSG_NE(routing0, nullptr, "Error-- no Ipv4 routing protocol object at node 0");
1512 Ptr<Ipv4GlobalRouting> globalRouting0 = routing0->GetObject<Ipv4GlobalRouting>();
1513 NS_TEST_ASSERT_MSG_NE(globalRouting0, nullptr, "Error-- no Ipv4GlobalRouting object at node 0");
1514
1515 // assign streams to the UniformRandomVariable
1516 globalRouting0->AssignStreams(0);
1517 // check that the correct number of routes were built
1518
1519 uint32_t nRoutes0 = globalRouting0->GetNRoutes();
1520 NS_TEST_ASSERT_MSG_EQ(nRoutes0, 14, "Error-- incorrect number of routes found on node 0");
1521
1522 // check that the routes are correct
1523 std::vector<Ipv4Address> expectedDests;
1524 std::vector<Ipv4Address> expectedNextHops;
1525
1526 // add all the expected destinations and gateways. This is pretty verbose
1527 // Please Note: The order of the following line is important because we check the routing table
1528 // entries in order. The test will fail if we reorder the vector entries.
1529
1530 // For Routing table of Node 0 we check the following Destinations and Gateways
1531 expectedDests.emplace_back("10.1.1.2");
1532 expectedDests.emplace_back("10.1.3.1");
1533 expectedDests.emplace_back("10.1.2.2");
1534 expectedDests.emplace_back("10.1.4.1");
1535 expectedDests.emplace_back("10.1.3.2");
1536 expectedDests.emplace_back("10.1.3.2");
1537 expectedDests.emplace_back("10.1.4.2");
1538 expectedDests.emplace_back("10.1.4.2");
1539 expectedDests.emplace_back("10.1.1.0");
1540 expectedDests.emplace_back("10.1.3.0");
1541 expectedDests.emplace_back("10.1.3.0");
1542 expectedDests.emplace_back("10.1.4.0");
1543 expectedDests.emplace_back("10.1.4.0");
1544 expectedDests.emplace_back("10.1.2.0");
1545
1546 expectedNextHops.emplace_back("10.1.1.2");
1547 expectedNextHops.emplace_back("10.1.1.2");
1548 expectedNextHops.emplace_back("10.1.2.2");
1549 expectedNextHops.emplace_back("10.1.2.2");
1550 expectedNextHops.emplace_back("10.1.1.2");
1551 expectedNextHops.emplace_back("10.1.2.2");
1552 expectedNextHops.emplace_back("10.1.1.2");
1553 expectedNextHops.emplace_back("10.1.2.2");
1554 expectedNextHops.emplace_back("10.1.1.2");
1555 expectedNextHops.emplace_back("10.1.1.2");
1556 expectedNextHops.emplace_back("10.1.2.2");
1557 expectedNextHops.emplace_back("10.1.1.2");
1558 expectedNextHops.emplace_back("10.1.2.2");
1559 expectedNextHops.emplace_back("10.1.2.2");
1560
1561 // Test 1: Check the Routing Table of Node 0
1562 CheckRoutesv4(globalRouting0, expectedDests, expectedNextHops);
1563
1564 // Test 2: Check that the equal cost routes are being used at least once.
1565 // we need to call RouteOutput() at node 0 and check the output
1566 // route from the table. The thing to check here is that different equal cost routes are
1567 // returned across different calls to this method.
1568
1569 Socket::SocketErrno errno_;
1570 Ptr<NetDevice> oif(nullptr);
1571 Ptr<Packet> packetv6 = Create<Packet>();
1572 Ipv4Header ipHeader;
1573 ipHeader.SetSource(Ipv4Address("10.1.1.1"));
1574 ipHeader.SetDestination(Ipv4Address("10.1.4.2"));
1575
1576 for (uint32_t i = 0; i < 10; i++)
1577 {
1578 Ptr<Ipv4Route> route = globalRouting0->RouteOutput(packetv6, ipHeader, oif, errno_);
1579 IncrementCountv4(route);
1580 }
1581
1582 // now the tests for IPv6-----------------------
1583
1584 Ptr<Ipv6L3Protocol> ip0v6 = nodes.Get(0)->GetObject<Ipv6L3Protocol>();
1585 NS_TEST_ASSERT_MSG_NE(ip0v6, nullptr, "Error-- no Ipv6 object at node 0");
1586 Ptr<Ipv6RoutingProtocol> routing0v6 = ip0v6->GetRoutingProtocol();
1587 NS_TEST_ASSERT_MSG_NE(routing0v6, nullptr, "Error-- no Ipv6 routing protocol object at node 0");
1588 Ptr<Ipv6GlobalRouting> globalRouting0v6 = routing0v6->GetObject<Ipv6GlobalRouting>();
1589 NS_TEST_ASSERT_MSG_NE(globalRouting0v6,
1590 nullptr,
1591 "Error-- no Ipv6GlobalRouting object at node 0");
1592
1593 // assign streams to the UniformRandomVariable
1594 globalRouting0v6->AssignStreams(0);
1595 // check that the correct number of routes were built
1596 uint32_t nRoutes0v6 = globalRouting0v6->GetNRoutes();
1597 NS_TEST_ASSERT_MSG_EQ(nRoutes0v6, 14, "Error-- incorrect number of routes found on node 0");
1598
1599 // check that the routes are correct
1600 std::vector<Ipv6Address> expectedDestsv6;
1601 std::vector<Ipv6Address> expectedNextHopsv6;
1602
1603 // add all the expected destinations and gateways. This is pretty verbose
1604 // Please Note: The order of the following line is important because we check the routing table
1605 // entries in order. The test will fail if we reorder the vector entries.
1606
1607 // For Routing table of Node 0 we check the following Destinations and Gateways
1608 expectedDestsv6.emplace_back("2001:1::200:ff:fe00:2");
1609 expectedDestsv6.emplace_back("2001:3::200:ff:fe00:7");
1610 expectedDestsv6.emplace_back("2001:2::200:ff:fe00:6");
1611 expectedDestsv6.emplace_back("2001:4::200:ff:fe00:3");
1612 expectedDestsv6.emplace_back("2001:3::200:ff:fe00:8");
1613 expectedDestsv6.emplace_back("2001:3::200:ff:fe00:8");
1614 expectedDestsv6.emplace_back("2001:4::200:ff:fe00:4");
1615 expectedDestsv6.emplace_back("2001:4::200:ff:fe00:4");
1616 expectedDestsv6.emplace_back("2001:1::");
1617 expectedDestsv6.emplace_back("2001:3::");
1618 expectedDestsv6.emplace_back("2001:3::");
1619 expectedDestsv6.emplace_back("2001:4::");
1620 expectedDestsv6.emplace_back("2001:4::");
1621 expectedDestsv6.emplace_back("2001:2::");
1622
1623 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:2");
1624 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:2");
1625 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:6");
1626 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:6");
1627 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:2");
1628 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:6");
1629 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:2");
1630 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:6");
1631 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:2");
1632 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:2");
1633 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:6");
1634 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:2");
1635 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:6");
1636 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:6");
1637 // Test 1: Check the Routing Table of Node 0
1638 CheckRoutesv6(globalRouting0v6, expectedDestsv6, expectedNextHopsv6);
1639
1640 // Test 2: Check that the equal cost routes are being used at least once.
1641 // we need to call RouteOutput() at node 0 and check the output
1642 // route from the table. The thing to check here is that different equal cost routes are
1643 // returned across different calls to this method.
1644
1645 Ptr<Packet> packet = Create<Packet>();
1646 Ipv6Header ipHeaderv6;
1647 ipHeaderv6.SetSource(Ipv6Address("2001:1::200:ff:fe00:1"));
1648 ipHeaderv6.SetDestination(Ipv6Address("2001:4::200:ff:fe00:4"));
1649
1650 for (uint32_t i = 0; i < 10; i++)
1651 {
1652 Ptr<Ipv6Route> route = globalRouting0v6->RouteOutput(packet, ipHeaderv6, oif, errno_);
1653 IncrementCountv6(route);
1654 }
1655
1657
1659 route1v4,
1660 1,
1661 "The routing path for node 0 to node 3 does not match the expected output, "
1662 "Equal Cost MultiPath (ECMP) routes are not being used correctly for ipv4");
1664 route2v4,
1665 1,
1666 "The routing path for node 0 to node 3 does not match the expected output, "
1667 "Equal Cost MultiPath (ECMP) routes are not being used correctly for ipv4");
1668
1670 route1v6,
1671 1,
1672 "The routing path for node 0 to node 3 does not match the expected output, "
1673 "Equal Cost MultiPath (ECMP) routes are not being used correctly for ipv6");
1675 route2v6,
1676 1,
1677 "The routing path for node 0 to node 3 does not match the expected output, "
1678 "Equal Cost MultiPath (ECMP) routes are not being used correctly for ipv6");
1679
1680 // end of test--------------------
1681
1683
1685
1686 RngSeedManager::SetSeed(oldseed);
1687 RngSeedManager::SetRun(oldrun);
1688 // This delete clears the srm, which deletes the LSDB, which clears
1689 // all of the LSAs, which each destroys the attached LinkRecords.
1690 delete srmv4;
1691 delete srmv6;
1692}
1693
1694/**
1695 * @ingroup internet-test
1696 *
1697 * @brief Global Route Manager TestSuite
1698 */
1700{
1701 public:
1703
1704 private:
1705};
1706
1714
1716 g_globalRoutingManagerImplTestSuite; //!< Static variable for test initialization
This test case is to check if NetworkRoutes are being built correctly, i.e if route computation works...
std::vector< GlobalRoutingLSA< Ipv6Manager > * > m_lsasv6
The ipv6 LSAs for the topology.
void DoRun() override
Implementation to actually run this TestCase.
void BuildLsav6()
Builds the ipv6 LSAs for the topology.
NodeContainer nodes
NodeContainer to hold the nodes in the topology.
std::vector< GlobalRoutingLSA< Ipv4Manager > * > m_lsasv4
The ipv4 LSAs for the topology.
void BuildLsav4()
Builds the ipv4 LSAs for the topology.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
The purpose of this test is to check if Equal Cost MultiPath (ECMP) Routes are being built and used c...
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void IncrementCountv4(Ptr< Ipv4Route > &route)
Helper function that checks the output of the routing path and increments the corresponding route cou...
std::vector< GlobalRoutingLSA< Ipv6Manager > * > m_lsasv6
The LSAs for the topology.
void IncrementCountv6(Ptr< Ipv6Route > &route)
Helper function that checks the output of the routing path and increments the corresponding route cou...
uint32_t route2v6
Counter to keep track of the number of times route2 is used for ipv6.
void CheckRoutesv4(Ptr< Ipv4GlobalRouting > &globalroutingprotocol, std::vector< Ipv4Address > &dests, std::vector< Ipv4Address > &gws)
function that checks the routing table entries for the expected output.
NodeContainer nodes
NodeContainer to hold the nodes in the topology.
std::vector< GlobalRoutingLSA< Ipv4Manager > * > m_lsasv4
The LSAs for the topology.
uint32_t route1v6
Counter to keep track of the number of times route1 is used for ipv6.
void DoRun() override
Implementation to actually run this TestCase.
uint32_t route2v4
Counter to keep track of the number of times route2 is used for ipv4.
void BuildLsav4()
Builds the LSAs for the topology.
void CheckRoutesv6(Ptr< Ipv6GlobalRouting > &globalroutingprotocol, std::vector< Ipv6Address > &dests, std::vector< Ipv6Address > &gws)
function that checks the routing table entries for the expected output.
uint32_t route1v4
Counter to keep track of the number of times route1 is used for ipv4.
void BuildLsav6()
Builds the LSAs for the topology.
AttributeValue implementation for Boolean.
Definition boolean.h:26
static void ResetRouterId()
Reset the router ID counter to zero.
A global router implementation.
The Link State DataBase (LSDB) of the Global Route Manager.
a Link State Advertisement (LSA) for a router, used in global routing.
@ LSA_SPF_NOT_EXPLORED
New vertex not yet considered.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
Helper class that adds ns3::Ipv4GlobalRouting objects.
Packet header for IPv4.
Definition ipv4-header.h:23
void SetDestination(Ipv4Address destination)
void SetSource(Ipv4Address source)
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Implement the IPv4 layer.
A record of an IPv4 routing table entry for Ipv4GlobalRouting and Ipv4StaticRouting.
Ipv4Address GetDest() const
Ipv4Address GetGateway() const
Helper class to auto-assign global IPv6 unicast addresses.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Describes an IPv6 address.
Helper class that adds ns3::Ipv4GlobalRouting objects.
Packet header for IPv6.
Definition ipv6-header.h:24
void SetDestination(Ipv6Address dst)
Set the "Destination address" field.
void SetSource(Ipv6Address src)
Set the "Source address" field.
Keep track of a set of IPv6 interfaces.
IPv6 layer implementation.
Describes an IPv6 prefix.
A record of an IPv6 route.
Ipv6Address GetDest() const
Get the destination.
Ipv6Address GetGateway() const
Get the gateway.
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
keep track of a set of node pointers.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
static uint64_t GetRun()
Get the current run number.
static uint32_t GetSeed()
Get the current seed value which will be used by all subsequently instantiated RandomVariableStream o...
build a set of SimpleNetDevice objects
void SetNetDevicePointToPointMode(bool pointToPointMode)
SimpleNetDevice is Broadcast capable and ARP needing.
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:125
static void Run()
Run the simulation.
Definition simulator.cc:161
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition simulator.cc:169
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition socket.h:73
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:296
@ QUICK
Fast test.
Definition test.h:1057
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
Type
Type of test.
Definition test.h:1271
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Definition test.cc:494
static GlobalRouteManagerImplTestSuite g_globalRoutingManagerImplTestSuite
Static variable for test initialization.
void SetDefault(std::string name, const AttributeValue &value)
Definition config.cc:886
GlobalRouting< Ipv4RoutingProtocol > Ipv4GlobalRouting
Create the typedef Ipv4GlobalRouting with T as Ipv4RoutingProtocol.
GlobalRouting< Ipv6RoutingProtocol > Ipv6GlobalRouting
Create the typedef Ipv6GlobalRouting with T as Ipv6RoutingProtocol.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:194
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:260
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:627
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:454
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
Definition test.h:133
#define NS_TEST_ASSERT_MSG_NE(actual, limit, msg)
Test that an actual and expected (limit) value are not equal and report and abort if not.
Definition test.h:553
#define NS_TEST_ASSERT_MSG_GT_OR_EQ(actual, limit, msg)
Test that an actual value is greater than or equal to a limit and report and abort if not.
Definition test.h:904
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1273
Every class exported by the ns3 library is enclosed in the ns3 namespace.