18 #include "ns3/ipv4-address-generator.h"
19 #include "ns3/simulation-singleton.h"
33 void DoRun()
override;
34 void DoTeardown()
override;
38 :
TestCase(
"Make sure the network number allocator is working on some of network prefixes.")
55 network = Ipv4AddressGenerator::GetNetwork(
Ipv4Mask(
"255.0.0.0"));
57 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.0.0.0"));
63 network = Ipv4AddressGenerator::GetNetwork(
Ipv4Mask(
"255.255.0.0"));
65 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.255.0.0"));
71 network = Ipv4AddressGenerator::GetNetwork(
Ipv4Mask(
"255.255.255.0"));
73 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.255.255.0"));
76 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.0.0.0"));
78 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.255.0.0"));
80 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.255.255.0"));
95 void DoRun()
override;
100 :
TestCase(
"Sanity check on allocation of addresses")
128 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
130 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
138 Simulator::Destroy();
150 void DoRun()
override;
155 :
TestCase(
"Make sure Network and address allocation play together.")
163 Simulator::Destroy();
180 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.0.0.0"));
193 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.255.0.0"));
201 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
203 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
206 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.255.255.0"));
208 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
223 void DoRun()
override;
228 :
TestCase(
"A quick kindof-semi-almost-real example")
246 Ipv4AddressGenerator::Init(
Ipv4Address(
"192.168.0.0"),
249 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
251 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
253 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
260 Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.255.255.0"));
266 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
281 void DoRun()
override;
286 :
TestCase(
"Make sure that the address collision logic works.")
294 Simulator::Destroy();
300 Ipv4AddressGenerator::AddAllocated(
"0.0.0.5");
301 Ipv4AddressGenerator::AddAllocated(
"0.0.0.10");
302 Ipv4AddressGenerator::AddAllocated(
"0.0.0.15");
303 Ipv4AddressGenerator::AddAllocated(
"0.0.0.20");
305 Ipv4AddressGenerator::AddAllocated(
"0.0.0.4");
306 Ipv4AddressGenerator::AddAllocated(
"0.0.0.3");
307 Ipv4AddressGenerator::AddAllocated(
"0.0.0.2");
308 Ipv4AddressGenerator::AddAllocated(
"0.0.0.1");
310 Ipv4AddressGenerator::AddAllocated(
"0.0.0.6");
311 Ipv4AddressGenerator::AddAllocated(
"0.0.0.7");
312 Ipv4AddressGenerator::AddAllocated(
"0.0.0.8");
313 Ipv4AddressGenerator::AddAllocated(
"0.0.0.9");
315 Ipv4AddressGenerator::AddAllocated(
"0.0.0.11");
316 Ipv4AddressGenerator::AddAllocated(
"0.0.0.12");
317 Ipv4AddressGenerator::AddAllocated(
"0.0.0.13");
318 Ipv4AddressGenerator::AddAllocated(
"0.0.0.14");
320 Ipv4AddressGenerator::AddAllocated(
"0.0.0.19");
321 Ipv4AddressGenerator::AddAllocated(
"0.0.0.18");
322 Ipv4AddressGenerator::AddAllocated(
"0.0.0.17");
323 Ipv4AddressGenerator::AddAllocated(
"0.0.0.16");
325 Ipv4AddressGenerator::TestMode();
326 bool allocated = Ipv4AddressGenerator::IsAddressAllocated(
"0.0.0.21");
328 bool added = Ipv4AddressGenerator::AddAllocated(
"0.0.0.21");
331 allocated = Ipv4AddressGenerator::IsAddressAllocated(
"0.0.0.4");
333 added = Ipv4AddressGenerator::AddAllocated(
"0.0.0.4");
336 allocated = Ipv4AddressGenerator::IsAddressAllocated(
"0.0.0.9");
338 added = Ipv4AddressGenerator::AddAllocated(
"0.0.0.9");
341 allocated = Ipv4AddressGenerator::IsAddressAllocated(
"0.0.0.16");
343 added = Ipv4AddressGenerator::AddAllocated(
"0.0.0.16");
346 allocated = Ipv4AddressGenerator::IsAddressAllocated(
"0.0.0.21");
348 added = Ipv4AddressGenerator::AddAllocated(
"0.0.0.21");
366 :
TestSuite(
"ipv4-address-generator", UNIT)
IPv4 address allocator Test.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
AddressAllocatorTestCase()
void DoRun() override
Implementation to actually run this TestCase.
IPv4 address collision Test.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
AddressCollisionTestCase()
void DoRun() override
Implementation to actually run this TestCase.
IPv4 AddressGenerator example (sort of) Test.
void DoRun() override
Implementation to actually run this TestCase.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
ExampleAddressGeneratorTestCase()
IPv4 Address Generator TestSuite.
Ipv4AddressGeneratorTestSuite()
IPv4 network and address allocator Test.
NetworkAndAddressTestCase()
void DoRun() override
Implementation to actually run this TestCase.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
IPv4 network number Test.
void DoRun() override
Implementation to actually run this TestCase.
NetworkNumberAllocatorTestCase()
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
Ipv4 addresses are stored in host order in this class.
a class to represent an Ipv4 address mask
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
void Reset()
Reset the initial value of every attribute as well as the value of every global to what they were bef...
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
static Ipv4AddressGeneratorTestSuite g_ipv4AddressGeneratorTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.