20 #include "ns3/ipv4-address-generator.h"
21 #include "ns3/ipv4-address-helper.h"
22 #include "ns3/simulator.h"
31 virtual void DoRun (
void);
32 virtual void DoTeardown (
void);
35 NetworkAllocatorHelperTestCase::NetworkAllocatorHelperTestCase ()
36 :
TestCase (
"Make sure the network allocator part is working on some common network prefixes.")
43 Ipv4AddressGenerator::Reset ();
44 Simulator::Destroy ();
53 h.
SetBase (
"1.0.0.0",
"255.0.0.0");
55 NS_TEST_EXPECT_MSG_EQ (network,
Ipv4Address (
"2.0.0.0"),
"XXX");
57 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"2.0.0.1"),
"XXX");
59 h.
SetBase (
"0.1.0.0",
"255.255.0.0");
61 NS_TEST_EXPECT_MSG_EQ (network,
Ipv4Address (
"0.2.0.0"),
"XXX");
63 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"0.2.0.1"),
"XXX");
65 h.
SetBase (
"0.0.1.0",
"255.255.255.0");
67 NS_TEST_EXPECT_MSG_EQ (network,
Ipv4Address (
"0.0.2.0"),
"XXX");
69 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"0.0.2.1"),
"XXX");
77 virtual void DoRun (
void);
81 AddressAllocatorHelperTestCase::AddressAllocatorHelperTestCase ()
82 :
TestCase (
"Make sure the address allocator part is working")
89 Ipv4AddressGenerator::Reset ();
90 Simulator::Destroy ();
100 h.
SetBase (
"1.0.0.0",
"255.0.0.0",
"0.0.0.3");
102 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"1.0.0.3"),
"XXX");
104 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"1.0.0.4"),
"XXX");
106 h.
SetBase (
"0.1.0.0",
"255.255.0.0",
"0.0.0.3");
108 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"0.1.0.3"),
"XXX");
110 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"0.1.0.4"),
"XXX");
112 h.
SetBase (
"0.0.1.0",
"255.255.255.0",
"0.0.0.3");
114 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"0.0.1.3"),
"XXX");
116 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"0.0.1.4"),
"XXX");
123 virtual void DoRun (
void);
127 ResetAllocatorHelperTestCase::ResetAllocatorHelperTestCase ()
128 :
TestCase (
"Make sure the reset to base behavior is working")
144 h.
SetBase (
"1.0.0.0",
"255.0.0.0",
"0.0.0.3");
146 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"1.0.0.3"),
"XXX");
148 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"1.0.0.4"),
"XXX");
150 NS_TEST_EXPECT_MSG_EQ (network,
Ipv4Address (
"2.0.0.0"),
"XXX");
152 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"2.0.0.3"),
"XXX");
154 h.
SetBase (
"0.1.0.0",
"255.255.0.0",
"0.0.0.3");
156 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"0.1.0.3"),
"XXX");
158 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"0.1.0.4"),
"XXX");
160 NS_TEST_EXPECT_MSG_EQ (network,
Ipv4Address (
"0.2.0.0"),
"XXX");
162 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"0.2.0.3"),
"XXX");
164 h.
SetBase (
"0.0.1.0",
"255.255.255.0",
"0.0.0.3");
166 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"0.0.1.3"),
"XXX");
168 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"0.0.1.4"),
"XXX");
170 NS_TEST_EXPECT_MSG_EQ (network,
Ipv4Address (
"0.0.2.0"),
"XXX");
172 NS_TEST_EXPECT_MSG_EQ (address,
Ipv4Address (
"0.0.2.3"),
"XXX");
178 Ipv4AddressGenerator::Reset ();
179 Simulator::Destroy ();
189 virtual void DoRun (
void);
193 IpAddressHelperTestCasev4::IpAddressHelperTestCasev4 ()
194 :
TestCase (
"IpAddressHelper Ipv4 test case (similar to IPv6)")
198 IpAddressHelperTestCasev4::~IpAddressHelperTestCasev4 ()
209 NS_TEST_ASSERT_MSG_EQ (ipAddr1,
Ipv4Address (
"255.255.255.255"),
"Ipv4AddressHelper failure");
211 ip1.
SetBase (
"192.168.0.0",
"255.255.255.0");
213 NS_TEST_ASSERT_MSG_EQ (ipAddr1,
Ipv4Address (
"192.168.0.1"),
"Ipv4AddressHelper failure");
215 NS_TEST_ASSERT_MSG_EQ (ipAddr1,
Ipv4Address (
"192.168.0.2"),
"Ipv4AddressHelper failure");
218 NS_TEST_ASSERT_MSG_EQ (ipAddr1,
Ipv4Address (
"192.168.1.1"),
"Ipv4AddressHelper failure");
225 NS_TEST_ASSERT_MSG_EQ (ipAddr1,
Ipv4Address (
"192.168.4.3"),
"Ipv4AddressHelper failure");
228 ip1.
SetBase (
"192.168.0.0",
"255.255.255.0",
"0.0.0.100");
230 NS_TEST_ASSERT_MSG_EQ (ipAddr1,
Ipv4Address (
"192.168.0.100"),
"Ipv4AddressHelper failure");
233 ip1.
SetBase (
"192.168.0.0",
"255.255.255.0",
"0.0.0.254");
235 NS_TEST_ASSERT_MSG_EQ (ipAddr1,
Ipv4Address (
"192.168.0.254"),
"Ipv4AddressHelper failure");
253 Ipv4AddressGenerator::Reset ();
254 Simulator::Destroy ();
269 } g_ipv4AddressHelperTestSuite;
virtual void DoRun(void)
Implementation to actually run this test case.
TestSuite(std::string name, Type type=UNIT)
Constuct a new test suite.
Ipv4Address NewAddress(void)
Increment the IP address counter used to allocate IP addresses.
virtual void DoTeardown(void)
Implementation to do any local setup required for this test case.
virtual void DoTeardown(void)
Implementation to do any local setup required for this test case.
virtual void DoTeardown(void)
Implementation to do any local setup required for this test case.
virtual void DoRun(void)
Implementation to actually run this test case.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
Ipv4 addresses are stored in host order in this class.
Ipv4Address NewNetwork(void)
Increment the network number and reset the IP address counter to the base value provided in the SetBa...
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
virtual void DoTeardown(void)
Implementation to do any local setup required for this test case.
virtual void DoRun(void)
Implementation to actually run this test case.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
virtual void DoRun(void)
Implementation to actually run this test case.