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