author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Mon, 31 Mar 2008 14:00:40 -0700 | |
changeset 2821 | 8e1f6f923c51 |
parent 2613 | 0e1267814e1c |
child 2823 | a743c59882a0 |
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 |
// |
2295
39452dbe604b
Fix OLSR example: don't add static routes, increase simulation time to 300 seconds.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
24 |
// n0 |
368
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 |
2327
6496b4d93372
Make the OLSR example a bit more complete, adding a 5th node, to exercise 3-hop routing.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2298
diff
changeset
|
27 |
// n2 -------------------------n3---------n4 |
368
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 |
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
38 |
// - Tracing of queues and packet receptions to file "simple-point-to-point-olsr.tr" |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
39 |
|
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
40 |
#include <iostream> |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
41 |
#include <fstream> |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
42 |
#include <string> |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
43 |
#include <cassert> |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
44 |
|
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
45 |
#include "ns3/core-module.h" |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
46 |
#include "ns3/simulator-module.h" |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
47 |
#include "ns3/helper-module.h" |
1742
cf76416ce75b
merge with ns-3-dev
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1421
diff
changeset
|
48 |
|
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
49 |
using namespace ns3; |
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
50 |
|
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
51 |
NS_LOG_COMPONENT_DEFINE ("SimpleGlobalRoutingExample"); |
1748
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
52 |
|
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
53 |
int |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
54 |
main (int argc, char *argv[]) |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
55 |
{ |
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
|
56 |
// 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
|
57 |
// for selected modules; the below lines suggest how to do this |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
58 |
#if 0 |
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
59 |
LogComponentEnable ("SimpleGlobalRoutingExample", LOG_LEVEL_INFO); |
1748
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
60 |
|
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
61 |
LogComponentEnable("Object", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
62 |
LogComponentEnable("Queue", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
63 |
LogComponentEnable("DropTailQueue", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
64 |
LogComponentEnable("Channel", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
65 |
LogComponentEnable("CsmaChannel", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
66 |
LogComponentEnable("NetDevice", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
67 |
LogComponentEnable("CsmaNetDevice", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
68 |
LogComponentEnable("Ipv4L3Protocol", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
69 |
LogComponentEnable("PacketSocket", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
70 |
LogComponentEnable("Socket", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
71 |
LogComponentEnable("UdpSocket", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
72 |
LogComponentEnable("UdpL4Protocol", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
73 |
LogComponentEnable("Ipv4L3Protocol", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
74 |
LogComponentEnable("Ipv4StaticRouting", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
75 |
LogComponentEnable("Ipv4Interface", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
76 |
LogComponentEnable("ArpIpv4Interface", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
77 |
LogComponentEnable("Ipv4LoopbackInterface", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
78 |
LogComponentEnable("OnOffApplication", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
79 |
LogComponentEnable("PacketSinkApplication", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
80 |
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_ALL); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
81 |
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_ALL); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
82 |
#endif |
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
83 |
// Set up some default values for the simulation. Use the |
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
|
84 |
|
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
85 |
Config::SetDefault ("ns3::OnOffApplication::PacketSize", Uinteger (210)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
86 |
Config::SetDefault ("ns3::OnOffApplication::DataRate", DataRate ("448kb/s")); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
87 |
|
1224
7cbc1d661b89
rename Bind to DefaultValue::Bind. fix bug 62
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1204
diff
changeset
|
88 |
//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
|
89 |
|
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 |
// Allow the user to override any of the defaults and the above |
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
91 |
// DefaultValue::Bind ()s at run-time, via command-line arguments |
2575
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
92 |
CommandLine cmd; |
1aae382e65e2
rewrite CommandLine to not handle DefaultValues anymore.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2503
diff
changeset
|
93 |
cmd.Parse (argc, argv); |
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
|
94 |
|
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
|
95 |
// 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
|
96 |
// topologies, we could configure a node factory. |
1748
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
97 |
NS_LOG_INFO ("Create nodes."); |
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
98 |
NodeContainer c; |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
99 |
c.Create (5); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
100 |
NodeContainer n02 = NodeContainer (c.Get(0), c.Get (2)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
101 |
NodeContainer n12 = NodeContainer (c.Get(1), c.Get (2)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
102 |
NodeContainer n32 = NodeContainer (c.Get(3), c.Get (2)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
103 |
NodeContainer n34 = NodeContainer (c.Get (3), c.Get (4)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
104 |
|
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
105 |
InternetStackHelper internet; |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
106 |
internet.Build (c); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
107 |
|
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
|
108 |
// We create the channels first without any IP addressing information |
1748
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
109 |
NS_LOG_INFO ("Create channels."); |
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
110 |
PointToPointHelper p2p; |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
111 |
p2p.SetChannelParameter ("BitRate", DataRate (5000000)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
112 |
p2p.SetChannelParameter ("Delay", MilliSeconds (2)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
113 |
NetDeviceContainer nd02 = p2p.Build (n02); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
114 |
NetDeviceContainer nd12 = p2p.Build (n12); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
115 |
p2p.SetChannelParameter ("BitRate", DataRate (1500000)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
116 |
p2p.SetChannelParameter ("Delay", MilliSeconds (10)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
117 |
NetDeviceContainer nd32 = p2p.Build (n32); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
118 |
NetDeviceContainer nd34 = p2p.Build (n34); |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
119 |
|
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
120 |
// Later, we add IP addresses. |
1748
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
121 |
NS_LOG_INFO ("Assign IP Addresses."); |
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
122 |
Ipv4AddressHelper ipv4; |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
123 |
ipv4.SetBase ("10.1.1.0", "255.255.255.0"); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
124 |
Ipv4InterfaceContainer i02 = ipv4.Allocate (nd02); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
125 |
|
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
126 |
ipv4.SetBase ("10.1.2.0", "255.255.255.0"); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
127 |
Ipv4InterfaceContainer i12 = ipv4.Allocate (nd12); |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
128 |
|
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
129 |
ipv4.SetBase ("10.1.3.0", "255.255.255.0"); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
130 |
Ipv4InterfaceContainer i32 = ipv4.Allocate (nd32); |
540
507eababb124
Separate address assignment from routing in PointToPoint topology code
Tom Henderson <tomh@tomh.org>
parents:
535
diff
changeset
|
131 |
|
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
132 |
ipv4.SetBase ("10.1.4.0", "255.255.255.0"); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
133 |
Ipv4InterfaceContainer i34 = ipv4.Allocate (nd34); |
2295
39452dbe604b
Fix OLSR example: don't add static routes, increase simulation time to 300 seconds.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
134 |
|
39452dbe604b
Fix OLSR example: don't add static routes, increase simulation time to 300 seconds.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2257
diff
changeset
|
135 |
// Enable OLSR |
1748
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
136 |
NS_LOG_INFO ("Enabling OLSR Routing."); |
2484
d5b05b706999
port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2298
diff
changeset
|
137 |
OlsrHelper olsr; |
d5b05b706999
port Olsr code to attributes/helpers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2298
diff
changeset
|
138 |
olsr.EnableAll (); |
535
fb6735f93868
Enable both ascii and pcap tracing
Tom Henderson <tomh@tomh.org>
parents:
534
diff
changeset
|
139 |
|
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
140 |
// 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
|
141 |
// 210 bytes at a rate of 448 Kb/s |
1748
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
142 |
NS_LOG_INFO ("Create Applications."); |
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
143 |
uint16_t port = 9; // Discard port (RFC 863) |
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
144 |
OnOffHelper onoff; |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
145 |
onoff.SetAppAttribute ("OnTime", ConstantVariable (1)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
146 |
onoff.SetAppAttribute ("OffTime", ConstantVariable (0)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
147 |
onoff.SetUdpRemote (i34.GetAddress (1), port); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
148 |
ApplicationContainer apps = onoff.Build (c.Get (0)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
149 |
apps.Start (Seconds (1.0)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
150 |
apps.Stop (Seconds (10.0)); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
151 |
|
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
152 |
// Create a packet sink to receive these packets |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
153 |
PacketSinkHelper sink; |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
154 |
sink.SetupUdp (Ipv4Address::GetAny (), port); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
155 |
apps = sink.Build (c.Get (3)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
156 |
apps.Start (Seconds (1.0)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
157 |
apps.Stop (Seconds (10.0)); |
1320
60b14f0bcff1
adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents:
1290
diff
changeset
|
158 |
|
382
26528ff50d38
Switch over simple-p2p.cc to use OnOffApplication
Tom Henderson <tomh@tomh.org>
parents:
381
diff
changeset
|
159 |
// Create a similar flow from n3 to n1, starting at time 1.1 seconds |
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
160 |
onoff.SetUdpRemote (i12.GetAddress (0), port); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
161 |
apps = onoff.Build (c.Get (3)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
162 |
apps.Start (Seconds (1.1)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
163 |
apps.Stop (Seconds (10.0)); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
164 |
|
1320
60b14f0bcff1
adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents:
1290
diff
changeset
|
165 |
// Create a packet sink to receive these packets |
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
166 |
apps = sink.Build (c.Get (1)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
167 |
apps.Start (Seconds (1.1)); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
168 |
apps.Stop (Seconds (10.0)); |
1320
60b14f0bcff1
adapt some example scripts to use the new PacketSink
Tom Henderson <tomh@tomh.org>
parents:
1290
diff
changeset
|
169 |
|
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
170 |
std::ofstream ascii; |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
171 |
ascii.open ("simple-point-to-point-olsr.tr"); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
172 |
PointToPointHelper::EnablePcap ("simple-point-to-point-olsr.pcap"); |
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
173 |
PointToPointHelper::EnableAscii (ascii); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
174 |
|
1748
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
175 |
NS_LOG_INFO ("Run Simulation."); |
2298
f61e41169911
Put back the simulation time in 30 seconds, else we generate huge trace files.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
2295
diff
changeset
|
176 |
Simulator::Run (); |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
177 |
Simulator::Destroy (); |
1748
d2b5acae027d
Update OLSR example.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
1745
diff
changeset
|
178 |
NS_LOG_INFO ("Done."); |
2821
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
179 |
|
8e1f6f923c51
port to helper API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2613
diff
changeset
|
180 |
return 0; |
368
1df1165d6a68
Rename file names from serial to p2p
Tom Henderson <tomh@tomh.org>
parents:
diff
changeset
|
181 |
} |