9#include "ns3/boolean.h" 
   11#include "ns3/icmpv4-l4-protocol.h" 
   12#include "ns3/inet-socket-address.h" 
   13#include "ns3/internet-stack-helper.h" 
   14#include "ns3/ipv4-address-helper.h" 
   15#include "ns3/ipv4-l3-protocol.h" 
   16#include "ns3/ipv4-static-routing.h" 
   18#include "ns3/node-container.h" 
   20#include "ns3/rip-helper.h" 
   22#include "ns3/simple-channel.h" 
   23#include "ns3/simple-net-device.h" 
   24#include "ns3/simulator.h" 
   25#include "ns3/socket-factory.h" 
   26#include "ns3/socket.h" 
   28#include "ns3/udp-l4-protocol.h" 
   29#include "ns3/udp-socket-factory.h" 
   59    void DoRun() 
override;
 
 
   77    uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
 
   81                          "Received Packet size is not equal to the Rx buffer size");
 
 
  123    internetRouters.
Install(routers);
 
  138        txNode->AddDevice(txDev);
 
  147        fwDev1routerA->SetAddress(
Mac48Address(
"00:00:00:00:00:02"));
 
  148        routerA->AddDevice(fwDev1routerA);
 
  150    net1.
Add(fwDev1routerA);
 
  154        fwDev2routerA->SetAddress(
Mac48Address(
"00:00:00:00:00:03"));
 
  155        routerA->AddDevice(fwDev2routerA);
 
  157    net2.
Add(fwDev2routerA);
 
  164        fwDev1routerB->SetAddress(
Mac48Address(
"00:00:00:00:00:04"));
 
  165        routerB->AddDevice(fwDev1routerB);
 
  167    net2.
Add(fwDev1routerB);
 
  171        fwDev2routerB->SetAddress(
Mac48Address(
"00:00:00:00:00:05"));
 
  172        routerB->AddDevice(fwDev2routerB);
 
  174    net3.
Add(fwDev2routerB);
 
  181        fwDev1routerC->SetAddress(
Mac48Address(
"00:00:00:00:00:06"));
 
  182        routerC->AddDevice(fwDev1routerC);
 
  184    net3.
Add(fwDev1routerC);
 
  188        fwDev2routerC->SetAddress(
Mac48Address(
"00:00:00:00:00:07"));
 
  189        routerC->AddDevice(fwDev2routerC);
 
  191    net4.
Add(fwDev2routerC);
 
  198        rxNode->AddDevice(rxDev);
 
  204    txDev->SetChannel(channel1);
 
  205    fwDev1routerA->SetChannel(channel1);
 
  208    fwDev2routerA->SetChannel(channel2);
 
  209    fwDev1routerB->SetChannel(channel2);
 
  212    fwDev2routerB->SetChannel(channel3);
 
  213    fwDev1routerC->SetChannel(channel3);
 
  216    fwDev2routerC->SetChannel(channel4);
 
  217    rxDev->SetChannel(channel4);
 
  237    staticRouting->SetDefaultRoute(
"10.0.1.2", 1);
 
  240    staticRouting->SetDefaultRoute(
"10.0.2.1", 1);
 
  244    Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
 
  251    Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
 
  252    txSocket->SetAllowBroadcast(
true);
 
 
  288    void DoRun() 
override;
 
 
  299    : 
TestCase(
"RIP counting to infinity")
 
 
  306    uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
 
  310                          "Received Packet size is not equal to the 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);
 
  473    staticRouting->SetDefaultRoute(
"10.0.1.2", 1);
 
  476    staticRouting->SetDefaultRoute(
"10.0.2.1", 1);
 
  480    Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
 
  487    Ptr<Socket> txSocket = txSocketFactory->CreateSocket();
 
  488    txSocket->SetAllowBroadcast(
true);
 
 
  509    void DoRun() 
override;
 
 
  525    : 
TestCase(
"RIP Split Horizon strategy")
 
 
  533    uint32_t availableData [[maybe_unused]] = socket->GetRxAvailable();
 
  536        socket->RecvFrom(std::numeric_limits<uint32_t>::max(), 0, srcAddr);
 
  538                          receivedPacketProbe->GetSize(),
 
  539                          "Received Packet size is not equal to the Rx buffer size");
 
  542    if (senderAddress == 
"192.168.0.2")
 
  545        receivedPacketProbe->RemoveHeader(hdr);
 
  550        for (
auto iter = rtes.begin(); iter != rtes.end(); iter++)
 
  552            if (iter->GetPrefix() == 
"10.0.1.0")
 
  554                bool correct = 
