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
NS_LOG_COMPONENT_DEFINE
(
"ns3::ArfWifiManager"
);
27
28
29
namespace
ns3 {
30
31
struct
ArfWifiRemoteStation
:
public
WifiRemoteStation
32
{
33
uint32_t
m_timer
;
34
uint32_t
m_success
;
35
uint32_t
m_failed
;
36
bool
m_recovery
;
37
uint32_t
m_retry
;
38
39
uint32_t
m_timerTimeout
;
40
uint32_t
m_successThreshold
;
41
42
uint32_t
m_rate
;
43
};
44
45
NS_OBJECT_ENSURE_REGISTERED
(
ArfWifiManager
);
46
47
TypeId
48
ArfWifiManager::GetTypeId
(
void
)
49
{
50
static
TypeId
tid =
TypeId
(
"ns3::ArfWifiManager"
)
51
.
SetParent
<
WifiRemoteStationManager
> ()
52
.AddConstructor<ArfWifiManager> ()
53
.AddAttribute (
"TimerThreshold"
,
"The 'timer' threshold in the ARF algorithm."
,
54
UintegerValue
(15),
55
MakeUintegerAccessor (&
ArfWifiManager::m_timerThreshold
),
56
MakeUintegerChecker<uint32_t> ())
57
.AddAttribute (
"SuccessThreshold"
,
58
"The minimum number of sucessfull transmissions to try a new rate."
,
59
UintegerValue
(10),
60
MakeUintegerAccessor (&
ArfWifiManager::m_successThreshold
),
61
MakeUintegerChecker<uint32_t> ())
62
;
63
return
tid;
64
}
65
66
ArfWifiManager::ArfWifiManager
()
67
{
68
}
69
ArfWifiManager::~ArfWifiManager
()
70
{
71
}
72
WifiRemoteStation
*
73
ArfWifiManager::DoCreateStation
(
void
)
const
74
{
75
ArfWifiRemoteStation
*station =
new
ArfWifiRemoteStation
();
76
77
station->
m_successThreshold
=
m_successThreshold
;
78
station->
m_timerTimeout
=
m_timerThreshold
;
79
station->
m_rate
= 0;
80
station->
m_success
= 0;
81
station->
m_failed
= 0;
82
station->
m_recovery
=
false
;
83
station->
m_retry
= 0;
84
station->
m_timer
= 0;
85
86
return
station;
87
}
88
89
void
90
ArfWifiManager::DoReportRtsFailed
(
WifiRemoteStation
*station)
91
{
92
}
102
void
103
ArfWifiManager::DoReportDataFailed
(
WifiRemoteStation
*st)
104
{
105
ArfWifiRemoteStation
*station = (
ArfWifiRemoteStation
*)st;
106
station->
m_timer
++;
107
station->
m_failed
++;
108
station->
m_retry
++;
109
station->
m_success
= 0;
110
111
if
(station->
m_recovery
)
112
{
113
NS_ASSERT
(station->
m_retry
>= 1);
114
if
(station->
m_retry
== 1)
115
{
116
// need recovery fallback
117
if
(station->
m_rate
!= 0)
118
{
119
station->
m_rate
--;
120
}
121
}
122
station->
m_timer
= 0;
123
}
124
else
125
{
126
NS_ASSERT
(station->
m_retry
>= 1);
127
if
(((station->
m_retry
- 1) % 2) == 1)
128
{
129
// need normal fallback
130
if
(station->
m_rate
!= 0)
131
{
132
station->
m_rate
--;
133
}
134
}
135
if
(station->
m_retry
>= 2)
136
{
137
station->
m_timer
= 0;
138
}
139
}
140
}
141
void
142
ArfWifiManager::DoReportRxOk
(
WifiRemoteStation
*station,
143
double
rxSnr,
WifiMode
txMode)
144
{
145
}
146
void
ArfWifiManager::DoReportRtsOk
(
WifiRemoteStation
*station,
147
double
ctsSnr,
WifiMode
ctsMode,
double
rtsSnr)
148
{
149
NS_LOG_DEBUG
(
"station="
<< station <<
" rts ok"
);
150
}
151
void
ArfWifiManager::DoReportDataOk
(
WifiRemoteStation
*st,
152
double
ackSnr,
WifiMode
ackMode,
double
dataSnr)
153
{
154
ArfWifiRemoteStation
*station = (
ArfWifiRemoteStation
*) st;
155
station->
m_timer
++;
156
station->
m_success
++;
157
station->
m_failed
= 0;
158
station->
m_recovery
=
false
;
159
station->
m_retry
= 0;
160
NS_LOG_DEBUG
(
"station="
<< station <<
" data ok success="
<< station->
m_success
<<
", timer="
<< station->
m_timer
);
161
if
((station->
m_success
==
m_successThreshold
162
|| station->
m_timer
==
m_timerThreshold
)
163
&& (station->
m_rate
< (station->
m_state
->
m_operationalRateSet
.size () - 1)))
164
{
165
NS_LOG_DEBUG
(
"station="
<< station <<
" inc rate"
);
166
station->
m_rate
++;
167
station->
m_timer
= 0;
168
station->
m_success
= 0;
169
station->
m_recovery
=
true
;
170
}
171
}
172
void
173
ArfWifiManager::DoReportFinalRtsFailed
(
WifiRemoteStation
*station)
174
{
175
}
176
void
177
ArfWifiManager::DoReportFinalDataFailed
(
WifiRemoteStation
*station)
178
{
179
}
180
181
WifiMode
182
ArfWifiManager::DoGetDataMode
(
WifiRemoteStation
*st, uint32_t size)
183
{
184
ArfWifiRemoteStation
*station = (
ArfWifiRemoteStation
*) st;
185
return
GetSupported
(station, station->
m_rate
);
186
}
187
WifiMode
188
ArfWifiManager::DoGetRtsMode
(
WifiRemoteStation
*st)
189
{
190
// XXX: we could/should implement the Arf algorithm for
191
// RTS only by picking a single rate within the BasicRateSet.
192
ArfWifiRemoteStation
*station = (
ArfWifiRemoteStation
*) st;
193
return
GetSupported
(station, 0);
194
}
195
196
bool
197
ArfWifiManager::IsLowLatency
(
void
)
const
198
{
199
return
true
;
200
}
201
202
}
// namespace ns3
src
wifi
model
arf-wifi-manager.cc
Generated on Fri Dec 21 2012 19:00:48 for ns-3 by
1.8.1.2