author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Wed, 29 Aug 2007 16:42:55 +0200 | |
changeset 1396 | 105d16b9bf04 |
parent 1290 | 48ebb7788499 |
child 1320 | 60b14f0bcff1 |
child 1419 | ac2a81821ab5 |
child 1439 | 4743aef86605 |
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 |
* 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
|
4 |
* 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
|
5 |
* published by the Free Software Foundation; |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
6 |
* |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
7 |
* 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
|
8 |
* 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
|
9 |
* 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
|
10 |
* GNU General Public License for more details. |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
11 |
* |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
12 |
* 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
|
13 |
* 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
|
14 |
* 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
|
15 |
* |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
16 |
* ns-2 simple.tcl script (ported from ns-2) |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
17 |
* Originally authored by Steve McCanne, 12/19/1996 |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
18 |
*/ |
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 |
// Port of ns-2/tcl/ex/simple.tcl to ns-3 |
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 |
// Network topology |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
23 |
// |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
24 |
// n0 |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
25 |
// \ 5 Mb/s, 2ms |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
26 |
// \ 1.5Mb/s, 10ms |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
27 |
// n2 -------------------------n3 |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
28 |
// / |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
29 |
// / 5 Mb/s, 2ms |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
30 |
// n1 |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
31 |
// |
988
89a9125a39c9
rename example from p2p to point-to-point
Tom Henderson <tomh@tomh.org>
parents:
973
diff
changeset
|
32 |
// - all links are point-to-point links with indicated one-way BW/delay |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
33 |
// - CBR/UDP flows from n0 to n3, and from n3 to n1 |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
34 |
// - FTP/TCP flow from n0 to n3, starting at time 1.2 to time 1.35 sec. |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
35 |
// - UDP packet size of 210 bytes, with per-packet interval 0.00375 sec. |
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
36 |
// (i.e., DataRate of 448,000 bps) |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
37 |
// - DropTail queues |
988
89a9125a39c9
rename example from p2p to point-to-point
Tom Henderson <tomh@tomh.org>
parents:
973
diff
changeset
|
38 |
// - Tracing of queues and packet receptions to file |
89a9125a39c9
rename example from p2p to point-to-point
Tom Henderson <tomh@tomh.org>
parents:
973
diff
changeset
|
39 |
// "simple-point-to-point.tr" |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
40 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
41 |
#include <iostream> |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
42 |
#include <fstream> |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
43 |
#include <string> |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
44 |
#include <cassert> |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
45 |
|
439
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
389
diff
changeset
|
46 |
#include "ns3/command-line.h" |
fed13fb45eef
Incorporated defaults and command-line arguments
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
389
diff
changeset
|
47 |
#include "ns3/default-value.h" |
543 | 48 |
#include "ns3/ptr.h" |
758 | 49 |
#include "ns3/random-variable.h" |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
50 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
51 |
#include "ns3/simulator.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
52 |
#include "ns3/nstime.h" |
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
|
53 |
#include "ns3/data-rate.h" |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
54 |
|
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
388
diff
changeset
|
55 |
#include "ns3/ascii-trace.h" |
456
5361882cc2f3
put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
389
diff
changeset
|
56 |
#include "ns3/pcap-trace.h" |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
57 |
#include "ns3/internet-node.h" |
973
2aea9e9f698c
src/devices/point-to-point/p2p-* -> src/devices/point-to-point/point-to-point-*
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
758
diff
changeset
|
58 |
#include "ns3/point-to-point-channel.h" |
2aea9e9f698c
src/devices/point-to-point/p2p-* -> src/devices/point-to-point/point-to-point-*
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
758
diff
changeset
|
59 |
#include "ns3/point-to-point-net-device.h" |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
60 |
#include "ns3/ipv4-address.h" |
1171
335886fe4ddd
InetAddress -> InetSocketAddress
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1167
diff
changeset
|
61 |
#include "ns3/inet-socket-address.h" |
752
a4febfb8416f
IIpv4 -> Ipv4
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
732
diff
changeset
|
62 |
#include "ns3/ipv4.h" |
453
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
444
diff
changeset
|
63 |
#include "ns3/socket.h" |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
64 |
#include "ns3/ipv4-route.h" |
973
2aea9e9f698c
src/devices/point-to-point/p2p-* -> src/devices/point-to-point/point-to-point-*
Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
parents:
758
diff
changeset
|
65 |
#include "ns3/point-to-point-topology.h" |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
66 |
#include "ns3/onoff-application.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
67 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
68 |
using namespace ns3; |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
69 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
70 |
int main (int argc, char *argv[]) |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
71 |
{ |
534
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
72 |
|
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
73 |
// Users may find it convenient to turn on explicit debugging |
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
74 |
// for selected modules; the below lines suggest how to do this |
1290 | 75 |
// remember to add #include "ns3/debug.h" before enabling these |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
76 |
#if 0 |
379
ae74e8a7bb44
net device copy and assignment, reference counted channel.
Craig Dowell
parents:
378
diff
changeset
|
77 |
DebugComponentEnable("Object"); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
78 |
DebugComponentEnable("Queue"); |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
79 |
DebugComponentEnable("DropTailQueue"); |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
80 |
DebugComponentEnable("Channel"); |
369
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
81 |
DebugComponentEnable("PointToPointChannel"); |
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
82 |
DebugComponentEnable("PointToPointNetDevice"); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
83 |
#endif |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
84 |
|
534
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
85 |
// Set up some default values for the simulation. Use the Bind() |
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
86 |
// technique to tell the system what subclass of Queue to use, |
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
87 |
// and what the queue limit is |
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
88 |
|
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
89 |
// The below Bind command tells the queue factory which class to |
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
90 |
// instantiate, when the queue factory is invoked in the topology code |
1224
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1204
diff
changeset
|
91 |
DefaultValue::Bind ("Queue", "DropTailQueue"); |
613
9679a238439d
add dox doc and DefaultValue support to OnOffApplication
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
92 |
|
1224
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1204
diff
changeset
|
93 |
DefaultValue::Bind ("OnOffApplicationPacketSize", "210"); |
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1204
diff
changeset
|
94 |
DefaultValue::Bind ("OnOffApplicationDataRate", "448kb/s"); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
95 |
|
1224
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1204
diff
changeset
|
96 |
//DefaultValue::Bind ("DropTailQueue::m_maxPackets", 30); |
534
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
97 |
|
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
98 |
// Allow the user to override any of the defaults and the above |
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
99 |
// Bind()s at run-time, via command-line arguments |
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
100 |
CommandLine::Parse (argc, argv); |
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
101 |
|
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
102 |
// Here, we will explicitly create four nodes. In more sophisticated |
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
103 |
// topologies, we could configure a node factory. |
732
df256f32b6ae
rename MakeNewObject to Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
731
diff
changeset
|
104 |
Ptr<Node> n0 = Create<InternetNode> (); |
df256f32b6ae
rename MakeNewObject to Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
731
diff
changeset
|
105 |
Ptr<Node> n1 = Create<InternetNode> (); |
df256f32b6ae
rename MakeNewObject to Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
731
diff
changeset
|
106 |
Ptr<Node> n2 = Create<InternetNode> (); |
df256f32b6ae
rename MakeNewObject to Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
731
diff
changeset
|
107 |
Ptr<Node> n3 = Create<InternetNode> (); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
108 |
|
534
9fa0b6f245d7
Cosmetic: change strings in the bind commands for queue. Move Bind() before CommandLine::Parse() in example script
Tom Henderson <tomh@tomh.org>
parents:
523
diff
changeset
|
109 |
// We create the channels first without any IP addressing information |
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
567
diff
changeset
|
110 |
Ptr<PointToPointChannel> channel0 = |
480
7cf532738f61
do not leak the channel from simple-p2p
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
479
diff
changeset
|
111 |
PointToPointTopology::AddPointToPointLink ( |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
112 |
n0, n2, DataRate(5000000), MilliSeconds(2)); |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
113 |
|
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
567
diff
changeset
|
114 |
Ptr<PointToPointChannel> channel1 = |
480
7cf532738f61
do not leak the channel from simple-p2p
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
479
diff
changeset
|
115 |
PointToPointTopology::AddPointToPointLink ( |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
116 |
n1, n2, DataRate(5000000), MilliSeconds(2)); |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
117 |
|
568
e1660959ecbb
use Ptr<> everywhere Object or NsUnknown are used
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
567
diff
changeset
|
118 |
Ptr<PointToPointChannel> channel2 = |
480
7cf532738f61
do not leak the channel from simple-p2p
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
479
diff
changeset
|
119 |
PointToPointTopology::AddPointToPointLink ( |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
120 |
n2, n3, DataRate(1500000), MilliSeconds(10)); |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
121 |
|
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
122 |
// Later, we add IP addresses. |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
123 |
PointToPointTopology::AddIpv4Addresses ( |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
124 |
channel0, n0, Ipv4Address("10.1.1.1"), |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
125 |
n2, Ipv4Address("10.1.1.2")); |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
126 |
|
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
127 |
PointToPointTopology::AddIpv4Addresses ( |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
128 |
channel1, n1, Ipv4Address("10.1.2.1"), |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
129 |
n2, Ipv4Address("10.1.2.2")); |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
130 |
|
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
131 |
PointToPointTopology::AddIpv4Addresses ( |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
132 |
channel2, n2, Ipv4Address("10.1.3.1"), |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
133 |
n3, Ipv4Address("10.1.3.2")); |
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
134 |
|
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
135 |
// Finally, we add static routes. These three steps (Channel and |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
136 |
// NetDevice creation, IP Address assignment, and routing) are |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
137 |
// separated because there may be a need to postpone IP Address |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
138 |
// assignment (emulation) or modify to use dynamic routing |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
139 |
PointToPointTopology::AddIpv4Routes(n0, n2, channel0); |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
140 |
PointToPointTopology::AddIpv4Routes(n1, n2, channel1); |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
141 |
PointToPointTopology::AddIpv4Routes(n2, n3, channel2); |
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
142 |
|
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
143 |
|
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
144 |
// Create the OnOff application to send UDP datagrams of size |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
145 |
// 210 bytes at a rate of 448 Kb/s |
732
df256f32b6ae
rename MakeNewObject to Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
731
diff
changeset
|
146 |
Ptr<OnOffApplication> ooff = Create<OnOffApplication> ( |
493
68542941fc8a
use ref/unref for Node in more cases
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
484
diff
changeset
|
147 |
n0, |
1204
d40723d53e3d
InetSocketAddress: replace explicit conversion to implicit conversion
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1171
diff
changeset
|
148 |
InetSocketAddress ("10.1.3.2", 80), |
753
683626e722bd
IUdp -> Udp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
752
diff
changeset
|
149 |
"Udp", |
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
150 |
ConstantVariable(1), |
613
9679a238439d
add dox doc and DefaultValue support to OnOffApplication
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
151 |
ConstantVariable(0)); |
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
152 |
// Start the application |
585
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
572
diff
changeset
|
153 |
ooff->Start(Seconds(1.0)); |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
572
diff
changeset
|
154 |
ooff->Stop (Seconds(10.0)); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
155 |
|
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
156 |
// Create a similar flow from n3 to n1, starting at time 1.1 seconds |
732
df256f32b6ae
rename MakeNewObject to Create
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
731
diff
changeset
|
157 |
ooff = Create<OnOffApplication> ( |
493
68542941fc8a
use ref/unref for Node in more cases
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
484
diff
changeset
|
158 |
n3, |
1204
d40723d53e3d
InetSocketAddress: replace explicit conversion to implicit conversion
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1171
diff
changeset
|
159 |
InetSocketAddress ("10.1.2.1", 80), |
753
683626e722bd
IUdp -> Udp
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
752
diff
changeset
|
160 |
"Udp", |
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
161 |
ConstantVariable(1), |
613
9679a238439d
add dox doc and DefaultValue support to OnOffApplication
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
607
diff
changeset
|
162 |
ConstantVariable(0)); |
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
163 |
// Start the application |
585
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
572
diff
changeset
|
164 |
ooff->Start(Seconds(1.1)); |
a009b03b720a
remove ApplicationList. Move functionality to Node class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
572
diff
changeset
|
165 |
ooff->Stop (Seconds(10.0)); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
166 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
167 |
// Here, finish off packet routing configuration |
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
168 |
// This will likely set by some global StaticRouting object in the future |
752
a4febfb8416f
IIpv4 -> Ipv4
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
732
diff
changeset
|
169 |
Ptr<Ipv4> ipv4; |
a4febfb8416f
IIpv4 -> Ipv4
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
732
diff
changeset
|
170 |
ipv4 = n0->QueryInterface<Ipv4> (Ipv4::iid); |
503
38f16e0e5513
fix last leaks with new refcounted mechanism
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
493
diff
changeset
|
171 |
ipv4->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1); |
752
a4febfb8416f
IIpv4 -> Ipv4
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
732
diff
changeset
|
172 |
ipv4 = n3->QueryInterface<Ipv4> (Ipv4::iid); |
503
38f16e0e5513
fix last leaks with new refcounted mechanism
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
493
diff
changeset
|
173 |
ipv4->SetDefaultRoute (Ipv4Address ("10.1.3.1"), 1); |
545
49c33ddf1683
Removed manual ref/unref calls for Ptr<Node>
Raj Bhattacharjea <raj.b@gatech.edu>
parents:
543
diff
changeset
|
174 |
|
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
175 |
// Configure tracing of all enqueue, dequeue, and NetDevice receive events |
988
89a9125a39c9
rename example from p2p to point-to-point
Tom Henderson <tomh@tomh.org>
parents:
973
diff
changeset
|
176 |
// Trace output will be sent to the simple-point-to-point.tr file |
89a9125a39c9
rename example from p2p to point-to-point
Tom Henderson <tomh@tomh.org>
parents:
973
diff
changeset
|
177 |
AsciiTrace asciitrace ("simple-point-to-point.tr"); |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
178 |
asciitrace.TraceAllQueues (); |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
179 |
asciitrace.TraceAllNetDeviceRx (); |
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
180 |
|
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
181 |
// Also configure some tcpdump traces; each interface will be traced |
988
89a9125a39c9
rename example from p2p to point-to-point
Tom Henderson <tomh@tomh.org>
parents:
973
diff
changeset
|
182 |
// The output files will be named |
89a9125a39c9
rename example from p2p to point-to-point
Tom Henderson <tomh@tomh.org>
parents:
973
diff
changeset
|
183 |
// simple-point-to-point.pcap-<nodeId>-<interfaceId> |
541 | 184 |
// and can be read by the "tcpdump -r" command (use "-tt" option to |
185 |
// display timestamps correctly) |
|
988
89a9125a39c9
rename example from p2p to point-to-point
Tom Henderson <tomh@tomh.org>
parents:
973
diff
changeset
|
186 |
PcapTrace pcaptrace ("simple-point-to-point.pcap"); |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
187 |
pcaptrace.TraceAllIp (); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
188 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
189 |
Simulator::Run (); |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
190 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
191 |
Simulator::Destroy (); |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
192 |
} |