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
simple-wifi-frame-aggregation.cc
Go to the documentation of this file.
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/network-module.h"
22
#include "ns3/applications-module.h"
23
#include "ns3/wifi-module.h"
24
#include "ns3/mobility-module.h"
25
#include "ns3/ipv4-global-routing-helper.h"
26
#include "ns3/internet-module.h"
27
28
//This is a simple example in order to show how 802.11n frame aggregation feature (A-MSDU) works.
29
//
30
//Network topology:
31
//
32
// Wifi 192.168.1.0
33
//
34
// AP
35
// * * *
36
// | | |
37
// n1 n2 n3
38
//
39
//Packets in this simulation aren't marked with a QosTag so they are considered
40
//belonging to BestEffort Access Class (AC_BE).
41
42
using namespace
ns3;
43
44
NS_LOG_COMPONENT_DEFINE
(
"SimpleWifiFrameAggregation"
);
45
46
int
main
(
int
argc,
char
*argv[])
47
{
48
//LogComponentEnable ("EdcaTxopN", LOG_LEVEL_DEBUG);
49
LogComponentEnable
(
"MsduAggregator"
,
LOG_LEVEL_INFO
);
50
LogComponentEnable
(
"UdpEchoClientApplication"
,
LOG_LEVEL_INFO
);
51
LogComponentEnable
(
"UdpEchoServerApplication"
,
LOG_LEVEL_INFO
);
52
53
uint32_t nWifi = 1;
54
CommandLine
cmd;
55
cmd.
AddValue
(
"nWifi"
,
"Number of wifi STA devices"
, nWifi);
56
cmd.
Parse
(argc,argv);
57
58
NodeContainer
wifiNodes;
59
wifiNodes.
Create
(2);
60
NodeContainer
wifiApNode;
61
wifiApNode.
Create
(1);
62
63
YansWifiChannelHelper
channel =
YansWifiChannelHelper::Default
();
64
YansWifiPhyHelper
phy =
YansWifiPhyHelper::Default
();
65
phy.
SetChannel
(channel.
Create
());
66
67
WifiHelper
wifi =
WifiHelper::Default
();
68
QosWifiMacHelper
mac =
QosWifiMacHelper::Default
();
69
wifi.
SetRemoteStationManager
(
"ns3::AarfWifiManager"
,
"FragmentationThreshold"
,
UintegerValue
(2500));
70
71
Ssid
ssid =
Ssid
(
"ns-3-802.11n"
);
72
mac.
SetType
(
"ns3::StaWifiMac"
,
73
"Ssid"
,
SsidValue
(ssid),
74
"ActiveProbing"
,
BooleanValue
(
false
));
75
mac.
SetMsduAggregatorForAc
(
AC_BE
,
"ns3::MsduStandardAggregator"
,
76
"MaxAmsduSize"
,
UintegerValue
(3839));
77
78
NetDeviceContainer
staDevices;
79
staDevices = wifi.
Install
(phy, mac, wifiNodes);
80
81
mac.
SetType
(
"ns3::ApWifiMac"
,
82
"Ssid"
,
SsidValue
(ssid));
83
mac.
SetMsduAggregatorForAc
(
AC_BE
,
"ns3::MsduStandardAggregator"
,
84
"MaxAmsduSize"
,
UintegerValue
(7935));
85
86
NetDeviceContainer
apDevice;
87
apDevice = wifi.
Install
(phy, mac, wifiApNode);
88
89
/* Setting mobility model */
90
MobilityHelper
mobility;
91
92
mobility.
SetPositionAllocator
(
"ns3::GridPositionAllocator"
,
93
"MinX"
,
DoubleValue
(0.0),
94
"MinY"
,
DoubleValue
(0.0),
95
"DeltaX"
,
DoubleValue
(5.0),
96
"DeltaY"
,
DoubleValue
(10.0),
97
"GridWidth"
,
UintegerValue
(3),
98
"LayoutType"
,
StringValue
(
"RowFirst"
));
99
100
mobility.
SetMobilityModel
(
"ns3::RandomWalk2dMobilityModel"
,
101
"Bounds"
,
RectangleValue
(
Rectangle
(-50, 50, -50, 50)));
102
mobility.
Install
(wifiNodes);
103
104
mobility.
SetMobilityModel
(
"ns3::ConstantPositionMobilityModel"
);
105
mobility.
Install
(wifiApNode);
106
107
/* Internet stack*/
108
InternetStackHelper
stack
;
109
stack.
Install
(wifiApNode);
110
stack.
Install
(wifiNodes);
111
112
Ipv4AddressHelper
address
;
113
114
address.
SetBase
(
"192.168.1.0"
,
"255.255.255.0"
);
115
Ipv4InterfaceContainer
wifiNodesInterfaces;
116
Ipv4InterfaceContainer
apNodeInterface;
117
118
wifiNodesInterfaces = address.
Assign
(staDevices);
119
apNodeInterface = address.
Assign
(apDevice);
120
121
/* Setting applications */
122
UdpEchoServerHelper
echoServer
(9);
123
124
ApplicationContainer
serverApps
= echoServer.
Install
(wifiNodes.
Get
(1));
125
serverApps.
Start
(Seconds (1.0));
126
serverApps.
Stop
(Seconds (10.0));
127
128
UdpEchoClientHelper
echoClient
(wifiNodesInterfaces.
GetAddress
(1), 9);
129
echoClient
.SetAttribute (
"MaxPackets"
,
UintegerValue
(3));
130
echoClient
.SetAttribute (
"Interval"
,
TimeValue
(Seconds (0.000001)));
131
echoClient
.SetAttribute (
"PacketSize"
,
UintegerValue
(1500));
132
133
ApplicationContainer
clientApps
=
134
echoClient
.Install (wifiNodes.
Get
(0));
135
clientApps.
Start
(Seconds (2.0));
136
clientApps.
Stop
(Seconds (10.0));
137
138
Ipv4GlobalRoutingHelper::PopulateRoutingTables
();
139
140
Simulator::Stop
(Seconds (10.0));
141
142
phy.
EnablePcap
(
"test-802.11n"
,
143
wifiNodes.
Get
(nWifi - 1)->
GetId
(), 0);
144
145
Simulator::Run
();
146
Simulator::Destroy
();
147
148
return
0;
149
}
examples
wireless
simple-wifi-frame-aggregation.cc
Generated on Fri Aug 30 2013 01:42:44 for ns-3 by
1.8.1.2