author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Mon, 06 Aug 2007 10:06:25 +0200 | |
changeset 1199 | d9caeae5943c |
parent 1121 | 541bfe1308b2 |
child 1201 | 9bb4f158c60e |
permissions | -rw-r--r-- |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
2 |
/* |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
3 |
* This program is free software; you can redistribute it and/or modify |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
4 |
* it under the terms of the GNU General Public License version 2 as |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
5 |
* published by the Free Software Foundation; |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
6 |
* |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
7 |
* This program is distributed in the hope that it will be useful, |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
10 |
* GNU General Public License for more details. |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
11 |
* |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
12 |
* You should have received a copy of the GNU General Public License |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
13 |
* along with this program; if not, write to the Free Software |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
14 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
15 |
* |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
16 |
* ns-2 simple.tcl script (ported from ns-2) |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
17 |
* Originally authored by Steve McCanne, 12/19/1996 |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
18 |
*/ |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
19 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
20 |
// Port of ns-2/tcl/ex/simple.tcl to ns-3 |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
21 |
// |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
22 |
// Network topology |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
23 |
// |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
24 |
// n0 |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
25 |
// \ 5 Mb/s, 2ms |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
26 |
// \ 1.5Mb/s, 10ms |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
27 |
// n2 -------------------------n3 |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
28 |
// / |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
29 |
// / 5 Mb/s, 2ms |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
30 |
// n1 |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
31 |
// |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
32 |
// - all links are point-to-point links with indicated one-way BW/delay |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
33 |
// - CBR/UDP flows from n0 to n3, and from n3 to n1 |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
34 |
// - FTP/TCP flow from n0 to n3, starting at time 1.2 to time 1.35 sec. |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
35 |
// - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec. |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
36 |
// (i.e., DataRate of 448,000 bps) |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
37 |
// - DropTail queues |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
38 |
// - Tracing of queues and packet receptions to file "simple-global-routing.tr" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
39 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
40 |
#include <iostream> |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
41 |
#include <fstream> |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
42 |
#include <string> |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
43 |
#include <cassert> |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
44 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
45 |
#include "ns3/debug.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
46 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
47 |
#include "ns3/command-line.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
48 |
#include "ns3/default-value.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
49 |
#include "ns3/ptr.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
50 |
#include "ns3/random-variable.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
51 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
52 |
#include "ns3/simulator.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
53 |
#include "ns3/nstime.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
54 |
#include "ns3/data-rate.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
55 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
56 |
#include "ns3/ascii-trace.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
57 |
#include "ns3/pcap-trace.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
58 |
#include "ns3/internet-node.h" |
1121
541bfe1308b2
fix compilation problems and test
Tom Henderson <tomh@tomh.org>
parents:
1117
diff
changeset
|
59 |
#include "ns3/point-to-point-channel.h" |
541bfe1308b2
fix compilation problems and test
Tom Henderson <tomh@tomh.org>
parents:
1117
diff
changeset
|
60 |
#include "ns3/point-to-point-net-device.h" |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
61 |
#include "ns3/ipv4-address.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
62 |
#include "ns3/ipv4.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
63 |
#include "ns3/socket.h" |
1199
d9caeae5943c
use the InetSocketAddress API for ip sockets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1121
diff
changeset
|
64 |
#include "ns3/inet-socket-address.h" |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
65 |
#include "ns3/ipv4-route.h" |
1121
541bfe1308b2
fix compilation problems and test
Tom Henderson <tomh@tomh.org>
parents:
1117
diff
changeset
|
66 |
#include "ns3/point-to-point-topology.h" |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
67 |
#include "ns3/onoff-application.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
68 |
#include "ns3/global-route-manager.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
69 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
70 |
using namespace ns3; |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
71 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
72 |
int main (int argc, char *argv[]) |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
73 |
{ |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
74 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
75 |
// Users may find it convenient to turn on explicit debugging |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
76 |
// for selected modules; the below lines suggest how to do this |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
77 |
#if 0 |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
78 |
DebugComponentEnable ("Object"); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
79 |
DebugComponentEnable ("Queue"); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
80 |
DebugComponentEnable ("DropTailQueue"); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
81 |
DebugComponentEnable ("Channel"); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
82 |
DebugComponentEnable ("PointToPointChannel"); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
83 |
DebugComponentEnable ("PointToPointNetDevice"); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
84 |
DebugComponentEnable ("GlobalRouter"); |
1199
d9caeae5943c
use the InetSocketAddress API for ip sockets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1121
diff
changeset
|
85 |
DebugComponentEnable ("GlobalRouteMaager"); |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
86 |
#endif |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
87 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
88 |
// Set up some default values for the simulation. Use the Bind () |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
89 |
// technique to tell the system what subclass of Queue to use, |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
90 |
// and what the queue limit is |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
91 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
92 |
// The below Bind command tells the queue factory which class to |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
93 |
// instantiate, when the queue factory is invoked in the topology code |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
94 |
Bind ("Queue", "DropTailQueue"); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
95 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
96 |
Bind ("OnOffApplicationPacketSize", "210"); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
97 |
Bind ("OnOffApplicationDataRate", "448kb/s"); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
98 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
99 |
//Bind ("DropTailQueue::m_maxPackets", 30); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
100 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
101 |
// Allow the user to override any of the defaults and the above |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
102 |
// Bind ()s at run-time, via command-line arguments |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
103 |
CommandLine::Parse (argc, argv); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
104 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
105 |
// Here, we will explicitly create four nodes. In more sophisticated |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
106 |
// topologies, we could configure a node factory. |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
107 |
Ptr<Node> n0 = Create<InternetNode> (); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
108 |
Ptr<Node> n1 = Create<InternetNode> (); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
109 |
Ptr<Node> n2 = Create<InternetNode> (); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
110 |
Ptr<Node> n3 = Create<InternetNode> (); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
111 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
112 |
// We create the channels first without any IP addressing information |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
113 |
Ptr<PointToPointChannel> channel0 = |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
114 |
PointToPointTopology::AddPointToPointLink ( |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
115 |
n0, n2, DataRate (5000000), MilliSeconds (2)); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
116 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
117 |
Ptr<PointToPointChannel> channel1 = |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
118 |
PointToPointTopology::AddPointToPointLink ( |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
119 |
n1, n2, DataRate (5000000), MilliSeconds (2)); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
120 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
121 |
Ptr<PointToPointChannel> channel2 = |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
122 |
PointToPointTopology::AddPointToPointLink ( |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
123 |
n2, n3, DataRate (1500000), MilliSeconds (10)); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
124 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
125 |
// Later, we add IP addresses. |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
126 |
PointToPointTopology::AddIpv4Addresses ( |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
127 |
channel0, n0, Ipv4Address ("10.1.1.1"), |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
128 |
n2, Ipv4Address ("10.1.1.2")); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
129 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
130 |
PointToPointTopology::AddIpv4Addresses ( |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
131 |
channel1, n1, Ipv4Address ("10.1.2.1"), |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
132 |
n2, Ipv4Address ("10.1.2.2")); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
133 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
134 |
PointToPointTopology::AddIpv4Addresses ( |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
135 |
channel2, n2, Ipv4Address ("10.1.3.1"), |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
136 |
n3, Ipv4Address ("10.1.3.2")); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
137 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
138 |
// Create router nodes, initialize routing database and set up the routing |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
139 |
// tables in the nodes. |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
140 |
GlobalRouteManager::PopulateRoutingTables (); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
141 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
142 |
// Create the OnOff application to send UDP datagrams of size |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
143 |
// 210 bytes at a rate of 448 Kb/s |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
144 |
Ptr<OnOffApplication> ooff = Create<OnOffApplication> ( |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
145 |
n0, |
1199
d9caeae5943c
use the InetSocketAddress API for ip sockets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1121
diff
changeset
|
146 |
InetSocketAddress ("10.1.3.2", 80).ConvertTo (), |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
147 |
"Udp", |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
148 |
ConstantVariable (1), |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
149 |
ConstantVariable (0)); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
150 |
// Start the application |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
151 |
ooff->Start (Seconds (1.0)); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
152 |
ooff->Stop (Seconds (10.0)); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
153 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
154 |
// Create a similar flow from n3 to n1, starting at time 1.1 seconds |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
155 |
ooff = Create<OnOffApplication> ( |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
156 |
n3, |
1199
d9caeae5943c
use the InetSocketAddress API for ip sockets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1121
diff
changeset
|
157 |
InetSocketAddress ("10.1.2.1", 80).ConvertTo (), |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
158 |
"Udp", |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
159 |
ConstantVariable (1), |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
160 |
ConstantVariable (0)); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
161 |
// Start the application |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
162 |
ooff->Start (Seconds (1.1)); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
163 |
ooff->Stop (Seconds (10.0)); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
164 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
165 |
// Configure tracing of all enqueue, dequeue, and NetDevice receive events |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
166 |
// Trace output will be sent to the simple-global-routing.tr file |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
167 |
AsciiTrace asciitrace ("simple-global-routing.tr"); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
168 |
asciitrace.TraceAllQueues (); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
169 |
asciitrace.TraceAllNetDeviceRx (); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
170 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
171 |
// Also configure some tcpdump traces; each interface will be traced |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
172 |
// The output files will be named simple-p2p.pcap-<nodeId>-<interfaceId> |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
173 |
// and can be read by the "tcpdump -r" command (use "-tt" option to |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
174 |
// display timestamps correctly) |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
175 |
PcapTrace pcaptrace ("simple-global-routing.pcap"); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
176 |
pcaptrace.TraceAllIp (); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
177 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
178 |
Simulator::Run (); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
179 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
180 |
Simulator::Destroy (); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
181 |
} |