9#include "ns3/boolean.h"
11#include "ns3/icmpv6-l4-protocol.h"
12#include "ns3/inet6-socket-address.h"
13#include "ns3/internet-stack-helper.h"
14#include "ns3/ipv6-address-helper.h"
15#include "ns3/ipv6-l3-protocol.h"
17#include "ns3/node-container.h"
19#include "ns3/ripng-helper.h"
21#include "ns3/simple-channel.h"
22#include "ns3/simple-net-device.h"
23#include "ns3/simulator.h"
24#include "ns3/socket-factory.h"
25#include "ns3/socket.h"
27#include "ns3/udp-l4-protocol.h"
28#include "ns3/udp-socket-factory.h"
58 void DoRun()
override;
76 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
80 "Received packet size is not equal to Rx buffer size");
122 internetv6routers.
Install(routers);
137 txNode->AddDevice(txDev);
146 fwDev1routerA->SetAddress(
Mac48Address(
"00:00:00:00:00:02"));
147 routerA->AddDevice(fwDev1routerA);
149 net1.
Add(fwDev1routerA);
153 fwDev2routerA->SetAddress(
Mac48Address(
"00:00:00:00:00:03"));
154 routerA->AddDevice(fwDev2routerA);
156 net2.
Add(fwDev2routerA);
163 fwDev1routerB->SetAddress(
Mac48Address(
"00:00:00:00:00:04"));
164 routerB->AddDevice(fwDev1routerB);
166 net2.
Add(fwDev1routerB);
170 fwDev2routerB->SetAddress(
Mac48Address(
"00:00:00:00:00:05"));
171 routerB->AddDevice(fwDev2routerB);
173 net3.
Add(fwDev2routerB);
180 fwDev1routerC->SetAddress(
Mac48Address(
"00:00:00:00:00:06"));
181 routerC->AddDevice(fwDev1routerC);
183 net3.
Add(fwDev1routerC);
187 fwDev2routerC->SetAddress(
Mac48Address(
"00:00:00:00:00:07"));
188 routerC->AddDevice(fwDev2routerC);
190 net4.
Add(fwDev2routerC);
197 rxNode->AddDevice(rxDev);
203 txDev->SetChannel(channel1);
204 fwDev1routerA->SetChannel(channel1);
207 fwDev2routerA->SetChannel(channel2);
208 fwDev1routerB->SetChannel(channel2);
211 fwDev2routerB->SetChannel(channel3);
212 fwDev1routerC->SetChannel(channel3);
215 fwDev2routerC->SetChannel(channel4);
216 rxDev->SetChannel(channel4);
241 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
249 Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
250 txSocket->SetAllowBroadcast(
true);
255 SendData(txSocket,
"2001:2::200:ff:fe00:8");
288 void DoRun()
override;
299 :
TestCase(
"RIPng counting to infinity")
306 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
310 "Received packet size is not equal to Rx buffer size");
359 internetv6routers.
Install(routers);
374 txNode->AddDevice(txDev);
383 fwDev1routerA->SetAddress(
Mac48Address(
"00:00:00:00:00:02"));
384 routerA->AddDevice(fwDev1routerA);
386 net1.
Add(fwDev1routerA);
390 fwDev2routerA->SetAddress(
Mac48Address(
"00:00:00:00:00:03"));
391 routerA->AddDevice(fwDev2routerA);
393 net2.
Add(fwDev2routerA);
400 fwDev1routerB->SetAddress(
Mac48Address(
"00:00:00:00:00:04"));
401 routerB->AddDevice(fwDev1routerB);
403 net2.
Add(fwDev1routerB);
407 fwDev2routerB->SetAddress(
Mac48Address(
"00:00:00:00:00:05"));
408 routerB->AddDevice(fwDev2routerB);
410 net3.
Add(fwDev2routerB);
417 fwDev1routerC->SetAddress(
Mac48Address(
"00:00:00:00:00:06"));
418 routerC->AddDevice(fwDev1routerC);
420 net3.
Add(fwDev1routerC);
424 fwDev2routerC->SetAddress(
Mac48Address(
"00:00:00:00:00:07"));
425 routerC->AddDevice(fwDev2routerC);
427 net4.
Add(fwDev2routerC);
434 rxNode->AddDevice(rxDev);
440 txDev->SetChannel(channel1);
441 fwDev1routerA->SetChannel(channel1);
444 fwDev2routerA->SetChannel(channel2);
445 fwDev1routerB->SetChannel(channel2);
448 fwDev2routerB->SetChannel(channel3);
449 fwDev1routerC->SetChannel(channel3);
452 fwDev2routerC->SetChannel(channel4);
453 rxDev->SetChannel(channel4);
478 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
486 Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
487 txSocket->SetAllowBroadcast(
true);
491 SendData(txSocket,
"2001:2::200:ff:fe00:8");
508 void DoRun()
override;
524 :
TestCase(
"RIPng Split Horizon strategy")
532 uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
535 socket->RecvFrom(std::numeric_limits<uint32_t>::max(), 0, srcAddr);
537 receivedPacketProbe->GetSize(),
538 "ReceivedPacketProbe size is not equal to the Rx buffer size");
541 if (senderAddress ==
"fe80::200:ff:fe00:4")
544 receivedPacketProbe->RemoveHeader(hdr);
548 for (
auto iter = rtes.begin(); iter != rtes.end(); iter++)
550 if (iter->GetPrefix() ==
"2001:1::")
552 bool correct =
false;
553 if (iter->GetRouteMetric() == 16)
558 else if (iter->GetRouteMetric() == 2)
565 "RIPng: unexpected metric value: " << iter->GetRouteMetric());
591 internetv6routers.
Install(routers);
594 internetv6nodes.
Install(listeners);
603 silentDev->SetAddress(
Mac48Address(
"00:00:00:00:00:01"));
604 fakeNode->AddDevice(silentDev);
613 silentDevRouterA->SetAddress(
Mac48Address(
"00:00:00:00:00:02"));
614 routerA->AddDevice(silentDevRouterA);
616 net0.
Add(silentDevRouterA);
620 fwDevRouterA->SetAddress(
Mac48Address(
"00:00:00:00:00:03"));
621 routerA->AddDevice(fwDevRouterA);
623 net1.
Add(fwDevRouterA);
629 fwDevRouterB->SetAddress(
Mac48Address(
"00:00:00:00:00:04"));
630 routerB->AddDevice(fwDevRouterB);
632 net1.
Add(fwDevRouterB);
638 listenerDev->SetAddress(
Mac48Address(
"00:00:00:00:00:05"));
639 listener->AddDevice(listenerDev);
641 net1.
Add(listenerDev);
645 silentDev->SetChannel(channel0);
646 silentDevRouterA->SetChannel(channel0);
649 fwDevRouterA->SetChannel(channel1);
650 fwDevRouterB->SetChannel(channel1);
651 listenerDev->SetChannel(channel1);
665 Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
666 rxSocket->BindToNetDevice(listenerDev);
670 rxSocket->SetRecvCallback(
699 TestCase::Duration::QUICK);
701 TestCase::Duration::QUICK);
703 TestCase::Duration::QUICK);
IPv6 RIPng count to infinity Test.
void SendData(Ptr< Socket > socket, std::string to)
Send data.
void DoSendData(Ptr< Socket > socket, std::string to)
Send data.
Ipv6RipngCountToInfinityTest()
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Ptr< Packet > m_receivedPacket
Received packet.
void DoRun() override
Implementation to actually run this TestCase.
IPv6 RIPng SplitHorizon strategy Test.
Ipv6RipngSplitHorizonStrategyTest(RipNg::SplitHorizonType_e strategy)
Constructor.
RipNg::SplitHorizonType_e m_setStrategy
Strategy set.
void DoRun() override
Implementation to actually run this TestCase.
RipNg::SplitHorizonType_e m_detectedStrategy
Strategy detected.
void ReceivePktProbe(Ptr< Socket > socket)
Receive data.
Ptr< Packet > m_receivedPacket
Received packet.
void DoRun() override
Implementation to actually run this TestCase.
void SendData(Ptr< Socket > socket, std::string to)
Send data.
void DoSendData(Ptr< Socket > socket, std::string to)
Send data.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
a polymophic address class
Hold variables of type enum.
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
Ipv6Address GetIpv6() const
Get the IPv6 address.
aggregate IP/TCP/UDP functionality to existing Nodes.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
Helper class to auto-assign global IPv6 unicast addresses.
Ipv6InterfaceContainer AssignWithoutAddress(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer but do not assign any IPv6 addresses.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Ipv6InterfaceContainer AssignWithoutOnLink(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses, but do not set the on-link property ...
Describes an IPv6 address.
Keep track of a set of IPv6 interfaces.
void SetForwarding(uint32_t i, bool state)
Set the state of the stack (act as a router or as an host) for the specified index.
void SetDefaultRouteInAllNodes(uint32_t router)
Set the default route for all the devices (except the router itself).
Describes an IPv6 prefix.
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.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void RemoveAllByteTags()
Remove all byte tags stored in this packet.
Smart pointer class similar to boost::intrusive_ptr.
Helper class that adds RIPng routing to nodes.
void SetInterfaceMetric(Ptr< Node > node, uint32_t interface, uint8_t metric)
Set a metric for an interface.
void Set(std::string name, const AttributeValue &value)
SplitHorizonType_e
Split Horizon strategy type.
@ SPLIT_HORIZON
Split Horizon.
@ POISON_REVERSE
Poison Reverse Split Horizon.
@ NO_SPLIT_HORIZON
No Split Horizon.
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 void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
static constexpr auto UNIT
API to create UDP socket instances.
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.
Time Seconds(double value)
Construct a Time in the indicated unit.
static Ipv6RipngTestSuite g_ipv6ripngTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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...