19 #include "ns3/ipv6-address-generator.h"
20 #include "ns3/simulation-singleton.h"
34 void DoRun()
override;
35 void DoTeardown()
override;
39 :
TestCase(
"Make sure the network number allocator is working on some of network prefixes.")
55 network = Ipv6AddressGenerator::GetNetwork(
Ipv6Prefix(
"FFFF::0"));
58 "network should equal the initialized network for given prefix");
59 network = Ipv6AddressGenerator::NextNetwork(
Ipv6Prefix(
"FFFF::0"));
65 network = Ipv6AddressGenerator::GetNetwork(
Ipv6Prefix(
"FFFF:FFFF::0"));
68 "network should equal the initialized network for given prefix");
69 network = Ipv6AddressGenerator::NextNetwork(
Ipv6Prefix(
"FFFF:FFFF::0"));
75 network = Ipv6AddressGenerator::GetNetwork(
Ipv6Prefix(
"FFFF:FFFF:FFFF::0"));
78 "network should equal the initialized network for given prefix");
79 network = Ipv6AddressGenerator::NextNetwork(
Ipv6Prefix(
"FFFF:FFFF:FFFF::0"));
94 void DoRun()
override;
99 :
TestCase(
"Sanity check on allocation of addresses")
112 "address should equal the initialized address for given prefix");
113 Ipv6AddressGenerator::NextNetwork(
Ipv6Prefix(64));
117 "address should equal the initialized address for given prefix");
121 "address should equal the initialized address for given prefix");
125 "address should equal the initialized address for given prefix");
129 "address should equal the initialized address for given prefix");
135 "address should equal initialized address for given prefix");
144 Simulator::Destroy();
156 void DoRun()
override;
161 :
TestCase(
"Make sure Network and address allocation play together.")
169 Simulator::Destroy();
182 "address should equal initialized address for given prefix");
186 "address should equal next address for given prefix");
188 network = Ipv6AddressGenerator::NextNetwork(
Ipv6Prefix(
"FFFF::"));
191 "address should equal next address for given prefix");
195 "address should equal next address for given prefix");
209 void DoRun()
override;
214 :
TestCase(
"A typical real-world example")
229 Ipv6AddressGenerator::Init(
Ipv6Address(
"2001:0AB8::"),
235 "address should equal initialized address for given prefix");
239 "address should equal next address for given prefix");
243 "address should equal next address for given prefix");
248 Ipv6AddressGenerator::NextNetwork(
Ipv6Prefix(
"FFFF:FFFF:FFFF::0"));
259 "address should equal initialized address for given prefix");
273 void DoRun()
override;
278 :
TestCase(
"Make sure that the address collision logic works.")
286 Simulator::Destroy();
292 Ipv6AddressGenerator::AddAllocated(
"0::0:5");
293 Ipv6AddressGenerator::AddAllocated(
"0::0:10");
294 Ipv6AddressGenerator::AddAllocated(
"0::0:15");
295 Ipv6AddressGenerator::AddAllocated(
"0::0:20");
297 Ipv6AddressGenerator::AddAllocated(
"0::0:4");
298 Ipv6AddressGenerator::AddAllocated(
"0::0:3");
299 Ipv6AddressGenerator::AddAllocated(
"0::0:2");
300 Ipv6AddressGenerator::AddAllocated(
"0::0:1");
302 Ipv6AddressGenerator::AddAllocated(
"0::0:6");
303 Ipv6AddressGenerator::AddAllocated(
"0::0:7");
304 Ipv6AddressGenerator::AddAllocated(
"0::0:8");
305 Ipv6AddressGenerator::AddAllocated(
"0::0:9");
307 Ipv6AddressGenerator::AddAllocated(
"0::0:11");
308 Ipv6AddressGenerator::AddAllocated(
"0::0:12");
309 Ipv6AddressGenerator::AddAllocated(
"0::0:13");
310 Ipv6AddressGenerator::AddAllocated(
"0::0:14");
312 Ipv6AddressGenerator::AddAllocated(
"0::0:19");
313 Ipv6AddressGenerator::AddAllocated(
"0::0:18");
314 Ipv6AddressGenerator::AddAllocated(
"0::0:17");
315 Ipv6AddressGenerator::AddAllocated(
"0::0:16");
317 Ipv6AddressGenerator::TestMode();
318 bool allocated = Ipv6AddressGenerator::IsAddressAllocated(
"0::0:21");
320 bool added = Ipv6AddressGenerator::AddAllocated(
"0::0:21");
323 allocated = Ipv6AddressGenerator::IsAddressAllocated(
"0::0:4");
325 added = Ipv6AddressGenerator::AddAllocated(
"0::0:4");
328 allocated = Ipv6AddressGenerator::IsAddressAllocated(
"0::0:9");
330 added = Ipv6AddressGenerator::AddAllocated(
"0::0:9");
333 allocated = Ipv6AddressGenerator::IsAddressAllocated(
"0::0:16");
335 added = Ipv6AddressGenerator::AddAllocated(
"0::0:16");
338 allocated = Ipv6AddressGenerator::IsAddressAllocated(
"0::0:21");
340 added = Ipv6AddressGenerator::AddAllocated(
"0::0:21");
IPv6 address allocator Test.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
AddressAllocator6TestCase()
IPv6 address collision Test.
void DoRun() override
Implementation to actually run this TestCase.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
AddressCollision6TestCase()
IPv6 example of an address generator Test.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
ExampleAddress6GeneratorTestCase()
void DoRun() override
Implementation to actually run this TestCase.
IPv6 address generator TestSuite.
Ipv6AddressGeneratorTestSuite()
IPv6 network number and address allocator Test.
void DoRun() override
Implementation to actually run this TestCase.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
NetworkAndAddress6TestCase()
IPv6 network number allocator Test.
NetworkNumber6AllocatorTestCase()
void DoRun() override
Implementation to actually run this TestCase.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
Describes an IPv6 address.
Describes an IPv6 prefix.
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 Ipv6AddressGeneratorTestSuite g_ipv6AddressGeneratorTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.