author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Tue, 11 Mar 2008 13:30:12 -0700 | |
changeset 2592 | 3ebf97150166 |
parent 2533 | 80cdc3eec057 |
child 2600 | 6c389d0c717d |
permissions | -rw-r--r-- |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
2 |
// |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
3 |
// Copyright (c) 2007 Emmanuelle Laprise |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
4 |
// |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
5 |
// This program is free software; you can redistribute it and/or modify |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
6 |
// it under the terms of the GNU General Public License version 2 as |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
7 |
// published by the Free Software Foundation; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
8 |
// |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
9 |
// This program is distributed in the hope that it will be useful, |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
12 |
// GNU General Public License for more details. |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
13 |
// |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
14 |
// You should have received a copy of the GNU General Public License |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
15 |
// along with this program; if not, write to the Free Software |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
16 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
17 |
// |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
18 |
// Author: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca> |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
19 |
// |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
20 |
|
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
21 |
#include <algorithm> |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
22 |
#include "ns3/assert.h" |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
23 |
#include "ns3/fatal-error.h" |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
24 |
#include "ns3/nstime.h" |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
25 |
#include "ns3/internet-node.h" |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
26 |
#include "ns3/ipv4-address.h" |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
27 |
#include "ns3/ipv4.h" |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
28 |
#include "ns3/queue.h" |
2533
80cdc3eec057
do not use Queue::CreateDefault
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2502
diff
changeset
|
29 |
#include "ns3/drop-tail-queue.h" |
2502
50d0da37f02f
introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2500
diff
changeset
|
30 |
#include "ns3/string.h" |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
31 |
|
1272 | 32 |
#include "csma-channel.h" |
33 |
#include "csma-net-device.h" |
|
34 |
#include "csma-ipv4-topology.h" |
|
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
35 |
|
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
36 |
namespace ns3 { |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
37 |
|
989
baeb6102ea71
return ifIndex when adding netdevice to node (topology)
Tom Henderson <tomh@tomh.org>
parents:
977
diff
changeset
|
38 |
uint32_t |
1433
a6fb891b59fd
cleanup. more complex multicast example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
39 |
CsmaIpv4Topology::AddIpv4CsmaNetDevice( |
a6fb891b59fd
cleanup. more complex multicast example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
40 |
Ptr<Node> node, |
a6fb891b59fd
cleanup. more complex multicast example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
41 |
Ptr<CsmaChannel> channel, |
1494
c2985e1cd091
rename Euixx to Macxx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1433
diff
changeset
|
42 |
Mac48Address addr) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
43 |
{ |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2533
diff
changeset
|
44 |
Ptr<Queue> q = CreateObject<DropTailQueue> (); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
45 |
|
989
baeb6102ea71
return ifIndex when adding netdevice to node (topology)
Tom Henderson <tomh@tomh.org>
parents:
977
diff
changeset
|
46 |
// assume full-duplex |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2533
diff
changeset
|
47 |
Ptr<CsmaNetDevice> nd = CreateObject<CsmaNetDevice> ("Node", node, |
2500
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
48 |
"Address", addr, |
2502
50d0da37f02f
introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2500
diff
changeset
|
49 |
"EncapsulationMode", String ("IpArp")); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
50 |
node->AddDevice (nd); |
1433
a6fb891b59fd
cleanup. more complex multicast example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
51 |
|
a6fb891b59fd
cleanup. more complex multicast example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
52 |
nd->AddQueue(q); |
a6fb891b59fd
cleanup. more complex multicast example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
53 |
nd->Attach (channel); |
a6fb891b59fd
cleanup. more complex multicast example
Craig Dowell <craigdo@ee.washington.edu>
parents:
1432
diff
changeset
|
54 |
return nd->GetIfIndex (); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
55 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
56 |
|
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
57 |
|
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
58 |
void |
1272 | 59 |
CsmaIpv4Topology::AddIpv4LlcCsmaNode(Ptr<Node> n1, |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1272
diff
changeset
|
60 |
Ptr<CsmaChannel> ch, |
1494
c2985e1cd091
rename Euixx to Macxx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1433
diff
changeset
|
61 |
Mac48Address addr) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
62 |
{ |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2533
diff
changeset
|
63 |
Ptr<Queue> q = CreateObject<DropTailQueue> (); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
64 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2533
diff
changeset
|
65 |
Ptr<CsmaNetDevice> nd0 = CreateObject<CsmaNetDevice> ("Node", n1, |
2500
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
66 |
"Address", addr, |
2502
50d0da37f02f
introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2500
diff
changeset
|
67 |
"EncapsulationMode", String ("Llc")); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
68 |
n1->AddDevice (nd0); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
69 |
nd0->SetSendEnable (true); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
70 |
nd0->SetReceiveEnable (false); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
71 |
nd0->AddQueue(q); |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
72 |
nd0->Attach (ch); |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
73 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2533
diff
changeset
|
74 |
Ptr<CsmaNetDevice> nd1 = CreateObject<CsmaNetDevice> ("Node", n1, |
2500
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
75 |
"Address", addr, |
2502
50d0da37f02f
introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2500
diff
changeset
|
76 |
"EncapsulationMode", String ("Llc")); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
77 |
n1->AddDevice (nd1); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
78 |
nd1->SetSendEnable (false); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
79 |
nd1->SetReceiveEnable (true); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
80 |
nd1->AddQueue(q); |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
81 |
nd1->Attach (ch); |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
82 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
83 |
|
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
84 |
void |
1272 | 85 |
CsmaIpv4Topology::AddIpv4RawCsmaNode(Ptr<Node> n1, |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1272
diff
changeset
|
86 |
Ptr<CsmaChannel> ch, |
1494
c2985e1cd091
rename Euixx to Macxx
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1433
diff
changeset
|
87 |
Mac48Address addr) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
88 |
{ |
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2533
diff
changeset
|
89 |
Ptr<Queue> q = CreateObject<DropTailQueue> (); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
90 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2533
diff
changeset
|
91 |
Ptr<CsmaNetDevice> nd0 = CreateObject<CsmaNetDevice> ("Node", n1, |
2500
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
92 |
"Address", addr, |
2502
50d0da37f02f
introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2500
diff
changeset
|
93 |
"EncapsulationMode", String ("Raw")); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
94 |
n1->AddDevice (nd0); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
95 |
nd0->SetSendEnable (true); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
96 |
nd0->SetReceiveEnable (false); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
97 |
nd0->AddQueue(q); |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
98 |
nd0->Attach (ch); |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
99 |
|
2592
3ebf97150166
get rid of CreateObjectWith
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2533
diff
changeset
|
100 |
Ptr<CsmaNetDevice> nd1 = CreateObject<CsmaNetDevice> ("Node", n1, |
2500
1fb9430f642d
convert CsmaNetDevice to Attributes.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2470
diff
changeset
|
101 |
"Address", addr, |
2502
50d0da37f02f
introduce the ns3::String class, get rid of the string -> Attribute implicit conversion, and get rid of MakeDataRate, port PointToPointNetDevice to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2500
diff
changeset
|
102 |
"EncapsulationMode", String ("Raw")); |
2470
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
103 |
n1->AddDevice (nd1); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
104 |
nd1->SetSendEnable (false); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
105 |
nd1->SetReceiveEnable (true); |
254581fb9e9c
make NetDevice fully virtual.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2257
diff
changeset
|
106 |
|
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
107 |
nd1->AddQueue(q); |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
108 |
nd1->Attach (ch); |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
109 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
110 |
|
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
111 |
uint32_t |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
112 |
CsmaIpv4Topology::AddIpv4Address( |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
113 |
Ptr<Node> node, |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
114 |
uint32_t netDeviceNumber, |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
115 |
const Ipv4Address address, |
1776
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1504
diff
changeset
|
116 |
const Ipv4Mask mask, |
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1504
diff
changeset
|
117 |
uint16_t metric) |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
118 |
{ |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
119 |
Ptr<NetDevice> nd = node->GetDevice(netDeviceNumber); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
120 |
|
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2231
diff
changeset
|
121 |
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> (); |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
122 |
uint32_t ifIndex = ipv4->AddInterface (nd); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
123 |
|
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
124 |
ipv4->SetAddress (ifIndex, address); |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
125 |
ipv4->SetNetworkMask (ifIndex, mask); |
1776
0d5be0c3d229
Add support for non-unit-cost metrics for Ipv4Interfaces (for use in routing); add example script simple-alternate-routing.cc
Tom Henderson <tomh@tomh.org>
parents:
1504
diff
changeset
|
126 |
ipv4->SetMetric (ifIndex, metric); |
1432
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
127 |
ipv4->SetUp (ifIndex); |
3aef7d7a71c2
more multicast plumbing
Craig Dowell <craigdo@ee.washington.edu>
parents:
1430
diff
changeset
|
128 |
return ifIndex; |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
129 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
130 |
|
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
131 |
void |
1272 | 132 |
CsmaIpv4Topology::AddIpv4Routes ( |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
133 |
Ptr<NetDevice> nd1, Ptr<NetDevice> nd2) |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
134 |
{ |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
135 |
// Assert that both are Ipv4 nodes |
2257
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2231
diff
changeset
|
136 |
Ptr<Ipv4> ip1 = nd1->GetNode ()->GetObject<Ipv4> (); |
71a58e70c671
QueryInterface -> GetObject
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2231
diff
changeset
|
137 |
Ptr<Ipv4> ip2 = nd2->GetNode ()->GetObject<Ipv4> (); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
138 |
NS_ASSERT(ip1 != 0 && ip2 != 0); |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
139 |
|
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
140 |
// Get interface indexes for both nodes corresponding to the right channel |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
141 |
uint32_t index1 = 0; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
142 |
bool found = false; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
143 |
for (uint32_t i = 0; i < ip1->GetNInterfaces (); i++) |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
144 |
{ |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
145 |
if (ip1 ->GetNetDevice (i) == nd1) |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
146 |
{ |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
147 |
index1 = i; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
148 |
found = true; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
149 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
150 |
} |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1272
diff
changeset
|
151 |
NS_ASSERT (found); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
152 |
|
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
153 |
uint32_t index2 = 0; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
154 |
found = false; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
155 |
for (uint32_t i = 0; i < ip2->GetNInterfaces (); i++) |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
156 |
{ |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
157 |
if (ip2 ->GetNetDevice (i) == nd2) |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
158 |
{ |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
159 |
index2 = i; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
160 |
found = true; |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
161 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
162 |
} |
1430
25fa26a6533e
many debug prints
Craig Dowell <craigdo@ee.washington.edu>
parents:
1272
diff
changeset
|
163 |
NS_ASSERT (found); |
977
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
164 |
|
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
165 |
ip1->AddHostRouteTo (ip2-> GetAddress (index2), index1); |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
166 |
ip2->AddHostRouteTo (ip1-> GetAddress (index1), index2); |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
167 |
} |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
168 |
|
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
169 |
} // namespace ns3 |
09bf4e458015
a csma/cd NetDevice subclass and a test script
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
diff
changeset
|
170 |