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
arf-wifi-manager.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2004,2005,2006 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
*/
20
21
#include "
arf-wifi-manager.h
"
22
#include "ns3/assert.h"
23
#include "ns3/log.h"
24
#include "ns3/uinteger.h"
25
26
#define Min(a,b) ((a < b) ? a : b)
27
28
NS_LOG_COMPONENT_DEFINE
(
"ns3::ArfWifiManager"
);
29
30
31
namespace
ns3 {
32
33
struct
ArfWifiRemoteStation
:
public
WifiRemoteStation
34
{
35
uint32_t
m_timer
;
36
uint32_t
m_success
;
37
uint32_t
m_failed
;
38
bool
m_recovery
;
39
uint32_t
m_retry
;
40
41
uint32_t
m_timerTimeout
;
42
uint32_t
m_successThreshold
;
43
44
uint32_t
m_rate
;
45
};
46
47
NS_OBJECT_ENSURE_REGISTERED
(
ArfWifiManager
);
48
49
TypeId
50
ArfWifiManager::GetTypeId
(
void
)
51
{
52
static
TypeId
tid =
TypeId
(
"ns3::ArfWifiManager"
)
53
.
SetParent
<
WifiRemoteStationManager
> ()
54
.AddConstructor<ArfWifiManager> ()
55
.AddAttribute (
"TimerThreshold"
,
"The 'timer' threshold in the ARF algorithm."
,
56
UintegerValue
(15),
57
MakeUintegerAccessor (&
ArfWifiManager::m_timerThreshold
),
58
MakeUintegerChecker<uint32_t> ())
59
.AddAttribute (
"SuccessThreshold"
,
60
"The minimum number of sucessfull transmissions to try a new rate."
,
61
UintegerValue
(10),
62
MakeUintegerAccessor (&
ArfWifiManager::m_successThreshold
),
63
MakeUintegerChecker<uint32_t> ())
64
;
65
return
tid;
66
}
67
68
ArfWifiManager::ArfWifiManager
()
69
{
70
NS_LOG_FUNCTION
(
this
);
71
}
72
ArfWifiManager::~ArfWifiManager
()
73
{
74
NS_LOG_FUNCTION
(
this
);
75
}
76
WifiRemoteStation
*
77
ArfWifiManager::DoCreateStation
(
void
)
const
78
{
79
NS_LOG_FUNCTION
(
this
);
80
ArfWifiRemoteStation
*station =
new
ArfWifiRemoteStation
();
81
82
station->
m_successThreshold
=
m_successThreshold
;
83
station->
m_timerTimeout
=
m_timerThreshold
;
84
station->
m_rate
= 0;
85
station->
m_success
= 0;
86
station->
m_failed
= 0;
87
station->
m_recovery
=
false
;
88
station->
m_retry
= 0;
89
station->
m_timer
= 0;
90
91
return
station;
92
}
93
94
void
95
ArfWifiManager::DoReportRtsFailed
(
WifiRemoteStation
*station)
96
{
97
NS_LOG_FUNCTION
(
this
<< station);
98
}
108
void
109
ArfWifiManager::DoReportDataFailed
(
WifiRemoteStation
*st)
110
{
111
NS_LOG_FUNCTION
(
this
<< st);
112
ArfWifiRemoteStation
*station = (
ArfWifiRemoteStation
*)st;
113
station->
m_timer
++;
114
station->
m_failed
++;
115
station->
m_retry
++;
116
station->
m_success
= 0;
117
118
if
(station->
m_recovery
)
119
{
120
NS_ASSERT
(station->
m_retry
>= 1);
121
if
(station->
m_retry
== 1)
122
{
123
// need recovery fallback
124
if
(station->
m_rate
!= 0)
125
{
126
station->
m_rate
--;
127
}
128
}
129
station->
m_timer
= 0;
130
}
131
else
132
{
133
NS_ASSERT
(station->
m_retry
>= 1);
134
if
(((station->
m_retry
- 1) % 2) == 1)
135
{
136
// need normal fallback
137
if
(station->
m_rate
!= 0)
138
{
139
station->
m_rate
--;
140
}
141
}
142
if
(station->
m_retry
>= 2)
143
{
144
station->
m_timer
= 0;
145
}
146
}
147
}
148
void
149
ArfWifiManager::DoReportRxOk
(
WifiRemoteStation
*station,
150
double
rxSnr,
WifiMode
txMode)
151
{
152
NS_LOG_FUNCTION
(
this
<< station << rxSnr << txMode);
153
}
154
void
ArfWifiManager::DoReportRtsOk
(
WifiRemoteStation
*station,
155
double
ctsSnr,
WifiMode
ctsMode,
double
rtsSnr)
156
{
157
NS_LOG_FUNCTION
(
this
<< station << ctsSnr << ctsMode << rtsSnr);
158
NS_LOG_DEBUG
(
"station="
<< station <<
" rts ok"
);
159
}
160
void
ArfWifiManager::DoReportDataOk
(
WifiRemoteStation
*st,
161
double
ackSnr,
WifiMode
ackMode,
double
dataSnr)
162
{
163
NS_LOG_FUNCTION
(
this
<< st << ackSnr << ackMode << dataSnr);
164
ArfWifiRemoteStation
*station = (
ArfWifiRemoteStation
*) st;
165
station->
m_timer
++;
166
station->
m_success
++;
167
station->
m_failed
= 0;
168
station->
m_recovery
=
false
;
169
station->
m_retry
= 0;
170
NS_LOG_DEBUG
(
"station="
<< station <<
" data ok success="
<< station->
m_success
<<
", timer="
<< station->
m_timer
);
171
if
((station->
m_success
==
m_successThreshold
172
|| station->
m_timer
==
m_timerThreshold
)
173
&& (station->
m_rate
< (station->
m_state
->
m_operationalRateSet
.size () - 1)))
174
{
175
NS_LOG_DEBUG
(
"station="
<< station <<
" inc rate"
);
176
station->
m_rate
++;
177
station->
m_timer
= 0;
178
station->
m_success
= 0;
179
station->
m_recovery
=
true
;
180
}
181
}
182
void
183
ArfWifiManager::DoReportFinalRtsFailed
(
WifiRemoteStation
*station)
184
{
185
NS_LOG_FUNCTION
(
this
<< station);
186
}
187
void
188
ArfWifiManager::DoReportFinalDataFailed
(
WifiRemoteStation
*station)
189
{
190
NS_LOG_FUNCTION
(
this
<< station);
191
}
192
193
WifiTxVector
194
ArfWifiManager::DoGetDataTxVector
(
WifiRemoteStation
*st, uint32_t size)
195
{
196
NS_LOG_FUNCTION
(
this
<< st << size);
197
ArfWifiRemoteStation
*station = (
ArfWifiRemoteStation
*) st;
198
return
WifiTxVector
(
GetSupported
(station, station->
m_rate
),
GetDefaultTxPowerLevel
(),
GetLongRetryCount
(station),
GetShortGuardInterval
(station),
Min
(
GetNumberOfReceiveAntennas
(station),
GetNumberOfTransmitAntennas
()),
GetNumberOfTransmitAntennas
(station),
GetStbc
(station));
199
}
200
WifiTxVector
201
ArfWifiManager::DoGetRtsTxVector
(
WifiRemoteStation
*st)
202
{
203
NS_LOG_FUNCTION
(
this
<< st);
206
ArfWifiRemoteStation
*station = (
ArfWifiRemoteStation
*) st;
207
return
WifiTxVector
(
GetSupported
(station, 0),
GetDefaultTxPowerLevel
(),
GetLongRetryCount
(station),
GetShortGuardInterval
(station),
Min
(
GetNumberOfReceiveAntennas
(station),
GetNumberOfTransmitAntennas
()),
GetNumberOfTransmitAntennas
(station),
GetStbc
(station));
208
}
209
210
bool
211
ArfWifiManager::IsLowLatency
(
void
)
const
212
{
213
NS_LOG_FUNCTION
(
this
);
214
return
true
;
215
}
216
217
}
// namespace ns3
src
wifi
model
arf-wifi-manager.cc
Generated on Fri Aug 30 2013 01:43:04 for ns-3 by
1.8.1.2