author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Mon, 04 Jun 2007 16:17:01 +0200 | |
changeset 728 | 95c426b1cb60 |
parent 607 | 1b7abeccfcda |
child 732 | df256f32b6ae |
permissions | -rw-r--r-- |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
2 |
// |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
3 |
// Copyright (c) 2006 Georgia Tech Research Corporation |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
4 |
// |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
5 |
// This program is free software; you can redistribute it and/or modify |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
6 |
// it under the terms of the GNU General Public License version 2 as |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
7 |
// published by the Free Software Foundation; |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
8 |
// |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
9 |
// This program is distributed in the hope that it will be useful, |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
12 |
// GNU General Public License for more details. |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
13 |
// |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
14 |
// You should have received a copy of the GNU General Public License |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
15 |
// along with this program; if not, write to the Free Software |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
16 |
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
17 |
// |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
18 |
// Author: George F. Riley<riley@ece.gatech.edu> |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
19 |
// |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
20 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
21 |
// |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
22 |
// Topology helper for ns3. |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
23 |
// George F. Riley, Georgia Tech, Spring 2007 |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
24 |
|
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
25 |
#include <algorithm> |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
26 |
#include "ns3/assert.h" |
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
27 |
#include "ns3/debug.h" |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
28 |
#include "ns3/fatal-error.h" |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
29 |
#include "ns3/nstime.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
30 |
#include "ns3/internet-node.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
31 |
#include "ns3/ipv4-address.h" |
522
d5039448597a
remove Node::GetIpv4
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
503
diff
changeset
|
32 |
#include "ns3/i-ipv4.h" |
584
d843d0d5314d
make Queue::CreateDefault use the ComponentManager.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
581
diff
changeset
|
33 |
#include "ns3/queue.h" |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
34 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
35 |
#include "p2p-channel.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
36 |
#include "p2p-net-device.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
37 |
#include "p2p-topology.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
38 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
39 |
namespace ns3 { |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
40 |
|
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
567
diff
changeset
|
41 |
Ptr<PointToPointChannel> |
369
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
42 |
PointToPointTopology::AddPointToPointLink( |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
43 |
Ptr<Node> n1, |
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
44 |
Ptr<Node> n2, |
373
960c8e8721de
Move simple-p2p.cc to DataRate; fix small bug in DataRate and add include guards
Tom Henderson <tomh@tomh.org>
parents:
369
diff
changeset
|
45 |
const DataRate& bps, |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
46 |
const Time& delay) |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
47 |
{ |
571
ac324a1cba74
rework the refcounting framework to use the MakeNewObject function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
568
diff
changeset
|
48 |
Ptr<PointToPointChannel> channel = MakeNewObject<PointToPointChannel> (bps, delay); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
49 |
|
571
ac324a1cba74
rework the refcounting framework to use the MakeNewObject function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
568
diff
changeset
|
50 |
Ptr<PointToPointNetDevice> net1 = MakeNewObject<PointToPointNetDevice> (n1); |
567
6fb98941c36f
remove leaks and rework the Ptr class to work with a new refcount mechanism
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
561
diff
changeset
|
51 |
|
584
d843d0d5314d
make Queue::CreateDefault use the ComponentManager.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
581
diff
changeset
|
52 |
Ptr<Queue> q = Queue::CreateDefault (); |
581
15240a33f517
make Queue derive from Interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
571
diff
changeset
|
53 |
net1->AddQueue(q); |
376
5801e09f82bf
Add net devices to net-device-list in topology
Tom Henderson <tomh@tomh.org>
parents:
375
diff
changeset
|
54 |
net1->Attach (channel); |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
55 |
|
571
ac324a1cba74
rework the refcounting framework to use the MakeNewObject function
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
568
diff
changeset
|
56 |
Ptr<PointToPointNetDevice> net2 = MakeNewObject<PointToPointNetDevice> (n2); |
567
6fb98941c36f
remove leaks and rework the Ptr class to work with a new refcount mechanism
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
561
diff
changeset
|
57 |
|
584
d843d0d5314d
make Queue::CreateDefault use the ComponentManager.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
581
diff
changeset
|
58 |
q = Queue::CreateDefault (); |
581
15240a33f517
make Queue derive from Interface
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
571
diff
changeset
|
59 |
net2->AddQueue(q); |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
60 |
net2->Attach (channel); |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
61 |
|
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
62 |
return channel; |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
63 |
} |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
64 |
|
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
65 |
void |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
66 |
PointToPointTopology::AddIpv4Addresses( |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
567
diff
changeset
|
67 |
Ptr<const PointToPointChannel> chan, |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
68 |
Ptr<Node> n1, const Ipv4Address& addr1, |
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
69 |
Ptr<Node> n2, const Ipv4Address& addr2) |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
70 |
{ |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
71 |
|
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
72 |
// Duplex link is assumed to be subnetted as a /30 |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
73 |
// May run this unnumbered in the future? |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
74 |
Ipv4Mask netmask("255.255.255.252"); |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
75 |
NS_ASSERT (netmask.IsMatch(addr1,addr2)); |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
76 |
|
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
77 |
// The PointToPoint channel is used to find the relevant NetDevices |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
78 |
NS_ASSERT (chan->GetNDevices () == 2); |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
567
diff
changeset
|
79 |
Ptr<NetDevice> nd1 = chan->GetDevice (0); |
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
567
diff
changeset
|
80 |
Ptr<NetDevice> nd2 = chan->GetDevice (1); |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
81 |
// Make sure that nd1 belongs to n1 and nd2 to n2 |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
82 |
if ( (nd1->GetNode ()->GetId () == n2->GetId () ) && |
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
83 |
(nd2->GetNode ()->GetId () == n1->GetId () ) ) |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
84 |
{ |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
85 |
std::swap(nd1, nd2); |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
86 |
} |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
87 |
NS_ASSERT (nd1->GetNode ()->GetId () == n1->GetId ()); |
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
88 |
NS_ASSERT (nd2->GetNode ()->GetId () == n2->GetId ()); |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
89 |
|
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
567
diff
changeset
|
90 |
Ptr<IIpv4> ip1 = n1->QueryInterface<IIpv4> (IIpv4::iid); |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
91 |
uint32_t index1 = ip1->AddInterface (nd1); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
92 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
390
diff
changeset
|
93 |
ip1->SetAddress (index1, addr1); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
390
diff
changeset
|
94 |
ip1->SetNetworkMask (index1, netmask); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
390
diff
changeset
|
95 |
ip1->SetUp (index1); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
96 |
|
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
567
diff
changeset
|
97 |
Ptr<IIpv4> ip2 = n2->QueryInterface<IIpv4> (IIpv4::iid); |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
98 |
uint32_t index2 = ip2->AddInterface (nd2); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
99 |
|
444
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
390
diff
changeset
|
100 |
ip2->SetAddress (index2, addr2); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
390
diff
changeset
|
101 |
ip2->SetNetworkMask (index2, netmask); |
1647ca57f19d
remove ipv4 interface from public API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
390
diff
changeset
|
102 |
ip2->SetUp (index2); |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
522
diff
changeset
|
103 |
|
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
104 |
} |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
105 |
|
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
106 |
void |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
107 |
PointToPointTopology::AddIpv4Routes ( |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
108 |
Ptr<Node> n1, Ptr<Node> n2, Ptr<const PointToPointChannel> chan) |
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
109 |
{ |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
110 |
// The PointToPoint channel is used to find the relevant NetDevices |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
111 |
NS_ASSERT (chan->GetNDevices () == 2); |
593 | 112 |
Ptr<NetDevice> nd1 = chan->GetDevice (0); |
113 |
Ptr<NetDevice> nd2 = chan->GetDevice (1); |
|
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
114 |
|
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
115 |
// Assert that n1 is the Node owning one of the two NetDevices |
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
116 |
// and make sure that nd1 corresponds to it |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
117 |
if (nd1->GetNode ()->GetId () == n1->GetId ()) |
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
118 |
{ |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
119 |
; // Do nothing |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
120 |
} |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
121 |
else if (nd2->GetNode ()->GetId () == n1->GetId ()) |
593 | 122 |
{ |
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
123 |
std::swap(nd1, nd2); |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
124 |
} |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
125 |
else |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
126 |
{ |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
127 |
NS_FATAL_ERROR("P2PTopo: Node does not contain an interface on Channel"); |
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
128 |
} |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
129 |
|
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
130 |
// Assert that n2 is the Node owning one of the two NetDevices |
593 | 131 |
// and make sure that nd2 corresponds to it |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
132 |
if (nd2->GetNode ()->GetId () != n2->GetId ()) |
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
133 |
{ |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
134 |
NS_FATAL_ERROR("P2PTopo: Node does not contain an interface on Channel"); |
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
135 |
} |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
136 |
|
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
137 |
// Assert that both are Ipv4 nodes |
728
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
138 |
Ptr<IIpv4> ip1 = nd1->GetNode ()->QueryInterface<IIpv4> (IIpv4::iid); |
95c426b1cb60
rename INode to Node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
139 |
Ptr<IIpv4> ip2 = nd2->GetNode ()->QueryInterface<IIpv4> (IIpv4::iid); |
593 | 140 |
NS_ASSERT(ip1 != 0 && ip2 != 0); |
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
141 |
|
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
142 |
// Get interface indexes for both nodes corresponding to the right channel |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
143 |
uint32_t index1 = 0; |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
144 |
bool found = false; |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
145 |
for (uint32_t i = 0; i < ip1->GetNInterfaces (); i++) |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
146 |
{ |
593 | 147 |
if (ip1 ->GetNetDevice (i) == nd1) |
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
148 |
{ |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
149 |
index1 = i; |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
150 |
found = true; |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
151 |
} |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
152 |
} |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
153 |
NS_ASSERT(found); |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
154 |
|
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
155 |
uint32_t index2 = 0; |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
156 |
found = false; |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
157 |
for (uint32_t i = 0; i < ip2->GetNInterfaces (); i++) |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
158 |
{ |
593 | 159 |
if (ip2 ->GetNetDevice (i) == nd2) |
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
160 |
{ |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
161 |
index2 = i; |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
162 |
found = true; |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
163 |
} |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
164 |
} |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
165 |
NS_ASSERT(found); |
593 | 166 |
|
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
167 |
ip1->AddHostRouteTo (ip2-> GetAddress (index2), index1); |
593 | 168 |
ip2->AddHostRouteTo (ip1-> GetAddress (index1), index2); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
169 |
} |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
170 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
171 |
} // namespace ns3 |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
172 |