Skip to content

Commit 5cc5c00

Browse files
internet: Add EcmpRouteCalculation testcase for GlobalRouting
1 parent ad08943 commit 5cc5c00

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

src/internet/test/ipv4-global-routing-test-suite.cc

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,6 +1276,126 @@ Ipv4GlobalRoutingSlash32TestCase::DoRun()
12761276
Simulator::Destroy();
12771277
}
12781278

1279+
/**
1280+
* @ingroup internet-test
1281+
*
1282+
* @brief This TestCase tests if ECMP Route Calculation works. It does not check the
1283+
* correctness of the routes.
1284+
*/
1285+
class EcmpRouteCalculationTestCase : public TestCase
1286+
{
1287+
public:
1288+
EcmpRouteCalculationTestCase();
1289+
void DoSetup() override;
1290+
void DoRun() override;
1291+
1292+
private:
1293+
NodeContainer nodes; //!< Nodes used in the test.
1294+
};
1295+
1296+
EcmpRouteCalculationTestCase::EcmpRouteCalculationTestCase()
1297+
: TestCase("ECMP Route Calculation TestCase")
1298+
{
1299+
}
1300+
1301+
void
1302+
EcmpRouteCalculationTestCase::DoSetup()
1303+
{
1304+
/*
1305+
This TestCase checks the resolution of issue #1243 in the issue tracker.
1306+
The problem was that Global Routing failed to calculate next hops when going from a
1307+
network vertex to a router vertex when ECMP Routes were involved.
1308+
1309+
// Network Topology
1310+
//
1311+
//
1312+
// ------n1------
1313+
// / \
1314+
// / \
1315+
// n0 n3----n4----n5
1316+
// \ /
1317+
// \ /
1318+
// ------n2------
1319+
//
1320+
// Link n0-n1: 10.1.1.1/30,10.1.1.2/30
1321+
// Link n0-n2: 10.1.2.1/30,10.1.2.2/30
1322+
// Link n1-n3: 10.1.3.1/30,10.1.3.2/30
1323+
// Link n2-n3: 10.1.4.1/30,10.1.4.2/30
1324+
// Link n3-n4: 10.1.5.1/24,10.1.5.2/24
1325+
// Link n4-n5: 10.1.6.1/24,10.1.6.2/24
1326+
//
1327+
// Note: Link n4-n5 is a LAN LINK. All others are simple P2P links.
1328+
*/
1329+
1330+
nodes.Create(6);
1331+
1332+
Ipv4GlobalRoutingHelper globalhelper;
1333+
InternetStackHelper stack;
1334+
stack.SetRoutingHelper(globalhelper);
1335+
stack.Install(nodes);
1336+
SimpleNetDeviceHelper devHelper;
1337+
devHelper.SetNetDevicePointToPointMode(true);
1338+
1339+
Ptr<SimpleChannel> channel1 = CreateObject<SimpleChannel>();
1340+
NetDeviceContainer d01 = devHelper.Install(nodes.Get(0), channel1);
1341+
d01.Add(devHelper.Install(nodes.Get(1), channel1));
1342+
1343+
Ptr<SimpleChannel> channel2 = CreateObject<SimpleChannel>();
1344+
NetDeviceContainer d23 = devHelper.Install(nodes.Get(2), channel2);
1345+
d23.Add(devHelper.Install(nodes.Get(3), channel2));
1346+
1347+
Ptr<SimpleChannel> channel3 = CreateObject<SimpleChannel>();
1348+
NetDeviceContainer d02 = devHelper.Install(nodes.Get(0), channel3);
1349+
d02.Add(devHelper.Install(nodes.Get(2), channel3));
1350+
1351+
Ptr<SimpleChannel> channel4 = CreateObject<SimpleChannel>();
1352+
NetDeviceContainer d34 = devHelper.Install(nodes.Get(3), channel4);
1353+
d34.Add(devHelper.Install(nodes.Get(4), channel4));
1354+
1355+
Ptr<SimpleChannel> channel5 = CreateObject<SimpleChannel>();
1356+
NetDeviceContainer d13 = devHelper.Install(nodes.Get(1), channel5);
1357+
d13.Add(devHelper.Install(nodes.Get(3), channel5));
1358+
1359+
devHelper.SetNetDevicePointToPointMode(false);
1360+
1361+
Ptr<SimpleChannel> channel6 = CreateObject<SimpleChannel>();
1362+
NetDeviceContainer d45 = devHelper.Install(nodes.Get(4), channel6);
1363+
d45.Add(devHelper.Install(nodes.Get(5), channel6));
1364+
1365+
// Assign IP addresses to the devices
1366+
Ipv4AddressHelper address;
1367+
address.SetBase("10.1.1.0", "255.255.255.252");
1368+
Ipv4InterfaceContainer i01 = address.Assign(d01);
1369+
1370+
address.SetBase("10.1.2.0", "255.255.255.252");
1371+
Ipv4InterfaceContainer i02 = address.Assign(d02);
1372+
1373+
address.SetBase("10.1.3.0", "255.255.255.252");
1374+
Ipv4InterfaceContainer i13 = address.Assign(d13);
1375+
1376+
address.SetBase("10.1.4.0", "255.255.255.224");
1377+
Ipv4InterfaceContainer i23 = address.Assign(d23);
1378+
1379+
address.SetBase("10.1.5.0", "255.255.255.0");
1380+
Ipv4InterfaceContainer i34 = address.Assign(d34);
1381+
1382+
address.SetBase("10.1.6.0", "255.255.255.0");
1383+
Ipv4InterfaceContainer i45 = address.Assign(d45);
1384+
}
1385+
1386+
void
1387+
EcmpRouteCalculationTestCase::DoRun()
1388+
{
1389+
// The purpose of this test is to make sure the code doesn't crash when calculating ECMP routes
1390+
// with a topology described in issue #1243. It does not look into the correctness of the
1391+
// routes. We have other tests to make sure the routes are correct.
1392+
Ipv4GlobalRoutingHelper::PopulateRoutingTables();
1393+
1394+
Simulator::Run();
1395+
Simulator::Stop(Seconds(2));
1396+
Simulator::Destroy();
1397+
}
1398+
12791399
/**
12801400
* @ingroup internet-test
12811401
*
@@ -1298,6 +1418,7 @@ Ipv4GlobalRoutingTestSuite::Ipv4GlobalRoutingTestSuite()
12981418
AddTestCase(new TwoBridgeTest, TestCase::Duration::QUICK);
12991419
AddTestCase(new Ipv4DynamicGlobalRoutingTestCase, TestCase::Duration::QUICK);
13001420
AddTestCase(new Ipv4GlobalRoutingSlash32TestCase, TestCase::Duration::QUICK);
1421+
AddTestCase(new EcmpRouteCalculationTestCase, TestCase::Duration::QUICK);
13011422
}
13021423

13031424
static Ipv4GlobalRoutingTestSuite

0 commit comments

Comments
 (0)