author | Gustavo J. A. M. Carneiro <gjc@inescporto.pt> |
Fri, 11 Jul 2008 18:39:19 +0100 | |
changeset 3416 | 926ccb845111 |
parent 3382 | d5f8e5fae1c6 |
child 3994 | 6cc096bc0761 |
permissions | -rw-r--r-- |
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
2 |
/* |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
3 |
* This program is free software; you can redistribute it and/or modify |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
4 |
* it under the terms of the GNU General Public License version 2 as |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
5 |
* published by the Free Software Foundation; |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
6 |
* |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
7 |
* This program is distributed in the hope that it will be useful, |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
8 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
9 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
10 |
* GNU General Public License for more details. |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
11 |
* |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
12 |
* You should have received a copy of the GNU General Public License |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
13 |
* along with this program; if not, write to the Free Software |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
14 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
15 |
*/ |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
16 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
17 |
#include "ns3/core-module.h" |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
18 |
#include "ns3/simulator-module.h" |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
19 |
#include "ns3/node-module.h" |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
20 |
#include "ns3/helper-module.h" |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
21 |
#include "ns3/global-routing-module.h" |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
22 |
#include "ns3/wifi-module.h" |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
23 |
#include "ns3/mobility-module.h" |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
24 |
|
3338
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
25 |
// Default Network Topology |
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
26 |
// |
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
27 |
// Wifi 10.1.3.0 |
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
28 |
// AP |
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
29 |
// * * * * |
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
30 |
// | | | | 10.1.1.0 |
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
31 |
// n5 n6 n7 n0 -------------- n1 n2 n3 n4 |
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
32 |
// point-to-point | | | | |
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
33 |
// ================ |
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
34 |
// LAN 10.1.2.0 |
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
35 |
|
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
36 |
using namespace ns3; |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
37 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
38 |
NS_LOG_COMPONENT_DEFINE ("ThirdScriptExample"); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
39 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
40 |
int |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
41 |
main (int argc, char *argv[]) |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
42 |
{ |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
43 |
LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
44 |
LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
45 |
|
3338
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
46 |
uint32_t nCsma = 3; |
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
47 |
uint32_t nWifi = 3; |
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
48 |
CommandLine cmd; |
3338
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
49 |
cmd.AddValue ("nCsma", "Number of \"extra\" CSMA nodes/devices", nCsma); |
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
50 |
cmd.AddValue ("nWifi", "Number of wifi STA devices", nWifi); |
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
51 |
cmd.Parse (argc,argv); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
52 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
53 |
NodeContainer p2pNodes; |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
54 |
p2pNodes.Create (2); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
55 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
56 |
PointToPointHelper pointToPoint; |
3382
d5f8e5fae1c6
fix bug 234 which changes required methods on helpers to constructor parameters. Update tutorial content to reflect. Change RemoteIpv4 attribute to RemoteAddress.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3339
diff
changeset
|
57 |
pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); |
d5f8e5fae1c6
fix bug 234 which changes required methods on helpers to constructor parameters. Update tutorial content to reflect. Change RemoteIpv4 attribute to RemoteAddress.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3339
diff
changeset
|
58 |
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); |
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
59 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
60 |
NetDeviceContainer p2pDevices; |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
61 |
p2pDevices = pointToPoint.Install (p2pNodes); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
62 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
63 |
NodeContainer csmaNodes; |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
64 |
csmaNodes.Add (p2pNodes.Get (1)); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
65 |
csmaNodes.Create (nCsma); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
66 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
67 |
CsmaHelper csma; |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
68 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
69 |
NetDeviceContainer csmaDevices; |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
70 |
csmaDevices = csma.Install (csmaNodes); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
71 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
72 |
NodeContainer wifiStaNodes; |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
73 |
wifiStaNodes.Create (nWifi); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
74 |
NodeContainer wifiApNode = p2pNodes.Get (0); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
75 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
76 |
Ptr<WifiChannel> channel = CreateObject<WifiChannel> (); |
3339
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
77 |
|
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
78 |
channel->SetPropagationDelayModel ( |
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
79 |
CreateObject<ConstantSpeedPropagationDelayModel> ()); |
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
80 |
|
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
81 |
Ptr<LogDistancePropagationLossModel> log = |
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
82 |
CreateObject<LogDistancePropagationLossModel> (); |
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
83 |
|
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
84 |
log->SetReferenceModel (CreateObject<FriisPropagationLossModel> ()); |
3339
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
85 |
|
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
86 |
channel->SetPropagationLossModel (log); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
87 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
88 |
WifiHelper wifi; |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
89 |
wifi.SetPhy ("ns3::WifiPhy"); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
90 |
wifi.SetRemoteStationManager ("ns3::ArfWifiManager"); |
3339
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
91 |
|
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
92 |
Ssid ssid = Ssid ("ns-3-ssid"); |
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
93 |
wifi.SetMac ("ns3::NqstaWifiMac", |
3339
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
94 |
"Ssid", SsidValue (ssid), |
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
95 |
"ActiveProbing", BooleanValue (false)); |
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
96 |
|
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
97 |
NetDeviceContainer staDevices; |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
98 |
staDevices = wifi.Install (wifiStaNodes, channel); |
3339
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
99 |
|
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
100 |
wifi.SetMac ("ns3::NqapWifiMac", |
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
101 |
"Ssid", SsidValue (ssid), |
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
102 |
"BeaconGeneration", BooleanValue (true), |
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
103 |
"BeaconInterval", TimeValue (Seconds (2.5))); |
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
104 |
|
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
105 |
NetDeviceContainer apDevices; |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
106 |
apDevices = wifi.Install (wifiApNode, channel); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
107 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
108 |
MobilityHelper mobility; |
3339
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
109 |
|
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
110 |
mobility.SetPositionAllocator ("ns3::GridPositionAllocator", |
3339
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
111 |
"MinX", DoubleValue (0.0), |
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
112 |
"MinY", DoubleValue (0.0), |
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
113 |
"DeltaX", DoubleValue (5.0), |
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
114 |
"DeltaY", DoubleValue (10.0), |
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
115 |
"GridWidth", UintegerValue (3), |
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
116 |
"LayoutType", StringValue ("RowFirst")); |
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
117 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
118 |
mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", |
3339
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
119 |
"Bounds", RectangleValue (Rectangle (-50, 50, -50, 50))); |
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
120 |
mobility.Install (wifiStaNodes); |
3339
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
121 |
|
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
122 |
mobility.SetMobilityModel ("ns3::StaticMobilityModel"); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
123 |
mobility.Install (wifiApNode); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
124 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
125 |
InternetStackHelper stack; |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
126 |
stack.Install (csmaNodes); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
127 |
stack.Install (wifiApNode); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
128 |
stack.Install (wifiStaNodes); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
129 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
130 |
Ipv4AddressHelper address; |
3339
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
131 |
|
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
132 |
address.SetBase ("10.1.1.0", "255.255.255.0"); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
133 |
Ipv4InterfaceContainer p2pInterfaces; |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
134 |
p2pInterfaces = address.Assign (p2pDevices); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
135 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
136 |
address.SetBase ("10.1.2.0", "255.255.255.0"); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
137 |
Ipv4InterfaceContainer csmaInterfaces; |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
138 |
csmaInterfaces = address.Assign (csmaDevices); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
139 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
140 |
address.SetBase ("10.1.3.0", "255.255.255.0"); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
141 |
address.Assign (staDevices); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
142 |
address.Assign (apDevices); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
143 |
|
3382
d5f8e5fae1c6
fix bug 234 which changes required methods on helpers to constructor parameters. Update tutorial content to reflect. Change RemoteIpv4 attribute to RemoteAddress.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3339
diff
changeset
|
144 |
UdpEchoServerHelper echoServer (9); |
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
145 |
|
3338
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
146 |
ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma)); |
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
147 |
serverApps.Start (Seconds (1.0)); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
148 |
serverApps.Stop (Seconds (10.0)); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
149 |
|
3382
d5f8e5fae1c6
fix bug 234 which changes required methods on helpers to constructor parameters. Update tutorial content to reflect. Change RemoteIpv4 attribute to RemoteAddress.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3339
diff
changeset
|
150 |
UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9); |
d5f8e5fae1c6
fix bug 234 which changes required methods on helpers to constructor parameters. Update tutorial content to reflect. Change RemoteIpv4 attribute to RemoteAddress.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3339
diff
changeset
|
151 |
echoClient.SetAttribute ("MaxPackets", UintegerValue (1)); |
d5f8e5fae1c6
fix bug 234 which changes required methods on helpers to constructor parameters. Update tutorial content to reflect. Change RemoteIpv4 attribute to RemoteAddress.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3339
diff
changeset
|
152 |
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.))); |
d5f8e5fae1c6
fix bug 234 which changes required methods on helpers to constructor parameters. Update tutorial content to reflect. Change RemoteIpv4 attribute to RemoteAddress.
Craig Dowell <craigdo@ee.washington.edu>
parents:
3339
diff
changeset
|
153 |
echoClient.SetAttribute ("PacketSize", UintegerValue (1024)); |
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
154 |
|
3338
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
155 |
ApplicationContainer clientApps = |
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
156 |
echoClient.Install (wifiStaNodes.Get (nWifi - 1)); |
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
157 |
clientApps.Start (Seconds (2.0)); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
158 |
clientApps.Stop (Seconds (10.0)); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
159 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
160 |
GlobalRouteManager::PopulateRoutingTables (); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
161 |
|
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
162 |
Simulator::Stop (Seconds (10.0)); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
163 |
|
3339
ff29f4ba75ed
finish up with a wifi example
Craig Dowell <craigdo@ee.washington.edu>
parents:
3338
diff
changeset
|
164 |
WifiHelper::EnablePcap ("third", |
3338
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
165 |
wifiStaNodes.Get (nWifi - 1)->GetId (), 0); |
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
166 |
CsmaHelper::EnablePcap ("third", |
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
167 |
csmaNodes.Get (nCsma)->GetId (), 0); |
7c645e1799b1
cleanup tutorial third.cc a bit
Craig Dowell <craigdo@ee.washington.edu>
parents:
3331
diff
changeset
|
168 |
|
3331
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
169 |
Simulator::Run (); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
170 |
Simulator::Destroy (); |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
171 |
return 0; |
7305032b6100
add updated tutorial examples
Craig Dowell <craigdo@ee.washington.edu>
parents:
diff
changeset
|
172 |
} |