00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <list>
00020 #include "ns3/assert.h"
00021 #include "ns3/log.h"
00022 #include "ns3/simulation-singleton.h"
00023 #include "ipv4-address-generator.h"
00024
00025 NS_LOG_COMPONENT_DEFINE("Ipv4AddressGenerator");
00026
00027 namespace ns3 {
00028
00029 class Ipv4AddressGeneratorImpl
00030 {
00031 public:
00032 Ipv4AddressGeneratorImpl ();
00033 virtual ~Ipv4AddressGeneratorImpl ();
00034
00035 void Init (const Ipv4Address net, const Ipv4Mask mask,
00036 const Ipv4Address addr);
00037
00038 Ipv4Address GetNetwork (const Ipv4Mask mask) const;
00039 Ipv4Address NextNetwork (const Ipv4Mask mask);
00040
00041 void InitAddress (const Ipv4Address addr, const Ipv4Mask mask);
00042 Ipv4Address GetAddress (const Ipv4Mask mask) const;
00043 Ipv4Address NextAddress (const Ipv4Mask mask);
00044
00045 void Reset (void);
00046 bool AddAllocated (const Ipv4Address addr);
00047
00048 void TestMode (void);
00049 private:
00050 static const uint32_t N_BITS = 32;
00051 static const uint32_t MOST_SIGNIFICANT_BIT = 0x80000000;
00052
00053 uint32_t MaskToIndex (Ipv4Mask mask) const;
00054
00055 class NetworkState
00056 {
00057 public:
00058 uint32_t mask;
00059 uint32_t shift;
00060 uint32_t network;
00061 uint32_t addr;
00062 uint32_t addrMax;
00063 };
00064
00065 NetworkState m_netTable[N_BITS];
00066
00067 class Entry
00068 {
00069 public:
00070 uint32_t addrLow;
00071 uint32_t addrHigh;
00072 };
00073
00074 std::list<Entry> m_entries;
00075 bool m_test;
00076 };
00077
00078 Ipv4AddressGeneratorImpl::Ipv4AddressGeneratorImpl ()
00079 : m_entries (), m_test (false)
00080 {
00081 NS_LOG_FUNCTION_NOARGS ();
00082 Reset ();
00083 }
00084
00085 void
00086 Ipv4AddressGeneratorImpl::Reset (void)
00087 {
00088 NS_LOG_FUNCTION_NOARGS ();
00089
00090 uint32_t mask = 0;
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 for (uint32_t i = 0; i < N_BITS; ++i)
00111 {
00112 m_netTable[i].mask = mask;
00113 mask >>= 1;
00114 mask |= MOST_SIGNIFICANT_BIT;
00115 m_netTable[i].network = 1;
00116 m_netTable[i].addr = 1;
00117 m_netTable[i].addrMax = ~mask;
00118 m_netTable[i].shift = N_BITS - i;
00119 }
00120 m_entries.clear ();
00121 m_test = false;
00122 }
00123
00124 Ipv4AddressGeneratorImpl::~Ipv4AddressGeneratorImpl ()
00125 {
00126 NS_LOG_FUNCTION_NOARGS ();
00127 }
00128
00129 void
00130 Ipv4AddressGeneratorImpl::Init (
00131 const Ipv4Address net,
00132 const Ipv4Mask mask,
00133 const Ipv4Address addr)
00134 {
00135 NS_LOG_FUNCTION_NOARGS ();
00136
00137
00138
00139
00140 uint32_t maskBits __attribute__((unused)) = mask.Get ();
00141 uint32_t netBits = net.Get ();
00142 uint32_t addrBits = addr.Get ();
00143
00144
00145
00146 NS_ASSERT_MSG((netBits & ~maskBits) == 0,
00147 "Ipv4AddressGeneratorImpl::Init (): Inconsistent network and mask");
00148
00149 NS_ASSERT_MSG((addrBits & maskBits) == 0,
00150 "Ipv4AddressGeneratorImpl::Init (): Inconsistent address and mask");
00151
00152
00153
00154
00155
00156
00157
00158 uint32_t index = MaskToIndex (mask);
00159
00160 m_netTable[index].network = netBits >> m_netTable[index].shift;
00161
00162 NS_ASSERT_MSG (addrBits <= m_netTable[index].addrMax,
00163 "Ipv4AddressGeneratorImpl::Init(): Address overflow");
00164
00165 m_netTable[index].addr = addrBits;
00166 return;
00167 }
00168
00169 Ipv4Address
00170 Ipv4AddressGeneratorImpl::GetNetwork (
00171 const Ipv4Mask mask) const
00172 {
00173 NS_LOG_FUNCTION_NOARGS ();
00174
00175 uint32_t index = MaskToIndex (mask);
00176 return Ipv4Address (m_netTable[index].network << m_netTable[index].shift);
00177 }
00178
00179 Ipv4Address
00180 Ipv4AddressGeneratorImpl::NextNetwork (
00181 const Ipv4Mask mask)
00182 {
00183 NS_LOG_FUNCTION_NOARGS ();
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193 uint32_t index = MaskToIndex (mask);
00194 ++m_netTable[index].network;
00195 return Ipv4Address (m_netTable[index].network << m_netTable[index].shift);
00196 }
00197
00198 void
00199 Ipv4AddressGeneratorImpl::InitAddress (
00200 const Ipv4Address addr,
00201 const Ipv4Mask mask)
00202 {
00203 NS_LOG_FUNCTION_NOARGS ();
00204
00205 uint32_t index = MaskToIndex (mask);
00206 uint32_t addrBits = addr.Get ();
00207
00208 NS_ASSERT_MSG (addrBits <= m_netTable[index].addrMax,
00209 "Ipv4AddressGeneratorImpl::InitAddress(): Address overflow");
00210
00211 m_netTable[index].addr = addrBits;
00212 }
00213
00214 Ipv4Address
00215 Ipv4AddressGeneratorImpl::GetAddress (
00216 const Ipv4Mask mask) const
00217 {
00218 NS_LOG_FUNCTION_NOARGS ();
00219
00220 uint32_t index = MaskToIndex (mask);
00221
00222 return Ipv4Address (
00223 (m_netTable[index].network << m_netTable[index].shift) |
00224 m_netTable[index].addr);
00225 }
00226
00227 Ipv4Address
00228 Ipv4AddressGeneratorImpl::NextAddress (const Ipv4Mask mask)
00229 {
00230 NS_LOG_FUNCTION_NOARGS ();
00231
00232
00233
00234
00235
00236
00237
00238 uint32_t index = MaskToIndex (mask);
00239
00240 NS_ASSERT_MSG (m_netTable[index].addr <= m_netTable[index].addrMax,
00241 "Ipv4AddressGeneratorImpl::NextAddress(): Address overflow");
00242
00243 Ipv4Address addr = Ipv4Address (
00244 (m_netTable[index].network << m_netTable[index].shift) |
00245 m_netTable[index].addr);
00246
00247 ++m_netTable[index].addr;
00248
00249
00250
00251
00252 AddAllocated (addr);
00253 return addr;
00254 }
00255
00256 bool
00257 Ipv4AddressGeneratorImpl::AddAllocated (const Ipv4Address address)
00258 {
00259 NS_LOG_FUNCTION_NOARGS ();
00260
00261 uint32_t addr = address.Get ();
00262
00263 NS_ASSERT_MSG (addr, "Ipv4AddressGeneratorImpl::Add(): "
00264 "Allocating the broadcast address is not a good idea");
00265
00266 std::list<Entry>::iterator i;
00267
00268 for (i = m_entries.begin (); i != m_entries.end (); ++i)
00269 {
00270 NS_LOG_LOGIC ("examine entry: " << Ipv4Address ((*i).addrLow) <<
00271 " to " << Ipv4Address ((*i).addrHigh));
00272
00273
00274
00275
00276 if (addr >= (*i).addrLow && addr <= (*i).addrHigh)
00277 {
00278 NS_LOG_LOGIC ("Ipv4AddressGeneratorImpl::Add(): "
00279 "Address Collision: " << Ipv4Address (addr));
00280 if (!m_test)
00281 {
00282 NS_ASSERT_MSG (0, "Ipv4AddressGeneratorImpl::Add(): "
00283 "Address Collision: " << Ipv4Address (addr));
00284 }
00285 return false;
00286 }
00287
00288
00289
00290
00291
00292 if (addr < (*i).addrLow - 1)
00293 {
00294 break;
00295 }
00296
00297
00298
00299
00300
00301
00302
00303 if (addr == (*i).addrHigh + 1)
00304 {
00305 std::list<Entry>::iterator j = i;
00306 ++j;
00307
00308 if (j != m_entries.end ())
00309 {
00310 if (addr == (*j).addrLow)
00311 {
00312 NS_LOG_LOGIC ("Ipv4AddressGeneratorImpl::Add(): "
00313 "Address Collision: " << Ipv4Address (addr));
00314 if (!m_test)
00315 {
00316 NS_ASSERT_MSG (0,
00317 "Ipv4AddressGeneratorImpl::Add(): "
00318 "Address Collision: " << Ipv4Address (addr));
00319 }
00320 return false;
00321 }
00322 }
00323
00324 NS_LOG_LOGIC ("New addrHigh = " << Ipv4Address (addr));
00325 (*i).addrHigh = addr;
00326 return true;
00327 }
00328
00329
00330
00331
00332
00333
00334
00335 if (addr == (*i).addrLow - 1)
00336 {
00337 NS_LOG_LOGIC ("New addrLow = " << Ipv4Address (addr));
00338 (*i).addrLow = addr;
00339 return true;
00340 }
00341 }
00342
00343 Entry entry;
00344 entry.addrLow = entry.addrHigh = addr;
00345 m_entries.insert(i, entry);
00346 return true;
00347 }
00348
00349 void
00350 Ipv4AddressGeneratorImpl::TestMode (void)
00351 {
00352 NS_LOG_FUNCTION_NOARGS ();
00353 m_test = true;
00354 }
00355
00356 uint32_t
00357 Ipv4AddressGeneratorImpl::MaskToIndex (Ipv4Mask mask) const
00358 {
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370 uint32_t maskBits = mask.Get ();
00371
00372 for (uint32_t i = 0; i < N_BITS; ++i)
00373 {
00374 if (maskBits & 1)
00375 {
00376 uint32_t index = N_BITS - i;
00377
00378 NS_ASSERT_MSG (index > 0 && index < N_BITS,
00379 "Ipv4AddressGenerator::MaskToIndex(): Illegal Mask");
00380
00381 return index;
00382 }
00383 maskBits >>= 1;
00384 }
00385 NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible");
00386 return 0;
00387 }
00388
00389 void
00390 Ipv4AddressGenerator::Init (
00391 const Ipv4Address net,
00392 const Ipv4Mask mask,
00393 const Ipv4Address addr)
00394 {
00395 NS_LOG_FUNCTION_NOARGS ();
00396
00397 SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
00398 ->Init (net, mask, addr);
00399 }
00400
00401 Ipv4Address
00402 Ipv4AddressGenerator::NextNetwork (const Ipv4Mask mask)
00403 {
00404 NS_LOG_FUNCTION_NOARGS ();
00405
00406 return SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
00407 ->NextNetwork (mask);
00408 }
00409
00410 Ipv4Address
00411 Ipv4AddressGenerator::GetNetwork (const Ipv4Mask mask)
00412 {
00413 NS_LOG_FUNCTION_NOARGS ();
00414
00415 return SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
00416 ->GetNetwork (mask);
00417 }
00418
00419 void
00420 Ipv4AddressGenerator::InitAddress (
00421 const Ipv4Address addr,
00422 const Ipv4Mask mask)
00423 {
00424 NS_LOG_FUNCTION_NOARGS ();
00425
00426 SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
00427 ->InitAddress (addr, mask);
00428 }
00429
00430 Ipv4Address
00431 Ipv4AddressGenerator::GetAddress (const Ipv4Mask mask)
00432 {
00433 NS_LOG_FUNCTION_NOARGS ();
00434
00435 return SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
00436 ->GetAddress (mask);
00437 }
00438
00439 Ipv4Address
00440 Ipv4AddressGenerator::NextAddress (const Ipv4Mask mask)
00441 {
00442 NS_LOG_FUNCTION_NOARGS ();
00443
00444 return SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
00445 ->NextAddress (mask);
00446 }
00447
00448 void
00449 Ipv4AddressGenerator::Reset (void)
00450 {
00451 NS_LOG_FUNCTION_NOARGS ();
00452
00453 return SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
00454 ->Reset ();
00455 }
00456
00457 bool
00458 Ipv4AddressGenerator::AddAllocated (const Ipv4Address addr)
00459 {
00460 NS_LOG_FUNCTION_NOARGS ();
00461
00462 return SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
00463 ->AddAllocated (addr);
00464 }
00465
00466 void
00467 Ipv4AddressGenerator::TestMode (void)
00468 {
00469 NS_LOG_FUNCTION_NOARGS ();
00470
00471 SimulationSingleton<Ipv4AddressGeneratorImpl>::Get ()
00472 ->TestMode ();
00473 }
00474
00475 };
00476
00477 #ifdef RUN_SELF_TESTS
00478
00479 #include "ns3/test.h"
00480
00481 namespace ns3 {
00482
00483 class Ipv4AddressGeneratorTest : public Test
00484 {
00485 public:
00486 Ipv4AddressGeneratorTest ();
00487 virtual bool RunTests (void);
00488 };
00489
00490 Ipv4AddressGeneratorTest::Ipv4AddressGeneratorTest ()
00491 : Test ("Ipv4AddressGenerator")
00492 {
00493 }
00494
00495 bool
00496 Ipv4AddressGeneratorTest::RunTests (void)
00497 {
00498 bool result = true;
00499 Ipv4Address network;
00500 Ipv4Address address;
00501
00502
00503
00504
00505 Ipv4AddressGenerator::Init (Ipv4Address ("1.0.0.0"), Ipv4Mask ("255.0.0.0"),
00506 Ipv4Address ("0.0.0.0"));
00507 network = Ipv4AddressGenerator::GetNetwork (Ipv4Mask ("255.0.0.0"));
00508 NS_TEST_ASSERT_EQUAL (network, Ipv4Address ("1.0.0.0"));
00509 network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.0.0.0"));
00510 NS_TEST_ASSERT_EQUAL (network, Ipv4Address ("2.0.0.0"));
00511
00512 Ipv4AddressGenerator::Init (Ipv4Address ("0.1.0.0"),
00513 Ipv4Mask ("255.255.0.0"), Ipv4Address ("0.0.0.0"));
00514 network = Ipv4AddressGenerator::GetNetwork (Ipv4Mask ("255.255.0.0"));
00515 NS_TEST_ASSERT_EQUAL (network, Ipv4Address ("0.1.0.0"));
00516 network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.0.0"));
00517 NS_TEST_ASSERT_EQUAL (network, Ipv4Address ("0.2.0.0"));
00518
00519 Ipv4AddressGenerator::Init (Ipv4Address ("0.0.1.0"),
00520 Ipv4Mask ("255.255.255.0"), Ipv4Address ("0.0.0.0"));
00521 network = Ipv4AddressGenerator::GetNetwork (Ipv4Mask ("255.255.255.0"));
00522 NS_TEST_ASSERT_EQUAL (network, Ipv4Address ("0.0.1.0"));
00523 network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.255.0"));
00524 NS_TEST_ASSERT_EQUAL (network, Ipv4Address ("0.0.2.0"));
00525
00526 network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.0.0.0"));
00527 NS_TEST_ASSERT_EQUAL (network, Ipv4Address ("3.0.0.0"));
00528 network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.0.0"));
00529 NS_TEST_ASSERT_EQUAL (network, Ipv4Address ("0.3.0.0"));
00530 network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.255.0"));
00531 NS_TEST_ASSERT_EQUAL (network, Ipv4Address ("0.0.3.0"));
00532
00533
00534
00535 Ipv4AddressGenerator::Init (Ipv4Address ("1.0.0.0"), Ipv4Mask ("255.0.0.0"),
00536 Ipv4Address ("0.0.0.3"));
00537 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.0.0.0"));
00538 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("1.0.0.3"));
00539 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.0.0.0"));
00540 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("1.0.0.4"));
00541
00542 Ipv4AddressGenerator::Init (Ipv4Address ("0.1.0.0"),
00543 Ipv4Mask ("255.255.0.0"), Ipv4Address ("0.0.0.3"));
00544 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.0.0"));
00545 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("0.1.0.3"));
00546 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.0.0"));
00547 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("0.1.0.4"));
00548
00549 Ipv4AddressGenerator::Init (Ipv4Address ("0.0.1.0"),
00550 Ipv4Mask ("255.255.255.0"), Ipv4Address ("0.0.0.3"));
00551 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
00552 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("0.0.1.3"));
00553 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
00554 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("0.0.1.4"));
00555
00556
00557
00558 Ipv4AddressGenerator::Init (Ipv4Address ("3.0.0.0"), Ipv4Mask ("255.0.0.0"),
00559 Ipv4Address ("0.0.0.3"));
00560 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.0.0.0"));
00561 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("3.0.0.3"));
00562 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.0.0.0"));
00563 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("3.0.0.4"));
00564
00565 network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.0.0.0"));
00566 NS_TEST_ASSERT_EQUAL (network, Ipv4Address ("4.0.0.0"));
00567 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.0.0.0"));
00568 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("4.0.0.5"));
00569
00570 Ipv4AddressGenerator::Init (Ipv4Address ("0.3.0.0"),
00571 Ipv4Mask ("255.255.0.0"), Ipv4Address ("0.0.0.3"));
00572 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.0.0"));
00573 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("0.3.0.3"));
00574 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.0.0"));
00575 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("0.3.0.4"));
00576
00577 network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.0.0"));
00578 NS_TEST_ASSERT_EQUAL (network, Ipv4Address ("0.4.0.0"));
00579 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.0.0"));
00580 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("0.4.0.5"));
00581
00582 Ipv4AddressGenerator::Init (Ipv4Address ("0.0.3.0"),
00583 Ipv4Mask ("255.255.255.0"), Ipv4Address ("0.0.0.3"));
00584 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
00585 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("0.0.3.3"));
00586 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
00587 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("0.0.3.4"));
00588
00589 network = Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.255.0"));
00590 NS_TEST_ASSERT_EQUAL (network, Ipv4Address ("0.0.4.0"));
00591 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
00592 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("0.0.4.5"));
00593
00594
00595
00596
00597
00598 Ipv4AddressGenerator::Init (Ipv4Address ("192.168.0.0"),
00599 Ipv4Mask ("255.255.255.0"), Ipv4Address ("0.0.0.3"));
00600 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
00601 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("192.168.0.3"));
00602 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
00603 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("192.168.0.4"));
00604 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
00605 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("192.168.0.5"));
00606
00607
00608
00609
00610
00611 Ipv4AddressGenerator::NextNetwork (Ipv4Mask ("255.255.255.0"));
00612 Ipv4AddressGenerator::InitAddress (Ipv4Address ("0.0.0.3"),
00613 Ipv4Mask ("255.255.255.0"));
00614
00615
00616
00617
00618 address = Ipv4AddressGenerator::NextAddress (Ipv4Mask ("255.255.255.0"));
00619 NS_TEST_ASSERT_EQUAL (address, Ipv4Address ("192.168.1.3"));
00620
00621
00622
00623 Ipv4AddressGenerator::Reset ();
00624
00625 Ipv4AddressGenerator::AddAllocated ("0.0.0.5");
00626 Ipv4AddressGenerator::AddAllocated ("0.0.0.10");
00627 Ipv4AddressGenerator::AddAllocated ("0.0.0.15");
00628 Ipv4AddressGenerator::AddAllocated ("0.0.0.20");
00629
00630 Ipv4AddressGenerator::AddAllocated ("0.0.0.4");
00631 Ipv4AddressGenerator::AddAllocated ("0.0.0.3");
00632 Ipv4AddressGenerator::AddAllocated ("0.0.0.2");
00633 Ipv4AddressGenerator::AddAllocated ("0.0.0.1");
00634
00635 Ipv4AddressGenerator::AddAllocated ("0.0.0.6");
00636 Ipv4AddressGenerator::AddAllocated ("0.0.0.7");
00637 Ipv4AddressGenerator::AddAllocated ("0.0.0.8");
00638 Ipv4AddressGenerator::AddAllocated ("0.0.0.9");
00639
00640 Ipv4AddressGenerator::AddAllocated ("0.0.0.11");
00641 Ipv4AddressGenerator::AddAllocated ("0.0.0.12");
00642 Ipv4AddressGenerator::AddAllocated ("0.0.0.13");
00643 Ipv4AddressGenerator::AddAllocated ("0.0.0.14");
00644
00645 Ipv4AddressGenerator::AddAllocated ("0.0.0.19");
00646 Ipv4AddressGenerator::AddAllocated ("0.0.0.18");
00647 Ipv4AddressGenerator::AddAllocated ("0.0.0.17");
00648 Ipv4AddressGenerator::AddAllocated ("0.0.0.16");
00649
00650 Ipv4AddressGenerator::TestMode ();
00651 bool added = Ipv4AddressGenerator::AddAllocated ("0.0.0.21");
00652 NS_TEST_ASSERT_EQUAL (added, true);
00653
00654 added = Ipv4AddressGenerator::AddAllocated ("0.0.0.4");
00655 NS_TEST_ASSERT_EQUAL (added, false);
00656
00657 added = Ipv4AddressGenerator::AddAllocated ("0.0.0.9");
00658 NS_TEST_ASSERT_EQUAL (added, false);
00659
00660 added = Ipv4AddressGenerator::AddAllocated ("0.0.0.16");
00661 NS_TEST_ASSERT_EQUAL (added, false);
00662
00663 added = Ipv4AddressGenerator::AddAllocated ("0.0.0.21");
00664 NS_TEST_ASSERT_EQUAL (added, false);
00665
00666 Ipv4AddressGenerator::Reset ();
00667
00668 return result;
00669 }
00670
00671 static Ipv4AddressGeneratorTest g_addressGeneratorTest;
00672
00673 }
00674
00675 #endif