author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Sun, 02 Mar 2008 21:57:28 +0100 | |
changeset 2533 | 80cdc3eec057 |
parent 2502 | 50d0da37f02f |
child 2575 | 1aae382e65e2 |
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 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
45 |
#include "ns3/log.h" |
1116
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" |
2494
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
51 |
#include "ns3/config.h" |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
52 |
#include "ns3/uinteger.h" |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
53 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
54 |
#include "ns3/simulator.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
55 |
#include "ns3/nstime.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
56 |
#include "ns3/data-rate.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
57 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
58 |
#include "ns3/ascii-trace.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
59 |
#include "ns3/pcap-trace.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
60 |
#include "ns3/internet-node.h" |
1121
541bfe1308b2
fix compilation problems and test
Tom Henderson <tomh@tomh.org>
parents:
1117
diff
changeset
|
61 |
#include "ns3/point-to-point-channel.h" |
541bfe1308b2
fix compilation problems and test
Tom Henderson <tomh@tomh.org>
parents:
1117
diff
changeset
|
62 |
#include "ns3/point-to-point-net-device.h" |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
63 |
#include "ns3/ipv4-address.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
64 |
#include "ns3/ipv4.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
65 |
#include "ns3/socket.h" |
1199
d9caeae5943c
use the InetSocketAddress API for ip sockets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1121
diff
changeset
|
66 |
#include "ns3/inet-socket-address.h" |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
67 |
#include "ns3/ipv4-route.h" |
1121
541bfe1308b2
fix compilation problems and test
Tom Henderson <tomh@tomh.org>
parents:
1117
diff
changeset
|
68 |
#include "ns3/point-to-point-topology.h" |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
69 |
#include "ns3/onoff-application.h" |
1320
60b14f0bcff1
adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents:
1224
diff
changeset
|
70 |
#include "ns3/packet-sink.h" |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
71 |
#include "ns3/global-route-manager.h" |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
72 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
73 |
using namespace ns3; |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
74 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
75 |
NS_LOG_COMPONENT_DEFINE ("SimpleGlobalRoutingExample"); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
76 |
|
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
77 |
int |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
78 |
main (int argc, char *argv[]) |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
79 |
{ |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
80 |
// 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
|
81 |
// 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
|
82 |
#if 0 |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
83 |
LogComponentEnable ("SimpleGlobalRoutingExample", LOG_LEVEL_INFO); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
84 |
|
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
85 |
LogComponentEnable("Object", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
86 |
LogComponentEnable("Queue", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
87 |
LogComponentEnable("DropTailQueue", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
88 |
LogComponentEnable("Channel", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
89 |
LogComponentEnable("CsmaChannel", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
90 |
LogComponentEnable("NetDevice", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
91 |
LogComponentEnable("CsmaNetDevice", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
92 |
LogComponentEnable("Ipv4L3Protocol", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
93 |
LogComponentEnable("PacketSocket", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
94 |
LogComponentEnable("Socket", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
95 |
LogComponentEnable("UdpSocket", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
96 |
LogComponentEnable("UdpL4Protocol", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
97 |
LogComponentEnable("Ipv4L3Protocol", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
98 |
LogComponentEnable("Ipv4StaticRouting", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
99 |
LogComponentEnable("Ipv4Interface", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
100 |
LogComponentEnable("ArpIpv4Interface", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
101 |
LogComponentEnable("Ipv4LoopbackInterface", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
102 |
LogComponentEnable("OnOffApplication", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
103 |
LogComponentEnable("PacketSinkApplication", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
104 |
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_ALL); |
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
105 |
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_ALL); |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
106 |
#endif |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
107 |
// Set up some default values for the simulation. Use the |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
108 |
|
2494
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
109 |
Config::SetDefault ("OnOffApplication::PacketSize", Uinteger (210)); |
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:
2494
diff
changeset
|
110 |
Config::SetDefault ("OnOffApplication::DataRate", DataRate ("448kb/s")); |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
111 |
|
1224
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1209
diff
changeset
|
112 |
//DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30); |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
113 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
114 |
// Allow the user to override any of the defaults and the above |
1224
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1209
diff
changeset
|
115 |
// DefaultValue::Bind ()s at run-time, via command-line arguments |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
116 |
CommandLine::Parse (argc, argv); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
117 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
118 |
// 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
|
119 |
// topologies, we could configure a node factory. |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
120 |
NS_LOG_INFO ("Create nodes."); |
2230
9f13ac3291e0
add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1514
diff
changeset
|
121 |
Ptr<Node> n0 = CreateObject<InternetNode> (); |
9f13ac3291e0
add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1514
diff
changeset
|
122 |
Ptr<Node> n1 = CreateObject<InternetNode> (); |
9f13ac3291e0
add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1514
diff
changeset
|
123 |
Ptr<Node> n2 = CreateObject<InternetNode> (); |
9f13ac3291e0
add CreateObject<> to instanciate subclasses of the Object base class. Replaces Create<>.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1514
diff
changeset
|
124 |
Ptr<Node> n3 = CreateObject<InternetNode> (); |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
125 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
126 |
// We create the channels first without any IP addressing information |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
127 |
NS_LOG_INFO ("Create channels."); |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
128 |
Ptr<PointToPointChannel> channel0 = |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
129 |
PointToPointTopology::AddPointToPointLink ( |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
130 |
n0, n2, DataRate (5000000), MilliSeconds (2)); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
131 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
132 |
Ptr<PointToPointChannel> channel1 = |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
133 |
PointToPointTopology::AddPointToPointLink ( |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
134 |
n1, n2, DataRate (5000000), MilliSeconds (2)); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
135 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
136 |
Ptr<PointToPointChannel> channel2 = |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
137 |
PointToPointTopology::AddPointToPointLink ( |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
138 |
n2, n3, DataRate (1500000), MilliSeconds (10)); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
139 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
140 |
// Later, we add IP addresses. |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
141 |
NS_LOG_INFO ("Assign IP Addresses."); |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
142 |
PointToPointTopology::AddIpv4Addresses ( |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
143 |
channel0, n0, Ipv4Address ("10.1.1.1"), |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
144 |
n2, Ipv4Address ("10.1.1.2")); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
145 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
146 |
PointToPointTopology::AddIpv4Addresses ( |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
147 |
channel1, n1, Ipv4Address ("10.1.2.1"), |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
148 |
n2, Ipv4Address ("10.1.2.2")); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
149 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
150 |
PointToPointTopology::AddIpv4Addresses ( |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
151 |
channel2, n2, Ipv4Address ("10.1.3.1"), |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
152 |
n3, Ipv4Address ("10.1.3.2")); |
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 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
|
155 |
// tables in the nodes. |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
156 |
GlobalRouteManager::PopulateRoutingTables (); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
157 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
158 |
// 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
|
159 |
// 210 bytes at a rate of 448 Kb/s |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
160 |
NS_LOG_INFO ("Create Applications."); |
1514
addb79f47ba5
change port number used by example scripts to 'discard' or 'echo' instead of '80'
Tom Henderson <tomh@tomh.org>
parents:
1504
diff
changeset
|
161 |
uint16_t port = 9; // Discard port (RFC 863) |
2494
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
162 |
Ptr<OnOffApplication> ooff = |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
163 |
CreateObjectWith<OnOffApplication> ("Node", n0, |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
164 |
"Remote", Address (InetSocketAddress ("10.1.3.2", port)), |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
165 |
"Protocol", TypeId::LookupByName ("Udp"), |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
166 |
"OnTime", ConstantVariable (1), |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
167 |
"OffTime", ConstantVariable (0)); |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
168 |
n0->AddApplication (ooff); |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
169 |
// Start the application |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
170 |
ooff->Start (Seconds (1.0)); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
171 |
ooff->Stop (Seconds (10.0)); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
172 |
|
1320
60b14f0bcff1
adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents:
1224
diff
changeset
|
173 |
// Create a packet sink to receive these packets |
60b14f0bcff1
adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents:
1224
diff
changeset
|
174 |
// The last argument "true" disables output from the Receive callback |
2494
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
175 |
Ptr<PacketSink> sink = |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
176 |
CreateObjectWith<PacketSink> ("Node", n3, |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
177 |
"Remote", Address (InetSocketAddress (Ipv4Address::GetAny (), port)), |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
178 |
"Protocol", TypeId::LookupByName ("Udp")); |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
179 |
n3->AddApplication (sink); |
1320
60b14f0bcff1
adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents:
1224
diff
changeset
|
180 |
// Start the sink |
60b14f0bcff1
adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents:
1224
diff
changeset
|
181 |
sink->Start (Seconds (1.0)); |
60b14f0bcff1
adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents:
1224
diff
changeset
|
182 |
sink->Stop (Seconds (10.0)); |
60b14f0bcff1
adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents:
1224
diff
changeset
|
183 |
|
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
184 |
// Create a similar flow from n3 to n1, starting at time 1.1 seconds |
2494
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
185 |
ooff = CreateObjectWith<OnOffApplication> ( |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
186 |
"Node", n3, |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
187 |
"Remote", Address (InetSocketAddress ("10.1.2.1", port)), |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
188 |
"Protocol", TypeId::LookupByName ("Udp"), |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
189 |
"OnTime", ConstantVariable (1), |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
190 |
"OffTime", ConstantVariable (0)); |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
191 |
n3->AddApplication (ooff); |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
192 |
// Start the application |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
193 |
ooff->Start (Seconds (1.1)); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
194 |
ooff->Stop (Seconds (10.0)); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
195 |
|
1320
60b14f0bcff1
adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents:
1224
diff
changeset
|
196 |
// Create a packet sink to receive these packets |
2494
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
197 |
sink = CreateObjectWith<PacketSink> ("Node", n1, |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
198 |
"Remote", Address (InetSocketAddress (Ipv4Address::GetAny (), port)), |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
199 |
"Protocol", TypeId::LookupByName ("Udp")); |
1c69ea12779c
port Applications to Attributes
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2230
diff
changeset
|
200 |
n1->AddApplication (sink); |
1320
60b14f0bcff1
adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents:
1224
diff
changeset
|
201 |
// Start the sink |
60b14f0bcff1
adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents:
1224
diff
changeset
|
202 |
sink->Start (Seconds (1.1)); |
60b14f0bcff1
adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents:
1224
diff
changeset
|
203 |
sink->Stop (Seconds (10.0)); |
60b14f0bcff1
adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents:
1224
diff
changeset
|
204 |
|
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
205 |
// 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
|
206 |
// Trace output will be sent to the simple-global-routing.tr file |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
207 |
NS_LOG_INFO ("Configure Tracing."); |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
208 |
AsciiTrace asciitrace ("simple-global-routing.tr"); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
209 |
asciitrace.TraceAllQueues (); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
210 |
asciitrace.TraceAllNetDeviceRx (); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
211 |
|
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
212 |
// 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
|
213 |
// 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
|
214 |
// 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
|
215 |
// display timestamps correctly) |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
216 |
PcapTrace pcaptrace ("simple-global-routing.pcap"); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
217 |
pcaptrace.TraceAllIp (); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
218 |
|
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
219 |
NS_LOG_INFO ("Run Simulation."); |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
220 |
Simulator::Run (); |
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
221 |
Simulator::Destroy (); |
1504
36ecc970ba96
checkpoint debug to log
Craig Dowell <craigdo@ee.washington.edu>
parents:
1456
diff
changeset
|
222 |
NS_LOG_INFO ("Done."); |
1201
9bb4f158c60e
main should return a value
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1199
diff
changeset
|
223 |
|
9bb4f158c60e
main should return a value
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1199
diff
changeset
|
224 |
return 0; |
1116
e806ecadcc9c
add simple-global-routing.cc
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
225 |
} |