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")
62 node->AddDevice(device);
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();
99 num = interface->GetNAddresses();
103 bool result = ipv4->RemoveAddress(index,
Ipv4Address(
"192.168.0.2"));
105 num = interface->GetNAddresses();
109 result = ipv4->RemoveAddress(index,
Ipv4Address(
"189.0.0.1"));
111 num = interface->GetNAddresses();
117 num = interface->GetNAddresses();
IPv4L3ProtocolTestSuite()
void DoRun() override
Implementation to actually run this TestCase.
~Ipv4L3ProtocolTestCase() override
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetLoopback()
a class to store IPv4 address information on an interface
Ipv4Address GetAddress() const
Get the local address.
The IPv4 representation of a network interface.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
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.