20 #include "ns3/ipv4-address-generator.h" 21 #include "ns3/simulation-singleton.h" 35 virtual void DoRun (
void);
36 virtual void DoTeardown (
void);
40 :
TestCase (
"Make sure the network number allocator is working on some of network prefixes.")
54 network = Ipv4AddressGenerator::GetNetwork (
Ipv4Mask (
"255.0.0.0"));
56 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.0.0.0"));
59 Ipv4AddressGenerator::Init (
Ipv4Address (
"0.1.0.0"),
61 network = Ipv4AddressGenerator::GetNetwork (
Ipv4Mask (
"255.255.0.0"));
63 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.255.0.0"));
66 Ipv4AddressGenerator::Init (
Ipv4Address (
"0.0.1.0"),
68 network = Ipv4AddressGenerator::GetNetwork (
Ipv4Mask (
"255.255.255.0"));
70 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.255.255.0"));
73 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.0.0.0"));
75 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.255.0.0"));
77 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.255.255.0"));
92 virtual void DoRun (
void);
97 :
TestCase (
"Sanity check on allocation of addresses")
113 Ipv4AddressGenerator::Init (
Ipv4Address (
"0.1.0.0"),
115 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.0.0"));
117 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.0.0"));
120 Ipv4AddressGenerator::Init (
Ipv4Address (
"0.0.1.0"),
122 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
124 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
132 Simulator::Destroy ();
146 virtual void DoRun (
void);
151 :
TestCase (
"Make sure Network and address allocation play together.")
159 Simulator::Destroy ();
175 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.0.0.0"));
180 Ipv4AddressGenerator::Init (
Ipv4Address (
"0.3.0.0"),
182 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.0.0"));
184 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.0.0"));
187 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.255.0.0"));
189 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.0.0"));
192 Ipv4AddressGenerator::Init (
Ipv4Address (
"0.0.3.0"),
194 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
196 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
199 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.255.255.0"));
201 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
216 virtual void DoRun (
void);
221 :
TestCase (
"A quick kindof-semi-almost-real example")
239 Ipv4AddressGenerator::Init (
Ipv4Address (
"192.168.0.0"),
241 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
243 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
245 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
252 Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.255.255.0"));
253 Ipv4AddressGenerator::InitAddress (
Ipv4Address (
"0.0.0.3"),
259 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
279 :
TestCase (
"Make sure that the address collision logic works.")
287 Simulator::Destroy ();
292 Ipv4AddressGenerator::AddAllocated (
"0.0.0.5");
293 Ipv4AddressGenerator::AddAllocated (
"0.0.0.10");
294 Ipv4AddressGenerator::AddAllocated (
"0.0.0.15");
295 Ipv4AddressGenerator::AddAllocated (
"0.0.0.20");
297 Ipv4AddressGenerator::AddAllocated (
"0.0.0.4");
298 Ipv4AddressGenerator::AddAllocated (
"0.0.0.3");
299 Ipv4AddressGenerator::AddAllocated (
"0.0.0.2");
300 Ipv4AddressGenerator::AddAllocated (
"0.0.0.1");
302 Ipv4AddressGenerator::AddAllocated (
"0.0.0.6");
303 Ipv4AddressGenerator::AddAllocated (
"0.0.0.7");
304 Ipv4AddressGenerator::AddAllocated (
"0.0.0.8");
305 Ipv4AddressGenerator::AddAllocated (
"0.0.0.9");
307 Ipv4AddressGenerator::AddAllocated (
"0.0.0.11");
308 Ipv4AddressGenerator::AddAllocated (
"0.0.0.12");
309 Ipv4AddressGenerator::AddAllocated (
"0.0.0.13");
310 Ipv4AddressGenerator::AddAllocated (
"0.0.0.14");
312 Ipv4AddressGenerator::AddAllocated (
"0.0.0.19");
313 Ipv4AddressGenerator::AddAllocated (
"0.0.0.18");
314 Ipv4AddressGenerator::AddAllocated (
"0.0.0.17");
315 Ipv4AddressGenerator::AddAllocated (
"0.0.0.16");
317 Ipv4AddressGenerator::TestMode ();
318 bool added = Ipv4AddressGenerator::AddAllocated (
"0.0.0.21");
321 added = Ipv4AddressGenerator::AddAllocated (
"0.0.0.4");
324 added = Ipv4AddressGenerator::AddAllocated (
"0.0.0.9");
327 added = Ipv4AddressGenerator::AddAllocated (
"0.0.0.16");
330 added = Ipv4AddressGenerator::AddAllocated (
"0.0.0.21");
349 :
TestSuite (
"ipv4-address-generator", UNIT)
IPv4 Address Generator TestSuite.
a class to represent an Ipv4 address mask
AddressCollisionTestCase()
IPv4 address collision Test.
AddressAllocatorTestCase()
NetworkAndAddressTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
#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.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
Ipv4AddressGeneratorTestSuite()
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
IPv4 AddressGenerator example (sort of) Test.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
IPv4 network and address allocator Test.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
IPv4 address allocator Test.
void Reset(void)
Reset the initial value of every attribute as well as the value of every global to what they were bef...
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
Ipv4 addresses are stored in host order in this class.
NetworkNumberAllocatorTestCase()
ExampleAddressGeneratorTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
void DoRun(void)
Implementation to actually run this TestCase.
IPv4 network number Test.