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
cara-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: Federico Maguolo <maguolof@dei.unipd.it>
19
*/
20
21
#include "
cara-wifi-manager.h
"
22
#include "ns3/assert.h"
23
#include "ns3/log.h"
24
#include "ns3/double.h"
25
#include "ns3/uinteger.h"
26
#include "ns3/simulator.h"
27
28
NS_LOG_COMPONENT_DEFINE
(
"Cara"
);
29
30
31
namespace
ns3 {
32
33
struct
CaraWifiRemoteStation
:
public
WifiRemoteStation
34
{
35
uint32_t
m_timer
;
36
uint32_t
m_success
;
37
uint32_t
m_failed
;
38
uint32_t
m_rate
;
39
};
40
41
NS_OBJECT_ENSURE_REGISTERED
(
CaraWifiManager
);
42
43
TypeId
44
CaraWifiManager::GetTypeId
(
void
)
45
{
46
static
TypeId
tid =
TypeId
(
"ns3::CaraWifiManager"
)
47
.
SetParent
<
WifiRemoteStationManager
> ()
48
.AddConstructor<CaraWifiManager> ()
49
.AddAttribute (
"ProbeThreshold"
,
50
"The number of consecutive transmissions failure to activate the RTS probe."
,
51
UintegerValue
(1),
52
MakeUintegerAccessor (&
CaraWifiManager::m_probeThreshold
),
53
MakeUintegerChecker<uint32_t> ())
54
.AddAttribute (
"FailureThreshold"
,
55
"The number of consecutive transmissions failure to decrease the rate."
,
56
UintegerValue
(2),
57
MakeUintegerAccessor (&
CaraWifiManager::m_failureThreshold
),
58
MakeUintegerChecker<uint32_t> ())
59
.AddAttribute (
"SuccessThreshold"
,
60
"The minimum number of sucessfull transmissions to try a new rate."
,
61
UintegerValue
(10),
62
MakeUintegerAccessor (&
CaraWifiManager::m_successThreshold
),
63
MakeUintegerChecker<uint32_t> ())
64
.AddAttribute (
"Timeout"
,
65
"The 'timer' in the CARA algorithm"
,
66
UintegerValue
(15),
67
MakeUintegerAccessor (&
CaraWifiManager::m_timerTimeout
),
68
MakeUintegerChecker<uint32_t> ())
69
;
70
return
tid;
71
}
72
73
CaraWifiManager::CaraWifiManager
()
74
:
WifiRemoteStationManager
()
75
{
76
}
77
CaraWifiManager::~CaraWifiManager
()
78
{
79
}
80
81
WifiRemoteStation
*
82
CaraWifiManager::DoCreateStation
(
void
)
const
83
{
84
CaraWifiRemoteStation
*station =
new
CaraWifiRemoteStation
();
85
station->
m_rate
= 0;
86
station->
m_success
= 0;
87
station->
m_failed
= 0;
88
station->
m_timer
= 0;
89
return
station;
90
}
91
92
void
93
CaraWifiManager::DoReportRtsFailed
(
WifiRemoteStation
*st)
94
{
95
}
96
97
void
98
CaraWifiManager::DoReportDataFailed
(
WifiRemoteStation
*st)
99
{
100
CaraWifiRemoteStation
*station = (
CaraWifiRemoteStation
*) st;
101
NS_LOG_FUNCTION
(station);
102
station->
m_timer
++;
103
station->
m_failed
++;
104
station->
m_success
= 0;
105
if
(station->
m_failed
>=
m_failureThreshold
)
106
{
107
NS_LOG_DEBUG
(
"self="
<< station <<
" dec rate"
);
108
if
(station->
m_rate
!= 0)
109
{
110
station->
m_rate
--;
111
}
112
station->
m_failed
= 0;
113
station->
m_timer
= 0;
114
}
115
}
116
void
117
CaraWifiManager::DoReportRxOk
(
WifiRemoteStation
*st,
118
double
rxSnr,
WifiMode
txMode)
119
{
120
}
121
void
122
CaraWifiManager::DoReportRtsOk
(
WifiRemoteStation
*st,
123
double
ctsSnr,
WifiMode
ctsMode,
double
rtsSnr)
124
{
125
NS_LOG_DEBUG
(
"self="
<< st <<
" rts ok"
);
126
}
127
void
128
CaraWifiManager::DoReportDataOk
(
WifiRemoteStation
*st,
129
double
ackSnr,
WifiMode
ackMode,
double
dataSnr)
130
{
131
CaraWifiRemoteStation
*station = (
CaraWifiRemoteStation
*) st;
132
station->
m_timer
++;
133
station->
m_success
++;
134
station->
m_failed
= 0;
135
NS_LOG_DEBUG
(
"self="
<< station <<
" data ok success="
<< station->
m_success
<<
", timer="
<< station->
m_timer
);
136
if
((station->
m_success
==
m_successThreshold
137
|| station->
m_timer
>=
m_timerTimeout
))
138
{
139
if
(station->
m_rate
<
GetNSupported
(station) - 1)
140
{
141
station->
m_rate
++;
142
}
143
NS_LOG_DEBUG
(
"self="
<< station <<
" inc rate="
<< station->
m_rate
);
144
station->
m_timer
= 0;
145
station->
m_success
= 0;
146
}
147
}
148
void
149
CaraWifiManager::DoReportFinalRtsFailed
(
WifiRemoteStation
*st)
150
{
151
}
152
void
153
CaraWifiManager::DoReportFinalDataFailed
(
WifiRemoteStation
*st)
154
{
155
}
156
157
WifiMode
158
CaraWifiManager::DoGetDataMode
(
WifiRemoteStation
*st,
159
uint32_t size)
160
{
161
CaraWifiRemoteStation
*station = (
CaraWifiRemoteStation
*) st;
162
return
GetSupported
(station, station->
m_rate
);
163
}
164
WifiMode
165
CaraWifiManager::DoGetRtsMode
(
WifiRemoteStation
*st)
166
{
167
// XXX: we could/should implement the Arf algorithm for
168
// RTS only by picking a single rate within the BasicRateSet.
169
return
GetSupported
(st, 0);
170
}
171
172
bool
173
CaraWifiManager::DoNeedRts
(
WifiRemoteStation
*st,
174
Ptr<const Packet>
packet,
bool
normally)
175
{
176
CaraWifiRemoteStation
*station = (
CaraWifiRemoteStation
*) st;
177
return
normally || station->
m_failed
>=
m_probeThreshold
;
178
}
179
180
bool
181
CaraWifiManager::IsLowLatency
(
void
)
const
182
{
183
return
true
;
184
}
185
186
}
// namespace ns3
src
wifi
model
cara-wifi-manager.cc
Generated on Tue Oct 9 2012 16:45:48 for ns-3 by
1.8.1.2