21 #include "ns3/ipv6-address-generator.h" 
   22 #include "ns3/simulation-singleton.h" 
   30   virtual void DoRun (
void);
 
   31   virtual void DoTeardown (
void);
 
   34 NetworkNumber6AllocatorTestCase::NetworkNumber6AllocatorTestCase ()
 
   35   : 
TestCase (
"Make sure the network number allocator is working on some of network prefixes.")
 
   41   Ipv6AddressGenerator::Reset ();
 
   50   network = Ipv6AddressGenerator::GetNetwork (
Ipv6Prefix (
"FFFF::0"));
 
   51   NS_TEST_EXPECT_MSG_EQ (network, 
Ipv6Address (
"1::0:0:0"), 
"network should equal the initialized network for given prefix");
 
   52   network = Ipv6AddressGenerator::NextNetwork (
Ipv6Prefix (
"FFFF::0"));
 
   53   NS_TEST_EXPECT_MSG_EQ (network, 
Ipv6Address (
"2::0:0:0"), 
"network should equal next network");
 
   55   Ipv6AddressGenerator::Init (
Ipv6Address (
"0:1::0:0"),
 
   57   network = Ipv6AddressGenerator::GetNetwork (
Ipv6Prefix (
"FFFF:FFFF::0"));
 
   58   NS_TEST_EXPECT_MSG_EQ (network, 
Ipv6Address (
"0:1::0"), 
"network should equal the initialized network for given prefix");
 
   59   network = Ipv6AddressGenerator::NextNetwork (
Ipv6Prefix (
"FFFF:FFFF::0"));
 
   60   NS_TEST_EXPECT_MSG_EQ (network, 
Ipv6Address (
"0:2::0"), 
"network should equal next network");
 
   62   Ipv6AddressGenerator::Init (
Ipv6Address (
"0:0:1::0"),
 
   64   network = Ipv6AddressGenerator::GetNetwork (
Ipv6Prefix (
"FFFF:FFFF:FFFF::0"));
 
   65   NS_TEST_EXPECT_MSG_EQ (network, 
Ipv6Address (
"0:0:1::0"), 
"network should equal the initialized network for given prefix");
 
   66   network = Ipv6AddressGenerator::NextNetwork (
Ipv6Prefix (
"FFFF:FFFF:FFFF::0"));
 
   67   NS_TEST_EXPECT_MSG_EQ (network, 
Ipv6Address (
"0:0:2::0"), 
"network should equal next network");
 
   76   virtual void DoRun (
void);
 
   80 AddressAllocator6TestCase::AddressAllocator6TestCase ()
 
   81   : 
TestCase (
"Sanity check on allocation of addresses")
 
   91   address = Ipv6AddressGenerator::GetNetwork (
Ipv6Prefix (64));
 
   92   NS_TEST_EXPECT_MSG_EQ (address, 
Ipv6Address (
"2001::0"), 
"address should equal the initialized address for given prefix");
 
   93   Ipv6AddressGenerator::NextNetwork (
Ipv6Prefix (64));
 
   94   address = Ipv6AddressGenerator::GetNetwork (
Ipv6Prefix (64));
 
   95   NS_TEST_EXPECT_MSG_EQ (address, 
Ipv6Address (
"2001:0:0:1::0"), 
"address should equal the initialized address for given prefix");
 
   96   address = Ipv6AddressGenerator::GetAddress (
Ipv6Prefix (64));
 
   97   NS_TEST_EXPECT_MSG_EQ (address, 
Ipv6Address (
"2001:0:0:1::1"), 
"address should equal the initialized address for given prefix");
 
   98   address = Ipv6AddressGenerator::NextAddress (
Ipv6Prefix (64));
 
   99   NS_TEST_EXPECT_MSG_EQ (address, 
Ipv6Address (
"2001:0:0:1::1"), 
"address should equal the initialized address for given prefix");
 
  100   address = Ipv6AddressGenerator::NextAddress (
Ipv6Prefix (64));
 
  101   NS_TEST_EXPECT_MSG_EQ (address, 
Ipv6Address (
"2001:0:0:1::2"), 
"address should equal the initialized address for given prefix");
 
  105   address = Ipv6AddressGenerator::NextAddress (
Ipv6Prefix (16));
 
  106   NS_TEST_EXPECT_MSG_EQ (address, 
Ipv6Address (
"1::3"), 
"address should equal initialized address for given prefix");
 
  107   address = Ipv6AddressGenerator::NextAddress (
Ipv6Prefix (16));
 
  108   NS_TEST_EXPECT_MSG_EQ (address, 
Ipv6Address (
"1::4"), 
"address should equal next address");
 
  115   Ipv6AddressGenerator::Reset ();
 
  116   Simulator::Destroy ();
 
  124   virtual void DoRun (
void);
 
  128 NetworkAndAddress6TestCase::NetworkAndAddress6TestCase ()
 
  129   : 
TestCase (
"Make sure Network and address allocation play together.")
 
  136   Ipv6AddressGenerator::Reset ();
 
  137   Simulator::Destroy ();
 
  148   address = Ipv6AddressGenerator::NextAddress (
Ipv6Prefix (16));
 
  149   NS_TEST_EXPECT_MSG_EQ (address, 
Ipv6Address (
"3::3"), 
"address should equal initialized address for given prefix");
 
  150   address = Ipv6AddressGenerator::NextAddress (
Ipv6Prefix (16));
 
  151   NS_TEST_EXPECT_MSG_EQ (address, 
Ipv6Address (
"3::4"), 
"address should equal next address for given prefix");
 
  153   network = Ipv6AddressGenerator::NextNetwork (
Ipv6Prefix (
"FFFF::"));
 
  154   NS_TEST_EXPECT_MSG_EQ (network, 
Ipv6Address (
"4::0"), 
"address should equal next address for given prefix");
 
  155   address = Ipv6AddressGenerator::NextAddress (
Ipv6Prefix (16));
 
  156   NS_TEST_EXPECT_MSG_EQ (address, 
Ipv6Address (
"4::3"), 
"address should equal next address for given prefix");
 
  165   virtual void DoRun (
void);
 
  169 ExampleAddress6GeneratorTestCase::ExampleAddress6GeneratorTestCase ()
 
  170   : 
TestCase (
"A typical real-world example")
 
  177   Ipv6AddressGenerator::Reset ();
 
  185   Ipv6AddressGenerator::Init (
Ipv6Address (
"2001:0AB8::"),
 
  187   address = Ipv6AddressGenerator::NextAddress (
Ipv6Prefix (48));
 
  188   NS_TEST_EXPECT_MSG_EQ (address, 
Ipv6Address (
"2001:0AB8::0:3"), 
"address should equal initialized address for given prefix");
 
  189   address = Ipv6AddressGenerator::NextAddress (
Ipv6Prefix (48));
 
  190   NS_TEST_EXPECT_MSG_EQ (address, 
Ipv6Address (
"2001:0AB8::0:4"), 
"address should equal next address for given prefix");
 
  191   address = Ipv6AddressGenerator::NextAddress (
Ipv6Prefix (48));
 
  192   NS_TEST_EXPECT_MSG_EQ (address, 
Ipv6Address (
"2001:0AB8::0:5"), 
"address should equal next address for given prefix");
 
  197   Ipv6AddressGenerator::NextNetwork (
Ipv6Prefix (
"FFFF:FFFF:FFFF::0"));
 
  201   Ipv6AddressGenerator::InitAddress (
Ipv6Address (
"::3"),
 
  206   address = Ipv6AddressGenerator::NextAddress (
Ipv6Prefix (48));
 
  207   NS_TEST_EXPECT_MSG_EQ (address, 
Ipv6Address (
"2001:0AB8:1::3"), 
"address should equal initialized address for given prefix");
 
  219 AddressCollision6TestCase::AddressCollision6TestCase ()
 
  220   : 
TestCase (
"Make sure that the address collision logic works.")
 
  227   Ipv6AddressGenerator::Reset ();
 
  228   Simulator::Destroy ();
 
  233   Ipv6AddressGenerator::AddAllocated (
"0::0:5");
 
  234   Ipv6AddressGenerator::AddAllocated (
"0::0:10");
 
  235   Ipv6AddressGenerator::AddAllocated (
"0::0:15");
 
  236   Ipv6AddressGenerator::AddAllocated (
"0::0:20");
 
  238   Ipv6AddressGenerator::AddAllocated (
"0::0:4");
 
  239   Ipv6AddressGenerator::AddAllocated (
"0::0:3");
 
  240   Ipv6AddressGenerator::AddAllocated (
"0::0:2");
 
  241   Ipv6AddressGenerator::AddAllocated (
"0::0:1");
 
  243   Ipv6AddressGenerator::AddAllocated (
"0::0:6");
 
  244   Ipv6AddressGenerator::AddAllocated (
"0::0:7");
 
  245   Ipv6AddressGenerator::AddAllocated (
"0::0:8");
 
  246   Ipv6AddressGenerator::AddAllocated (
"0::0:9");
 
  248   Ipv6AddressGenerator::AddAllocated (
"0::0:11");
 
  249   Ipv6AddressGenerator::AddAllocated (
"0::0:12");
 
  250   Ipv6AddressGenerator::AddAllocated (
"0::0:13");
 
  251   Ipv6AddressGenerator::AddAllocated (
"0::0:14");
 
  253   Ipv6AddressGenerator::AddAllocated (
"0::0:19");
 
  254   Ipv6AddressGenerator::AddAllocated (
"0::0:18");
 
  255   Ipv6AddressGenerator::AddAllocated (
"0::0:17");
 
  256   Ipv6AddressGenerator::AddAllocated (
"0::0:16");
 
  258   Ipv6AddressGenerator::TestMode ();
 
  259   bool added = Ipv6AddressGenerator::AddAllocated (
"0::0:21");
 
  260   NS_TEST_EXPECT_MSG_EQ (added, 
true, 
"address should get allocated");
 
  262   added = Ipv6AddressGenerator::AddAllocated (
"0::0:4");
 
  263   NS_TEST_EXPECT_MSG_EQ (added, 
false, 
"address should not get allocated");
 
  265   added = Ipv6AddressGenerator::AddAllocated (
"0::0:9");
 
  266   NS_TEST_EXPECT_MSG_EQ (added, 
false, 
"address should not get allocated");
 
  268   added = Ipv6AddressGenerator::AddAllocated (
"0::0:16");
 
  269   NS_TEST_EXPECT_MSG_EQ (added, 
false, 
"address should not get allocated");
 
  271   added = Ipv6AddressGenerator::AddAllocated (
"0::0:21");
 
  272   NS_TEST_EXPECT_MSG_EQ (added, 
false, 
"address should not get allocated");
 
  288 } g_ipv6AddressGeneratorTestSuite;
 
virtual void DoRun(void)
Implementation to actually run this test case. 
virtual void DoRun(void)
Implementation to actually run this test case. 
virtual void DoTeardown(void)
Implementation to do any local setup required for this test case. 
TestSuite(std::string name, Type type=UNIT)
Constuct a new test suite. 
virtual void DoTeardown(void)
Implementation to do any local setup required for this test case. 
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite. 
virtual void DoTeardown(void)
Implementation to do any local setup required for this test case. 
Describes an IPv6 address. 
virtual void DoRun(void)
Implementation to actually run this test case. 
virtual void DoRun(void)
Implementation to actually run this test case. 
void DoTeardown(void)
Implementation to do any local setup required for this test case. 
Describes an IPv6 prefix. It is just a bitmask like Ipv4Mask. 
void DoRun(void)
Implementation to actually run this test case. 
virtual void DoTeardown(void)
Implementation to do any local setup required for this test case.