false;
 
  555                if (iter->GetRouteMetric() == 16)
 
  560                else if (iter->GetRouteMetric() == 2)
 
  567                                      "RIP: unexpected metric value: " << iter->GetRouteMetric());
 
 
  593    internetRouters.
Install(routers);
 
  596    internetNodes.
Install(listeners);
 
  605        silentDev->SetAddress(
Mac48Address(
"00:00:00:00:00:01"));
 
  606        fakeNode->AddDevice(silentDev);
 
  615        silentDevRouterA->SetAddress(
Mac48Address(
"00:00:00:00:00:02"));
 
  616        routerA->AddDevice(silentDevRouterA);
 
  618    net0.
Add(silentDevRouterA);
 
  622        fwDevRouterA->SetAddress(
Mac48Address(
"00:00:00:00:00:03"));
 
  623        routerA->AddDevice(fwDevRouterA);
 
  625    net1.
Add(fwDevRouterA);
 
  631        fwDevRouterB->SetAddress(
Mac48Address(
"00:00:00:00:00:04"));
 
  632        routerB->AddDevice(fwDevRouterB);
 
  634    net1.
Add(fwDevRouterB);
 
  640        listenerDev->SetAddress(
Mac48Address(
"00:00:00:00:00:05"));
 
  641        listener->AddDevice(listenerDev);
 
  643    net1.
Add(listenerDev);
 
  647    silentDev->SetChannel(channel0);
 
  648    silentDevRouterA->SetChannel(channel0);
 
  651    fwDevRouterA->SetChannel(channel1);
 
  652    fwDevRouterB->SetChannel(channel1);
 
  653    listenerDev->SetChannel(channel1);
 
  666    Ptr<Socket> rxSocket = rxSocketFactory->CreateSocket();
 
  667    rxSocket->BindToNetDevice(listenerDev);
 
  671    rxSocket->SetRecvCallback(
 
 
  700                    TestCase::Duration::QUICK);
 
  702                    TestCase::Duration::QUICK);
 
  704                    TestCase::Duration::QUICK);
 
 
 
IPv4 RIP count to infinity Test.
void DoRun() override
Implementation to actually run this TestCase.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
void DoSendData(Ptr< Socket > socket, std::string to)
Send data.
Ipv4RipCountToInfinityTest()
void SendData(Ptr< Socket > socket, std::string to)
Send data.
Ptr< Packet > m_receivedPacket
Received packet.
IPv4 RIP SplitHorizon strategy Test.
void ReceivePktProbe(Ptr< Socket > socket)
Receive data.
Rip::SplitHorizonType_e m_detectedStrategy
Strategy detected.
Ipv4RipSplitHorizonStrategyTest(Rip::SplitHorizonType_e strategy)
Constructor.
Rip::SplitHorizonType_e m_setStrategy
Strategy set.
void DoRun() override
Implementation to actually run this TestCase.
void SendData(Ptr< Socket > socket, std::string to)
Send data.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Ptr< Packet > m_receivedPacket
Received packet.
void DoRun() override
Implementation to actually run this TestCase.
void DoSendData(Ptr< Socket > socket, std::string to)
Send data.
a polymophic address class
Hold variables of type enum.
Ipv4Address GetIpv4() const
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input 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)
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.
Access to the IPv4 forwarding table, interfaces, and configuration.
virtual Ptr< Ipv4RoutingProtocol > GetRoutingProtocol() const =0
Get the routing protocol to be used by this Ipv4 stack.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
a class to represent an Ipv4 address mask
static Ptr< T > GetRouting(Ptr< Ipv4RoutingProtocol > protocol)
Request a specified routing protocol <T> from Ipv4RoutingProtocol protocol.
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 RIP routing to nodes.
void Set(std::string name, const AttributeValue &value)
void SetInterfaceMetric(Ptr< Node > node, uint32_t interface, uint8_t metric)
Set a metric for an interface.
SplitHorizonType_e
Split Horizon strategy type.
@ SPLIT_HORIZON
Split Horizon.
@ NO_SPLIT_HORIZON
No Split Horizon.
@ POISON_REVERSE
Poison Reverse 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 Ipv4RipTestSuite g_ipv4ripTestSuite
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...