author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Wed, 02 Jan 2008 09:09:24 +0100 | |
changeset 2230 | 9f13ac3291e0 |
parent 1845 | 836f0c983165 |
permissions | -rw-r--r-- |
1844 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2007 University of Washington |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License version 2 as |
|
7 |
* published by the Free Software Foundation; |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
*/ |
|
18 |
||
19 |
#include "ns3/mac48-address.h" |
|
20 |
#include "ns3/csma-net-device.h" |
|
21 |
#include "ns3/csma-topology.h" |
|
22 |
#include "ns3/csma-ipv4-topology.h" |
|
23 |
||
1845
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
24 |
#include "ipv4-bus-network.h" |
1844 | 25 |
#include "ipv4-address-generator.h" |
26 |
||
27 |
namespace ns3 { |
|
28 |
||
1845
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
29 |
Ipv4Network::Ipv4Network ( |
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
30 |
Ipv4Address network, |
1844 | 31 |
Ipv4Mask mask, |
1845
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
32 |
Ipv4Address address) |
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
33 |
: |
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
34 |
m_network (network), m_mask (mask), m_baseAddress (address) |
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
35 |
{ |
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
36 |
} |
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
37 |
|
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
38 |
Ipv4Network::~Ipv4Network () |
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
39 |
{ |
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
40 |
} |
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
41 |
|
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
42 |
Ipv4BusNetwork::Ipv4BusNetwork ( |
1844 | 43 |
Ipv4Address network, |
1845
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
44 |
Ipv4Mask mask, |
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
45 |
Ipv4Address baseAddress, |
1844 | 46 |
DataRate bps, |
47 |
Time delay, |
|
1845
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
48 |
uint32_t n) |
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
49 |
: |
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
50 |
Ipv4Network (network, mask, baseAddress) |
1844 | 51 |
{ |
52 |
Ipv4AddressGenerator::SeedNetwork (mask, network); |
|
1845
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
53 |
Ipv4AddressGenerator::SeedAddress (mask, baseAddress); |
1844 | 54 |
|
55 |
m_channel = CsmaTopology::CreateCsmaChannel (bps, delay); |
|
56 |
||
57 |
for (uint32_t i = 0; i < n; ++i) |
|
58 |
{ |
|
2230
9f13ac3291e0
add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1845
diff
changeset
|
59 |
Ptr<Node> node = CreateObject<InternetNode> (); |
1844 | 60 |
uint32_t nd = CsmaIpv4Topology::AddIpv4CsmaNetDevice (node, m_channel, |
61 |
Mac48Address::Allocate ()); |
|
62 |
Ipv4Address address = Ipv4AddressGenerator::AllocateAddress (mask, |
|
63 |
network); |
|
64 |
CsmaIpv4Topology::AddIpv4Address (node, nd, address, mask); |
|
65 |
m_nodes.push_back (node); |
|
66 |
} |
|
67 |
} |
|
68 |
||
1845
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
69 |
Ipv4BusNetwork::~Ipv4BusNetwork () |
1844 | 70 |
{ |
71 |
} |
|
72 |
||
73 |
Ptr<Node> |
|
1845
836f0c983165
improve obj design example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1844
diff
changeset
|
74 |
Ipv4BusNetwork::GetNode (uint32_t n) |
1844 | 75 |
{ |
76 |
return m_nodes[n]; |
|
77 |
} |
|
78 |
||
79 |
}; // namespace ns3 |