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
NS_LOG_FUNCTION
(
this
);
69
}
70
ArfWifiManager::~ArfWifiManager
()
71
{
72
NS_LOG_FUNCTION
(
this
);
73
}
74
WifiRemoteStation
*
75
ArfWifiManager::DoCreateStation
(
void
)
const
76
{
77
NS_LOG_FUNCTION
(
this
);
78
ArfWifiRemoteStation
*station =
new
ArfWifiRemoteStation
();
79
80
station->
m_successThreshold
=
m_successThreshold
;
81
station->
m_timerTimeout
=
m_timerThreshold
;
82
station->
m_rate
= 0;
83
station->
m_success
= 0;
84
station->
m_failed
= 0;
85
station->
m_recovery
=
false
;
86
station->
m_retry
= 0;
87
station->
m_timer
= 0;
88
89
return
station;
90
}
91
92
void
93
ArfWifiManager::DoReportRtsFailed
(
WifiRemoteStation
*station)
94
{
95
NS_LOG_FUNCTION
(
this
<< station);
96
}
106
void
107
ArfWifiManager::DoReportDataFailed
(
WifiRemoteStation
*st)
108
{
109
NS_LOG_FUNCTION
(
this
<< st);
110
ArfWifiRemoteStation
*station = (
ArfWifiRemoteStation
*)st;
111
station->
m_timer
++;
112
station->
m_failed
++;
113
station->
m_retry
++;
114
station->
m_success
= 0;
115
116
if
(station->
m_recovery
)
117
{
118
NS_ASSERT
(station->
m_retry
>= 1);
119
if
(station->
m_retry
== 1)
120
{
121
// need recovery fallback
122
if
(station->
m_rate
!= 0)
123
{
124
station->
m_rate
--;
125
}
126
}
127
station->
m_timer
= 0;
128
}
129
else
130
{
131
NS_ASSERT
(station->
m_retry
>= 1);
132
if
(((station->
m_retry
- 1) % 2) == 1)
133
{
134
// need normal fallback
135
if
(station->
m_rate
!= 0)
136
{
137
station->
m_rate
--;
138
}
139
}
140
if
(station->
m_retry
>= 2)
141
{
142
station->
m_timer
= 0;
143
}
144
}
145
}
146
void
147
ArfWifiManager::DoReportRxOk
(
WifiRemoteStation
*station,
148
double
rxSnr,
WifiMode
txMode)
149
{
150
NS_LOG_FUNCTION
(
this
<< station << rxSnr << txMode);
151
}
152
void
ArfWifiManager::DoReportRtsOk
(
WifiRemoteStation
*station,
153
double
ctsSnr,
WifiMode
ctsMode,
double
rtsSnr)
154
{
155
NS_LOG_FUNCTION
(
this
<< station << ctsSnr << ctsMode << rtsSnr);
156
NS_LOG_DEBUG
(
"station="
<< station <<
" rts ok"
);
157
}
158
void
ArfWifiManager::DoReportDataOk
(
WifiRemoteStation
*st,
159
double
ackSnr,
WifiMode
ackMode,
double
dataSnr)
160
{
161
NS_LOG_FUNCTION
(
this
<< st << ackSnr << ackMode << dataSnr);
162
ArfWifiRemoteStation
*station = (
ArfWifiRemoteStation
*) st;
163
station->
m_timer
++;
164
station->
m_success
++;
165
station->
m_failed
= 0;
166
station->
m_recovery
=
false
;
167
station->
m_retry
= 0;
168
NS_LOG_DEBUG
(
"station="
<< station <<
" data ok success="
<< station->
m_success
<<
", timer="
<< station->
m_timer
);
169
if
((station->
m_success
==
m_successThreshold
170
|| station->
m_timer
==
m_timerThreshold
)
171
&& (station->
m_rate
< (station->
m_state
->
m_operationalRateSet
.size () - 1)))
172
{
173
NS_LOG_DEBUG
(
"station="
<< station <<
" inc rate"
);
174
station->
m_rate
++;
175
station->
m_timer
= 0;
176
station->
m_success
= 0;
177
station->
m_recovery
=
true
;
178
}
179
}
180
void
181
ArfWifiManager::DoReportFinalRtsFailed
(
WifiRemoteStation
*station)
182
{
183
NS_LOG_FUNCTION
(
this
<< station);
184
}
185
void
186
ArfWifiManager::DoReportFinalDataFailed
(
WifiRemoteStation
*station)
187
{
188
NS_LOG_FUNCTION
(
this
<< station);
189
}
190
191
WifiMode
192
ArfWifiManager::DoGetDataMode
(
WifiRemoteStation
*st, uint32_t size)
193
{
194
NS_LOG_FUNCTION
(
this
<< st << size);
195
ArfWifiRemoteStation
*station = (
ArfWifiRemoteStation
*) st;
196
return
GetSupported
(station, station->
m_rate
);
197
}
198
WifiMode
199
ArfWifiManager::DoGetRtsMode
(
WifiRemoteStation
*st)
200
{
201
NS_LOG_FUNCTION
(
this
<< st);
202
// XXX: we could/should implement the Arf algorithm for
203
// RTS only by picking a single rate within the BasicRateSet.
204
ArfWifiRemoteStation
*station = (
ArfWifiRemoteStation
*) st;
205
return
GetSupported
(station, 0);
206
}
207
208
bool
209
ArfWifiManager::IsLowLatency
(
void
)
const
210
{
211
NS_LOG_FUNCTION
(
this
);
212
return
true
;
213
}
214
215
}
// namespace ns3
src
wifi
model
arf-wifi-manager.cc
Generated on Tue May 14 2013 11:08:35 for ns-3 by
1.8.1.2