author | Tom Henderson <tomh@tomh.org> |
Fri, 20 Aug 2010 12:17:19 -0700 | |
changeset 6589 | 9c325569fb01 |
parent 6309 | 8d46400b959e |
permissions | -rw-r--r-- |
4408 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 2009 MIRKO BANCHI |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License version 2 as |
|
7 |
* published by the Free Software Foundation; |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
17 |
* |
|
18 |
* Author: Mirko Banchi <mk.banchi@gmail.com> |
|
19 |
*/ |
|
20 |
#include "ns3/core-module.h" |
|
21 |
#include "ns3/simulator-module.h" |
|
22 |
#include "ns3/node-module.h" |
|
23 |
#include "ns3/helper-module.h" |
|
24 |
#include "ns3/wifi-module.h" |
|
25 |
#include "ns3/mobility-module.h" |
|
26 |
||
27 |
//This is a simple example in order to show how 802.11n frame aggregation feature (A-MSDU) works. |
|
28 |
// |
|
29 |
//Network topology: |
|
30 |
// |
|
31 |
// Wifi 192.168.1.0 |
|
32 |
// |
|
33 |
// AP |
|
34 |
// * * * |
|
35 |
// | | | |
|
36 |
// n1 n2 n3 |
|
37 |
// |
|
38 |
//Packets in this simulation aren't marked with a QosTag so they are considered |
|
39 |
//belonging to BestEffort Access Class (AC_BE). |
|
40 |
||
41 |
using namespace ns3; |
|
42 |
||
43 |
NS_LOG_COMPONENT_DEFINE ("SimpleWifiFrameAggregation"); |
|
44 |
||
45 |
int main (int argc, char *argv[]) |
|
46 |
{ |
|
47 |
//LogComponentEnable ("EdcaTxopN", LOG_LEVEL_DEBUG); |
|
48 |
LogComponentEnable ("MsduAggregator", LOG_LEVEL_INFO); |
|
49 |
LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO); |
|
50 |
LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO); |
|
51 |
||
52 |
uint32_t nWifi = 1; |
|
53 |
CommandLine cmd; |
|
54 |
cmd.AddValue ("nWifi", "Number of wifi STA devices", nWifi); |
|
55 |
cmd.Parse (argc,argv); |
|
56 |
||
57 |
NodeContainer wifiNodes; |
|
58 |
wifiNodes.Create (2); |
|
59 |
NodeContainer wifiApNode; |
|
60 |
wifiApNode.Create (1); |
|
61 |
||
62 |
YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); |
|
63 |
YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); |
|
64 |
phy.SetChannel (channel.Create ()); |
|
65 |
||
66 |
WifiHelper wifi = WifiHelper::Default (); |
|
67 |
QosWifiMacHelper mac = QosWifiMacHelper::Default (); |
|
68 |
wifi.SetRemoteStationManager ("ns3::AarfWifiManager", "FragmentationThreshold", UintegerValue (2500)); |
|
69 |
||
70 |
Ssid ssid = Ssid ("ns-3-802.11n"); |
|
71 |
mac.SetType ("ns3::QstaWifiMac", |
|
72 |
"Ssid", SsidValue (ssid), |
|
73 |
"ActiveProbing", BooleanValue (false)); |
|
74 |
mac.SetMsduAggregatorForAc (AC_BE, "ns3::MsduStandardAggregator", |
|
75 |
"MaxAmsduSize", UintegerValue (3839)); |
|
76 |
||
77 |
NetDeviceContainer staDevices; |
|
78 |
staDevices = wifi.Install (phy, mac, wifiNodes); |
|
79 |
||
80 |
mac.SetType ("ns3::QapWifiMac", |
|
6309 | 81 |
"Ssid", SsidValue (ssid)); |
4408 | 82 |
mac.SetMsduAggregatorForAc (AC_BE, "ns3::MsduStandardAggregator", |
83 |
"MaxAmsduSize", UintegerValue (7935)); |
|
84 |
||
85 |
NetDeviceContainer apDevice; |
|
86 |
apDevice = wifi.Install (phy, mac, wifiApNode); |
|
87 |
||
88 |
/* Setting mobility model */ |
|
89 |
MobilityHelper mobility; |
|
90 |
||
91 |
mobility.SetPositionAllocator ("ns3::GridPositionAllocator", |
|
92 |
"MinX", DoubleValue (0.0), |
|
93 |
"MinY", DoubleValue (0.0), |
|
94 |
"DeltaX", DoubleValue (5.0), |
|
95 |
"DeltaY", DoubleValue (10.0), |
|
96 |
"GridWidth", UintegerValue (3), |
|
97 |
"LayoutType", StringValue ("RowFirst")); |
|
98 |
||
99 |
mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel", |
|
100 |
"Bounds", RectangleValue (Rectangle (-50, 50, -50, 50))); |
|
101 |
mobility.Install (wifiNodes); |
|
102 |
||
103 |
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
|
104 |
mobility.Install (wifiApNode); |
|
105 |
||
106 |
/* Internet stack*/ |
|
107 |
InternetStackHelper stack; |
|
108 |
stack.Install (wifiApNode); |
|
109 |
stack.Install (wifiNodes); |
|
110 |
||
111 |
Ipv4AddressHelper address; |
|
112 |
||
113 |
address.SetBase ("192.168.1.0", "255.255.255.0"); |
|
114 |
Ipv4InterfaceContainer wifiNodesInterfaces; |
|
115 |
Ipv4InterfaceContainer apNodeInterface; |
|
116 |
||
117 |
wifiNodesInterfaces = address.Assign (staDevices); |
|
118 |
apNodeInterface = address.Assign (apDevice); |
|
119 |
||
120 |
/* Setting applications */ |
|
121 |
UdpEchoServerHelper echoServer (9); |
|
122 |
||
123 |
ApplicationContainer serverApps = echoServer.Install (wifiNodes.Get (1)); |
|
124 |
serverApps.Start (Seconds (1.0)); |
|
125 |
serverApps.Stop (Seconds (10.0)); |
|
126 |
||
127 |
UdpEchoClientHelper echoClient (wifiNodesInterfaces.GetAddress (1), 9); |
|
128 |
echoClient.SetAttribute ("MaxPackets", UintegerValue (3)); |
|
129 |
echoClient.SetAttribute ("Interval", TimeValue (Seconds (0.000001))); |
|
130 |
echoClient.SetAttribute ("PacketSize", UintegerValue (1500)); |
|
131 |
||
132 |
ApplicationContainer clientApps = |
|
133 |
echoClient.Install (wifiNodes.Get (0)); |
|
134 |
clientApps.Start (Seconds (2.0)); |
|
135 |
clientApps.Stop (Seconds (10.0)); |
|
136 |
||
4616
a84f60b6cd12
bug 600: lower the default routing priority of Ipv4GlobalRouting; move to helper
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
4492
diff
changeset
|
137 |
Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
4408 | 138 |
|
139 |
Simulator::Stop (Seconds (10.0)); |
|
140 |
||
4492
3ebeb7bf3c15
added support for radiotap and prism headers
Nicola Baldo <nbaldo@cttc.es>
parents:
4408
diff
changeset
|
141 |
phy.EnablePcap ("test-802.11n", |
4408 | 142 |
wifiNodes.Get (nWifi - 1)->GetId (), 0); |
143 |
||
144 |
Simulator::Run (); |
|
145 |
Simulator::Destroy (); |
|
146 |
||
147 |
return 0; |
|
148 |
} |