20 #include "ns3/ipv4-address-generator.h"
21 #include "ns3/simulation-singleton.h"
29 virtual void DoRun (
void);
30 virtual void DoTeardown (
void);
34 :
TestCase (
"Make sure the network number allocator is working on some of network prefixes.")
48 network = Ipv4AddressGenerator::GetNetwork (
Ipv4Mask (
"255.0.0.0"));
50 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.0.0.0"));
53 Ipv4AddressGenerator::Init (
Ipv4Address (
"0.1.0.0"),
55 network = Ipv4AddressGenerator::GetNetwork (
Ipv4Mask (
"255.255.0.0"));
57 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.255.0.0"));
60 Ipv4AddressGenerator::Init (
Ipv4Address (
"0.0.1.0"),
62 network = Ipv4AddressGenerator::GetNetwork (
Ipv4Mask (
"255.255.255.0"));
64 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.255.255.0"));
67 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.0.0.0"));
69 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.255.0.0"));
71 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.255.255.0"));
80 virtual void DoRun (
void);
85 :
TestCase (
"Sanity check on allocation of addresses")
96 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.0.0.0"));
98 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.0.0.0"));
101 Ipv4AddressGenerator::Init (
Ipv4Address (
"0.1.0.0"),
103 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.0.0"));
105 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.0.0"));
108 Ipv4AddressGenerator::Init (
Ipv4Address (
"0.0.1.0"),
110 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
112 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
120 Simulator::Destroy ();
128 virtual void DoRun (
void);
133 :
TestCase (
"Make sure Network and address allocation play together.")
141 Simulator::Destroy ();
152 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.0.0.0"));
154 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.0.0.0"));
157 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.0.0.0"));
159 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.0.0.0"));
162 Ipv4AddressGenerator::Init (
Ipv4Address (
"0.3.0.0"),
164 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.0.0"));
166 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.0.0"));
169 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.255.0.0"));
171 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.0.0"));
174 Ipv4AddressGenerator::Init (
Ipv4Address (
"0.0.3.0"),
176 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
178 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
181 network = Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.255.255.0"));
183 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
192 virtual void DoRun (
void);
197 :
TestCase (
"A quick kindof-semi-almost-real example")
215 Ipv4AddressGenerator::Init (
Ipv4Address (
"192.168.0.0"),
217 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
219 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
221 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
228 Ipv4AddressGenerator::NextNetwork (
Ipv4Mask (
"255.255.255.0"));
229 Ipv4AddressGenerator::InitAddress (
Ipv4Address (
"0.0.0.3"),
235 address = Ipv4AddressGenerator::NextAddress (
Ipv4Mask (
"255.255.255.0"));
249 :
TestCase (
"Make sure that the address collision logic works.")
257 Simulator::Destroy ();
262 Ipv4AddressGenerator::AddAllocated (
"0.0.0.5");
263 Ipv4AddressGenerator::AddAllocated (
"0.0.0.10");
264 Ipv4AddressGenerator::AddAllocated (
"0.0.0.15");
265 Ipv4AddressGenerator::AddAllocated (
"0.0.0.20");
267 Ipv4AddressGenerator::AddAllocated (
"0.0.0.4");
268 Ipv4AddressGenerator::AddAllocated (
"0.0.0.3");
269 Ipv4AddressGenerator::AddAllocated (
"0.0.0.2");
270 Ipv4AddressGenerator::AddAllocated (
"0.0.0.1");
272 Ipv4AddressGenerator::AddAllocated (
"0.0.0.6");
273 Ipv4AddressGenerator::AddAllocated (
"0.0.0.7");
274 Ipv4AddressGenerator::AddAllocated (
"0.0.0.8");
275 Ipv4AddressGenerator::AddAllocated (
"0.0.0.9");
277 Ipv4AddressGenerator::AddAllocated (
"0.0.0.11");
278 Ipv4AddressGenerator::AddAllocated (
"0.0.0.12");
279 Ipv4AddressGenerator::AddAllocated (
"0.0.0.13");
280 Ipv4AddressGenerator::AddAllocated (
"0.0.0.14");
282 Ipv4AddressGenerator::AddAllocated (
"0.0.0.19");
283 Ipv4AddressGenerator::AddAllocated (
"0.0.0.18");
284 Ipv4AddressGenerator::AddAllocated (
"0.0.0.17");
285 Ipv4AddressGenerator::AddAllocated (
"0.0.0.16");
287 Ipv4AddressGenerator::TestMode ();
288 bool added = Ipv4AddressGenerator::AddAllocated (
"0.0.0.21");
291 added = Ipv4AddressGenerator::AddAllocated (
"0.0.0.4");
294 added = Ipv4AddressGenerator::AddAllocated (
"0.0.0.9");
297 added = Ipv4AddressGenerator::AddAllocated (
"0.0.0.16");
300 added = Ipv4AddressGenerator::AddAllocated (
"0.0.0.21");
void Reset(void)
Reset the initial value of every attribute as well as the value of every global to what they were bef...
a class to represent an Ipv4 address mask
AddressCollisionTestCase()
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.
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.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void DoTeardown(void)
Implementation to do any local setup required for this TestCase.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Ipv4AddressGeneratorTestSuite g_ipv4AddressGeneratorTestSuite
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.