author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Thu, 08 Nov 2007 15:25:57 +0100 | |
changeset 2090 | 3622fda1717b |
parent 2054 | ba8e810bae4c |
child 2156 | 754a843db672 |
permissions | -rw-r--r-- |
1948 | 1 |
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 |
/* |
|
3 |
* Copyright (c) 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 "ns3/packet.h" |
|
22 |
#include "ns3/simulator.h" |
|
23 |
#include "ns3/assert.h" |
|
2012
54dd9789c670
enable logging
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2009
diff
changeset
|
24 |
#include "ns3/log.h" |
1948 | 25 |
|
26 |
#include "mac-high-nqsta.h" |
|
27 |
#include "wifi-mac-header.h" |
|
28 |
#include "wifi-net-device.h" |
|
29 |
#include "mgt-headers.h" |
|
30 |
#include "wifi-phy.h" |
|
31 |
#include "dca-txop.h" |
|
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
32 |
#include "mac-stations.h" |
1948 | 33 |
|
2012
54dd9789c670
enable logging
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2009
diff
changeset
|
34 |
NS_LOG_COMPONENT_DEFINE ("MacHighNqsta"); |
1948 | 35 |
|
2012
54dd9789c670
enable logging
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2009
diff
changeset
|
36 |
#define TRACE(x) \ |
54dd9789c670
enable logging
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2009
diff
changeset
|
37 |
NS_LOG_DEBUG (Simulator::Now () << " " << x); |
1948 | 38 |
|
39 |
/* |
|
40 |
* The state machine for this NQSTA is: |
|
41 |
-------------- ----------- |
|
42 |
| Associated | <-------------------- -------> | Refused | |
|
43 |
-------------- \ / ----------- |
|
44 |
\ \ / |
|
45 |
\ ----------------- ----------------------------- |
|
46 |
\-> | Beacon Missed | --> | Wait Association Response | |
|
47 |
----------------- ----------------------------- |
|
48 |
\ ^ |
|
49 |
\ | |
|
50 |
\ ----------------------- |
|
51 |
\-> | Wait Probe Response | |
|
52 |
----------------------- |
|
53 |
*/ |
|
54 |
||
55 |
||
56 |
namespace ns3 { |
|
57 |
||
58 |
MacHighNqsta::MacHighNqsta () |
|
59 |
: m_state (BEACON_MISSED), |
|
60 |
m_probeRequestTimeout (Seconds (0.5)), |
|
61 |
m_assocRequestTimeout (Seconds (0.5)), |
|
62 |
m_probeRequestEvent (), |
|
63 |
m_assocRequestEvent (), |
|
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
64 |
m_beaconWatchdogEnd (Seconds (0.0)) |
1948 | 65 |
{ |
66 |
// this is the default value for the number of beacons missed |
|
67 |
// before attempting to reassociate. |
|
68 |
m_maxMissedBeacons = 10; |
|
69 |
} |
|
70 |
||
71 |
MacHighNqsta::~MacHighNqsta () |
|
2054
ba8e810bae4c
derive WifiPhy from Object and manage it with a Ptr<>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2012
diff
changeset
|
72 |
{ |
ba8e810bae4c
derive WifiPhy from Object and manage it with a Ptr<>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2012
diff
changeset
|
73 |
m_phy = 0; |
ba8e810bae4c
derive WifiPhy from Object and manage it with a Ptr<>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2012
diff
changeset
|
74 |
} |
1948 | 75 |
|
76 |
void |
|
77 |
MacHighNqsta::SetDcaTxop (DcaTxop *dca) |
|
78 |
{ |
|
79 |
m_dca = dca; |
|
80 |
} |
|
81 |
void |
|
1964
041240a915f8
build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1952
diff
changeset
|
82 |
MacHighNqsta::SetDevice (WifiNetDevice *device) |
1948 | 83 |
{ |
1964
041240a915f8
build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1952
diff
changeset
|
84 |
m_device = device; |
1948 | 85 |
} |
86 |
void |
|
87 |
MacHighNqsta::SetForwardCallback (ForwardCallback callback) |
|
88 |
{ |
|
89 |
m_forward = callback; |
|
90 |
} |
|
91 |
void |
|
92 |
MacHighNqsta::SetAssociatedCallback (AssociatedCallback callback) |
|
93 |
{ |
|
94 |
m_associatedCallback = callback; |
|
95 |
} |
|
96 |
void |
|
97 |
MacHighNqsta::SetDisAssociatedCallback (DisAssociatedCallback callback) |
|
98 |
{ |
|
99 |
m_disAssociatedCallback = callback; |
|
100 |
} |
|
101 |
void |
|
2054
ba8e810bae4c
derive WifiPhy from Object and manage it with a Ptr<>
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2012
diff
changeset
|
102 |
MacHighNqsta::SetPhy (Ptr<WifiPhy> phy) |
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
103 |
{ |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
104 |
m_phy = phy; |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
105 |
} |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
106 |
void |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
107 |
MacHighNqsta::SetStations (MacStations *stations) |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
108 |
{ |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
109 |
m_stations = stations; |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
110 |
} |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
111 |
|
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
112 |
void |
1948 | 113 |
MacHighNqsta::SetMaxMissedBeacons (uint32_t missed) |
114 |
{ |
|
115 |
m_maxMissedBeacons = missed; |
|
116 |
} |
|
117 |
void |
|
118 |
MacHighNqsta::SetProbeRequestTimeout (Time timeout) |
|
119 |
{ |
|
120 |
m_probeRequestTimeout = timeout; |
|
121 |
} |
|
122 |
void |
|
123 |
MacHighNqsta::SetAssocRequestTimeout (Time timeout) |
|
124 |
{ |
|
125 |
m_assocRequestTimeout = timeout; |
|
126 |
} |
|
127 |
||
128 |
Mac48Address |
|
129 |
MacHighNqsta::GetBssid (void) const |
|
130 |
{ |
|
131 |
return m_bssid; |
|
132 |
} |
|
133 |
void |
|
134 |
MacHighNqsta::SetBssid (Mac48Address bssid) |
|
135 |
{ |
|
136 |
m_bssid = bssid; |
|
137 |
||
138 |
} |
|
139 |
void |
|
140 |
MacHighNqsta::StartActiveAssociation (void) |
|
141 |
{ |
|
142 |
TryToEnsureAssociated (); |
|
143 |
} |
|
144 |
||
145 |
Mac48Address |
|
146 |
MacHighNqsta::GetBroadcastBssid (void) |
|
147 |
{ |
|
148 |
return Mac48Address::GetBroadcast (); |
|
149 |
} |
|
150 |
||
151 |
void |
|
152 |
MacHighNqsta::SendProbeRequest (void) |
|
153 |
{ |
|
154 |
TRACE ("send probe request"); |
|
155 |
WifiMacHeader hdr; |
|
156 |
hdr.SetProbeReq (); |
|
157 |
hdr.SetAddr1 (GetBroadcastBssid ()); |
|
1964
041240a915f8
build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1952
diff
changeset
|
158 |
hdr.SetAddr2 (m_device->GetSelfAddress ()); |
1948 | 159 |
hdr.SetAddr3 (GetBroadcastBssid ()); |
160 |
hdr.SetDsNotFrom (); |
|
161 |
hdr.SetDsNotTo (); |
|
162 |
Packet packet; |
|
163 |
MgtProbeRequestHeader probe; |
|
1964
041240a915f8
build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1952
diff
changeset
|
164 |
probe.SetSsid (m_device->GetSsid ()); |
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
165 |
probe.SetSupportedRates (GetSupportedRates ()); |
1948 | 166 |
packet.AddHeader (probe); |
167 |
||
168 |
m_dca->Queue (packet, hdr); |
|
169 |
||
170 |
m_probeRequestEvent = Simulator::Schedule (m_probeRequestTimeout, |
|
171 |
&MacHighNqsta::ProbeRequestTimeout, this); |
|
172 |
} |
|
173 |
||
174 |
void |
|
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
175 |
MacHighNqsta::SendAssociationRequest (void) |
1948 | 176 |
{ |
2012
54dd9789c670
enable logging
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2009
diff
changeset
|
177 |
TRACE ("send assoc request to=" << GetBssid ()); |
1948 | 178 |
WifiMacHeader hdr; |
179 |
hdr.SetAssocReq (); |
|
180 |
hdr.SetAddr1 (GetBssid ()); |
|
1964
041240a915f8
build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1952
diff
changeset
|
181 |
hdr.SetAddr2 (m_device->GetSelfAddress ()); |
1948 | 182 |
hdr.SetAddr3 (GetBssid ()); |
183 |
hdr.SetDsNotFrom (); |
|
184 |
hdr.SetDsNotTo (); |
|
185 |
Packet packet; |
|
186 |
MgtAssocRequestHeader assoc; |
|
1964
041240a915f8
build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1952
diff
changeset
|
187 |
assoc.SetSsid (m_device->GetSsid ()); |
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
188 |
assoc.SetSupportedRates (GetSupportedRates ()); |
1948 | 189 |
packet.AddHeader (assoc); |
190 |
||
191 |
m_dca->Queue (packet, hdr); |
|
192 |
||
193 |
m_assocRequestEvent = Simulator::Schedule (m_assocRequestTimeout, |
|
194 |
&MacHighNqsta::AssocRequestTimeout, this); |
|
195 |
} |
|
196 |
void |
|
197 |
MacHighNqsta::TryToEnsureAssociated (void) |
|
198 |
{ |
|
199 |
switch (m_state) { |
|
200 |
case ASSOCIATED: |
|
201 |
return; |
|
202 |
break; |
|
203 |
case WAIT_PROBE_RESP: |
|
204 |
/* we have sent a probe request earlier so we |
|
205 |
do not need to re-send a probe request immediately. |
|
206 |
We just need to wait until probe-request-timeout |
|
207 |
or until we get a probe response |
|
208 |
*/ |
|
209 |
break; |
|
210 |
case BEACON_MISSED: |
|
211 |
/* we were associated but we missed a bunch of beacons |
|
212 |
* so we should assume we are not associated anymore. |
|
213 |
* We try to initiate a probe request now. |
|
214 |
*/ |
|
215 |
m_disAssociatedCallback (); |
|
216 |
m_state = WAIT_PROBE_RESP; |
|
217 |
SendProbeRequest (); |
|
218 |
break; |
|
219 |
case WAIT_ASSOC_RESP: |
|
220 |
/* we have sent an assoc request so we do not need to |
|
221 |
re-send an assoc request right now. We just need to |
|
222 |
wait until either assoc-request-timeout or until |
|
223 |
we get an assoc response. |
|
224 |
*/ |
|
225 |
break; |
|
226 |
case REFUSED: |
|
227 |
/* we have sent an assoc request and received a negative |
|
228 |
assoc resp. We wait until someone restarts an |
|
229 |
association with a given ssid. |
|
230 |
*/ |
|
231 |
break; |
|
232 |
} |
|
233 |
} |
|
234 |
||
235 |
void |
|
236 |
MacHighNqsta::AssocRequestTimeout (void) |
|
237 |
{ |
|
238 |
TRACE ("assoc request timeout"); |
|
239 |
m_state = WAIT_ASSOC_RESP; |
|
240 |
SendAssociationRequest (); |
|
241 |
} |
|
242 |
void |
|
243 |
MacHighNqsta::ProbeRequestTimeout (void) |
|
244 |
{ |
|
245 |
TRACE ("probe request timeout"); |
|
246 |
m_state = WAIT_PROBE_RESP; |
|
247 |
SendProbeRequest (); |
|
248 |
} |
|
249 |
void |
|
250 |
MacHighNqsta::MissedBeacons (void) |
|
251 |
{ |
|
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
252 |
if (m_beaconWatchdogEnd > Simulator::Now ()) |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
253 |
{ |
2090
3622fda1717b
calculate the delay, not -delay.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2054
diff
changeset
|
254 |
m_beaconWatchdog = Simulator::Schedule (m_beaconWatchdogEnd - Simulator::Now (), |
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
255 |
&MacHighNqsta::MissedBeacons, this); |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
256 |
return; |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
257 |
} |
1948 | 258 |
m_state = BEACON_MISSED; |
259 |
} |
|
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
260 |
void |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
261 |
MacHighNqsta::RestartBeaconWatchdog (Time delay) |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
262 |
{ |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
263 |
m_beaconWatchdogEnd = std::max (Simulator::Now () + delay, m_beaconWatchdogEnd); |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
264 |
if (Simulator::GetDelayLeft (m_beaconWatchdog) < delay && |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
265 |
m_beaconWatchdog.IsExpired ()) |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
266 |
{ |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
267 |
m_beaconWatchdog = Simulator::Schedule (delay, &MacHighNqsta::MissedBeacons, this); |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
268 |
} |
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
269 |
} |
1948 | 270 |
bool |
271 |
MacHighNqsta::IsAssociated (void) |
|
272 |
{ |
|
273 |
return (m_state == ASSOCIATED)?true:false; |
|
274 |
} |
|
275 |
||
276 |
void |
|
277 |
MacHighNqsta::Queue (Packet packet, Mac48Address to) |
|
278 |
{ |
|
279 |
if (!IsAssociated ()) |
|
280 |
{ |
|
281 |
TryToEnsureAssociated (); |
|
282 |
return; |
|
283 |
} |
|
284 |
//TRACE ("enqueue size="<<packet.GetSize ()<<", to="<<to); |
|
285 |
WifiMacHeader hdr; |
|
286 |
hdr.SetTypeData (); |
|
287 |
hdr.SetAddr1 (GetBssid ()); |
|
1964
041240a915f8
build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1952
diff
changeset
|
288 |
hdr.SetAddr2 (m_device->GetSelfAddress ()); |
1948 | 289 |
hdr.SetAddr3 (to); |
290 |
hdr.SetDsNotFrom (); |
|
291 |
hdr.SetDsTo (); |
|
292 |
m_dca->Queue (packet, hdr); |
|
293 |
} |
|
294 |
||
295 |
void |
|
296 |
MacHighNqsta::Receive (Packet packet, WifiMacHeader const *hdr) |
|
297 |
{ |
|
298 |
NS_ASSERT (!hdr->IsCtl ()); |
|
1964
041240a915f8
build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1952
diff
changeset
|
299 |
if (hdr->GetAddr1 () != m_device->GetSelfAddress () && |
1948 | 300 |
!hdr->GetAddr1 ().IsBroadcast ()) |
301 |
{ |
|
302 |
// packet is not for us |
|
303 |
} |
|
304 |
else if (hdr->IsData ()) |
|
305 |
{ |
|
1964
041240a915f8
build and link
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1952
diff
changeset
|
306 |
m_forward (packet, hdr->GetAddr2 ()); |
1948 | 307 |
} |
308 |
else if (hdr->IsProbeReq () || |
|
309 |
hdr->IsAssocReq ()) |
|
310 |
{ |
|
311 |
/* this is a frame aimed at an AP. |
|
312 |
* so we can safely ignore it. |
|
313 |
*/ |
|
314 |
} |
|
315 |
else if (hdr->IsBeacon ()) |
|
316 |
{ |
|
317 |
MgtBeaconHeader beacon; |
|
318 |
packet.RemoveHeader (beacon); |
|
319 |
bool goodBeacon = false; |
|
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
320 |
if (m_device->GetSsid ().IsBroadcast () || |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
321 |
beacon.GetSsid ().IsEqual (m_device->GetSsid ())) |
1948 | 322 |
{ |
323 |
Time delay = MicroSeconds (beacon.GetBeaconIntervalUs () * m_maxMissedBeacons); |
|
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
324 |
RestartBeaconWatchdog (delay); |
1948 | 325 |
goodBeacon = true; |
326 |
} |
|
327 |
if (goodBeacon) |
|
328 |
{ |
|
329 |
SetBssid (hdr->GetAddr3 ()); |
|
330 |
} |
|
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
331 |
if (goodBeacon && m_state == BEACON_MISSED) |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
332 |
{ |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
333 |
m_state = WAIT_ASSOC_RESP; |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
334 |
SendAssociationRequest (); |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
335 |
} |
1948 | 336 |
} |
337 |
else if (hdr->IsProbeResp ()) |
|
338 |
{ |
|
339 |
if (m_state == WAIT_PROBE_RESP) |
|
340 |
{ |
|
341 |
MgtProbeResponseHeader probeResp; |
|
342 |
packet.RemoveHeader (probeResp); |
|
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
343 |
if (!probeResp.GetSsid ().IsEqual (m_device->GetSsid ())) |
1948 | 344 |
{ |
345 |
//not a probe resp for our ssid. |
|
346 |
return; |
|
347 |
} |
|
348 |
SetBssid (hdr->GetAddr3 ()); |
|
349 |
Time delay = MicroSeconds (probeResp.GetBeaconIntervalUs () * m_maxMissedBeacons); |
|
1952
2ad2630756e3
do not use the Watchdog class
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1951
diff
changeset
|
350 |
RestartBeaconWatchdog (delay); |
1948 | 351 |
if (m_probeRequestEvent.IsRunning ()) |
352 |
{ |
|
353 |
m_probeRequestEvent.Cancel (); |
|
354 |
} |
|
355 |
m_state = WAIT_ASSOC_RESP; |
|
356 |
SendAssociationRequest (); |
|
357 |
} |
|
358 |
} |
|
359 |
else if (hdr->IsAssocResp ()) |
|
360 |
{ |
|
361 |
if (m_state == WAIT_ASSOC_RESP) |
|
362 |
{ |
|
363 |
MgtAssocResponseHeader assocResp; |
|
364 |
packet.RemoveHeader (assocResp); |
|
365 |
if (m_assocRequestEvent.IsRunning ()) |
|
366 |
{ |
|
367 |
m_assocRequestEvent.Cancel (); |
|
368 |
} |
|
369 |
if (assocResp.GetStatusCode ().IsSuccess ()) |
|
370 |
{ |
|
371 |
m_state = ASSOCIATED; |
|
372 |
TRACE ("assoc completed"); |
|
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
373 |
SupportedRates rates = assocResp.GetSupportedRates (); |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
374 |
MacStation *ap = m_stations->Lookup (hdr->GetAddr2 ()); |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
375 |
for (uint32_t i = 0; i < m_phy->GetNModes (); i++) |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
376 |
{ |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
377 |
WifiMode mode = m_phy->GetMode (i); |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
378 |
if (rates.IsSupportedRate (mode.GetPhyRate ())) |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
379 |
{ |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
380 |
ap->AddSupportedMode (mode); |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
381 |
if (rates.IsBasicRate (mode.GetPhyRate ())) |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
382 |
{ |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
383 |
m_stations->AddBasicMode (mode); |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
384 |
} |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
385 |
} |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
386 |
} |
1948 | 387 |
m_associatedCallback (); |
388 |
} |
|
389 |
else |
|
390 |
{ |
|
391 |
TRACE ("assoc refused"); |
|
392 |
m_state = REFUSED; |
|
393 |
} |
|
394 |
} |
|
395 |
} |
|
396 |
} |
|
397 |
||
2009
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
398 |
SupportedRates |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
399 |
MacHighNqsta::GetSupportedRates (void) const |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
400 |
{ |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
401 |
SupportedRates rates; |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
402 |
for (uint32_t i = 0; i < m_phy->GetNModes (); i++) |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
403 |
{ |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
404 |
WifiMode mode = m_phy->GetMode (i); |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
405 |
rates.AddSupportedRate (mode.GetPhyRate ()); |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
406 |
} |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
407 |
return rates; |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
408 |
} |
afed751cc0b5
dynamically update the list of supported rates based on the ap supported rates
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1964
diff
changeset
|
409 |
|
1948 | 410 |
} // namespace ns3 |