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-helper.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2008 INRIA
4
* Copyright (c) 2009 MIRKO BANCHI
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 2 as
8
* published by the Free Software Foundation;
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
*
19
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20
* Author: Mirko Banchi <mk.banchi@gmail.com>
21
*/
22
#include "
wifi-helper.h
"
23
#include "ns3/wifi-net-device.h"
24
#include "ns3/wifi-mac.h"
25
#include "ns3/regular-wifi-mac.h"
26
#include "ns3/dca-txop.h"
27
#include "ns3/edca-txop-n.h"
28
#include "ns3/minstrel-wifi-manager.h"
29
#include "ns3/wifi-phy.h"
30
#include "ns3/wifi-remote-station-manager.h"
31
#include "ns3/wifi-channel.h"
32
#include "ns3/yans-wifi-channel.h"
33
#include "ns3/propagation-delay-model.h"
34
#include "ns3/propagation-loss-model.h"
35
#include "ns3/mobility-model.h"
36
#include "ns3/log.h"
37
#include "ns3/config.h"
38
#include "ns3/pointer.h"
39
#include "ns3/simulator.h"
40
#include "ns3/names.h"
41
42
NS_LOG_COMPONENT_DEFINE
(
"WifiHelper"
);
43
44
namespace
ns3 {
45
46
WifiPhyHelper::~WifiPhyHelper
()
47
{
48
}
49
50
WifiMacHelper::~WifiMacHelper
()
51
{
52
}
53
54
WifiHelper::WifiHelper
()
55
: m_standard (
WIFI_PHY_STANDARD_80211a
)
56
{
57
}
58
59
WifiHelper
60
WifiHelper::Default
(
void
)
61
{
62
WifiHelper
helper;
63
helper.
SetRemoteStationManager
(
"ns3::ArfWifiManager"
);
64
return
helper;
65
}
66
67
void
68
WifiHelper::SetRemoteStationManager
(std::string type,
69
std::string n0,
const
AttributeValue
&v0,
70
std::string n1,
const
AttributeValue
&v1,
71
std::string n2,
const
AttributeValue
&v2,
72
std::string n3,
const
AttributeValue
&v3,
73
std::string n4,
const
AttributeValue
&v4,
74
std::string n5,
const
AttributeValue
&v5,
75
std::string n6,
const
AttributeValue
&v6,
76
std::string n7,
const
AttributeValue
&v7)
77
{
78
m_stationManager
=
ObjectFactory
();
79
m_stationManager
.
SetTypeId
(type);
80
m_stationManager
.
Set
(n0, v0);
81
m_stationManager
.
Set
(n1, v1);
82
m_stationManager
.
Set
(n2, v2);
83
m_stationManager
.
Set
(n3, v3);
84
m_stationManager
.
Set
(n4, v4);
85
m_stationManager
.
Set
(n5, v5);
86
m_stationManager
.
Set
(n6, v6);
87
m_stationManager
.
Set
(n7, v7);
88
}
89
90
void
91
WifiHelper::SetStandard
(
enum
WifiPhyStandard
standard)
92
{
93
m_standard
= standard;
94
}
95
96
NetDeviceContainer
97
WifiHelper::Install
(
const
WifiPhyHelper
&phyHelper,
98
const
WifiMacHelper
&macHelper,
NodeContainer
c)
const
99
{
100
NetDeviceContainer
devices;
101
for
(
NodeContainer::Iterator
i = c.
Begin
(); i != c.
End
(); ++i)
102
{
103
Ptr<Node>
node = *i;
104
Ptr<WifiNetDevice>
device = CreateObject<WifiNetDevice> ();
105
Ptr<WifiRemoteStationManager>
manager =
m_stationManager
.
Create
<
WifiRemoteStationManager
> ();
106
Ptr<WifiMac>
mac = macHelper.
Create
();
107
Ptr<WifiPhy>
phy = phyHelper.
Create
(node, device);
108
mac->SetAddress (
Mac48Address::Allocate
());
109
mac->
ConfigureStandard
(
m_standard
);
110
phy->
ConfigureStandard
(
m_standard
);
111
device->SetMac (mac);
112
device->SetPhy (phy);
113
device->SetRemoteStationManager (manager);
114
node->
AddDevice
(device);
115
devices.
Add
(device);
116
NS_LOG_DEBUG
(
"node="
<< node <<
", mob="
<< node->
GetObject
<
MobilityModel
> ());
117
}
118
return
devices;
119
}
120
121
NetDeviceContainer
122
WifiHelper::Install
(
const
WifiPhyHelper
&phy,
123
const
WifiMacHelper
&mac,
Ptr<Node>
node)
const
124
{
125
return
Install
(phy, mac,
NodeContainer
(node));
126
}
127
128
NetDeviceContainer
129
WifiHelper::Install
(
const
WifiPhyHelper
&phy,
130
const
WifiMacHelper
&mac, std::string nodeName)
const
131
{
132
Ptr<Node>
node = Names::Find<Node> (nodeName);
133
return
Install
(phy, mac,
NodeContainer
(node));
134
}
135
136
void
137
WifiHelper::EnableLogComponents
(
void
)
138
{
139
LogComponentEnable
(
"Aarfcd"
,
LOG_LEVEL_ALL
);
140
LogComponentEnable
(
"AdhocWifiMac"
,
LOG_LEVEL_ALL
);
141
LogComponentEnable
(
"AmrrWifiRemoteStation"
,
LOG_LEVEL_ALL
);
142
LogComponentEnable
(
"ApWifiMac"
,
LOG_LEVEL_ALL
);
143
LogComponentEnable
(
"ns3::ArfWifiManager"
,
LOG_LEVEL_ALL
);
144
LogComponentEnable
(
"Cara"
,
LOG_LEVEL_ALL
);
145
LogComponentEnable
(
"DcaTxop"
,
LOG_LEVEL_ALL
);
146
LogComponentEnable
(
"DcfManager"
,
LOG_LEVEL_ALL
);
147
LogComponentEnable
(
"DsssErrorRateModel"
,
LOG_LEVEL_ALL
);
148
LogComponentEnable
(
"EdcaTxopN"
,
LOG_LEVEL_ALL
);
149
LogComponentEnable
(
"InterferenceHelper"
,
LOG_LEVEL_ALL
);
150
LogComponentEnable
(
"Jakes"
,
LOG_LEVEL_ALL
);
151
LogComponentEnable
(
"MacLow"
,
LOG_LEVEL_ALL
);
152
LogComponentEnable
(
"MacRxMiddle"
,
LOG_LEVEL_ALL
);
153
LogComponentEnable
(
"MsduAggregator"
,
LOG_LEVEL_ALL
);
154
LogComponentEnable
(
"MsduStandardAggregator"
,
LOG_LEVEL_ALL
);
155
LogComponentEnable
(
"NistErrorRateModel"
,
LOG_LEVEL_ALL
);
156
LogComponentEnable
(
"OnoeWifiRemoteStation"
,
LOG_LEVEL_ALL
);
157
LogComponentEnable
(
"PropagationLossModel"
,
LOG_LEVEL_ALL
);
158
LogComponentEnable
(
"RegularWifiMac"
,
LOG_LEVEL_ALL
);
159
LogComponentEnable
(
"RraaWifiManager"
,
LOG_LEVEL_ALL
);
160
LogComponentEnable
(
"StaWifiMac"
,
LOG_LEVEL_ALL
);
161
LogComponentEnable
(
"SupportedRates"
,
LOG_LEVEL_ALL
);
162
LogComponentEnable
(
"WifiChannel"
,
LOG_LEVEL_ALL
);
163
LogComponentEnable
(
"WifiPhyStateHelper"
,
LOG_LEVEL_ALL
);
164
LogComponentEnable
(
"WifiPhy"
,
LOG_LEVEL_ALL
);
165
LogComponentEnable
(
"WifiRemoteStationManager"
,
LOG_LEVEL_ALL
);
166
LogComponentEnable
(
"YansErrorRateModel"
,
LOG_LEVEL_ALL
);
167
LogComponentEnable
(
"YansWifiChannel"
,
LOG_LEVEL_ALL
);
168
LogComponentEnable
(
"YansWifiPhy"
,
LOG_LEVEL_ALL
);
169
}
170
171
int64_t
172
WifiHelper::AssignStreams
(
NetDeviceContainer
c, int64_t stream)
173
{
174
int64_t currentStream = stream;
175
Ptr<NetDevice>
netDevice;
176
for
(
NetDeviceContainer::Iterator
i = c.
Begin
(); i != c.
End
(); ++i)
177
{
178
netDevice = (*i);
179
Ptr<WifiNetDevice>
wifi = DynamicCast<WifiNetDevice> (netDevice);
180
if
(wifi)
181
{
182
// Handle any random numbers in the PHY objects.
183
currentStream += wifi->GetPhy ()->AssignStreams (currentStream);
184
185
// Handle any random numbers in the station managers.
186
Ptr<WifiRemoteStationManager>
manager = wifi->GetRemoteStationManager ();
187
Ptr<MinstrelWifiManager>
minstrel = DynamicCast<MinstrelWifiManager> (manager);
188
if
(minstrel)
189
{
190
currentStream += minstrel->AssignStreams (currentStream);
191
}
192
193
// Handle any random numbers in the MAC objects.
194
Ptr<WifiMac>
mac = wifi->GetMac ();
195
Ptr<RegularWifiMac>
rmac = DynamicCast<RegularWifiMac> (mac);
196
if
(rmac)
197
{
198
PointerValue
ptr;
199
rmac->GetAttribute (
"DcaTxop"
, ptr);
200
Ptr<DcaTxop>
dcaTxop = ptr.
Get
<
DcaTxop
> ();
201
currentStream += dcaTxop->
AssignStreams
(currentStream);
202
203
rmac->GetAttribute (
"VO_EdcaTxopN"
, ptr);
204
Ptr<EdcaTxopN>
vo_edcaTxopN = ptr.
Get
<
EdcaTxopN
> ();
205
currentStream += vo_edcaTxopN->
AssignStreams
(currentStream);
206
207
rmac->GetAttribute (
"VI_EdcaTxopN"
, ptr);
208
Ptr<EdcaTxopN>
vi_edcaTxopN = ptr.
Get
<
EdcaTxopN
> ();
209
currentStream += vi_edcaTxopN->
AssignStreams
(currentStream);
210
211
rmac->GetAttribute (
"BE_EdcaTxopN"
, ptr);
212
Ptr<EdcaTxopN>
be_edcaTxopN = ptr.
Get
<
EdcaTxopN
> ();
213
currentStream += be_edcaTxopN->
AssignStreams
(currentStream);
214
215
rmac->GetAttribute (
"BK_EdcaTxopN"
, ptr);
216
Ptr<EdcaTxopN>
bk_edcaTxopN = ptr.
Get
<
EdcaTxopN
> ();
217
currentStream += bk_edcaTxopN->
AssignStreams
(currentStream);
218
}
219
}
220
}
221
return
(currentStream - stream);
222
}
223
224
}
// namespace ns3
src
wifi
helper
wifi-helper.cc
Generated on Fri Dec 21 2012 19:00:48 for ns-3 by
1.8.1.2