5#include "ns3/boolean.h"
6#include "ns3/bridge-helper.h"
8#include "ns3/global-route-manager.h"
9#include "ns3/global-routing.h"
10#include "ns3/inet-socket-address.h"
11#include "ns3/internet-stack-helper.h"
12#include "ns3/ipv4-address-helper.h"
13#include "ns3/ipv4-global-routing-helper.h"
14#include "ns3/ipv4-interface.h"
15#include "ns3/ipv4-l3-protocol.h"
16#include "ns3/ipv4-packet-info-tag.h"
17#include "ns3/ipv4-routing-protocol.h"
18#include "ns3/ipv4-routing-table-entry.h"
19#include "ns3/ipv4-static-routing-helper.h"
20#include "ns3/ipv6-address-helper.h"
21#include "ns3/ipv6-global-routing-helper.h"
22#include "ns3/ipv6-packet-info-tag.h"
23#include "ns3/ipv6-route.h"
25#include "ns3/neighbor-cache-helper.h"
26#include "ns3/node-container.h"
28#include "ns3/packet.h"
29#include "ns3/pointer.h"
30#include "ns3/simple-channel.h"
31#include "ns3/simple-net-device-helper.h"
32#include "ns3/simple-net-device.h"
33#include "ns3/simulator.h"
34#include "ns3/socket-factory.h"
35#include "ns3/string.h"
37#include "ns3/udp-socket-factory.h"
38#include "ns3/uinteger.h"
123 void DoRun()
override;
131 :
TestCase(
"Global routing on point-to-point link")
149 internet.SetRoutingHelper(ipv4RoutingHelper);
150 internet.SetRoutingHelper(ipv6RoutingHelper);
154 ipv4.SetBase(
"10.1.1.0",
"255.255.255.252");
181 uint32_t nRoutesV40 = globalRoutingV40->GetNRoutes();
190 uint32_t nRoutesV41 = globalRoutingV41->GetNRoutes();
193 routeV4 = globalRoutingV41->GetRoute(0);
211 uint32_t nRoutesV60 = globalRoutingV60->GetNRoutes();
219 "Error-- wrong destination mask");
222 "Error-- wrong gateway");
225 uint32_t nRoutesV61 = globalRoutingV61->GetNRoutes();
228 routeV6 = globalRoutingV61->GetRoute(0);
233 "Error-- wrong destination mask");
236 "Error-- wrong gateway");
252 void DoRun()
override;
260 :
TestCase(
"Global routing on broadcast link")
278 internet.SetRoutingHelper(ipv4RoutingHelper);
279 internet.SetRoutingHelper(ipv6RoutingHelper);
283 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
310 uint32_t nRoutesv40 = globalRoutingv40->GetNRoutes();
313 for (
uint32_t i = 0; i < globalRoutingv40->GetNRoutes(); i++)
320 uint32_t nRoutesv41 = globalRoutingv41->GetNRoutes();
323 for (
uint32_t i = 0; i < globalRoutingv40->GetNRoutes(); i++)
342 uint32_t nRoutesv60 = globalRoutingv60->GetNRoutes();
345 for (
uint32_t i = 0; i < globalRoutingv60->GetNRoutes(); i++)
353 uint32_t nRoutesv61 = globalRoutingv61->GetNRoutes();
356 for (
uint32_t i = 0; i < globalRoutingv60->GetNRoutes(); i++)
376 void DoRun()
override;
384 :
TestCase(
"Global routing across two hops (point-to-point links)")
410 internet.SetRoutingHelper(ipv4RoutingHelper);
411 internet.SetRoutingHelper(ipv6RoutingHelper);
416 ipv4.SetBase(
"10.1.1.0",
"255.255.255.252");
418 ipv4.SetBase(
"10.1.2.0",
"255.255.255.252");
453 uint32_t nRoutesv40 = globalRoutingv40->GetNRoutes();
464 uint32_t nRoutesv41 = globalRoutingv41->GetNRoutes();
468 routev4 = globalRoutingv41->GetRoute(0);
473 routev4 = globalRoutingv41->GetRoute(1);
478 routev4 = globalRoutingv41->GetRoute(2);
483 routev4 = globalRoutingv41->GetRoute(3);
491 uint32_t nRoutesv42 = globalRoutingv42->GetNRoutes();
495 routev4 = globalRoutingv42->GetRoute(0);
519 uint32_t nRoutesv60 = globalRoutingv60->GetNRoutes();
528 "Error-- wrong destination mask");
531 "Error-- wrong gateway");
535 uint32_t nRoutesv61 = globalRoutingv61->GetNRoutes();
539 routev6 = globalRoutingv61->GetRoute(0);
544 "Error-- wrong destination");
547 "Error-- wrong destination mask");
550 "Error-- wrong gateway");
552 routev6 = globalRoutingv61->GetRoute(1);
557 "Error-- wrong destination");
560 "Error-- wrong destination mask");
563 "Error-- wrong gateway");
565 routev6 = globalRoutingv61->GetRoute(2);
571 "Error-- wrong destination mask");
574 "Error-- wrong gateway");
576 routev6 = globalRoutingv61->GetRoute(3);
582 "Error-- wrong destination mask");
585 "Error-- wrong gateway");
589 uint32_t nRoutesv62 = globalRoutingv62->GetNRoutes();
593 routev6 = globalRoutingv62->GetRoute(0);
598 "Error-- wrong destination mask");
601 "Error-- wrong gateway");
616 void DoRun()
override;
624 :
TestCase(
"Global routing across two hops (broadcast links)")
648 internet.SetRoutingHelper(ipv4RoutingHelper);
649 internet.SetRoutingHelper(ipv6RoutingHelper);
653 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
655 ipv4.SetBase(
"10.1.2.0",
"255.255.255.0");
689 uint32_t nRoutesv40 = globalRoutingv40->GetNRoutes();
696 routev4 = globalRoutingv40->GetRoute(1);
702 uint32_t nRoutesv41 = globalRoutingv41->GetNRoutes();
705 routev4 = globalRoutingv41->GetRoute(0);
709 routev4 = globalRoutingv41->GetRoute(1);
732 uint32_t nRoutesv60 = globalRoutingv60->GetNRoutes();
741 "Error-- wrong destination mask");
744 routev6 = globalRoutingv60->GetRoute(1);
749 "Error-- wrong destination mask");
752 "Error-- wrong gateway");
755 uint32_t nRoutesv61 = globalRoutingv61->GetNRoutes();
759 routev6 = globalRoutingv61->GetRoute(0);
764 "Error-- wrong destination mask");
767 routev6 = globalRoutingv61->GetRoute(1);
772 "Error-- wrong destination mask");
788 void DoRun()
override;
796 :
TestCase(
"Global routing across bridging topology (bug 2102)")
819 bridgeFacingDevices.
Add(net2.
Get(0));
820 switchDevices.Add(net2.
Get(1));
827 bridgeFacingDevices.
Add(net3.
Get(1));
828 switchDevices.Add(net3.
Get(0));
838 bridge.
Install(switchNode, switchDevices);
845 internet.SetRoutingHelper(ipv4RoutingHelper);
846 internet.SetRoutingHelper(ipv6RoutingHelper);
848 internet.Install(
m_nodes.Get(0));
849 internet.Install(
m_nodes.Get(1));
851 internet.Install(
m_nodes.Get(3));
852 internet.Install(
m_nodes.Get(4));
855 address.SetBase(
"10.1.1.0",
"255.255.255.0");
858 address.SetBase(
"10.1.2.0",
"255.255.255.0");
859 address.Assign(bridgeFacingDevices);
861 address.SetBase(
"10.1.3.0",
"255.255.255.0");
862 address.Assign(net4);
868 ipv6.
Assign(bridgeFacingDevices);
905 uint32_t nRoutesv40 = globalRoutingv40->GetNRoutes();
908 for (
uint32_t i = 0; i < globalRoutingv40->GetNRoutes(); i++)
910 routev4 = globalRoutingv40->GetRoute(i);
918 "Error-- wrong destination");
921 "Error-- wrong gateway");
927 uint32_t nRoutesv41 = globalRoutingv41->GetNRoutes();
930 for (
uint32_t i = 0; i < globalRoutingv41->GetNRoutes(); i++)
932 routev4 = globalRoutingv41->GetRoute(i);
940 "Error-- wrong destination");
943 "Error-- wrong gateway");
947 NS_LOG_DEBUG(
"BridgeTest skip print out of n2 and n3, go next to node n4");
952 uint32_t nRoutesv44 = globalRoutingv44->GetNRoutes();
955 for (
uint32_t i = 0; i < globalRoutingv44->GetNRoutes(); i++)
957 routev4 = globalRoutingv44->GetRoute(i);
965 "Error-- wrong destination");
968 "Error-- wrong gateway");
997 uint32_t nRoutesv60 = globalRoutingv60->GetNRoutes();
1000 for (
uint32_t i = 0; i < globalRoutingv60->GetNRoutes(); i++)
1002 routev6 = globalRoutingv60->GetRoute(i);
1010 "Error-- wrong destination");
1013 "Error-- wrong destination mask");
1016 "Error-- wrong gateway");
1022 uint32_t nRoutesv61 = globalRoutingv61->GetNRoutes();
1025 for (
uint32_t i = 0; i < globalRoutingv61->GetNRoutes(); i++)
1027 routev6 = globalRoutingv61->GetRoute(i);
1035 "Error-- wrong destination");
1038 "Error-- wrong destination mask");
1041 "Error-- wrong gateway");
1045 NS_LOG_DEBUG(
"BridgeTest skip print out of n2 and n3, go next to node n4");
1050 uint32_t nRoutesv64 = globalRoutingv64->GetNRoutes();
1053 for (
uint32_t i = 0; i < globalRoutingv64->GetNRoutes(); i++)
1055 routev6 = globalRoutingv64->GetRoute(i);
1063 "Error-- wrong destination");
1066 "Error-- wrong destination mask");
1069 "Error-- wrong gateway");
1084 void DoRun()
override;
1092 :
TestCase(
"Global routing across two bridges")
1116 bridgeFacingDevices.
Add(net2.
Get(0));
1117 switchn2Devices.
Add(net2.
Get(1));
1124 switchn2Devices.
Add(net3.
Get(0));
1125 switchn3Devices.
Add(net3.
Get(1));
1132 switchn3Devices.
Add(net4.
Get(0));
1133 bridgeFacingDevices.
Add(net4.
Get(1));
1137 bridgen2Helper.
Install(switchn2Node, switchn2Devices);
1141 bridgen3Helper.
Install(switchn3Node, switchn3Devices);
1148 internet.SetRoutingHelper(ipv4RoutingHelper);
1149 internet.SetRoutingHelper(ipv6RoutingHelper);
1151 internet.Install(
m_nodes.Get(0));
1152 internet.Install(
m_nodes.Get(1));
1155 internet.Install(
m_nodes.Get(4));
1158 addressv4.
SetBase(
"10.1.1.0",
"255.255.255.0");
1161 addressv4.
SetBase(
"10.1.2.0",
"255.255.255.0");
1162 addressv4.
Assign(bridgeFacingDevices);
1169 addressv6.
Assign(bridgeFacingDevices);
1196 uint32_t nRoutesv40 = globalRoutingv40->GetNRoutes();
1199 for (
uint32_t i = 0; i < globalRoutingv40->GetNRoutes(); i++)
1201 routev4 = globalRoutingv40->GetRoute(i);
1209 "Error-- wrong destination");
1212 "Error-- wrong gateway");
1215 NS_LOG_DEBUG(
"BridgeTest skip print out of n1-n3, go next to node n4");
1220 uint32_t nRoutesv44 = globalRoutingv44->GetNRoutes();
1223 for (
uint32_t i = 0; i < globalRoutingv44->GetNRoutes(); i++)
1225 routev4 = globalRoutingv44->GetRoute(i);
1233 "Error-- wrong destination");
1236 "Error-- wrong gateway");
1258 uint32_t nRoutesv60 = globalRoutingv60->GetNRoutes();
1261 for (
uint32_t i = 0; i < globalRoutingv60->GetNRoutes(); i++)
1263 routev6 = globalRoutingv60->GetRoute(i);
1271 "Error-- wrong destination");
1274 "Error-- wrong destination mask");
1277 "Error-- wrong gateway");
1280 NS_LOG_DEBUG(
"BridgeTest skip print out of n1-n3, go next to node n4");
1285 uint32_t nRoutesv64 = globalRoutingv64->GetNRoutes();
1288 for (
uint32_t i = 0; i < globalRoutingv64->GetNRoutes(); i++)
1290 routev6 = globalRoutingv64->GetRoute(i);
1298 "Error-- wrong destination");
1301 "Error-- wrong destination mask");
1304 "Error-- wrong gateway");
1339 void DoRun()
override;
1345 std::vector<uint8_t>
1347 std::vector<uint8_t>
1354 :
TestCase(
"Ipv4 Dynamic global routing example"),
1369 iter->second =
false;
1370 iter->first->Close();
1371 iter->first =
nullptr;
1381 while ((packet = socket->RecvFrom(from)))
1383 if (packet->GetSize() == 0)
1389 found = packet->PeekPacketTag(tag);
1463 internet.SetRoutingHelper(routingHelper);
1464 internet.Install(
c);
1480 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
1483 ipv4.SetBase(
"10.1.2.0",
"255.255.255.0");
1486 ipv4.SetBase(
"10.1.3.0",
"255.255.255.0");
1489 ipv4.SetBase(
"10.250.1.0",
"255.255.255.0");
1492 ipv4.SetBase(
"172.16.1.0",
"255.255.255.0");
1504 std::pair<Ptr<Socket>,
bool> sendSockA;
1506 sendSockA.first->Bind();
1508 sendSockA.second =
true;
1513 std::pair<Ptr<Socket>,
bool> sendSockB;
1515 sendSockB.first->Bind();
1517 sendSockB.second =
true;
1526 sink2->ShutdownSend();
1528 sink2->SetRecvPktInfo(
true);
1572 std::vector<uint8_t> firstInterfaceTest{0, 5, 0, 0, 5, 5, 0, 0, 5, 5, 0, 5, 0, 0, 5, 5};
1573 std::vector<uint8_t> secondInterfaceTest{0, 0, 5, 5, 0, 0, 5, 5, 0, 0, 0, 0, 5, 5, 0, 0};
1575 for (
uint32_t index = 0; index < firstInterfaceTest.size(); index++)
1579 "Dynamic global routing did deliver the wrong number of packets "
1580 "to the first interface at time "
1584 for (
uint32_t index = 0; index < secondInterfaceTest.size(); index++)
1588 "Dynamic global routing did deliver the wrong number of packets "
1589 "to the second interface at time "
1634 void DoRun()
override;
1640 std::vector<uint8_t>
1642 std::vector<uint8_t>
1649 :
TestCase(
"Ipv6 Dynamic global routing example"),
1664 iter->second =
false;
1665 iter->first->Close();
1666 iter->first =
nullptr;
1677 while ((packet = socket->RecvFrom(from)))
1679 if (packet->GetSize() == 0)
1685 found = packet->PeekPacketTag(tag);
1729 ipv6->SetUp(ifIndex);
1730 ipv6->AddAddress(ifIndex, address);
1768 internet.SetRoutingHelper(ipv6RoutingHelper);
1770 internet.Install(
c);
1810 std::pair<Ptr<Socket>,
bool> sendSockA;
1812 sendSockA.first->Bind();
1814 sendSockA.second =
true;
1819 std::pair<Ptr<Socket>,
bool> sendSockB;
1821 sendSockB.first->Bind();
1823 sendSockB.second =
true;
1832 sink2->ShutdownSend();
1834 sink2->SetRecvPktInfo(
true);
1893 std::vector<uint8_t> firstInterfaceTest{0, 5, 0, 0, 5, 5, 0, 0, 5, 5, 0, 5, 0, 0, 5, 5};
1894 std::vector<uint8_t> secondInterfaceTest{0, 0, 5, 5, 0, 0, 5, 5, 0, 0, 0, 0, 5, 5, 0, 0};
1896 for (
uint32_t index = 0; index < firstInterfaceTest.size(); index++)
1900 "Dynamic global routing did deliver the wrong number of packets "
1901 "to the first interface at time "
1905 for (
uint32_t index = 0; index < secondInterfaceTest.size(); index++)
1909 "Dynamic global routing did deliver the wrong number of packets "
1910 "to the second interface at time "
1949 void DoRun()
override;
1954 :
TestCase(
"Slash 32 global routing example")
1965 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
1969 "Received packet size is not equal to Rx buffer size");
2007 internet.Install(c);
2017 nA->AddDevice(deviceA);
2024 nC->AddDevice(deviceC);
2028 ipv4.SetBase(
"10.1.1.0",
"255.255.255.252");
2031 ipv4.SetBase(
"10.1.1.4",
"255.255.255.252");
2038 int32_t ifIndexA = ipv4A->AddInterface(deviceA);
2039 int32_t ifIndexC = ipv4C->AddInterface(deviceC);
2043 ipv4A->AddAddress(ifIndexA, ifInAddrA);
2044 ipv4A->SetMetric(ifIndexA, 1);
2045 ipv4A->SetUp(ifIndexA);
2049 ipv4C->AddAddress(ifIndexC, ifInAddrC);
2050 ipv4C->SetMetric(ifIndexC, 1);
2051 ipv4C->SetUp(ifIndexC);
2059 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
2066 Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
2067 txSocket->SetAllowBroadcast(
true);
2075 "Static routing with /32 did not deliver all packets.");
2091 void DoRun()
override;
2098 :
TestCase(
"ECMP Route Calculation TestCase")
2137 stack.SetRoutingHelper(globalhelperv4);
2138 stack.SetRoutingHelper(globalhelperv6);
2139 stack.Install(
nodes);
2171 address.SetBase(
"10.1.1.0",
"255.255.255.252");
2174 address.SetBase(
"10.1.2.0",
"255.255.255.252");
2177 address.SetBase(
"10.1.3.0",
"255.255.255.252");
2180 address.SetBase(
"10.1.4.0",
"255.255.255.224");
2183 address.SetBase(
"10.1.5.0",
"255.255.255.0");
2186 address.SetBase(
"10.1.6.0",
"255.255.255.0");
2232 void DoRun()
override;
2309 :
TestCase(
"Test API calls to GlobalRoutingProtocol")
2324 std::vector<Ipv4Address> path)
2333 "Error-- no Ipv4 routing protocol object at source node");
2337 "Error-- no Ipv4GlobalRouting object at source node");
2347 m_lastRoute = globalRouting->RouteOutput(packet, ipHeader, oif, errno_);
2349 for (
uint32_t i = 1; i < pathSize; i++)
2353 if (i != pathSize - 1)
2360 routing = ip->GetRoutingProtocol();
2365 "Error-- no Ipv4GlobalRouting object at node");
2448 bridgeFacingDevices.
Add(d78.
Get(0));
2449 switchDevices.Add(d78.
Get(1));
2450 bridgeFacingDevices.
Add(d89.
Get(1));
2451 switchDevices.Add(d89.
Get(0));
2455 bridge.
Install(switchNode, switchDevices);
2459 internet.SetRoutingHelper(glbrouting);
2460 internet.Install(
nodes.Get(0));
2461 internet.Install(
nodes.Get(1));
2462 internet.Install(
nodes.Get(2));
2463 internet.Install(
nodes.Get(3));
2464 internet.Install(
nodes.Get(4));
2465 internet.Install(
nodes.Get(5));
2466 internet.Install(
nodes.Get(6));
2467 internet.Install(
nodes.Get(7));
2469 internet.Install(
nodes.Get(9));
2473 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
2476 ipv4.SetBase(
"10.1.2.0",
"255.255.255.0");
2479 ipv4.SetBase(
"10.1.3.0",
"255.255.255.0");
2482 ipv4.SetBase(
"10.250.1.0",
"255.255.255.0");
2485 ipv4.SetBase(
"172.16.1.0",
"255.255.255.0");
2488 ipv4.SetBase(
"10.1.4.0",
"255.255.255.0");
2491 ipv4.SetBase(
"10.1.5.0",
"255.255.255.0");
2511 std::vector<Ipv4Address>
2515 pathToCheck1.emplace_back(
"10.1.1.1");
2516 pathToCheck1.emplace_back(
"10.1.1.2");
2517 pathToCheck1.emplace_back(
"10.1.2.1");
2518 pathToCheck1.emplace_back(
"172.16.1.2");
2520 std::vector<Ptr<Node>>
2522 pathNodes1.push_back(
nodes.Get(0));
2523 pathNodes1.push_back(
nodes.Get(2));
2524 pathNodes1.push_back(
nodes.Get(1));
2525 pathNodes1.push_back(
nodes.Get(6));
2530 std::vector<Ipv4Address> pathToCheck2;
2531 pathToCheck2.emplace_back(
"10.1.2.1");
2532 pathToCheck2.emplace_back(
"10.1.2.2");
2533 pathToCheck2.emplace_back(
"10.250.1.4");
2535 std::vector<Ptr<Node>> pathNodes2;
2536 pathNodes2.push_back(
nodes.Get(1));
2537 pathNodes2.push_back(
nodes.Get(2));
2538 pathNodes2.push_back(
nodes.Get(5));
2543 std::vector<Ipv4Address> pathToCheck3;
2544 pathToCheck3.emplace_back(
"172.16.1.1");
2545 pathToCheck3.emplace_back(
"172.16.1.2");
2546 pathToCheck3.emplace_back(
"10.1.4.2");
2547 pathToCheck3.emplace_back(
"10.1.5.2");
2549 std::vector<Ptr<Node>> pathNodes3;
2550 pathNodes3.push_back(
nodes.Get(1));
2551 pathNodes3.push_back(
nodes.Get(6));
2552 pathNodes3.push_back(
nodes.Get(7));
2553 pathNodes3.push_back(
nodes.Get(9));
2558 std::vector<Ipv4Address> pathToCheck4;
2559 pathToCheck4.emplace_back(
"10.1.5.2");
2560 pathToCheck4.emplace_back(
"10.1.5.1");
2561 pathToCheck4.emplace_back(
"10.1.4.1");
2562 pathToCheck4.emplace_back(
"10.1.3.1");
2563 pathToCheck4.emplace_back(
"10.250.1.1");
2564 pathToCheck4.emplace_back(
"10.1.1.1");
2566 std::vector<Ptr<Node>> pathNodes4;
2567 pathNodes4.push_back(
nodes.Get(9));
2568 pathNodes4.push_back(
nodes.Get(7));
2569 pathNodes4.push_back(
nodes.Get(6));
2570 pathNodes4.push_back(
nodes.Get(5));
2571 pathNodes4.push_back(
nodes.Get(2));
2572 pathNodes4.push_back(
nodes.Get(0));
2595 void DoRun()
override;
2676 :
TestCase(
"Test API calls to GlobalRoutingProtocol")
2691 std::vector<Ipv6Address> path)
2700 "Error-- no Ipv4 routing protocol object at source node");
2704 "Error-- no Ipv4GlobalRouting object at source node");
2715 m_lastRoute = globalRouting->RouteOutput(packet, ipHeader, oif, errno_);
2717 for (
uint32_t i = 1; i < pathSize; i++)
2721 if (i != pathSize - 1)
2728 routing = ip->GetRoutingProtocol();
2733 "Error-- no Ipv4GlobalRouting object at node");
2816 bridgeFacingDevices.
Add(d78.
Get(0));
2817 switchDevices.Add(d78.
Get(1));
2818 bridgeFacingDevices.
Add(d89.
Get(1));
2819 switchDevices.Add(d89.
Get(0));
2823 bridge.
Install(switchNode, switchDevices);
2827 internet.SetRoutingHelper(glbrouting);
2828 internet.Install(
nodes.Get(0));
2829 internet.Install(
nodes.Get(1));
2830 internet.Install(
nodes.Get(2));
2831 internet.Install(
nodes.Get(3));
2832 internet.Install(
nodes.Get(4));
2833 internet.Install(
nodes.Get(5));
2834 internet.Install(
nodes.Get(6));
2835 internet.Install(
nodes.Get(7));
2837 internet.Install(
nodes.Get(9));
2879 std::vector<Ipv6Address>
2883 pathToCheck1.emplace_back(
"2001:1::200:ff:fe00:1");
2884 pathToCheck1.emplace_back(
"fe80::200:ff:fe00:2");
2885 pathToCheck1.emplace_back(
"fe80::200:ff:fe00:5");
2886 pathToCheck1.emplace_back(
"2001:5::200:ff:fe00:4");
2888 std::vector<Ptr<Node>>
2890 pathNodes1.push_back(
nodes.Get(0));
2891 pathNodes1.push_back(
nodes.Get(2));
2892 pathNodes1.push_back(
nodes.Get(1));
2893 pathNodes1.push_back(
nodes.Get(6));
2897 std::vector<Ipv6Address> pathToCheck2;
2898 pathToCheck2.emplace_back(
"2001:2::200:ff:fe00:5");
2899 pathToCheck2.emplace_back(
"fe80::200:ff:fe00:4");
2900 pathToCheck2.emplace_back(
"2001:3::200:ff:fe00:7");
2901 std::vector<Ptr<Node>> pathNodes2;
2902 pathNodes2.push_back(
nodes.Get(1));
2903 pathNodes2.push_back(
nodes.Get(6));
2904 pathNodes2.push_back(
nodes.Get(5));
2908 std::vector<Ipv6Address> pathToCheck3;
2909 pathToCheck3.emplace_back(
"2001:2::200:ff:fe00:6");
2910 pathToCheck3.emplace_back(
"fe80::200:ff:fe00:4");
2911 pathToCheck3.emplace_back(
"fe80::200:ff:fe00:a");
2912 pathToCheck3.emplace_back(
"2001:7::200:ff:fe00:12");
2914 std::vector<Ptr<Node>> pathNodes3;
2915 pathNodes3.push_back(
nodes.Get(1));
2916 pathNodes3.push_back(
nodes.Get(6));
2917 pathNodes3.push_back(
nodes.Get(7));
2918 pathNodes3.push_back(
nodes.Get(9));
2923 std::vector<Ipv6Address> pathToCheck4;
2924 pathToCheck4.emplace_back(
"2001:7::200:ff:fe00:12");
2925 pathToCheck4.emplace_back(
"fe80::200:ff:fe00:f");
2926 pathToCheck4.emplace_back(
"fe80::200:ff:fe00:9");
2927 pathToCheck4.emplace_back(
"fe80::200:ff:fe00:3");
2928 pathToCheck4.emplace_back(
"fe80::200:ff:fe00:6");
2929 pathToCheck4.emplace_back(
"2001:1::200:ff:fe00:1");
2931 std::vector<Ptr<Node>> pathNodes4;
2932 pathNodes4.push_back(
nodes.Get(9));
2933 pathNodes4.push_back(
nodes.Get(7));
2934 pathNodes4.push_back(
nodes.Get(6));
2935 pathNodes4.push_back(
nodes.Get(1));
2936 pathNodes4.push_back(
nodes.Get(2));
2937 pathNodes4.push_back(
nodes.Get(0));
NodeContainer n1n2
Nodecontainer n1 + n2.
NodeContainer n0n2
Nodecontainer n0 + n2.
GlobalRouting Bridge test.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
NodeContainer m_nodes
Nodes used in the test.
This TestCase tests if ECMP Route Calculation works.
void DoRun() override
Implementation to actually run this TestCase.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
EcmpRouteCalculationTestCase()
NodeContainer nodes
Nodes used in the test.
TestCase to check calls to GlobalRoutingProtocol API.
void DoRun() override
Implementation to actually run this TestCase.
Ipv4RoutingProtocol::MulticastForwardCallback m_mcb
Multicast forward callback.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void MyErrorCallback(Ptr< const Packet > packet, const Ipv4Header &header, Socket::SocketErrno errno_)
Callback function for RouteInput() API of GlobalRoutingProtocol.
NodeContainer nodes
Nodes used in the test.
void MyLocalDeliverCallback(Ptr< const Packet > packet, const Ipv4Header &header, uint32_t iif)
Callback function for RouteInput() API of GlobalRoutingProtocol.
void MyUnicastCallback(Ptr< Ipv4Route > route, Ptr< const Packet > packet, const Ipv4Header &header)
Callback function for RouteInput() API of GlobalRoutingProtocol.
Ipv4RoutingProtocol::LocalDeliverCallback m_lcb
Local delivery callback.
~GlobalRoutingv4ProtocolTestCase() override
void CheckPath(std::vector< Ptr< Node > > pathNodes, std::vector< Ipv4Address > path)
Checks the Path taken by packets by calling RouteInput() and RouteOutput() APIs of GlobalRoutingProto...
Ipv4RoutingProtocol::UnicastForwardCallback m_ucb
Unicast forward callback.
Ptr< Ipv4Route > m_lastRoute
Route to be tested.
GlobalRoutingv4ProtocolTestCase()
Ipv4RoutingProtocol::ErrorCallback m_ecb
Error callback.
TestCase to check calls to GlobalRoutingProtocol API.
~GlobalRoutingv6ProtocolTestCase() override
Ptr< Ipv6Route > m_lastRoute
Route to be tested.
void CheckPath(std::vector< Ptr< Node > > pathNodes, std::vector< Ipv6Address > path)
Checks the Path taken by packets by calling RouteInput() and RouteOutput() APIs of GlobalRoutingProto...
Ipv6RoutingProtocol::LocalDeliverCallback m_lcb
Local delivery callback.
void MyUnicastCallback(Ptr< const NetDevice > idev, Ptr< Ipv6Route > rtentry, Ptr< const Packet > p, const Ipv6Header &header)
Callback function for RouteInput() API of GlobalRoutingProtocol.
NodeContainer nodes
Nodes used in the test.
void MyErrorCallback(Ptr< const Packet > packet, const Ipv6Header &header, Socket::SocketErrno errno_)
Callback function for RouteInput() API of GlobalRoutingProtocol.
void MyLocalDeliverCallback(Ptr< const Packet > packet, const Ipv6Header &header, uint32_t iif)
Callback function for RouteInput() API of GlobalRoutingProtocol.
Ipv6RoutingProtocol::MulticastForwardCallback m_mcb
Multicast forward callback.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
GlobalRoutingv6ProtocolTestCase()
void DoRun() override
Implementation to actually run this TestCase.
Ipv6RoutingProtocol::ErrorCallback m_ecb
Error callback.
Ipv6RoutingProtocol::UnicastForwardCallback m_ucb
Unicast forward callback.
IPv4 Dynamic GlobalRouting test.
void DoRun() override
Implementation to actually run this TestCase.
uint16_t m_packetSize
Packet size.
~Ipv4DynamicGlobalRoutingTestCase() override
std::vector< uint8_t > m_secondInterface
Packets received on the 2nd interface at a given time.
Ipv4DynamicGlobalRoutingTestCase()
void HandleRead(Ptr< Socket > socket)
Handle an incoming packet.
uint16_t m_count
Number of packets received.
DataRate m_dataRate
Data rate.
std::vector< std::pair< Ptr< Socket >, bool > > m_sendSocks
Sending sockets.
std::vector< uint8_t > m_firstInterface
Packets received on the 1st interface at a given time.
NodeContainer c
nodes in the topology
void ShutDownSock(uint8_t index)
Shutdown a socket.
void SendData(uint8_t index)
Send some data.
IPv4 Dynamic GlobalRouting /32 test.
void ReceivePkt(Ptr< Socket > socket)
Receive a packet.
void SendData(Ptr< Socket > socket, std::string to)
Send a packet.
~Ipv4GlobalRoutingSlash32TestCase() override
void DoRun() override
Implementation to actually run this TestCase.
Ipv4GlobalRoutingSlash32TestCase()
void DoSendData(Ptr< Socket > socket, std::string to)
Send a packet.
Ptr< Packet > m_receivedPacket
number of received packets
IPv4 GlobalRouting TestSuite.
Ipv4GlobalRoutingTestSuite()
IPv6 Dynamic GlobalRouting test.
~Ipv6DynamicGlobalRoutingTestCase() override
uint16_t m_packetSize
Packet size.
DataRate m_dataRate
Data rate.
uint16_t m_count
Number of packets received.
std::vector< std::pair< Ptr< Socket >, bool > > m_sendSocks
Sending sockets.
void SendData(uint8_t index)
Send some data.
std::vector< uint8_t > m_secondInterface
Packets received on the 2nd interface at a given time.
void ShutDownSock(uint8_t index)
Shutdown a socket.
std::vector< uint8_t > m_firstInterface
Packets received on the 1st interface at a given time.
void DoRun() override
Implementation to actually run this TestCase.
void HandleRead(Ptr< Socket > socket)
Handle an incoming packet.
NodeContainer c
nodes in the topology
void SetInterfaceUp(Ptr< Ipv6 > ipv6, uint32_t ifIndex, Ipv6InterfaceAddress address)
This function does two things, set the specified ipv6 interface as up and Adds the specified Ipv6Addr...
Ipv6DynamicGlobalRoutingTestCase()
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
NodeContainer m_nodes
Nodes used in the test.
void DoRun() override
Implementation to actually run this TestCase.
NodeContainer m_nodes
Nodes used in the test.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
GlobalRouting Two bridges test.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
NodeContainer m_nodes
Nodes used in the test.
GlobalRouting Two LAN test.
NodeContainer m_nodes
Nodes used in the test.
void DoRun() override
Implementation to actually run this TestCase.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
GlobalRouting Two Link test.
void DoRun() override
Implementation to actually run this TestCase.
NodeContainer m_nodes
Nodes used in the test.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
a polymophic address class
AttributeValue implementation for Boolean.
Add capability to bridge multiple LAN segments (IEEE 802.1D bridging).
NetDeviceContainer Install(Ptr< Node > node, NetDeviceContainer c)
This method creates an ns3::BridgeNetDevice with the attributes configured by BridgeHelper::SetDevice...
Class for representing data rates.
static void ResetRouterId()
Reset the router ID counter to zero.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetAny()
Helper class that adds ns3::Ipv4GlobalRouting objects.
static void PopulateRoutingTables()
Build a routing database and initialize the routing tables of the nodes in the simulation.
Access to the IPv4 forwarding table, interfaces, and configuration.
virtual void SetUp(uint32_t interface)=0
virtual void SetDown(uint32_t interface)=0
a class to store IPv4 address information on an interface
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Implement the IPv4 layer.
a class to represent an Ipv4 address mask
This class implements Linux struct pktinfo in order to deliver ancillary information to the socket in...
uint32_t GetRecvIf() const
Get the tag's receiving interface.
Callback< void, Ptr< Ipv4MulticastRoute >, Ptr< const Packet >, const Ipv4Header & > MulticastForwardCallback
Callback for multicast packets to be forwarded.
Callback< void, Ptr< const Packet >, const Ipv4Header &, uint32_t > LocalDeliverCallback
Callback for packets to be locally delivered.
Callback< void, Ptr< Ipv4Route >, Ptr< const Packet >, const Ipv4Header & > UnicastForwardCallback
Callback for unicast packets to be forwarded.
Callback< void, Ptr< const Packet >, const Ipv4Header &, Socket::SocketErrno > ErrorCallback
Callback for routing errors (e.g., no route found).
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.
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
Helper class that adds ns3::Ipv4GlobalRouting objects.
static void PopulateRoutingTables()
Build a routing database and initialize the routing tables of the nodes in the simulation.
Access to the IPv6 forwarding table, interfaces, and configuration.
virtual void SetDown(uint32_t interface)=0
Set the interface into the "down" state.
IPv6 address associated with an interface.
Keep track of a set of IPv6 interfaces.
Ipv6Address GetAddress(uint32_t i, uint32_t j) const
Get the address for the specified index.
IPv6 layer implementation.
This class implements a tag that carries socket ancillary data to the socket interface.
uint32_t GetRecvIf() const
Get the tag's receiving interface.
Describes an IPv6 prefix.
static Ipv6Prefix GetZero()
Get the zero prefix ( /0).
Callback< void, Ptr< const Packet >, const Ipv6Header &, Socket::SocketErrno > ErrorCallback
Callback for routing errors (e.g., no route found).
Callback< void, Ptr< const NetDevice >, Ptr< Ipv6MulticastRoute >, Ptr< const Packet >, const Ipv6Header & > MulticastForwardCallback
Callback for multicast packets to be forwarded.
Callback< void, Ptr< const Packet >, const Ipv6Header &, uint32_t > LocalDeliverCallback
Callback for packets to be locally delivered.
Callback< void, Ptr< const NetDevice >, Ptr< Ipv6Route >, Ptr< const Packet >, const Ipv6Header & > UnicastForwardCallback
Callback for unicast packets to be forwarded.
A record of an IPv6 route.
Ipv6Address GetDest() const
Get the destination.
Ipv6Prefix GetDestNetworkPrefix() const
Get the destination prefix.
Ipv6Address GetGateway() const
Get the gateway.
static Mac48Address Allocate()
Allocate a new Mac48Address.
A helper class to populate neighbor cache.
void PopulateNeighborCache()
Populate neighbor ARP and NDISC caches for all devices.
void SetDynamicNeighborCache(bool enable)
Enable/disable dynamic neighbor cache, auto-generated neighbor cache will update by IP addresses chan...
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
Smart pointer class similar to boost::intrusive_ptr.
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 EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
SocketErrno
Enumeration of the possible errors returned by a socket.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
API to create UDP socket instances.
static Ipv4GlobalRoutingTestSuite g_globalRoutingTestSuite
Static variable for test initialization.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
void SetDefault(std::string name, const AttributeValue &value)
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.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#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.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
#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.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.