21 #include "ns3/arp-l3-protocol.h"
22 #include "ns3/inet-socket-address.h"
23 #include "ns3/ipv4-interface.h"
24 #include "ns3/ipv4-l3-protocol.h"
26 #include "ns3/loopback-net-device.h"
28 #include "ns3/simulator.h"
43 void DoRun()
override;
47 :
TestCase(
"Verify the IPv4 layer 3 protocol")
63 interface->SetDevice(device);
64 interface->SetNode(node);
65 uint32_t index =
ipv4->AddIpv4Interface(interface);
69 interface->AddAddress(ifaceAddr1);
71 interface->AddAddress(ifaceAddr2);
73 interface->AddAddress(ifaceAddr3);
75 interface->AddAddress(ifaceAddr4);
76 uint32_t
num = interface->GetNAddresses();
78 interface->RemoveAddress(2);
79 num = interface->GetNAddresses();
85 output = interface->RemoveAddress(
Ipv4Address(
"250.0.0.1"));
87 num = interface->GetNAddresses();
91 output = interface->RemoveAddress(
Ipv4Address(
"253.123.9.81"));
93 num = interface->GetNAddresses();
97 output = interface->RemoveAddress(Ipv4Address::GetLoopback());
99 num = interface->GetNAddresses();
105 num = interface->GetNAddresses();
111 num = interface->GetNAddresses();
115 result =
ipv4->RemoveAddress(index, Ipv4Address::GetLoopback());
117 num = interface->GetNAddresses();
120 Simulator::Destroy();
IPv4L3ProtocolTestSuite()
void DoRun() override
Implementation to actually run this TestCase.
~Ipv4L3ProtocolTestCase() override
Ipv4 addresses are stored in host order in this class.
a class to store IPv4 address information on an interface
Ipv4Address GetAddress() const
Get the local address.
The IPv4 representation of a network interface.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
@ UNIT
This test suite implements a Unit Test.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#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.
static IPv4L3ProtocolTestSuite g_ipv4protocolTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.