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-stack-helper.h"
20#include "ns3/ipv4-address-helper.h"
21#include "ns3/ipv4-global-routing-helper.h"
22#include "ns3/ipv6-address-helper.h"
23#include "ns3/ipv6-global-routing-helper.h"
24#include "ns3/ipv6-route.h"
25#include "ns3/node-container.h"
26#include "ns3/rng-seed-manager.h"
27#include "ns3/simple-net-device-helper.h"
28#include "ns3/simulator.h"
29#include "ns3/test.h"
30
31#include <cstdlib> // for rand()
32using namespace ns3;
33
34NS_LOG_COMPONENT_DEFINE("GlobalRouteManagerImplTestSuite");
35
36//
37// This test suite is designed to check the Working of the GlobalRouteManagerImpl
38// For that reason, the tests in this suite manually build LSAs for each topology
39// we manually call DebugSPFCalculate() to fill routing tables of the node we are interested in.
40//
41// TestCase 1: LinkRoutesTestCase
42// This test case tests that:
43// - GLobalRouteManagerLSDB stores the LSAs with key as the correct link state ID
44// - GlobalRouteManagerImpl checks for stubnodes and computes default routes for them
45// - HostRoutes are computed correctly for point-to-point links
46//
47// TestCase 2: LanRoutesTestCase
48// This test case tests that:
49// - Network LSAs are handled by the GlobalRouteManagerImpl
50// - GlobalRouteManagerImpl computes the routes correctly for a LAN topology
51//
52// TestCase 3: RandomEcmpRoutesTestCase
53// This test case tests that:
54// - GlobalRouteManagerImpl computes ECMP routes correctly.
55// - Those random routes are in fact used by the GlobalRouting protocol
56//
57
58/**
59 * @ingroup internet
60 * @ingroup tests
61 * @defgroup internet-test internet module tests
62 */
63
64/**
65 * @ingroup internet-test
66 *
67 * @brief Global Route Manager Test
68 */
70{
71 public:
73 void DoSetup() override;
74 void DoRun() override;
75
76 private:
77 /**
78 *@brief Builds the LSAs for the topology. These LSAs are manually created and inserted into the
79 * GlobalRouteManagerLSDB.Each node exports a router LSA.
80 */
81 void BuildLsav4();
82
83 /**
84 *@brief Builds the LSAs for the topology. These LSAs are manually created and inserted into the
85 * GlobalRouteManagerLSDB.Each node exports a router LSA.
86 */
87 void BuildLsav6();
88
89 /**
90 * @brief Checks the Routing Table Entries for the expected output.
91 * @param globalroutingprotocol The routing protocol for the node whose routing table is to be
92 * checked.
93 * @param dests The expected destinations.
94 * @param gws The expected gateways.
95 */
96 void CheckRoutesv4(Ptr<Ipv4GlobalRouting>& globalroutingprotocol,
97 std::vector<Ipv4Address>& dests,
98 std::vector<Ipv4Address>& gws);
99
100 /**
101 * @brief Checks the Routing Table Entries for the expected output.
102 * @param globalroutingprotocol The routing protocol for the node whose routing table is to be
103 * checked.
104 * @param dests The expected destinations.
105 * @param gws The expected gateways.
106 */
107 void CheckRoutesv6(Ptr<Ipv6GlobalRouting>& globalroutingprotocol,
108 std::vector<Ipv6Address>& dests,
109 std::vector<Ipv6Address>& gws);
110
111 NodeContainer nodes; //!< NodeContainer to hold the nodes in the topology
112 std::vector<GlobalRoutingLSA<Ipv4Manager>*> m_lsasv4; //!< The LSAs for the topology
113 std::vector<GlobalRoutingLSA<Ipv6Manager>*> m_lsasv6; //!< The LSAs for the topology
114};
115
117 : TestCase("LinkRoutesTestCase")
118{
119}
120
121void
123 std::vector<Ipv4Address>& dests,
124 std::vector<Ipv4Address>& gws)
125{
126 // check each individual Routing Table Entry for its destination and gateway
127 for (uint32_t i = 0; i < globalroutingprotocol->GetNRoutes(); i++)
128 {
129 Ipv4RoutingTableEntry* route = globalroutingprotocol->GetRoute(i);
130 NS_LOG_DEBUG("dest " << route->GetDest() << " gw " << route->GetGateway());
131 NS_TEST_ASSERT_MSG_EQ(route->GetDest(), dests[i], "Error-- wrong destination");
132 NS_TEST_ASSERT_MSG_EQ(route->GetGateway(), gws[i], "Error-- wrong gateway");
133 }
134}
135
136void
138 std::vector<Ipv6Address>& dests,
139 std::vector<Ipv6Address>& gws)
140{
141 // check each individual Routing Table Entry for its destination and gateway
142 for (uint32_t i = 0; i < globalroutingprotocol->GetNRoutes(); i++)
143 {
144 Ipv6RoutingTableEntry* route = globalroutingprotocol->GetRoute(i);
145 NS_LOG_DEBUG("dest " << route->GetDest() << " gw " << route->GetGateway());
146 NS_TEST_ASSERT_MSG_EQ(route->GetDest(), dests[i], "Error-- wrong destination");
147 NS_TEST_ASSERT_MSG_EQ(route->GetGateway(), gws[i], "Error-- wrong gateway");
148 }
149}
150
151void
153{
154 // Simple p2p links. n0,n1 and n3 are stub nodes
155 //
156 //
157 // n0
158 // \ link 0
159 // \ link 2
160 // n2 -------------------------n3
161 // /
162 // / link 1
163 // n1
164 //
165 // link0: n0->10.1.1.1/30, n2-> 10.1.1.2/30
166 // link1: n1-> 10.1.2.1/30, n2->10.1.2.2/30
167 // link2: n2->10.1.3.1/30, n3-> 10.1.3.2/30
168 //
169 //
170 //
171
172 nodes.Create(4);
173
174 Ipv4GlobalRoutingHelper globalhelperv4;
175 Ipv6GlobalRoutingHelper globalhelperv6;
177 stack.SetRoutingHelper(globalhelperv4);
178 stack.SetRoutingHelper(globalhelperv6);
179 stack.Install(nodes);
180
181 SimpleNetDeviceHelper devHelper;
182 devHelper.SetNetDevicePointToPointMode(true);
184 NetDeviceContainer d02 = devHelper.Install(nodes.Get(0), channel1);
185 d02.Add(devHelper.Install(nodes.Get(2), channel1));
187 NetDeviceContainer d12 = devHelper.Install(nodes.Get(1), channel2);
188 d12.Add(devHelper.Install(nodes.Get(2), channel2));
190 NetDeviceContainer d23 = devHelper.Install(nodes.Get(2), channel3);
191 d23.Add(devHelper.Install(nodes.Get(3), channel3));
192
193 // Assign IP addresses to the devices
194 Ipv4AddressHelper address;
195 address.SetBase("10.1.1.0", "255.255.255.252");
196 Ipv4InterfaceContainer i02 = address.Assign(d02);
197 address.SetBase("10.1.2.0", "255.255.255.252");
198 Ipv4InterfaceContainer i12 = address.Assign(d12);
199 address.SetBase("10.1.3.0", "255.255.255.252");
200 Ipv4InterfaceContainer i23 = address.Assign(d23);
201
202 Ipv6AddressHelper addressv6;
203 addressv6.SetBase("2001:1::", Ipv6Prefix(64));
204 Ipv6InterfaceContainer i02v6 = addressv6.Assign(d02);
205 addressv6.SetBase("2001:2::", Ipv6Prefix(64));
206 Ipv6InterfaceContainer i12v6 = addressv6.Assign(d12);
207 addressv6.SetBase("2001:3::", Ipv6Prefix(64));
208 Ipv6InterfaceContainer i23v6 = addressv6.Assign(d23);
209}
210
211void
213{
214 // Manually build the link state database; four routers (0-3), 3 point-to-point
215 // links
216
217 // Router 0
220 "0.0.0.2", // link id -> router ID 0.0.0.2
221 "10.1.1.1", // link data -> Local IP address of router 0
222 1); // metric
223
226 "10.1.1.2", // link id ->adjacent neighbor's IP address
227 "255.255.255.252",
228 1);
229
230 auto lsa0 = new GlobalRoutingLSA<Ipv4Manager>();
232 lsa0->SetLinkStateId("0.0.0.0");
233 lsa0->SetAdvertisingRouter("0.0.0.0");
234 lsa0->SetNode(nodes.Get(0));
235 lsa0->AddLinkRecord(lr0);
236 lsa0->AddLinkRecord(lr1);
237 m_lsasv4.push_back(lsa0);
238
239 // Router 1
240 auto lr2 =
242 "0.0.0.2",
243 "10.1.2.1",
244 1);
245
246 auto lr3 =
248 "10.1.2.2",
249 "255.255.255.252",
250 1);
251
252 auto lsa1 = new GlobalRoutingLSA<Ipv4Manager>();
254 lsa1->SetLinkStateId("0.0.0.1");
255 lsa1->SetAdvertisingRouter("0.0.0.1");
256 lsa1->AddLinkRecord(lr2);
257 lsa1->AddLinkRecord(lr3);
258 lsa1->SetNode(nodes.Get(1));
259 m_lsasv4.push_back(lsa1);
260
261 // Router 2
262 auto lr4 =
264 "0.0.0.0",
265 "10.1.1.2",
266 1);
267
268 auto lr5 =
270 "10.1.1.1",
271 "255.255.255.252",
272 1);
273
274 auto lr6 =
276 "0.0.0.1",
277 "10.1.2.2",
278 1);
279
280 auto lr7 =
282 "10.1.2.2",
283 "255.255.255.252",
284 1);
285
286 auto lr8 =
288 "0.0.0.3",
289 "10.1.3.1",
290 1);
291
292 auto lr9 =
294 "10.1.3.2",
295 "255.255.255.252",
296 1);
297
298 auto lsa2 = new GlobalRoutingLSA<Ipv4Manager>();
300 lsa2->SetLinkStateId("0.0.0.2");
301 lsa2->SetAdvertisingRouter("0.0.0.2");
302 lsa2->AddLinkRecord(lr4);
303 lsa2->AddLinkRecord(lr5);
304 lsa2->AddLinkRecord(lr6);
305 lsa2->AddLinkRecord(lr7);
306 lsa2->AddLinkRecord(lr8);
307 lsa2->AddLinkRecord(lr9);
308 lsa2->SetNode(nodes.Get(2));
309 m_lsasv4.push_back(lsa2);
310
311 // Router 3
312 auto lr10 =
314 "0.0.0.2",
315 "10.1.3.2",
316 1);
317
318 auto lr11 =
320 "10.1.3.1",
321 "255.255.255.252",
322 1);
323
324 auto lsa3 = new GlobalRoutingLSA<Ipv4Manager>();
326 lsa3->SetLinkStateId("0.0.0.3");
327 lsa3->SetAdvertisingRouter("0.0.0.3");
328 lsa3->AddLinkRecord(lr10);
329 lsa3->AddLinkRecord(lr11);
330 lsa3->SetNode(nodes.Get(3));
331 m_lsasv4.push_back(lsa3);
332}
333
334void
336{
337 // Manually build the link state database; four routers (0-3), 3 point-to-point
338 // links
339
340 // Router 0
343 "::ffff:0.0.0.2", // link id -> router ID 0.0.0.2
344 "2001:1::200:ff:fe00:1", // link data -> Local GlobalUnicast IP address of router 0
345 "fe80::200:ff:fe00:1", // Local Link Local IP address of router 0
346 1); // metric
347
348 // only need to do this once for prefix of 64 bits
349 uint8_t buf[16];
350 auto prefix = Ipv6Prefix(64);
351 prefix.GetBytes(buf); // frown
352
355 "2001:1::200:ff:fe00:2", // link id ->adjacent neighbor's IP address
356 Ipv6Address(buf), // Link Data -> Prefix converted to Ipv6Address associated with neighbours
357 // Ip address
358 1);
359
360 auto lsa0 = new GlobalRoutingLSA<Ipv6Manager>();
362 lsa0->SetLinkStateId("::ffff:0.0.0.0");
363 lsa0->SetAdvertisingRouter("::ffff:0.0.0.0");
364 lsa0->SetNode(nodes.Get(0));
365 lsa0->AddLinkRecord(lr0);
366 lsa0->AddLinkRecord(lr1);
367 m_lsasv6.push_back(lsa0);
368
369 // Router 1
372 "::ffff:0.0.0.2", // link id -> router ID
373 "2001:2::200:ff:fe00:3", // link data -> Local Global Unicast IP address of router 1
374 "fe80::200:ff:fe00:3", // link loc data -> Local Link Local IP address of router 1
375 1);
376
379 "2001:2::200:ff:fe00:4", // link id ->adjacent neighbor's IP address
380 Ipv6Address(buf), // Link Data -> Prefix converted to Ipv6Address associated with neighbours
381 // Ip address
382 1);
383
384 auto lsa1 = new GlobalRoutingLSA<Ipv6Manager>();
386 lsa1->SetLinkStateId("::ffff:0.0.0.1");
387 lsa1->SetAdvertisingRouter("::ffff:0.0.0.1");
388 lsa1->AddLinkRecord(lr2);
389 lsa1->AddLinkRecord(lr3);
390 lsa1->SetNode(nodes.Get(1));
391 m_lsasv6.push_back(lsa1);
392
393 // Router 2
396 "::ffff:0.0.0.0", // link id -> router ID
397 "2001:1::200:ff:fe00:2", // link data -> Local Global Unicast IP address of router 2
398 "fe80::200:ff:fe00:2", // link loc data -> Local Link Local IP address of router 2
399 1);
400
403 "2001:1::200:ff:fe00:1", // link id ->adjacent neighbor's IP address
404 Ipv6Address(buf), // Link Data -> Prefix converted to Ipv6Address associated with neighbours
405 // Ip address
406 1);
407
408 auto lr6 =
410 "::ffff:0.0.0.1",
411 "2001:2::200:ff:fe00:4",
412 "fe80::200:ff:fe00:4",
413 1);
414
415 auto lr7 =
417 "2001:2::200:ff:fe00:3",
418 Ipv6Address(buf),
419 1);
420
421 auto lr8 =
423 "::ffff:0.0.0.3",
424 "2001:3::200:ff:fe00:5",
425 "fe80::200:ff:fe00:5",
426 1);
427
428 auto lr9 =
430 "2001:3::200:ff:fe00:6",
431 Ipv6Address(buf),
432 1);
433
434 auto lsa2 = new GlobalRoutingLSA<Ipv6Manager>();
436 lsa2->SetLinkStateId("::ffff:0.0.0.2");
437 lsa2->SetAdvertisingRouter("::ffff:0.0.0.2");
438 lsa2->AddLinkRecord(lr4);
439 lsa2->AddLinkRecord(lr5);
440 lsa2->AddLinkRecord(lr6);
441 lsa2->AddLinkRecord(lr7);
442 lsa2->AddLinkRecord(lr8);
443 lsa2->AddLinkRecord(lr9);
444 lsa2->SetNode(nodes.Get(2));
445 m_lsasv6.push_back(lsa2);
446
447 // Router 3
448 auto lr10 =
450 "::ffff:0.0.0.2",
451 "2001:3::200:ff:fe00:6",
452 "fe80::200:ff:fe00:6",
453 1);
454
455 auto lr11 =
457 "2001:3::200:ff:fe00:5",
458 Ipv6Address(buf),
459 1);
460
461 auto lsa3 = new GlobalRoutingLSA<Ipv6Manager>();
463 lsa3->SetLinkStateId("::ffff:0.0.0.3");
464 lsa3->SetAdvertisingRouter("::ffff:0.0.0.3");
465 lsa3->AddLinkRecord(lr10);
466 lsa3->AddLinkRecord(lr11);
467 lsa3->SetNode(nodes.Get(3));
468 m_lsasv6.push_back(lsa3);
469}
470
471void
473{
474 // This test is for checking the individual working of GlobalRouteManagerImpl
475 // and GlobalRouteManagerLSDB, so we will not use the GlobalRoutingHelper
476 // to create the routing tables, but instead we will manually create the LSAs
477 // and insert them into the GlobalRouteManagerLSDB, and then use the
478 // GlobalRouteManagerImpl to calculate the routes based on the LSDB.
479 // This is a manual setup of the LSAs, which would normally be done by the
480 // GlobalRoutingHelper.
481
482 BuildLsav4();
483
484 // Test the database
485 auto srmlsdb = new GlobalRouteManagerLSDB<Ipv4Manager>();
486 srmlsdb->Insert(m_lsasv4[0]->GetLinkStateId(), m_lsasv4[0]);
487 srmlsdb->Insert(m_lsasv4[1]->GetLinkStateId(), m_lsasv4[1]);
488 srmlsdb->Insert(m_lsasv4[2]->GetLinkStateId(), m_lsasv4[2]);
489 srmlsdb->Insert(m_lsasv4[3]->GetLinkStateId(), m_lsasv4[3]);
490
492 m_lsasv4[2],
493 srmlsdb->GetLSA(m_lsasv4[2]->GetLinkStateId()),
494 "The Ipv4Address is not stored as the link state ID"); // LSAs are mapped by router id as
495 // key here we check that they are
496 // indeed getting the right lsa for
497 // the right key
498
499 // next, calculate routes based on the manually created LSDB
501 srm->DebugUseLsdb(srmlsdb); // manually add in an LSDB
502
503 srm->DebugSPFCalculate(m_lsasv4[0]->GetLinkStateId()); // fill routing table for node n0
504
505 srm->DebugSPFCalculate(m_lsasv4[1]->GetLinkStateId()); // fill routing table for node n1
506
507 srm->DebugSPFCalculate(m_lsasv4[2]->GetLinkStateId()); // fill routing table for node n2
508
509 srm->DebugSPFCalculate(m_lsasv4[3]->GetLinkStateId()); // fill routing table for node n3
510
511 BuildLsav6();
512
513 // Test the database
514 auto srmlsdbv6 = new GlobalRouteManagerLSDB<Ipv6Manager>();
515 srmlsdbv6->Insert(m_lsasv6[0]->GetLinkStateId(), m_lsasv6[0]);
516 srmlsdbv6->Insert(m_lsasv6[1]->GetLinkStateId(), m_lsasv6[1]);
517 srmlsdbv6->Insert(m_lsasv6[2]->GetLinkStateId(), m_lsasv6[2]);
518 srmlsdbv6->Insert(m_lsasv6[3]->GetLinkStateId(), m_lsasv6[3]);
519
521 m_lsasv6[2],
522 srmlsdbv6->GetLSA(m_lsasv6[2]->GetLinkStateId()),
523 "The Ipv6Address is not stored as the link state ID"); // LSAs are mapped by router id as
524 // key here we check that they are
525 // indeed getting the right lsa for
526 // the right key
527
528 // next, calculate routes based on the manually created LSDB
529 auto srmv6 = new GlobalRouteManagerImpl<Ipv6Manager>();
530 srmv6->DebugUseLsdb(srmlsdbv6); // manually add in an LSDB
531
532 srmv6->DebugSPFCalculate(m_lsasv6[0]->GetLinkStateId()); // fill ipv6 routing table for node n0
533
534 srmv6->DebugSPFCalculate(m_lsasv6[1]->GetLinkStateId()); // fill ipv6 routing table for node n1
535
536 srmv6->DebugSPFCalculate(m_lsasv6[2]->GetLinkStateId()); // fill ipv6 routing table for node n2
537
538 srmv6->DebugSPFCalculate(m_lsasv6[3]->GetLinkStateId()); // fill ipv6 routing table for node n3
539
540 //-----------------Now the tests for Ipv4------------------
541 // Test 1: Check if the SPF calculate Sets default routes for Stub nodes
542 Ptr<Ipv4L3Protocol> ip0 = nodes.Get(0)->GetObject<Ipv4L3Protocol>();
543 NS_TEST_ASSERT_MSG_NE(ip0, nullptr, "Error-- no Ipv4 object at node 0");
544 Ptr<Ipv4RoutingProtocol> routing0 = ip0->GetRoutingProtocol();
545 NS_TEST_ASSERT_MSG_NE(routing0, nullptr, "Error-- no Ipv4 routing protocol object at node 0");
546 Ptr<Ipv4GlobalRouting> globalRouting0 = routing0->GetObject<Ipv4GlobalRouting>();
547 NS_TEST_ASSERT_MSG_NE(globalRouting0, nullptr, "Error-- no Ipv4GlobalRouting object at node 0");
548
549 // Check that the right number of entries are in the routing table
550 uint32_t nRoutes0 = globalRouting0->GetNRoutes();
551 NS_TEST_ASSERT_MSG_EQ(nRoutes0, 1, "Error-- default route not found for stub node");
552
553 Ipv4RoutingTableEntry* route = nullptr;
554 route = globalRouting0->GetRoute(0);
555 // the only route is the default route on this node
557 Ipv4Address("0.0.0.0"),
558 "Error-- wrong destination for default route");
559 NS_TEST_ASSERT_MSG_EQ(route->GetGateway(), Ipv4Address("10.1.1.2"), "Error-- wrong gateway");
560
561 // Test 2: Check if SPFCalculate sets the correct routes for node 2
562 Ptr<Ipv4L3Protocol> ip2 = nodes.Get(2)->GetObject<Ipv4L3Protocol>();
563 NS_TEST_ASSERT_MSG_NE(ip2, nullptr, "Error-- no Ipv4 object at node 2");
564 Ptr<Ipv4RoutingProtocol> routing2 = ip2->GetRoutingProtocol();
565 NS_TEST_ASSERT_MSG_NE(routing2, nullptr, "Error-- no Ipv4 routing protocol object at node 2");
566 Ptr<Ipv4GlobalRouting> globalRouting2 = routing2->GetObject<Ipv4GlobalRouting>();
567 NS_TEST_ASSERT_MSG_NE(globalRouting2, nullptr, "Error-- no Ipv4GlobalRouting object at node 2");
568
569 // check that the correct number of routes were built
570 uint32_t nRoutes2 = globalRouting2->GetNRoutes();
571 NS_LOG_DEBUG("LinkRoutesTest nRoutes2 " << nRoutes2);
572 NS_TEST_ASSERT_MSG_EQ(nRoutes2, 6, "Error--- Incorrect number of routes found on node 2");
573
574 // check that all the routes in the routing table are correct for node 2
575 std::vector<Ipv4Address> expecteddests;
576 std::vector<Ipv4Address> expectedgws;
577 expecteddests.emplace_back("10.1.1.1");
578 expecteddests.emplace_back("10.1.2.1");
579 expecteddests.emplace_back("10.1.3.2");
580 expecteddests.emplace_back("10.1.1.0");
581 expecteddests.emplace_back("10.1.2.0");
582 expecteddests.emplace_back("10.1.3.0");
583
584 expectedgws.emplace_back("10.1.1.1");
585 expectedgws.emplace_back("10.1.2.1");
586 expectedgws.emplace_back("10.1.3.2");
587 expectedgws.emplace_back("10.1.1.1");
588 expectedgws.emplace_back("10.1.2.1");
589 expectedgws.emplace_back("10.1.3.2");
590
591 CheckRoutesv4(globalRouting2, expecteddests, expectedgws);
592
593 //-----------------Now the tests for Ipv6------------------
594 // Test 1: Check if the SPF calculate Sets default routes for Stub nodes
595 Ptr<Ipv6L3Protocol> ip0v6 = nodes.Get(0)->GetObject<Ipv6L3Protocol>();
596 NS_TEST_ASSERT_MSG_NE(ip0v6, nullptr, "Error-- no Ipv6 object at node 0");
597 Ptr<Ipv6RoutingProtocol> routing0v6 = ip0v6->GetRoutingProtocol();
598 NS_TEST_ASSERT_MSG_NE(routing0v6, nullptr, "Error-- no Ipv6 routing protocol object at node 0");
599 Ptr<Ipv6GlobalRouting> globalRouting0v6 = routing0v6->GetObject<Ipv6GlobalRouting>();
600 NS_TEST_ASSERT_MSG_NE(globalRouting0v6,
601 nullptr,
602 "Error-- no Ipv6GlobalRouting object at node 0");
603
604 // Check that the right number of entries are in the routing table
605 uint32_t nRoutes0v6 = globalRouting0v6->GetNRoutes();
606 NS_TEST_ASSERT_MSG_EQ(nRoutes0v6, 1, "Error-- default route not found for stub node");
607
608 Ipv6RoutingTableEntry* routev6 = nullptr;
609 routev6 = globalRouting0v6->GetRoute(0);
610 // the only route is the default route on this node
612 Ipv6Address("::"),
613 "Error-- wrong destination for default route");
615 Ipv6Address("fe80::200:ff:fe00:2"),
616 "Error-- wrong gateway");
617
618 // Test 2: Check if SPFCalculate sets the correct routes for node 2
619 Ptr<Ipv6L3Protocol> ip2v6 = nodes.Get(2)->GetObject<Ipv6L3Protocol>();
620 NS_TEST_ASSERT_MSG_NE(ip2v6, nullptr, "Error-- no Ipv6 object at node 2");
621 Ptr<Ipv6RoutingProtocol> routing2v6 = ip2v6->GetRoutingProtocol();
622 NS_TEST_ASSERT_MSG_NE(routing2v6, nullptr, "Error-- no Ipv6 routing protocol object at node 2");
623 Ptr<Ipv6GlobalRouting> globalRouting2v6 = routing2v6->GetObject<Ipv6GlobalRouting>();
624 NS_TEST_ASSERT_MSG_NE(globalRouting2v6,
625 nullptr,
626 "Error-- no Ipv6GlobalRouting object at node 2");
627
628 // check that the correct number of routes were built
629 uint32_t nRoutes2v6 = globalRouting2v6->GetNRoutes();
630 NS_LOG_DEBUG("LinkRoutesTest nRoutes2 " << nRoutes2v6);
631 NS_TEST_ASSERT_MSG_EQ(nRoutes2v6, 6, "Error--- Incorrect number of routes found on node 2");
632
633 // check that all the routes in the routing table are correct for node 2
634 std::vector<Ipv6Address> expecteddestsv6;
635 std::vector<Ipv6Address> expectedgwsv6;
636 expecteddestsv6.emplace_back("2001:1::200:ff:fe00:1");
637 expecteddestsv6.emplace_back("2001:2::200:ff:fe00:3");
638 expecteddestsv6.emplace_back("2001:3::200:ff:fe00:6");
639 expecteddestsv6.emplace_back("2001:1::");
640 expecteddestsv6.emplace_back("2001:2::");
641 expecteddestsv6.emplace_back("2001:3::");
642
643 expectedgwsv6.emplace_back("fe80::200:ff:fe00:1");
644 expectedgwsv6.emplace_back("fe80::200:ff:fe00:3");
645 expectedgwsv6.emplace_back("fe80::200:ff:fe00:6");
646 expectedgwsv6.emplace_back("fe80::200:ff:fe00:1");
647 expectedgwsv6.emplace_back("fe80::200:ff:fe00:3");
648 expectedgwsv6.emplace_back("fe80::200:ff:fe00:6");
649
650 CheckRoutesv6(globalRouting2v6, expecteddestsv6, expectedgwsv6);
651
653
656
657 // This delete clears the srm, which deletes the LSDB, which clears
658 // all of the LSAs, which each destroys the attached LinkRecords.
659 delete srm;
660 delete srmv6;
661 // reset the router ID counter to zero so that it does not affect other tests
662 // that may run after this one in the same program run.
665}
666
667/**
668 * @ingroup internet-test
669 *
670 * @brief This test case is to check if NetworkRoutes are being built correctly, i.e if route
671 * computation works for a LAN Topology.
672 */
674{
675 public:
677 void DoSetup() override;
678 void DoRun() override;
679
680 private:
681 /**
682 *@brief Builds the ipv4 LSAs for the topology. These LSAs are manually created and inserted
683 *into the GlobalRouteManagerLSDB.Each node exports a router LSA. In addition,the designated
684 *router also Exports the Network LSA.
685 */
686 void BuildLsav4();
687
688 /**
689 *@brief Builds the ipv6 LSAs for the topology. These LSAs are manually created and inserted
690 *into the GlobalRouteManagerLSDB.Each node exports a router LSA. In addition,the designated
691 *router also Exports the Network LSA.
692 */
693 void BuildLsav6();
694
695 NodeContainer nodes; //!< NodeContainer to hold the nodes in the topology
696 std::vector<GlobalRoutingLSA<Ipv4Manager>*> m_lsasv4; //!< The ipv4 LSAs for the topology
697 std::vector<GlobalRoutingLSA<Ipv6Manager>*> m_lsasv6; //!< The ipv6 LSAs for the topology
698};
699
701 : TestCase("LanRoutesTestCase")
702{
703}
704
705void
707{
708 // Simple Csma Network with three nodes
709 //
710 // n0 n1
711 // | (shared csma/cd) |
712 // -------------------------
713 // |
714 // n2
715 //
716 // n0:10.1.1.1/29
717 // n1:10.1.1.2/29
718 // n2:10.1.1.3/29
719 nodes.Create(3);
720 Ipv4GlobalRoutingHelper globalhelperv4;
721 Ipv6GlobalRoutingHelper globalhelperv6;
723 stack.SetRoutingHelper(globalhelperv4);
724 stack.SetRoutingHelper(globalhelperv6);
725 stack.Install(nodes);
726 SimpleNetDeviceHelper devHelper;
728 NetDeviceContainer d012 = devHelper.Install(nodes.Get(0), channel);
729 d012.Add(devHelper.Install(nodes.Get(1), channel));
730 d012.Add(devHelper.Install(nodes.Get(2), channel));
731
732 // assign IP addresses to the devices
733 Ipv4AddressHelper address;
734 address.SetBase("10.1.1.0", "255.255.255.248");
735 Ipv4InterfaceContainer i012 = address.Assign(d012);
736
737 Ipv6AddressHelper addressv6;
738 addressv6.SetBase("2001:1::", Ipv6Prefix(64));
739 Ipv6InterfaceContainer i012v6 = addressv6.Assign(d012);
740}
741
742void
744{
745 // we manually create the link state database, we could have used BuildRoutingTables() but this
746 // way testing the GlobalRouteManagerImpl without the involvement of GLobalRouter makes it
747 // easier to debug each individually
748
749 // router 0
752 "10.1.1.1",
753 "10.1.1.1",
754 1);
755 auto lsa0 = new GlobalRoutingLSA<Ipv4Manager>();
757 lsa0->AddLinkRecord(lr0);
758 lsa0->SetLinkStateId("0.0.0.0");
759 lsa0->SetAdvertisingRouter("0.0.0.0");
760 lsa0->SetNode(nodes.Get(0));
761 m_lsasv4.push_back(lsa0);
762
763 // router 1
766 "10.1.1.1",
767 "10.1.1.2",
768 1);
769 auto lsa1 = new GlobalRoutingLSA<Ipv4Manager>();
771 lsa1->AddLinkRecord(lr1);
772 lsa1->SetLinkStateId("0.0.0.1");
773 lsa1->SetAdvertisingRouter("0.0.0.1");
774 lsa1->SetNode(nodes.Get(1));
775 m_lsasv4.push_back(lsa1);
776
777 // router 2
780 "10.1.1.1",
781 "10.1.1.3",
782 1);
783 auto lsa2 = new GlobalRoutingLSA<Ipv4Manager>();
785 lsa2->AddLinkRecord(lr2);
786 lsa2->SetLinkStateId("0.0.0.2");
787 lsa2->SetAdvertisingRouter("0.0.0.2");
788 lsa2->SetNode(nodes.Get(2));
789 m_lsasv4.push_back(lsa2);
790
791 // router0 is the designated router for the LAN. it also exports the network LSA
792 auto lsa0network = new GlobalRoutingLSA<Ipv4Manager>();
793 lsa0network->SetLSType(GlobalRoutingLSA<Ipv4Manager>::NetworkLSA);
794 lsa0network->SetLinkStateId("10.1.1.1");
795 lsa0network->SetAdvertisingRouter("0.0.0.0");
796 lsa0network->AddAttachedRouter("10.1.1.1");
797 lsa0network->AddAttachedRouter("10.1.1.2");
798 lsa0network->AddAttachedRouter("10.1.1.3");
799 lsa0network->SetNetworkLSANetworkMask("255.255.255.248");
800 m_lsasv4.push_back(lsa0network); // note the index of the network lsa
801}
802
803void
805{
806 // we manually create the link state database, we could have used BuildRoutingTables() but this
807 // way testing the GlobalRouteManagerImpl without the involvement of GLobalRouter makes it
808 // easier to debug each individually
809
810 // router 0
813 "2001:1::200:ff:fe00:1", // link id -> Link ID is the ip address of the designated router
814 "2001:1::200:ff:fe00:1", // link data is this routers own Global Unicast ip address
815 "fe80::200:ff:fe00:1", // the link local data is the link local address of this router for
816 // this link
817 1);
818 auto lsa0 = new GlobalRoutingLSA<Ipv6Manager>();
820 lsa0->AddLinkRecord(lr0);
821 lsa0->SetLinkStateId("::ffff:0.0.0.0");
822 lsa0->SetAdvertisingRouter("::ffff:0.0.0.0");
823 lsa0->SetNode(nodes.Get(0));
824 m_lsasv6.push_back(lsa0);
825
826 // router 1
829 "2001:1::200:ff:fe00:1", // link id -> Link ID is the ip address of the designated router
830 "2001:1::200:ff:fe00:2", // link data is this routers own Global Unicast ip address
831 "fe80::200:ff:fe00:2", // the link local data is the link local address of this router for
832 // this link
833 1);
834 auto lsa1 = new GlobalRoutingLSA<Ipv6Manager>();
836 lsa1->AddLinkRecord(lr1);
837 lsa1->SetLinkStateId("::ffff:0.0.0.1");
838 lsa1->SetAdvertisingRouter("::ffff:0.0.0.1");
839 lsa1->SetNode(nodes.Get(1));
840 m_lsasv6.push_back(lsa1);
841
842 // router 2
845 "2001:1::200:ff:fe00:1",
846 "2001:1::200:ff:fe00:3",
847 "fe80::200:ff:fe00:3",
848 1);
849 auto lsa2 = new GlobalRoutingLSA<Ipv6Manager>();
851 lsa2->AddLinkRecord(lr2);
852 lsa2->SetLinkStateId("::ffff:0.0.0.2");
853 lsa2->SetAdvertisingRouter("::ffff:0.0.0.2");
854 lsa2->SetNode(nodes.Get(2));
855 m_lsasv6.push_back(lsa2);
856
857 // router0 is the designated router for the LAN. it also exports the network LSA
858 auto lsa0network = new GlobalRoutingLSA<Ipv6Manager>();
859 lsa0network->SetLSType(GlobalRoutingLSA<Ipv6Manager>::NetworkLSA);
860 lsa0network->SetLinkStateId("2001:1::200:ff:fe00:1");
861 lsa0network->SetAdvertisingRouter("::ffff:0.0.0.0");
862 lsa0network->AddAttachedRouter("2001:1::200:ff:fe00:1");
863 lsa0network->AddAttachedRouter("2001:1::200:ff:fe00:2");
864 lsa0network->AddAttachedRouter("2001:1::200:ff:fe00:3");
865
866 lsa0network->SetNetworkLSANetworkMask(Ipv6Prefix(64));
867 m_lsasv6.push_back(lsa0network); // note the index of the network lsa
868}
869
870void
872{
873 BuildLsav4();
874 // insert the LSAs into the GlobalRouteManagerLSDB
875 auto srmlsdb = new GlobalRouteManagerLSDB<Ipv4Manager>();
876
877 srmlsdb->Insert(m_lsasv4[0]->GetLinkStateId(), m_lsasv4[0]);
878 srmlsdb->Insert(m_lsasv4[1]->GetLinkStateId(), m_lsasv4[1]);
879 srmlsdb->Insert(m_lsasv4[2]->GetLinkStateId(), m_lsasv4[2]);
880 srmlsdb->Insert(m_lsasv4[3]->GetLinkStateId(), m_lsasv4[3]);
881
882 // create the GlobalRouteManagerImpl
883 auto srmv4 = new GlobalRouteManagerImpl<Ipv4Manager>();
884 srmv4->DebugUseLsdb(srmlsdb);
885
886 srmv4->DebugSPFCalculate(m_lsasv4[0]->GetLinkStateId()); // fill the routing table for node 0
887
888 // now for ipv6
889 BuildLsav6();
890 // insert the LSAs into the GlobalRouteManagerLSDB
891 auto srmlsdbv6 = new GlobalRouteManagerLSDB<Ipv6Manager>();
892
893 srmlsdbv6->Insert(m_lsasv6[0]->GetLinkStateId(), m_lsasv6[0]);
894 srmlsdbv6->Insert(m_lsasv6[1]->GetLinkStateId(), m_lsasv6[1]);
895 srmlsdbv6->Insert(m_lsasv6[2]->GetLinkStateId(), m_lsasv6[2]);
896 srmlsdbv6->Insert(m_lsasv6[3]->GetLinkStateId(), m_lsasv6[3]);
897
898 // create the GlobalRouteManagerImpl
899 auto srmv6 = new GlobalRouteManagerImpl<Ipv6Manager>();
900 srmv6->DebugUseLsdb(srmlsdbv6);
901
902 srmv6->DebugSPFCalculate(m_lsasv6[0]->GetLinkStateId()); // fill the routing table for node 0
903
904 // now the tests for IPv4-----------------------
905
906 Ptr<Ipv4L3Protocol> ip0 = nodes.Get(0)->GetObject<Ipv4L3Protocol>();
907 NS_TEST_ASSERT_MSG_NE(ip0, nullptr, "Error-- no Ipv4 object at node 0");
908 Ptr<Ipv4RoutingProtocol> routing0 = ip0->GetRoutingProtocol();
909 NS_TEST_ASSERT_MSG_NE(routing0, nullptr, "Error-- no Ipv4 routing protocol object at node 0");
910 Ptr<Ipv4GlobalRouting> globalRouting0 = routing0->GetObject<Ipv4GlobalRouting>();
911 NS_TEST_ASSERT_MSG_NE(globalRouting0, nullptr, "Error-- no Ipv4GlobalRouting object at node 0");
912
913 // The only route to check is the network route
914 uint32_t nRoutes0 = globalRouting0->GetNRoutes();
915 NS_TEST_ASSERT_MSG_EQ(nRoutes0, 1, "Error-- Network route not found for node 0");
916 Ipv4RoutingTableEntry* route = globalRouting0->GetRoute(0);
918 Ipv4Address("10.1.1.0"),
919 "Error-- wrong destination for network route");
921 Ipv4Address("0.0.0.0"),
922 "Error-- wrong gateway for network route");
923
924 // now the tests for IPv6-----------------------
925
926 Ptr<Ipv6L3Protocol> ip0v6 = nodes.Get(0)->GetObject<Ipv6L3Protocol>();
927 NS_TEST_ASSERT_MSG_NE(ip0v6, nullptr, "Error-- no Ipv6 object at node 0");
928 Ptr<Ipv6RoutingProtocol> routing0v6 = ip0v6->GetRoutingProtocol();
929 NS_TEST_ASSERT_MSG_NE(routing0v6, nullptr, "Error-- no Ipv6 routing protocol object at node 0");
930 Ptr<Ipv6GlobalRouting> globalRouting0v6 = routing0v6->GetObject<Ipv6GlobalRouting>();
931 NS_TEST_ASSERT_MSG_NE(globalRouting0v6,
932 nullptr,
933 "Error-- no Ipv6GlobalRouting object at node 0");
934
935 // The only route to check is the network route
936 uint32_t nRoutes0v6 = globalRouting0v6->GetNRoutes();
937 NS_TEST_ASSERT_MSG_EQ(nRoutes0v6, 1, "Error-- Network route not found for node 0");
938 Ipv6RoutingTableEntry* routev6 = globalRouting0v6->GetRoute(0);
940 Ipv6Address("2001:1::"),
941 "Error-- wrong destination for network route");
943 Ipv6Address("::"),
944 "Error-- wrong gateway for network route");
945
947
950 // This delete clears the srm, which deletes the LSDB, which clears
951 // all of the LSAs, which each destroys the attached LinkRecords.
952 delete srmv4;
953 delete srmv6;
956}
957
958/**
959 * @ingroup internet-test
960 *
961 * @brief The purpose of this test is to check if Equal Cost MultiPath (ECMP) Routes are being built
962 * and used correctly.
963 */
965{
966 public:
968
969 void DoSetup() override;
970 void DoRun() override;
971
972 private:
973 /**
974 *@brief Builds the LSAs for the topology. These LSAs are manually created and inserted into the
975 * GlobalRouteManagerLSDB.Each node exports a router LSA.
976 */
977 void BuildLsav4();
978
979 /**
980 *@brief Builds the LSAs for the topology. These LSAs are manually created and inserted into the
981 * GlobalRouteManagerLSDB.Each node exports a router LSA.
982 */
983 void BuildLsav6();
984
985 /**
986 * @brief Helper function that checks the output of the routing path
987 * and increments the corresponding route counter.
988 * @param route The routing path to check
989 */
990 void IncrementCountv4(Ptr<Ipv4Route>& route);
991
992 /**
993 * @brief Helper function that checks the output of the routing path
994 * and increments the corresponding route counter.
995 * @param route The routing path to check
996 */
997 void IncrementCountv6(Ptr<Ipv6Route>& route);
998 /**
999 * @brief function that checks the routing table entries for the expected output.
1000 * @param globalroutingprotocol The routing protocol for the node whose routing table is to be
1001 * checked.
1002 * @param dests The expected destinations.
1003 * @param gws The expected gateways.
1004 */
1005 void CheckRoutesv4(Ptr<Ipv4GlobalRouting>& globalroutingprotocol,
1006 std::vector<Ipv4Address>& dests,
1007 std::vector<Ipv4Address>& gws);
1008
1009 /**
1010 * @brief function that checks the routing table entries for the expected output.
1011 * @param globalroutingprotocol The routing protocol for the node whose routing table is to be
1012 * checked.
1013 * @param dests The expected destinations.
1014 * @param gws The expected gateways.
1015 */
1016 void CheckRoutesv6(Ptr<Ipv6GlobalRouting>& globalroutingprotocol,
1017 std::vector<Ipv6Address>& dests,
1018 std::vector<Ipv6Address>& gws);
1019 uint32_t route1v4 = 0; //!< Counter to keep track of the number of times route1 is used for ipv4
1020 uint32_t route2v4 = 0; //!< Counter to keep track of the number of times route2 is used for ipv4
1021 uint32_t route1v6 = 0; //!< Counter to keep track of the number of times route1 is used for ipv6
1022 uint32_t route2v6 = 0; //!< Counter to keep track of the number of times route2 is used for ipv6
1023 NodeContainer nodes; //!< NodeContainer to hold the nodes in the topology
1024 std::vector<GlobalRoutingLSA<Ipv4Manager>*> m_lsasv4; //!< The LSAs for the topology
1025 std::vector<GlobalRoutingLSA<Ipv6Manager>*> m_lsasv6; //!< The LSAs for the topology
1026};
1027
1029 : TestCase("RandomEcmpTestCase")
1030{
1031}
1032
1033void
1035{
1036 Config::SetDefault("ns3::Ipv4GlobalRouting::RandomEcmpRouting", BooleanValue(true));
1037 Config::SetDefault("ns3::Ipv6GlobalRouting::RandomEcmpRouting", BooleanValue(true));
1038
1039 /*
1040 // Creating a Simple topology with 4 nodes and 3 links
1041 //
1042 //
1043 //
1044 // ------n1------
1045 // / \
1046 // / \
1047 // n0 n3
1048 // \ /
1049 // \ /
1050 // ------n2------
1051 //
1052 // Link n0-n1: 10.1.1.1/30,10.1.1.2/30
1053 // Link n0-n2: 10.1.2.1/30,10.1.2.2/30
1054 // Link n1-n3: 10.1.3.1/30,10.1.3.2/30
1055 // Link n2-n3: 10.1.4.1/30,10.1.4.2/30
1056 */
1057 nodes.Create(4);
1058
1059 Ipv4GlobalRoutingHelper globalhelper;
1060 Ipv6GlobalRoutingHelper globalhelperv6;
1061 InternetStackHelper stack;
1062 stack.SetRoutingHelper(globalhelper);
1063 stack.SetRoutingHelper(globalhelperv6);
1064 stack.Install(nodes);
1065 SimpleNetDeviceHelper devHelper;
1066 devHelper.SetNetDevicePointToPointMode(true);
1068 NetDeviceContainer d01 = devHelper.Install(nodes.Get(0), channel1);
1069 d01.Add(devHelper.Install(nodes.Get(1), channel1));
1071 NetDeviceContainer d23 = devHelper.Install(nodes.Get(2), channel2);
1072 d23.Add(devHelper.Install(nodes.Get(3), channel2));
1074 NetDeviceContainer d02 = devHelper.Install(nodes.Get(0), channel3);
1075 d02.Add(devHelper.Install(nodes.Get(2), channel3));
1077 NetDeviceContainer d13 = devHelper.Install(nodes.Get(1), channel4);
1078 d13.Add(devHelper.Install(nodes.Get(3), channel4));
1079
1080 // Assign IP addresses to the devices
1081 Ipv4AddressHelper address;
1082 address.SetBase("10.1.1.0", "255.255.255.252");
1083 Ipv4InterfaceContainer i01 = address.Assign(d01);
1084
1085 address.SetBase("10.1.2.0", "255.255.255.252");
1086 Ipv4InterfaceContainer i02 = address.Assign(d02);
1087
1088 address.SetBase("10.1.3.0", "255.255.255.252");
1089 Ipv4InterfaceContainer i13 = address.Assign(d13);
1090
1091 address.SetBase("10.1.4.0", "255.255.255.252");
1092 Ipv4InterfaceContainer i23 = address.Assign(d23);
1093
1094 Ipv6AddressHelper addressv6;
1095 addressv6.SetBase("2001:1::", Ipv6Prefix(64));
1096 Ipv6InterfaceContainer i01v6 = addressv6.Assign(d01);
1097 addressv6.SetBase("2001:2::", Ipv6Prefix(64));
1098 Ipv6InterfaceContainer i02v6 = addressv6.Assign(d02);
1099 addressv6.SetBase("2001:3::", Ipv6Prefix(64));
1100 Ipv6InterfaceContainer i13v6 = addressv6.Assign(d13);
1101 addressv6.SetBase("2001:4::", Ipv6Prefix(64));
1102 Ipv6InterfaceContainer i23v6 = addressv6.Assign(d23);
1103}
1104
1105void
1107 std::vector<Ipv4Address>& dests,
1108 std::vector<Ipv4Address>& gws)
1109{
1110 // check each individual routes destination and gateway
1111 for (uint32_t i = 0; i < globalroutingprotocol->GetNRoutes(); i++)
1112 {
1113 Ipv4RoutingTableEntry* route = globalroutingprotocol->GetRoute(i);
1114 NS_LOG_DEBUG("dest " << route->GetDest() << " gw " << route->GetGateway());
1115 NS_TEST_ASSERT_MSG_EQ(route->GetDest(), dests[i], "Error-- wrong destination");
1116 NS_TEST_ASSERT_MSG_EQ(route->GetGateway(), gws[i], "Error-- wrong gateway");
1117 }
1118}
1119
1120void
1122 std::vector<Ipv6Address>& dests,
1123 std::vector<Ipv6Address>& gws)
1124{
1125 // check each individual routes destination and gateway
1126 for (uint32_t i = 0; i < globalroutingprotocol->GetNRoutes(); i++)
1127 {
1128 Ipv6RoutingTableEntry* route = globalroutingprotocol->GetRoute(i);
1129 NS_LOG_DEBUG("dest " << route->GetDest() << " gw " << route->GetGateway());
1130 NS_TEST_ASSERT_MSG_EQ(route->GetDest(), dests[i], "Error-- wrong destination");
1131 NS_TEST_ASSERT_MSG_EQ(route->GetGateway(), gws[i], "Error-- wrong gateway");
1132 }
1133}
1134
1135void
1137{
1138 if (route->GetGateway() == Ipv4Address("10.1.1.2"))
1139 {
1140 route1v4++;
1141 }
1142 else if (route->GetGateway() == Ipv4Address("10.1.2.2"))
1143 {
1144 route2v4++;
1145 }
1146}
1147
1148void
1150{
1151 if (route->GetGateway() == Ipv6Address("fe80::200:ff:fe00:2"))
1152 {
1153 route1v6++;
1154 }
1155 else if (route->GetGateway() == Ipv6Address("fe80::200:ff:fe00:6"))
1156 {
1157 route2v6++;
1158 }
1159}
1160
1161void
1163{
1164 // we manually create the link state database, we could have used BuildRoutingTables() but this
1165 // way testing the GlobalRouteManagerImpl without the involvement of GLobalRouter makes it
1166 // easier to debug each individually
1167
1168 // router 0
1169 auto lr0 =
1171 "0.0.0.1",
1172 "10.1.1.1",
1173 1);
1174 auto lr1 =
1176 "10.1.1.2",
1177 "255.255.255.252",
1178 1);
1179
1180 auto lr2 =
1182 "0.0.0.2",
1183 "10.1.2.1",
1184 1);
1185 auto lr3 =
1187 "10.1.2.2",
1188 "255.255.255.252",
1189 1);
1190
1191 auto lsa0 = new GlobalRoutingLSA<Ipv4Manager>();
1194 lsa0->SetLinkStateId("0.0.0.0");
1195 lsa0->SetAdvertisingRouter("0.0.0.0");
1196 lsa0->SetNode(nodes.Get(0));
1197 lsa0->AddLinkRecord(lr0);
1198 lsa0->AddLinkRecord(lr1);
1199 lsa0->AddLinkRecord(lr2);
1200 lsa0->AddLinkRecord(lr3);
1201 m_lsasv4.push_back(lsa0);
1202
1203 // router 1
1204 auto lr4 =
1206 "0.0.0.0",
1207 "10.1.1.2",
1208 1);
1209 auto lr5 =
1211 "10.1.1.1",
1212 "255.255.255.252",
1213 1);
1214
1215 auto lr6 =
1217 "0.0.0.3",
1218 "10.1.3.1",
1219 1);
1220 auto lr7 =
1222 "10.1.3.2",
1223 "255.255.255.252",
1224 1);
1225
1226 auto lsa1 = new GlobalRoutingLSA<Ipv4Manager>();
1229 lsa1->SetLinkStateId("0.0.0.1");
1230 lsa1->SetAdvertisingRouter("0.0.0.1");
1231 lsa1->SetNode(nodes.Get(1));
1232 lsa1->AddLinkRecord(lr4);
1233 lsa1->AddLinkRecord(lr5);
1234 lsa1->AddLinkRecord(lr6);
1235 lsa1->AddLinkRecord(lr7);
1236 m_lsasv4.push_back(lsa1);
1237
1238 // router 2
1239 auto lr8 =
1241 "0.0.0.0",
1242 "10.1.2.2",
1243 1);
1244 auto lr9 =
1246 "10.1.2.1",
1247 "255.255.255.252",
1248 1);
1249 auto lr10 =
1251 "0.0.0.3",
1252 "10.1.4.1",
1253 1);
1254 auto lr11 =
1256 "10.1.4.2",
1257 "255.255.255.252",
1258 1);
1259
1260 auto lsa2 = new GlobalRoutingLSA<Ipv4Manager>();
1263 lsa2->SetLinkStateId("0.0.0.2");
1264 lsa2->SetAdvertisingRouter("0.0.0.2");
1265 lsa2->SetNode(nodes.Get(2));
1266 lsa2->AddLinkRecord(lr8);
1267 lsa2->AddLinkRecord(lr9);
1268 lsa2->AddLinkRecord(lr10);
1269 lsa2->AddLinkRecord(lr11);
1270 m_lsasv4.push_back(lsa2);
1271
1272 // router 3
1273 auto lr12 =
1275 "0.0.0.1",
1276 "10.1.3.2",
1277 1);
1278 auto lr13 =
1280 "10.1.3.1",
1281 "255.255.255.252",
1282 1);
1283 auto lr14 =
1285 "0.0.0.2",
1286 "10.1.4.2",
1287 1);
1288 auto lr15 =
1290 "10.1.4.1",
1291 "255.255.255.252",
1292 1);
1293
1294 auto lsa3 = new GlobalRoutingLSA<Ipv4Manager>();
1297 lsa3->SetLinkStateId("0.0.0.3");
1298 lsa3->SetAdvertisingRouter("0.0.0.3");
1299 lsa3->SetNode(nodes.Get(3));
1300 lsa3->AddLinkRecord(lr12);
1301 lsa3->AddLinkRecord(lr13);
1302 lsa3->AddLinkRecord(lr14);
1303 lsa3->AddLinkRecord(lr15);
1304 m_lsasv4.push_back(lsa3);
1305}
1306
1307void
1309{
1310 // we manually create the link state database, we could have used BuildRoutingTables() but this
1311 // way testing the GlobalRouteManagerImpl without the involvement of GLobalRouter makes it
1312 // easier to debug each individually
1313
1314 // router 0
1315 auto lr0 =
1317 "::ffff:0.0.0.1",
1318 "2001:1::200:ff:fe00:1",
1319 "fe80::200:ff:fe00:1",
1320 1);
1321 // only need to do this once for prefix of 64 bits
1322 uint8_t buf[16];
1323 auto prefix = Ipv6Prefix(64);
1324 prefix.GetBytes(buf); // frown
1325
1326 auto lr1 =
1328 "2001:1::200:ff:fe00:2",
1329 Ipv6Address(buf),
1330 1);
1331 auto lr2 =
1333 "::ffff:0.0.0.2",
1334 "2001:2::200:ff:fe00:5",
1335 "fe80::200:ff:fe00:5",
1336 1);
1337 auto lr3 =
1339 "2001:2::200:ff:fe00:6",
1340 Ipv6Address(buf),
1341 1);
1342
1343 auto lsa0 = new GlobalRoutingLSA<Ipv6Manager>();
1346 lsa0->SetLinkStateId("::ffff:0.0.0.0");
1347 lsa0->SetAdvertisingRouter("::ffff:0.0.0.0");
1348 lsa0->SetNode(nodes.Get(0));
1349 lsa0->AddLinkRecord(lr0);
1350 lsa0->AddLinkRecord(lr1);
1351 lsa0->AddLinkRecord(lr2);
1352 lsa0->AddLinkRecord(lr3);
1353 m_lsasv6.push_back(lsa0);
1354
1355 // router 1
1356 auto lr4 =
1358 "::ffff:0.0.0.0",
1359 "2001:1::200:ff:fe00:2",
1360 "fe80::200:ff:fe00:2",
1361 1);
1362 auto lr5 =
1364 "2001:1::200:ff:fe00:1",
1365 Ipv6Address(buf),
1366 1);
1367
1368 auto lr6 =
1370 "::ffff:0.0.0.3",
1371 "2001:3::200:ff:fe00:7",
1372 "fe80::200:ff:fe00:7",
1373 1);
1374 auto lr7 =
1376 "2001:3::200:ff:fe00:8",
1377 Ipv6Address(buf),
1378 1);
1379
1380 auto lsa1 = new GlobalRoutingLSA<Ipv6Manager>();
1383 lsa1->SetLinkStateId("::ffff:0.0.0.1");
1384 lsa1->SetAdvertisingRouter("::ffff:0.0.0.1");
1385 lsa1->SetNode(nodes.Get(1));
1386 lsa1->AddLinkRecord(lr4);
1387 lsa1->AddLinkRecord(lr5);
1388 lsa1->AddLinkRecord(lr6);
1389 lsa1->AddLinkRecord(lr7);
1390 m_lsasv6.push_back(lsa1);
1391
1392 // router 2
1393 auto lr8 =
1395 "::ffff:0.0.0.0",
1396 "2001:2::200:ff:fe00:6",
1397 "fe80::200:ff:fe00:6",
1398 1);
1399 auto lr9 =
1401 "2001:2::200:ff:fe00:5",
1402 Ipv6Address(buf),
1403 1);
1404 auto lr10 =
1406 "::ffff:0.0.0.3",
1407 "2001:4::200:ff:fe00:3",
1408 "fe80::200:ff:fe00:3",
1409 1);
1410 auto lr11 =
1412 "2001:4::200:ff:fe00:4",
1413 Ipv6Address(buf),
1414 1);
1415
1416 auto lsa2 = new GlobalRoutingLSA<Ipv6Manager>();
1419 lsa2->SetLinkStateId("::ffff:0.0.0.2");
1420 lsa2->SetAdvertisingRouter("::ffff:0.0.0.2");
1421 lsa2->SetNode(nodes.Get(2));
1422 lsa2->AddLinkRecord(lr8);
1423 lsa2->AddLinkRecord(lr9);
1424 lsa2->AddLinkRecord(lr10);
1425 lsa2->AddLinkRecord(lr11);
1426 m_lsasv6.push_back(lsa2);
1427
1428 // router 3
1429 auto lr12 =
1431 "::ffff:0.0.0.1",
1432 "2001:3::200:ff:fe00:8",
1433 "fe80::200:ff:fe00:8",
1434 1);
1435 auto lr13 =
1437 "2001:3::200:ff:fe00:7",
1438 Ipv6Address(buf),
1439 1);
1440 auto lr14 =
1442 "::ffff:0.0.0.2",
1443 "2001:4::200:ff:fe00:4",
1444 "fe80::200:ff:fe00:4",
1445 1);
1446 auto lr15 =
1448 "2001:4::200:ff:fe00:3",
1449 Ipv6Address(buf),
1450 1);
1451
1452 auto lsa3 = new GlobalRoutingLSA<Ipv6Manager>();
1455 lsa3->SetLinkStateId("::ffff:0.0.0.3");
1456 lsa3->SetAdvertisingRouter("::ffff:0.0.0.3");
1457 lsa3->SetNode(nodes.Get(3));
1458 lsa3->AddLinkRecord(lr12);
1459 lsa3->AddLinkRecord(lr13);
1460 lsa3->AddLinkRecord(lr14);
1461 lsa3->AddLinkRecord(lr15);
1462 m_lsasv6.push_back(lsa3);
1463}
1464
1465void
1467{
1468 // We need a deterministic output to pass the test. So we set a fixed seed and run for our
1469 // UniformRandomVariable
1474
1475 BuildLsav4();
1476
1477 // insert the LSAs into the GlobalRouteManagerLSDB
1478 auto srmlsdbv4 = new GlobalRouteManagerLSDB<Ipv4Manager>();
1479 srmlsdbv4->Insert(m_lsasv4[0]->GetLinkStateId(), m_lsasv4[0]);
1480 srmlsdbv4->Insert(m_lsasv4[1]->GetLinkStateId(), m_lsasv4[1]);
1481 srmlsdbv4->Insert(m_lsasv4[2]->GetLinkStateId(), m_lsasv4[2]);
1482 srmlsdbv4->Insert(m_lsasv4[3]->GetLinkStateId(), m_lsasv4[3]);
1483
1484 // create the GlobalRouteManagerImpl
1485 auto srmv4 = new GlobalRouteManagerImpl<Ipv4Manager>();
1486 srmv4->DebugUseLsdb(srmlsdbv4);
1487
1488 // we manually call the DebugSPFCalculate to fill the routing tables for node 0
1489 srmv4->DebugSPFCalculate(m_lsasv4[0]->GetLinkStateId());
1490
1491 // now for ipv6
1492 BuildLsav6();
1493
1494 // insert the LSAs into the GlobalRouteManagerLSDB
1495 auto srmlsdbv6 = new GlobalRouteManagerLSDB<Ipv6Manager>();
1496 srmlsdbv6->Insert(m_lsasv6[0]->GetLinkStateId(), m_lsasv6[0]);
1497 srmlsdbv6->Insert(m_lsasv6[1]->GetLinkStateId(), m_lsasv6[1]);
1498 srmlsdbv6->Insert(m_lsasv6[2]->GetLinkStateId(), m_lsasv6[2]);
1499 srmlsdbv6->Insert(m_lsasv6[3]->GetLinkStateId(), m_lsasv6[3]);
1500
1501 // create the GlobalRouteManagerImpl
1502 auto srmv6 = new GlobalRouteManagerImpl<Ipv6Manager>();
1503 srmv6->DebugUseLsdb(srmlsdbv6);
1504 // we manually call the DebugSPFCalculate to fill the routing tables for node 0
1505 srmv6->DebugSPFCalculate(m_lsasv6[0]->GetLinkStateId());
1506
1507 // now the tests-----------------------
1508
1509 Ptr<Ipv4L3Protocol> ip0 = nodes.Get(0)->GetObject<Ipv4L3Protocol>();
1510 NS_TEST_ASSERT_MSG_NE(ip0, nullptr, "Error-- no Ipv4 object at node 0");
1511 Ptr<Ipv4RoutingProtocol> routing0 = ip0->GetRoutingProtocol();
1512 NS_TEST_ASSERT_MSG_NE(routing0, nullptr, "Error-- no Ipv4 routing protocol object at node 0");
1513 Ptr<Ipv4GlobalRouting> globalRouting0 = routing0->GetObject<Ipv4GlobalRouting>();
1514 NS_TEST_ASSERT_MSG_NE(globalRouting0, nullptr, "Error-- no Ipv4GlobalRouting object at node 0");
1515
1516 // assign streams to the UniformRandomVariable
1517 globalRouting0->AssignStreams(0);
1518 // check that the correct number of routes were built
1519
1520 uint32_t nRoutes0 = globalRouting0->GetNRoutes();
1521 NS_TEST_ASSERT_MSG_EQ(nRoutes0, 14, "Error-- incorrect number of routes found on node 0");
1522
1523 // check that the routes are correct
1524 std::vector<Ipv4Address> expectedDests;
1525 std::vector<Ipv4Address> expectedNextHops;
1526
1527 // add all the expected destinations and gateways. This is pretty verbose
1528 // Please Note: The order of the following line is important because we check the routing table
1529 // entries in order. The test will fail if we reorder the vector entries.
1530
1531 // For Routing table of Node 0 we check the following Destinations and Gateways
1532 expectedDests.emplace_back("10.1.1.2");
1533 expectedDests.emplace_back("10.1.3.1");
1534 expectedDests.emplace_back("10.1.2.2");
1535 expectedDests.emplace_back("10.1.4.1");
1536 expectedDests.emplace_back("10.1.3.2");
1537 expectedDests.emplace_back("10.1.3.2");
1538 expectedDests.emplace_back("10.1.4.2");
1539 expectedDests.emplace_back("10.1.4.2");
1540 expectedDests.emplace_back("10.1.1.0");
1541 expectedDests.emplace_back("10.1.3.0");
1542 expectedDests.emplace_back("10.1.3.0");
1543 expectedDests.emplace_back("10.1.4.0");
1544 expectedDests.emplace_back("10.1.4.0");
1545 expectedDests.emplace_back("10.1.2.0");
1546
1547 expectedNextHops.emplace_back("10.1.1.2");
1548 expectedNextHops.emplace_back("10.1.1.2");
1549 expectedNextHops.emplace_back("10.1.2.2");
1550 expectedNextHops.emplace_back("10.1.2.2");
1551 expectedNextHops.emplace_back("10.1.1.2");
1552 expectedNextHops.emplace_back("10.1.2.2");
1553 expectedNextHops.emplace_back("10.1.1.2");
1554 expectedNextHops.emplace_back("10.1.2.2");
1555 expectedNextHops.emplace_back("10.1.1.2");
1556 expectedNextHops.emplace_back("10.1.1.2");
1557 expectedNextHops.emplace_back("10.1.2.2");
1558 expectedNextHops.emplace_back("10.1.1.2");
1559 expectedNextHops.emplace_back("10.1.2.2");
1560 expectedNextHops.emplace_back("10.1.2.2");
1561
1562 // Test 1: Check the Routing Table of Node 0
1563 CheckRoutesv4(globalRouting0, expectedDests, expectedNextHops);
1564
1565 // Test 2: Check that the equal cost routes are being used at least once.
1566 // we need to call RouteOutput() at node 0 and check the output
1567 // route from the table. The thing to check here is that different equal cost routes are
1568 // returned across different calls to this method.
1569
1570 Socket::SocketErrno errno_;
1571 Ptr<NetDevice> oif(nullptr);
1572 Ptr<Packet> packetv6 = Create<Packet>();
1573 Ipv4Header ipHeader;
1574 ipHeader.SetSource(Ipv4Address("10.1.1.1"));
1575 ipHeader.SetDestination(Ipv4Address("10.1.4.2"));
1576
1577 for (uint32_t i = 0; i < 10; i++)
1578 {
1579 Ptr<Ipv4Route> route = globalRouting0->RouteOutput(packetv6, ipHeader, oif, errno_);
1580 IncrementCountv4(route);
1581 }
1582
1583 // now the tests for IPv6-----------------------
1584
1585 Ptr<Ipv6L3Protocol> ip0v6 = nodes.Get(0)->GetObject<Ipv6L3Protocol>();
1586 NS_TEST_ASSERT_MSG_NE(ip0v6, nullptr, "Error-- no Ipv6 object at node 0");
1587 Ptr<Ipv6RoutingProtocol> routing0v6 = ip0v6->GetRoutingProtocol();
1588 NS_TEST_ASSERT_MSG_NE(routing0v6, nullptr, "Error-- no Ipv6 routing protocol object at node 0");
1589 Ptr<Ipv6GlobalRouting> globalRouting0v6 = routing0v6->GetObject<Ipv6GlobalRouting>();
1590 NS_TEST_ASSERT_MSG_NE(globalRouting0v6,
1591 nullptr,
1592 "Error-- no Ipv6GlobalRouting object at node 0");
1593
1594 // assign streams to the UniformRandomVariable
1595 globalRouting0v6->AssignStreams(0);
1596 // check that the correct number of routes were built
1597 uint32_t nRoutes0v6 = globalRouting0v6->GetNRoutes();
1598 NS_TEST_ASSERT_MSG_EQ(nRoutes0v6, 14, "Error-- incorrect number of routes found on node 0");
1599
1600 // check that the routes are correct
1601 std::vector<Ipv6Address> expectedDestsv6;
1602 std::vector<Ipv6Address> expectedNextHopsv6;
1603
1604 // add all the expected destinations and gateways. This is pretty verbose
1605 // Please Note: The order of the following line is important because we check the routing table
1606 // entries in order. The test will fail if we reorder the vector entries.
1607
1608 // For Routing table of Node 0 we check the following Destinations and Gateways
1609 expectedDestsv6.emplace_back("2001:1::200:ff:fe00:2");
1610 expectedDestsv6.emplace_back("2001:3::200:ff:fe00:7");
1611 expectedDestsv6.emplace_back("2001:2::200:ff:fe00:6");
1612 expectedDestsv6.emplace_back("2001:4::200:ff:fe00:3");
1613 expectedDestsv6.emplace_back("2001:3::200:ff:fe00:8");
1614 expectedDestsv6.emplace_back("2001:3::200:ff:fe00:8");
1615 expectedDestsv6.emplace_back("2001:4::200:ff:fe00:4");
1616 expectedDestsv6.emplace_back("2001:4::200:ff:fe00:4");
1617 expectedDestsv6.emplace_back("2001:1::");
1618 expectedDestsv6.emplace_back("2001:3::");
1619 expectedDestsv6.emplace_back("2001:3::");
1620 expectedDestsv6.emplace_back("2001:4::");
1621 expectedDestsv6.emplace_back("2001:4::");
1622 expectedDestsv6.emplace_back("2001:2::");
1623
1624 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:2");
1625 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:2");
1626 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:6");
1627 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:6");
1628 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:2");
1629 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:6");
1630 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:2");
1631 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:6");
1632 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:2");
1633 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:2");
1634 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:6");
1635 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:2");
1636 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:6");
1637 expectedNextHopsv6.emplace_back("fe80::200:ff:fe00:6");
1638 // Test 1: Check the Routing Table of Node 0
1639 CheckRoutesv6(globalRouting0v6, expectedDestsv6, expectedNextHopsv6);
1640
1641 // Test 2: Check that the equal cost routes are being used at least once.
1642 // we need to call RouteOutput() at node 0 and check the output
1643 // route from the table. The thing to check here is that different equal cost routes are
1644 // returned across different calls to this method.
1645
1646 Ptr<Packet> packet = Create<Packet>();
1647 Ipv6Header ipHeaderv6;
1648 ipHeaderv6.SetSource(Ipv6Address("2001:1::200:ff:fe00:1"));
1649 ipHeaderv6.SetDestination(Ipv6Address("2001:4::200:ff:fe00:4"));
1650
1651 for (uint32_t i = 0; i < 10; i++)
1652 {
1653 Ptr<Ipv6Route> route = globalRouting0v6->RouteOutput(packet, ipHeaderv6, oif, errno_);
1654 IncrementCountv6(route);
1655 }
1656
1658
1660 route1v4,
1661 1,
1662 "The routing path for node 0 to node 3 does not match the expected output, "
1663 "Equal Cost MultiPath (ECMP) routes are not being used correctly for ipv4");
1665 route2v4,
1666 1,
1667 "The routing path for node 0 to node 3 does not match the expected output, "
1668 "Equal Cost MultiPath (ECMP) routes are not being used correctly for ipv4");
1669
1671 route1v6,
1672 1,
1673 "The routing path for node 0 to node 3 does not match the expected output, "
1674 "Equal Cost MultiPath (ECMP) routes are not being used correctly for ipv6");
1676 route2v6,
1677 1,
1678 "The routing path for node 0 to node 3 does not match the expected output, "
1679 "Equal Cost MultiPath (ECMP) routes are not being used correctly for ipv6");
1680
1681 // end of test--------------------
1682
1684
1686
1687 RngSeedManager::SetSeed(oldseed);
1688 RngSeedManager::SetRun(oldrun);
1689 // This delete clears the srm, which deletes the LSDB, which clears
1690 // all of the LSAs, which each destroys the attached LinkRecords.
1691 delete srmv4;
1692 delete srmv6;
1693}
1694
1695/**
1696 * @ingroup internet-test
1697 *
1698 * @brief Global Route Manager TestSuite
1699 */
1701{
1702 public:
1704
1705 private:
1706};
1707
1715
1717 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.
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:201
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:267
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:492
#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:1313
Every class exported by the ns3 library is enclosed in the ns3 namespace.