author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Wed, 02 May 2007 15:07:33 +0200 | |
changeset 493 | 68542941fc8a |
parent 484 | cf7fbb84d74b |
child 503 | 38f16e0e5513 |
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 |
// |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
32 |
// - all links are p2p links with indicated one-way BW/delay |
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 |
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
38 |
// - Tracing of queues and packet receptions to file "simple-p2p.tr" |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
39 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
40 |
#include <iostream> |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
41 |
#include <fstream> |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
42 |
#include <string> |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
43 |
#include <cassert> |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
44 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
45 |
#include "ns3/debug.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
46 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
47 |
#include "ns3/simulator.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
48 |
#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
|
49 |
#include "ns3/data-rate.h" |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
50 |
|
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
388
diff
changeset
|
51 |
#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
|
52 |
#include "ns3/pcap-trace.h" |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
53 |
#include "ns3/internet-node.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
54 |
#include "ns3/p2p-channel.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
55 |
#include "ns3/p2p-net-device.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
56 |
#include "ns3/mac-address.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
57 |
#include "ns3/ipv4-address.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
58 |
#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
|
59 |
#include "ns3/udp.h" |
ddbb935800d8
remove DatagramSocket, use Socket base class for UdpSocket subclass.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
444
diff
changeset
|
60 |
#include "ns3/socket.h" |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
61 |
#include "ns3/ipv4-route.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
62 |
#include "ns3/drop-tail.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
63 |
#include "ns3/node-list.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
64 |
#include "ns3/trace-root.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
65 |
#include "ns3/p2p-topology.h" |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
66 |
#include "ns3/onoff-application.h" |
381
83b52d112c99
Add ApplicationList and Capability
Tom Henderson <tomh@tomh.org>
parents:
380
diff
changeset
|
67 |
#include "ns3/application-list.h" |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
68 |
#include "ns3/random-variable.h" |
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 |
using namespace ns3; |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
71 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
72 |
int main (int argc, char *argv[]) |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
73 |
{ |
380 | 74 |
#if 0 |
379
ae74e8a7bb44
net device copy and assignment, reference counted channel.
Craig Dowell
parents:
378
diff
changeset
|
75 |
DebugComponentEnable("Object"); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
76 |
DebugComponentEnable("Queue"); |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
77 |
DebugComponentEnable("DropTailQueue"); |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
78 |
DebugComponentEnable("Channel"); |
369
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
79 |
DebugComponentEnable("PointToPointChannel"); |
29ea5d1a83c8
Rename classes from Serial to PointToPoint
Tom Henderson <tomh@tomh.org>
parents:
368
diff
changeset
|
80 |
DebugComponentEnable("PointToPointNetDevice"); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
81 |
#endif |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
82 |
|
375
de64c081a2e0
Make queues copyable; change p2p-topology.cc to reflect this
Tom Henderson <tomh@tomh.org>
parents:
373
diff
changeset
|
83 |
// Optionally, specify some default values for Queue objects. |
de64c081a2e0
Make queues copyable; change p2p-topology.cc to reflect this
Tom Henderson <tomh@tomh.org>
parents:
373
diff
changeset
|
84 |
// For this example, we specify that we want each queue to |
de64c081a2e0
Make queues copyable; change p2p-topology.cc to reflect this
Tom Henderson <tomh@tomh.org>
parents:
373
diff
changeset
|
85 |
// be a DropTail queue, with a limit of 30 packets. |
de64c081a2e0
Make queues copyable; change p2p-topology.cc to reflect this
Tom Henderson <tomh@tomh.org>
parents:
373
diff
changeset
|
86 |
// Specify DropTail for default queue type (note. this is actually |
de64c081a2e0
Make queues copyable; change p2p-topology.cc to reflect this
Tom Henderson <tomh@tomh.org>
parents:
373
diff
changeset
|
87 |
// the default, but included here as an example). |
de64c081a2e0
Make queues copyable; change p2p-topology.cc to reflect this
Tom Henderson <tomh@tomh.org>
parents:
373
diff
changeset
|
88 |
Queue::Default(DropTailQueue()); |
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
89 |
// Specify limit of 30 in units of packets (not implemented). |
375
de64c081a2e0
Make queues copyable; change p2p-topology.cc to reflect this
Tom Henderson <tomh@tomh.org>
parents:
373
diff
changeset
|
90 |
// Queue::Default().SetLimitPackets(30); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
91 |
|
482
f844579404cb
remove Node::Copy, Node::Create and Node::*Prototype* methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
480
diff
changeset
|
92 |
Node* n0 = new InternetNode (); |
f844579404cb
remove Node::Copy, Node::Create and Node::*Prototype* methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
480
diff
changeset
|
93 |
Node* n1 = new InternetNode (); |
f844579404cb
remove Node::Copy, Node::Create and Node::*Prototype* methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
480
diff
changeset
|
94 |
Node* n2 = new InternetNode (); |
f844579404cb
remove Node::Copy, Node::Create and Node::*Prototype* methods.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
480
diff
changeset
|
95 |
Node* n3 = new InternetNode (); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
96 |
|
480
7cf532738f61
do not leak the channel from simple-p2p
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
479
diff
changeset
|
97 |
PointToPointChannel *channel0 = |
7cf532738f61
do not leak the channel from simple-p2p
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
479
diff
changeset
|
98 |
PointToPointTopology::AddPointToPointLink ( |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
99 |
n0, Ipv4Address("10.1.1.1"), |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
100 |
n2, Ipv4Address("10.1.1.2"), |
383
780e2f7d7231
One-line bug fix on PointToPointTopology
Tom Henderson <tomh@tomh.org>
parents:
382
diff
changeset
|
101 |
DataRate(5000000), MilliSeconds(2)); |
480
7cf532738f61
do not leak the channel from simple-p2p
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
479
diff
changeset
|
102 |
channel0->Unref (); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
103 |
|
480
7cf532738f61
do not leak the channel from simple-p2p
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
479
diff
changeset
|
104 |
PointToPointChannel *channel1 = |
7cf532738f61
do not leak the channel from simple-p2p
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
479
diff
changeset
|
105 |
PointToPointTopology::AddPointToPointLink ( |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
106 |
n1, Ipv4Address("10.1.2.1"), |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
107 |
n2, Ipv4Address("10.1.2.2"), |
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
|
108 |
DataRate(5000000), MilliSeconds(2)); |
480
7cf532738f61
do not leak the channel from simple-p2p
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
479
diff
changeset
|
109 |
channel1->Unref (); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
110 |
|
480
7cf532738f61
do not leak the channel from simple-p2p
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
479
diff
changeset
|
111 |
PointToPointChannel *channel2 = |
7cf532738f61
do not leak the channel from simple-p2p
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
479
diff
changeset
|
112 |
PointToPointTopology::AddPointToPointLink ( |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
113 |
n2, Ipv4Address("10.1.3.1"), |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
114 |
n3, Ipv4Address("10.1.3.2"), |
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
|
115 |
DataRate(1500000), MilliSeconds(10)); |
480
7cf532738f61
do not leak the channel from simple-p2p
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
479
diff
changeset
|
116 |
channel2->Unref (); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
117 |
|
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
118 |
// 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
|
119 |
// 210 bytes at a rate of 448 Kb/s |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
120 |
OnOffApplication* ooff0 = new OnOffApplication( |
493
68542941fc8a
use ref/unref for Node in more cases
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
484
diff
changeset
|
121 |
n0, |
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
122 |
Ipv4Address("10.1.3.2"), |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
123 |
80, |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
124 |
ConstantVariable(1), |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
125 |
ConstantVariable(0), |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
126 |
DataRate(448000), |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
127 |
210); |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
128 |
// Add to Node's ApplicationList (takes ownership of pointer) |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
129 |
n0->GetApplicationList()->Add(ooff0); |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
130 |
// Start the application |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
131 |
ooff0->Start(Seconds(1.0)); |
479
eefc92272862
do not use Simulator::StopAt to avoid too many memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
473
diff
changeset
|
132 |
ooff0->Stop (Seconds(10.0)); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
133 |
|
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
134 |
// Create a similar flow from n3 to n1, starting at time 1.1 seconds |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
135 |
OnOffApplication* ooff1 = new OnOffApplication( |
493
68542941fc8a
use ref/unref for Node in more cases
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
484
diff
changeset
|
136 |
n3, |
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
137 |
Ipv4Address("10.1.2.1"), |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
138 |
80, |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
139 |
ConstantVariable(1), |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
140 |
ConstantVariable(0), |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
141 |
DataRate(448000), |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
142 |
210); |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
143 |
// Add to Node's ApplicationList (takes ownership of pointer) |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
144 |
n3->GetApplicationList()->Add(ooff1); |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
145 |
// Start the application |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
146 |
ooff1->Start(Seconds(1.1)); |
479
eefc92272862
do not use Simulator::StopAt to avoid too many memory leaks
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
473
diff
changeset
|
147 |
ooff1->Stop (Seconds(10.0)); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
148 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
149 |
// 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
|
150 |
// This will likely set by some global StaticRouting object in the future |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
151 |
n0->GetIpv4()->SetDefaultRoute (Ipv4Address ("10.1.1.2"), 1); |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
152 |
n3->GetIpv4()->SetDefaultRoute (Ipv4Address ("10.1.3.1"), 1); |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
153 |
|
484
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
482
diff
changeset
|
154 |
n0->Unref (); |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
482
diff
changeset
|
155 |
n1->Unref (); |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
482
diff
changeset
|
156 |
n2->Unref (); |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
482
diff
changeset
|
157 |
n3->Unref (); |
cf7fbb84d74b
rework the Node and NodeList classes to manage reference counts correctly
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
482
diff
changeset
|
158 |
|
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
159 |
// Configure tracing of all enqueue, dequeue, and NetDevice receive events |
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
160 |
// Trace output will be sent to the simple-p2p.tr file |
462
9f39ce362810
re-enable ascii trace output by default
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
461
diff
changeset
|
161 |
#if 1 |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
162 |
AsciiTrace trace ("simple-p2p.tr"); |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
163 |
trace.TraceAllQueues (); |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
164 |
trace.TraceAllNetDeviceRx (); |
456
5361882cc2f3
put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
389
diff
changeset
|
165 |
#else |
5361882cc2f3
put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
389
diff
changeset
|
166 |
PcapTrace trace ("simple-p2p.tr"); |
5361882cc2f3
put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
389
diff
changeset
|
167 |
trace.TraceAllIp (); |
5361882cc2f3
put together a PcapTrace and test it
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
389
diff
changeset
|
168 |
#endif |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
169 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
170 |
Simulator::Run (); |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
171 |
|
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
172 |
Simulator::Destroy (); |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
173 |
} |