author | Craig Dowell <craigdo@ee.washington.edu> |
Tue, 24 Jun 2008 15:40:24 -0700 | |
changeset 3322 | 951296e9a277 |
parent 2810 | 92e2b4ffae4a |
permissions | -rw-r--r-- |
1835
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
2 |
/* |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
3 |
* This program is free software; you can redistribute it and/or modify |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
4 |
* it under the terms of the GNU General Public License version 2 as |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
5 |
* published by the Free Software Foundation; |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
6 |
* |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
7 |
* This program is distributed in the hope that it will be useful, |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
10 |
* GNU General Public License for more details. |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
11 |
* |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
12 |
* You should have received a copy of the GNU General Public License |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
13 |
* along with this program; if not, write to the Free Software |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
14 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
15 |
*/ |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
16 |
|
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
17 |
#include "ns3/log.h" |
2810
92e2b4ffae4a
use src/node/ipv4-address-generator.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1838
diff
changeset
|
18 |
#include "ns3/ipv4-address-generator.h" |
1835
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
19 |
|
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
20 |
NS_LOG_COMPONENT_DEFINE ("TestIpv4"); |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
21 |
|
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
22 |
using namespace ns3; |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
23 |
|
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
24 |
int |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
25 |
main (int argc, char *argv[]) |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
26 |
{ |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
27 |
LogComponentEnable ("TestIpv4", LOG_LEVEL_ALL); |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
28 |
|
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
29 |
NS_LOG_INFO ("Test Ipv4"); |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
30 |
|
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
31 |
Ipv4Mask mask1 ("255.0.0.0"); |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
32 |
|
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
33 |
for (uint32_t i = 0; i < 10; ++i) |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
34 |
{ |
2810
92e2b4ffae4a
use src/node/ipv4-address-generator.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1838
diff
changeset
|
35 |
Ipv4Address network = Ipv4AddressGenerator::NextNetwork (mask1); |
92e2b4ffae4a
use src/node/ipv4-address-generator.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1838
diff
changeset
|
36 |
Ipv4Address address = Ipv4AddressGenerator::NextAddress (mask1); |
1835
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
37 |
NS_LOG_INFO ("address = " << address); |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
38 |
} |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
39 |
|
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
40 |
Ipv4Mask mask2 ("255.255.0.0"); |
2810
92e2b4ffae4a
use src/node/ipv4-address-generator.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1838
diff
changeset
|
41 |
Ipv4AddressGenerator::Init (Ipv4Address ("192.168.0.0"), mask2); |
92e2b4ffae4a
use src/node/ipv4-address-generator.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1838
diff
changeset
|
42 |
Ipv4AddressGenerator::InitAddress (Ipv4Address ("0.0.0.3"), mask2); |
1835
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
43 |
|
2810
92e2b4ffae4a
use src/node/ipv4-address-generator.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1838
diff
changeset
|
44 |
Ipv4Address network1 = Ipv4AddressGenerator::NextNetwork (mask2); |
1835
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
45 |
for (uint32_t i = 0; i < 10; ++i) |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
46 |
{ |
2810
92e2b4ffae4a
use src/node/ipv4-address-generator.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1838
diff
changeset
|
47 |
Ipv4Address address = Ipv4AddressGenerator::NextAddress (mask2); |
1835
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
48 |
NS_LOG_INFO ("address = " << address); |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
49 |
} |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
50 |
|
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
51 |
Ipv4Mask mask3 ("255.255.255.0"); |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
52 |
|
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
53 |
for (uint32_t i = 0; i < 10; ++i) |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
54 |
{ |
2810
92e2b4ffae4a
use src/node/ipv4-address-generator.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1838
diff
changeset
|
55 |
Ipv4Address network = Ipv4AddressGenerator::NextNetwork (mask3); |
92e2b4ffae4a
use src/node/ipv4-address-generator.h
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1838
diff
changeset
|
56 |
Ipv4Address address = Ipv4AddressGenerator::NextAddress (mask3); |
1835
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
57 |
NS_LOG_INFO ("address = " << address); |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
58 |
} |
ccd0fc4d9bf8
prototype address and network allocation
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
59 |
} |