A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
wifi-msdu-aggregator-test-suite.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2010 Dean Armstrong
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: Dean Armstrong <deanarm@gmail.com>
19
*/
20
#include "ns3/test.h"
21
#include "ns3/simulator.h"
22
#include "ns3/log.h"
23
24
#include "ns3/boolean.h"
25
#include "ns3/string.h"
26
#include "ns3/double.h"
27
28
#include "ns3/ssid.h"
29
#include "ns3/data-rate.h"
30
#include "ns3/inet-socket-address.h"
31
#include "ns3/packet-sink.h"
32
33
#include "ns3/wifi-helper.h"
34
#include "ns3/qos-wifi-mac-helper.h"
35
#include "ns3/yans-wifi-helper.h"
36
#include "ns3/mobility-helper.h"
37
#include "ns3/internet-stack-helper.h"
38
#include "ns3/ipv4-address-helper.h"
39
#include "ns3/packet-sink-helper.h"
40
#include "ns3/on-off-helper.h"
41
42
NS_LOG_COMPONENT_DEFINE
(
"WifiMsduAggregatorThroughputTest"
);
43
44
using namespace
ns3;
45
46
class
WifiMsduAggregatorThroughputTest
:
public
TestCase
47
{
48
public
:
49
WifiMsduAggregatorThroughputTest
();
50
virtual
void
DoRun (
void
);
51
52
private
:
53
bool
m_writeResults
;
54
};
55
56
WifiMsduAggregatorThroughputTest::WifiMsduAggregatorThroughputTest
()
57
:
TestCase
(
"MsduAggregator throughput test"
),
58
m_writeResults (false)
59
{
60
}
61
62
void
63
WifiMsduAggregatorThroughputTest::DoRun
(
void
)
64
{
65
WifiHelper
wifi = WifiHelper::Default ();
66
67
QosWifiMacHelper
wifiMac = QosWifiMacHelper::Default ();
68
YansWifiPhyHelper
wifiPhy = YansWifiPhyHelper::Default ();
69
YansWifiChannelHelper
wifiChannel = YansWifiChannelHelper::Default ();
70
wifiPhy.
SetChannel
(wifiChannel.
Create
());
71
72
Ssid
ssid =
Ssid
(
"wifi-amsdu-throughput"
);
73
// It may seem a little farcical running an 802.11n aggregation
74
// scenario with 802.11b rates (transmit rate fixed to 1 Mbps, no
75
// less), but this approach tests the bit we need to without unduly
76
// increasing the complexity of the simulation.
77
std::string phyMode (
"DsssRate1Mbps"
);
78
wifi.
SetStandard
(
WIFI_PHY_STANDARD_80211b
);
79
wifi.
SetRemoteStationManager
(
"ns3::ConstantRateWifiManager"
,
80
"DataMode"
,
StringValue
(phyMode),
81
"ControlMode"
,
StringValue
(phyMode));
82
83
// Setup the AP, which will be the source of traffic for this test
84
// and thus has an aggregator on AC_BE.
85
NodeContainer
ap;
86
ap.
Create
(1);
87
wifiMac.
SetType
(
"ns3::ApWifiMac"
,
88
"Ssid"
,
SsidValue
(ssid),
89
"BeaconGeneration"
,
BooleanValue
(
true
),
90
"BeaconInterval"
,
TimeValue
(
MicroSeconds
(102400)));
91
wifiMac.
SetMsduAggregatorForAc
(
AC_BE
,
"ns3::MsduStandardAggregator"
,
92
"MaxAmsduSize"
,
UintegerValue
(4000));
93
NetDeviceContainer
apDev = wifi.
Install
(wifiPhy, wifiMac, ap);
94
95
// Setup one STA, which will be the sink for traffic in this test.
96
NodeContainer
sta;
97
sta.
Create
(1);
98
wifiMac.
SetType
(
"ns3::StaWifiMac"
,
99
"Ssid"
,
SsidValue
(ssid),
100
"ActiveProbing"
,
BooleanValue
(
false
));
101
NetDeviceContainer
staDev = wifi.
Install
(wifiPhy, wifiMac, sta);
102
103
// Our devices will have fixed positions
104
MobilityHelper
mobility;
105
mobility.
SetMobilityModel
(
"ns3::ConstantPositionMobilityModel"
);
106
mobility.
SetPositionAllocator
(
"ns3::GridPositionAllocator"
,
107
"MinX"
,
DoubleValue
(0.0),
108
"MinY"
,
DoubleValue
(0.0),
109
"DeltaX"
,
DoubleValue
(5.0),
110
"DeltaY"
,
DoubleValue
(10.0),
111
"GridWidth"
,
UintegerValue
(2),
112
"LayoutType"
,
StringValue
(
"RowFirst"
));
113
mobility.
Install
(sta);
114
mobility.
Install
(ap);
115
116
// Now we install internet stacks on our devices
117
InternetStackHelper
stack;
118
stack.
Install
(ap);
119
stack.
Install
(sta);
120
121
Ipv4AddressHelper
address;
122
address.
SetBase
(
"192.168.0.0"
,
"255.255.255.0"
);
123
Ipv4InterfaceContainer
staNodeInterface, apNodeInterface;
124
staNodeInterface = address.
Assign
(staDev);
125
apNodeInterface = address.
Assign
(apDev);
126
127
// The applications for this test will see a unidirectional UDP
128
// stream from the AP to the STA. The following UDP port will be
129
// used (arbitrary choice).
130
uint16_t udpPort = 50000;
131
132
// The packet sink application is on the STA device, and is running
133
// right from the start. The traffic source will turn on at 1 second
134
// and then off at 9 seconds, so we turn the sink off at 9 seconds
135
// too in order to measure throughput in a fixed window.
136
PacketSinkHelper
packetSink (
"ns3::UdpSocketFactory"
,
137
InetSocketAddress
(Ipv4Address::GetAny (),
138
udpPort));
139
ApplicationContainer
sinkApp = packetSink.
Install
(sta.
Get
(0));
140
sinkApp.
Start
(
Seconds
(0));
141
sinkApp.
Stop
(
Seconds
(9.0));
142
143
// The packet source is an on-off application on the AP
144
// device. Given that we have fixed the transmit rate at 1 Mbps
145
// above, a 1 Mbps stream at the transport layer should be sufficent
146
// to determine whether aggregation is working or not.
147
//
148
// We configure this traffic stream to operate between 1 and 9 seconds.
149
OnOffHelper
onoff (
"ns3::UdpSocketFactory"
,
150
InetSocketAddress
(staNodeInterface.
GetAddress
(0),
151
udpPort));
152
onoff.
SetAttribute
(
"PacketSize"
,
UintegerValue
(100));
153
onoff.
SetConstantRate
(
DataRate
(
"1Mbps"
));
154
ApplicationContainer
sourceApp = onoff.
Install
(ap.
Get
(0));
155
sourceApp.
Start
(
Seconds
(1.0));
156
sourceApp.
Stop
(
Seconds
(9.0));
157
158
// Enable tracing at the AP
159
if
(
m_writeResults
)
160
{
161
wifiPhy.
EnablePcap
(
"wifi-amsdu-throughput"
, sta.
Get
(0)->
GetId
(), 0);
162
}
163
164
Simulator::Stop (
Seconds
(10.0));
165
Simulator::Run
();
166
Simulator::Destroy ();
167
168
// Now the simulation is complete we note the total number of octets
169
// receive at the packet sink so that we can shortly test that this
170
// is plausible.
171
uint32_t totalOctetsThrough =
172
DynamicCast<PacketSink>(sinkApp.
Get
(0))->GetTotalRx ();
173
174
// Check that throughput was acceptable. This threshold is set based
175
// on inspection of a trace where things are working. Basically, we
176
// there get 26 UDP packets (of size 100, as specified above)
177
// aggregated per A-MSDU, for which the complete frame exchange
178
// (including RTS/CTS and plus medium access) takes around 32
179
// ms. Over the eight seconds of the test this means we expect about
180
// 650 kilobytes, so a pass threshold of 600000 seems to provide a
181
// fair amount of margin to account for reduced utilisation around
182
// stream startup, and contention around AP beacon transmission.
183
//
184
// If aggregation is turned off, then we get about 350 kilobytes in
185
// the same test, so we'll definitely catch the major failures.
186
NS_TEST_ASSERT_MSG_GT
(totalOctetsThrough, 600000,
187
"A-MSDU test fails for low throughput of "
188
<< totalOctetsThrough <<
" octets"
);
189
}
190
191
192
// For now the MSDU Aggregator Test Suite contains only the one test
193
// that is defined in this file, so it's class definition and
194
// instantiation can live here.
195
class
WifiMsduAggregatorTestSuite
:
public
TestSuite
196
{
197
public
:
198
WifiMsduAggregatorTestSuite
();
199
};
200
201
WifiMsduAggregatorTestSuite::WifiMsduAggregatorTestSuite
()
202
:
TestSuite
(
"ns3-wifi-msdu-aggregator"
, SYSTEM)
203
{
204
AddTestCase
(
new
WifiMsduAggregatorThroughputTest
);
205
}
206
207
static
WifiMsduAggregatorTestSuite
wifiMsduAggregatorTestSuite
;
src
test
ns3wifi
wifi-msdu-aggregator-test-suite.cc
Generated on Fri Dec 21 2012 19:00:47 for ns-3 by
1.8.1.2