153 { |
153 { |
154 TRACE ("send probe request"); |
154 TRACE ("send probe request"); |
155 WifiMacHeader hdr; |
155 WifiMacHeader hdr; |
156 hdr.SetProbeReq (); |
156 hdr.SetProbeReq (); |
157 hdr.SetAddr1 (GetBroadcastBssid ()); |
157 hdr.SetAddr1 (GetBroadcastBssid ()); |
158 hdr.SetAddr2 (m_interface->GetSelfAddress ()); |
158 hdr.SetAddr2 (m_device->GetSelfAddress ()); |
159 hdr.SetAddr3 (GetBroadcastBssid ()); |
159 hdr.SetAddr3 (GetBroadcastBssid ()); |
160 hdr.SetDsNotFrom (); |
160 hdr.SetDsNotFrom (); |
161 hdr.SetDsNotTo (); |
161 hdr.SetDsNotTo (); |
162 Packet packet; |
162 Packet packet; |
163 MgtProbeRequestHeader probe; |
163 MgtProbeRequestHeader probe; |
164 probe.SetSsid (m_interface->GetSsid ()); |
164 probe.SetSsid (m_device->GetSsid ()); |
165 SupportedRates rates = GetSupportedRates (); |
165 SupportedRates rates = GetSupportedRates (); |
166 probe.SetSupportedRates (rates); |
166 probe.SetSupportedRates (rates); |
167 packet.AddHeader (probe); |
167 packet.AddHeader (probe); |
168 |
168 |
169 m_dca->Queue (packet, hdr); |
169 m_dca->Queue (packet, hdr); |
177 { |
177 { |
178 TRACE ("send assoc request"); |
178 TRACE ("send assoc request"); |
179 WifiMacHeader hdr; |
179 WifiMacHeader hdr; |
180 hdr.SetAssocReq (); |
180 hdr.SetAssocReq (); |
181 hdr.SetAddr1 (GetBssid ()); |
181 hdr.SetAddr1 (GetBssid ()); |
182 hdr.SetAddr2 (m_interface->GetSelfAddress ()); |
182 hdr.SetAddr2 (m_device->GetSelfAddress ()); |
183 hdr.SetAddr3 (GetBssid ()); |
183 hdr.SetAddr3 (GetBssid ()); |
184 hdr.SetDsNotFrom (); |
184 hdr.SetDsNotFrom (); |
185 hdr.SetDsNotTo (); |
185 hdr.SetDsNotTo (); |
186 Packet packet; |
186 Packet packet; |
187 MgtAssocRequestHeader assoc; |
187 MgtAssocRequestHeader assoc; |
188 assoc.SetSsid (m_interface->GetSsid ()); |
188 assoc.SetSsid (m_device->GetSsid ()); |
189 SupportedRates rates = GetSupportedRates (); |
189 SupportedRates rates = GetSupportedRates (); |
190 assoc.SetSupportedRates (rates); |
190 assoc.SetSupportedRates (rates); |
191 packet.AddHeader (assoc); |
191 packet.AddHeader (assoc); |
192 |
192 |
193 m_dca->Queue (packet, hdr); |
193 m_dca->Queue (packet, hdr); |
285 } |
285 } |
286 //TRACE ("enqueue size="<<packet.GetSize ()<<", to="<<to); |
286 //TRACE ("enqueue size="<<packet.GetSize ()<<", to="<<to); |
287 WifiMacHeader hdr; |
287 WifiMacHeader hdr; |
288 hdr.SetTypeData (); |
288 hdr.SetTypeData (); |
289 hdr.SetAddr1 (GetBssid ()); |
289 hdr.SetAddr1 (GetBssid ()); |
290 hdr.SetAddr2 (m_interface->GetSelfAddress ()); |
290 hdr.SetAddr2 (m_device->GetSelfAddress ()); |
291 hdr.SetAddr3 (to); |
291 hdr.SetAddr3 (to); |
292 hdr.SetDsNotFrom (); |
292 hdr.SetDsNotFrom (); |
293 hdr.SetDsTo (); |
293 hdr.SetDsTo (); |
294 m_dca->Queue (packet, hdr); |
294 m_dca->Queue (packet, hdr); |
295 } |
295 } |
296 |
296 |
297 void |
297 void |
298 MacHighNqsta::Receive (Packet packet, WifiMacHeader const *hdr) |
298 MacHighNqsta::Receive (Packet packet, WifiMacHeader const *hdr) |
299 { |
299 { |
300 NS_ASSERT (!hdr->IsCtl ()); |
300 NS_ASSERT (!hdr->IsCtl ()); |
301 if (hdr->GetAddr1 () != m_interface->GetSelfAddress () && |
301 if (hdr->GetAddr1 () != m_device->GetSelfAddress () && |
302 !hdr->GetAddr1 ().IsBroadcast ()) |
302 !hdr->GetAddr1 ().IsBroadcast ()) |
303 { |
303 { |
304 // packet is not for us |
304 // packet is not for us |
305 } |
305 } |
306 else if (hdr->IsData ()) |
306 else if (hdr->IsData ()) |
307 { |
307 { |
308 m_forward (packet); |
308 m_forward (packet, hdr->GetAddr2 ()); |
309 } |
309 } |
310 else if (hdr->IsProbeReq () || |
310 else if (hdr->IsProbeReq () || |
311 hdr->IsAssocReq ()) |
311 hdr->IsAssocReq ()) |
312 { |
312 { |
313 /* this is a frame aimed at an AP. |
313 /* this is a frame aimed at an AP. |
317 else if (hdr->IsBeacon ()) |
317 else if (hdr->IsBeacon ()) |
318 { |
318 { |
319 MgtBeaconHeader beacon; |
319 MgtBeaconHeader beacon; |
320 packet.RemoveHeader (beacon); |
320 packet.RemoveHeader (beacon); |
321 bool goodBeacon = false; |
321 bool goodBeacon = false; |
322 if (m_interface->GetSsid ().IsBroadcast ()) |
322 if (m_device->GetSsid ().IsBroadcast ()) |
323 { |
323 { |
324 // we do not have any special ssid so this |
324 // we do not have any special ssid so this |
325 // beacon is as good as another. |
325 // beacon is as good as another. |
326 Time delay = MicroSeconds (beacon.GetBeaconIntervalUs () * m_maxMissedBeacons); |
326 Time delay = MicroSeconds (beacon.GetBeaconIntervalUs () * m_maxMissedBeacons); |
327 RestartBeaconWatchdog (delay); |
327 RestartBeaconWatchdog (delay); |
328 goodBeacon = true; |
328 goodBeacon = true; |
329 } |
329 } |
330 else if (beacon.GetSsid ().IsEqual (m_interface->GetSsid ())) |
330 else if (beacon.GetSsid ().IsEqual (m_device->GetSsid ())) |
331 { |
331 { |
332 //beacon for our ssid. |
332 //beacon for our ssid. |
333 Time delay = MicroSeconds (beacon.GetBeaconIntervalUs () * m_maxMissedBeacons); |
333 Time delay = MicroSeconds (beacon.GetBeaconIntervalUs () * m_maxMissedBeacons); |
334 RestartBeaconWatchdog (delay); |
334 RestartBeaconWatchdog (delay); |
335 goodBeacon = true; |
335 goodBeacon = true; |
348 { |
348 { |
349 if (m_state == WAIT_PROBE_RESP) |
349 if (m_state == WAIT_PROBE_RESP) |
350 { |
350 { |
351 MgtProbeResponseHeader probeResp; |
351 MgtProbeResponseHeader probeResp; |
352 packet.RemoveHeader (probeResp); |
352 packet.RemoveHeader (probeResp); |
353 if (!probeResp.GetSsid ().IsEqual (m_interface->GetSsid ())) |
353 if (!probeResp.GetSsid ().IsEqual (m_device->GetSsid ())) |
354 { |
354 { |
355 //not a probe resp for our ssid. |
355 //not a probe resp for our ssid. |
356 return; |
356 return; |
357 } |
357 } |
358 SetBssid (hdr->GetAddr3 ()); |
358 SetBssid (hdr->GetAddr3 ()); |