author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Mon, 23 Mar 2009 09:56:27 +0100 | |
changeset 4359 | 8d689bf4405f |
parent 4264 | 9d2e96c4e6e4 |
permissions | -rw-r--r-- |
3831
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
2 |
/* |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
3 |
* This program is free software; you can redistribute it and/or modify |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
4 |
* it under the terms of the GNU General Public License version 2 as |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
5 |
* published by the Free Software Foundation; |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
6 |
* |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
7 |
* This program is distributed in the hope that it will be useful, |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
10 |
* GNU General Public License for more details. |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
11 |
* |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
12 |
* You should have received a copy of the GNU General Public License |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
13 |
* along with this program; if not, write to the Free Software |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
14 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
15 |
*/ |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
16 |
|
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
17 |
// Network topology |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
18 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
19 |
// Normally, the use case for emulated net devices is in collections of |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
20 |
// small simulations that connect to the outside world through specific |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
21 |
// interfaces. For example, one could construct a number of virtual |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
22 |
// machines and connect them via a host-only network. To use the emulated |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
23 |
// net device, you would need to set all of the host-only interfaces in |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
24 |
// promiscuous mode and provide an appropriate device name (search for "eth1" |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
25 |
// below). One could also use the emulated net device in a testbed situation |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
26 |
// where the host on which the simulation is running has a specific interface |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
27 |
// of interested. You would also need to set this specific interface into |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
28 |
// promiscuous mode and provide an appropriate device name. |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
29 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
30 |
// This philosophy carries over to this simple example. |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
31 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
32 |
// We don't assume any special configuration and all of the ns-3 emulated net |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
33 |
// devices will actually talk to the same underlying OS device. We rely on |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
34 |
// the fact that the OS will deliver copies of our packets to the other ns-3 |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
35 |
// net devices since we operate in promiscuous mode. |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
36 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
37 |
// Packets will be sent out over the device, but we use MAC spoofing. The |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
38 |
// MAC addresses will be generated using the Organizationally Unique Identifier |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
39 |
// (OUI) 00:00:00 as a base. This vendor code is not assigned to any |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
40 |
// organization and so should not conflict with any real hardware. We'll use |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
41 |
// the first n of these addresses, where n is the number of nodes, in this |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
42 |
// simualtion. It is up to you to determine that using these MAC addresses is |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
43 |
// okay on your network and won't conflict with anything else (including another |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
44 |
// simulation using emu devices) on your network. Once you have made this |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
45 |
// determination, you need to put the interface you chose into promiscuous mode. |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
46 |
// We don't do it for you since you need to think about it first. |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
47 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
48 |
// This simulation uses the real-time simulator and so will consume ten seconds |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
49 |
// of real time. |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
50 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
51 |
// By default, we create the following topology |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
52 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
53 |
// n0 n1 n2 n3 |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
54 |
// | | | | |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
55 |
// ----------------- |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
56 |
// "eth1" |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
57 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
58 |
// - UDP flows from n0 to n1 and back |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
59 |
// - DropTail queues |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
60 |
// - Tracing of queues and packet receptions to file "udp-echo.tr" |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
61 |
// - pcap tracing on all devices |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
62 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
63 |
|
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
64 |
#include <fstream> |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
65 |
#include "ns3/core-module.h" |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
66 |
#include "ns3/simulator-module.h" |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
67 |
#include "ns3/helper-module.h" |
4210
da9be6abb1b2
bug 486: patches for icc compilation.
Timo Bingmann <timo.bingmann@student.kit.edu>
parents:
3831
diff
changeset
|
68 |
#include "ns3/emu-helper.h" |
3831
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
69 |
|
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
70 |
using namespace ns3; |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
71 |
|
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
72 |
NS_LOG_COMPONENT_DEFINE ("EmulatedUdpEchoExample"); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
73 |
|
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
74 |
int |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
75 |
main (int argc, char *argv[]) |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
76 |
{ |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
77 |
std::string deviceName ("eth1"); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
78 |
uint32_t nNodes = 4; |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
79 |
|
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
80 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
81 |
// Allow the user to override any of the defaults at run-time, via command-line |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
82 |
// arguments |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
83 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
84 |
CommandLine cmd; |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
85 |
cmd.AddValue("deviceName", "device name", deviceName); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
86 |
cmd.AddValue("nNodes", "number of nodes to create (>= 2)", nNodes); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
87 |
cmd.Parse (argc, argv); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
88 |
|
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
89 |
GlobalValue::Bind ("SimulatorImplementationType", |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
90 |
StringValue ("ns3::RealtimeSimulatorImpl")); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
91 |
|
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
92 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
93 |
// need at least two nodes |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
94 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
95 |
nNodes = nNodes < 2 ? 2 : nNodes; |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
96 |
|
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
97 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
98 |
// Explicitly create the nodes required by the topology (shown above). |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
99 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
100 |
NS_LOG_INFO ("Create nodes."); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
101 |
NodeContainer n; |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
102 |
n.Create (nNodes); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
103 |
|
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
104 |
InternetStackHelper internet; |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
105 |
internet.Install (n); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
106 |
|
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
107 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
108 |
// Explicitly create the channels required by the topology (shown above). |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
109 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
110 |
NS_LOG_INFO ("Create channels."); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
111 |
EmuHelper emu; |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
112 |
emu.SetAttribute ("DeviceName", StringValue (deviceName)); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
113 |
NetDeviceContainer d = emu.Install (n); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
114 |
|
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
115 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
116 |
// We've got the "hardware" in place. Now we need to add IP addresses. |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
117 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
118 |
Ipv4AddressHelper ipv4; |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
119 |
NS_LOG_INFO ("Assign IP Addresses."); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
120 |
ipv4.SetBase ("10.1.1.0", "255.255.255.0"); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
121 |
Ipv4InterfaceContainer i = ipv4.Assign (d); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
122 |
|
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
123 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
124 |
// Create a UdpEchoServer application on node one. |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
125 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
126 |
NS_LOG_INFO ("Create Applications."); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
127 |
UdpEchoServerHelper server (9); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
128 |
ApplicationContainer apps = server.Install (n.Get(1)); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
129 |
apps.Start (Seconds (1.0)); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
130 |
apps.Stop (Seconds (10.0)); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
131 |
|
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
132 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
133 |
// Create a UdpEchoClient application to send UDP datagrams from node zero to node one. |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
134 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
135 |
uint32_t packetSize = 1024; |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
136 |
uint32_t maxPacketCount = 1; |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
137 |
Time interPacketInterval = Seconds (1.); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
138 |
UdpEchoClientHelper client (i.GetAddress (1), 9); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
139 |
client.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount)); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
140 |
client.SetAttribute ("Interval", TimeValue (interPacketInterval)); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
141 |
client.SetAttribute ("PacketSize", UintegerValue (packetSize)); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
142 |
apps = client.Install (n.Get (0)); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
143 |
apps.Start (Seconds (2.0)); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
144 |
apps.Stop (Seconds (10.0)); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
145 |
|
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
146 |
std::ofstream ascii; |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
147 |
ascii.open ("emu-udp-echo.tr"); |
4264
9d2e96c4e6e4
Piles of changes for tracing rework
Craig Dowell <craigdo@ee.washington.edu>
parents:
4210
diff
changeset
|
148 |
EmuHelper::EnablePcapAll ("emu-udp-echo", true); |
3831
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
149 |
|
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
150 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
151 |
// Now, do the actual simulation. |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
152 |
// |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
153 |
NS_LOG_INFO ("Run Simulation."); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
154 |
Simulator::Run (); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
155 |
Simulator::Destroy (); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
156 |
NS_LOG_INFO ("Done."); |
16c2970a0344
add emu-udp-echo example
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
157 |
} |