18#include "ns3/ipv4-address-generator.h"
19#include "ns3/simulation-singleton.h"
34 void DoRun()
override;
39 :
TestCase(
"Make sure the network number allocator is working on some of network prefixes.")
56 network = Ipv4AddressGenerator::GetNetwork(
Ipv4Mask(
"255.0.0.0"));
58 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.0.0.0"));
64 network = Ipv4AddressGenerator::GetNetwork(
Ipv4Mask(
"255.255.0.0"));
66 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.255.0.0"));
72 network = Ipv4AddressGenerator::GetNetwork(
Ipv4Mask(
"255.255.255.0"));
74 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.255.255.0"));
77 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.0.0.0"));
79 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.255.0.0"));
81 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.255.255.0"));
97 void DoRun()
override;
102 :
TestCase(
"Sanity check on allocation of addresses")
130 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
132 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
140 Simulator::Destroy();
153 void DoRun()
override;
158 :
TestCase(
"Make sure Network and address allocation play together.")
166 Simulator::Destroy();
183 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.0.0.0"));
196 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.255.0.0"));
204 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
206 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
209 network = Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.255.255.0"));
211 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
227 void DoRun()
override;
232 :
TestCase(
"A quick kindof-semi-almost-real example")
250 Ipv4AddressGenerator::Init(
Ipv4Address(
"192.168.0.0"),
253 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
255 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
257 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
264 Ipv4AddressGenerator::NextNetwork(
Ipv4Mask(
"255.255.255.0"));
270 address = Ipv4AddressGenerator::NextAddress(
Ipv4Mask(
"255.255.255.0"));
286 void DoRun()
override;
291 :
TestCase(
"Make sure that the address collision logic works.")
299 Simulator::Destroy();
305 Ipv4AddressGenerator::AddAllocated(
"0.0.0.5");
306 Ipv4AddressGenerator::AddAllocated(
"0.0.0.10");
307 Ipv4AddressGenerator::AddAllocated(
"0.0.0.15");
308 Ipv4AddressGenerator::AddAllocated(
"0.0.0.20");
310 Ipv4AddressGenerator::AddAllocated(
"0.0.0.4");
311 Ipv4AddressGenerator::AddAllocated(
"0.0.0.3");
312 Ipv4AddressGenerator::AddAllocated(
"0.0.0.2");
313 Ipv4AddressGenerator::AddAllocated(
"0.0.0.1");
315 Ipv4AddressGenerator::AddAllocated(
"0.0.0.6");
316 Ipv4AddressGenerator::AddAllocated(
"0.0.0.7");
317 Ipv4AddressGenerator::AddAllocated(
"0.0.0.8");
318 Ipv4AddressGenerator::AddAllocated(
"0.0.0.9");
320 Ipv4AddressGenerator::AddAllocated(
"0.0.0.11");
321 Ipv4AddressGenerator::AddAllocated(
"0.0.0.12");
322 Ipv4AddressGenerator::AddAllocated(
"0.0.0.13");
323 Ipv4AddressGenerator::AddAllocated(
"0.0.0.14");
325 Ipv4AddressGenerator::AddAllocated(
"0.0.0.19");
326 Ipv4AddressGenerator::AddAllocated(
"0.0.0.18");
327 Ipv4AddressGenerator::AddAllocated(
"0.0.0.17");
328 Ipv4AddressGenerator::AddAllocated(
"0.0.0.16");
330 Ipv4AddressGenerator::TestMode();
331 bool added = Ipv4AddressGenerator::AddAllocated(
"0.0.0.21");
334 added = Ipv4AddressGenerator::AddAllocated(
"0.0.0.4");
337 added = Ipv4AddressGenerator::AddAllocated(
"0.0.0.9");
340 added = Ipv4AddressGenerator::AddAllocated(
"0.0.0.16");
343 added = Ipv4AddressGenerator::AddAllocated(
"0.0.0.21");
362 :
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.