22 #include "ns3/simulator.h" 25 #include "ns3/inet-socket-address.h" 28 #include "ns3/ipv4-l3-protocol.h" 29 #include "ns3/arp-l3-protocol.h" 30 #include "ns3/ipv4-interface.h" 31 #include "ns3/loopback-net-device.h" 46 virtual void DoRun (
void);
51 TestCase (
"Verify the IPv4 layer 3 protocol")
66 interface->SetDevice (device);
67 interface->SetNode (node);
68 uint32_t index = ipv4->AddIpv4Interface (interface);
73 interface->AddAddress (ifaceAddr1);
76 interface->AddAddress (ifaceAddr2);
79 interface->AddAddress (ifaceAddr3);
82 interface->AddAddress (ifaceAddr4);
83 uint32_t num = interface->GetNAddresses ();
85 interface->RemoveAddress (2);
86 num = interface->GetNAddresses ();
90 "The addresses should be identical");
93 output = interface->RemoveAddress (
Ipv4Address (
"250.0.0.1"));
95 "Wrong Interface Address Removed??");
96 num = interface->GetNAddresses ();
100 output = interface->RemoveAddress (
Ipv4Address (
"253.123.9.81"));
102 "Removed non-existent address??");
103 num = interface->GetNAddresses ();
107 output = interface->RemoveAddress (Ipv4Address::GetLoopback ());
109 "Able to remove loopback address??");
110 num = interface->GetNAddresses ();
114 bool result = ipv4->RemoveAddress (index,
Ipv4Address 117 num = interface->GetNAddresses ();
121 result = ipv4->RemoveAddress (index,
Ipv4Address (
"189.0.0.1"));
123 "Removed non-existent address??");
124 num = interface->GetNAddresses ();
128 result = ipv4->RemoveAddress (index, Ipv4Address::GetLoopback ());
130 "Able to remove loopback address??");
131 num = interface->GetNAddresses ();
134 Simulator::Destroy ();
The IPv4 representation of a network interface.
IPv4L3ProtocolTestSuite()
virtual ~Ipv4L3ProtocolTestCase()
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static IPv4L3ProtocolTestSuite g_ipv4protocolTestSuite
Static variable for test initialization.
Ipv4 addresses are stored in host order in this class.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
a class to store IPv4 address information on an interface
Ptr< T > CreateObject(void)
Create an object by type, with varying number of constructor parameters.
virtual void DoRun(void)
Implementation to actually run this TestCase.
This test suite implements a Unit Test.