LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 IITP RAS | 3 * Copyright (c) 2009 IITP RAS |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 * Correct channel switching is: | 201 * Correct channel switching is: |
202 * | 202 * |
203 * 1. Interface down, e.g. to stop packets from layer 3 | 203 * 1. Interface down, e.g. to stop packets from layer 3 |
204 * 2. Wait before all output queues will be empty | 204 * 2. Wait before all output queues will be empty |
205 * 3. Switch PHY channel | 205 * 3. Switch PHY channel |
206 * 4. Interface up | 206 * 4. Interface up |
207 * | 207 * |
208 * Now we use dirty channel switch -- just change frequency | 208 * Now we use dirty channel switch -- just change frequency |
209 */ | 209 */ |
210 Ptr<YansWifiPhy> phy = m_phy->GetObject<YansWifiPhy> (); | 210 Ptr<YansWifiPhy> phy = m_phy->GetObject<YansWifiPhy> (); |
211 phy->SetChannelNumber (static_cast<uint8_t>(new_id)); | 211 phy->SetChannelNumber (static_cast<uint8_t> (new_id)); |
212 // Don't know NAV on new channel | 212 // Don't know NAV on new channel |
213 m_dcfManager->NotifyNavResetNow (Seconds (0)); | 213 m_dcfManager->NotifyNavResetNow (Seconds (0)); |
214 } | 214 } |
215 //----------------------------------------------------------------------------- | 215 //----------------------------------------------------------------------------- |
216 // Forward frame down | 216 // Forward frame down |
217 //----------------------------------------------------------------------------- | 217 //----------------------------------------------------------------------------- |
218 void | 218 void |
219 MeshWifiInterfaceMac::ForwardDown (Ptr<const Packet> const_packet, Mac48Address
from, Mac48Address to) | 219 MeshWifiInterfaceMac::ForwardDown (Ptr<const Packet> const_packet, Mac48Address
from, Mac48Address to) |
220 { | 220 { |
221 // copy packet to allow modifications | 221 // copy packet to allow modifications |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 SupportedRates | 314 SupportedRates |
315 MeshWifiInterfaceMac::GetSupportedRates () const | 315 MeshWifiInterfaceMac::GetSupportedRates () const |
316 { | 316 { |
317 // set the set of supported rates and make sure that we indicate | 317 // set the set of supported rates and make sure that we indicate |
318 // the Basic Rate set in this set of supported rates. | 318 // the Basic Rate set in this set of supported rates. |
319 SupportedRates rates; | 319 SupportedRates rates; |
320 for (uint8_t i = 0; i < m_phy->GetNModes (); i++) | 320 for (uint8_t i = 0; i < m_phy->GetNModes (); i++) |
321 { | 321 { |
322 WifiMode mode = m_phy->GetMode (i); | 322 WifiMode mode = m_phy->GetMode (i); |
323 uint16_t gi = ConvertGuardIntervalToNanoSeconds (mode, m_phy->GetShortGuar
dInterval (), m_phy->GetGuardInterval ()); | 323 uint16_t gi = ConvertGuardIntervalToNanoSeconds (mode, m_phy->GetShortGuar
dInterval (), m_phy->GetGuardInterval ()); |
324 rates.AddSupportedRate (static_cast<uint32_t>(mode.GetDataRate (m_phy->Get
ChannelWidth (), gi, 1))); | 324 rates.AddSupportedRate (static_cast<uint32_t> (mode.GetDataRate (m_phy->Ge
tChannelWidth (), gi, 1))); |
325 } | 325 } |
326 // set the basic rates | 326 // set the basic rates |
327 for (uint8_t j = 0; j < m_stationManager->GetNBasicModes (); j++) | 327 for (uint8_t j = 0; j < m_stationManager->GetNBasicModes (); j++) |
328 { | 328 { |
329 WifiMode mode = m_stationManager->GetBasicMode (j); | 329 WifiMode mode = m_stationManager->GetBasicMode (j); |
330 uint16_t gi = ConvertGuardIntervalToNanoSeconds (mode, m_phy->GetShortGuar
dInterval (), m_phy->GetGuardInterval ()); | 330 uint16_t gi = ConvertGuardIntervalToNanoSeconds (mode, m_phy->GetShortGuar
dInterval (), m_phy->GetGuardInterval ()); |
331 rates.SetBasicRate (static_cast<uint32_t>(mode.GetDataRate (m_phy->GetChan
nelWidth (), gi, 1))); | 331 rates.SetBasicRate (static_cast<uint32_t> (mode.GetDataRate (m_phy->GetCha
nnelWidth (), gi, 1))); |
332 } | 332 } |
333 return rates; | 333 return rates; |
334 } | 334 } |
335 bool | 335 bool |
336 MeshWifiInterfaceMac::CheckSupportedRates (SupportedRates rates) const | 336 MeshWifiInterfaceMac::CheckSupportedRates (SupportedRates rates) const |
337 { | 337 { |
338 for (uint8_t i = 0; i < m_stationManager->GetNBasicModes (); i++) | 338 for (uint8_t i = 0; i < m_stationManager->GetNBasicModes (); i++) |
339 { | 339 { |
340 WifiMode mode = m_stationManager->GetBasicMode (i); | 340 WifiMode mode = m_stationManager->GetBasicMode (i); |
341 uint16_t gi = ConvertGuardIntervalToNanoSeconds (mode, m_phy->GetShortGuar
dInterval (), m_phy->GetGuardInterval ()); | 341 uint16_t gi = ConvertGuardIntervalToNanoSeconds (mode, m_phy->GetShortGuar
dInterval (), m_phy->GetGuardInterval ()); |
342 if (!rates.IsSupportedRate (static_cast<uint32_t>(mode.GetDataRate (m_phy-
>GetChannelWidth (), gi, 1)))) | 342 if (!rates.IsSupportedRate (static_cast<uint32_t> (mode.GetDataRate (m_phy
->GetChannelWidth (), gi, 1)))) |
343 { | 343 { |
344 return false; | 344 return false; |
345 } | 345 } |
346 } | 346 } |
347 return true; | 347 return true; |
348 } | 348 } |
349 //----------------------------------------------------------------------------- | 349 //----------------------------------------------------------------------------- |
350 // Beacons | 350 // Beacons |
351 //----------------------------------------------------------------------------- | 351 //----------------------------------------------------------------------------- |
352 void | 352 void |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 // update supported rates | 441 // update supported rates |
442 if (beacon_hdr.GetSsid ().IsEqual (GetSsid ())) | 442 if (beacon_hdr.GetSsid ().IsEqual (GetSsid ())) |
443 { | 443 { |
444 SupportedRates rates = beacon_hdr.GetSupportedRates (); | 444 SupportedRates rates = beacon_hdr.GetSupportedRates (); |
445 | 445 |
446 for (uint8_t i = 0; i < m_phy->GetNModes (); i++) | 446 for (uint8_t i = 0; i < m_phy->GetNModes (); i++) |
447 { | 447 { |
448 WifiMode mode = m_phy->GetMode (i); | 448 WifiMode mode = m_phy->GetMode (i); |
449 uint16_t gi = ConvertGuardIntervalToNanoSeconds (mode, m_phy->GetS
hortGuardInterval (), m_phy->GetGuardInterval ()); | 449 uint16_t gi = ConvertGuardIntervalToNanoSeconds (mode, m_phy->GetS
hortGuardInterval (), m_phy->GetGuardInterval ()); |
450 uint64_t rate = mode.GetDataRate (m_phy->GetChannelWidth (), gi, 1
); | 450 uint64_t rate = mode.GetDataRate (m_phy->GetChannelWidth (), gi, 1
); |
451 if (rates.IsSupportedRate (static_cast<uint32_t>(rate))) | 451 if (rates.IsSupportedRate (static_cast<uint32_t> (rate))) |
452 { | 452 { |
453 m_stationManager->AddSupportedMode (hdr->GetAddr2 (), mode); | 453 m_stationManager->AddSupportedMode (hdr->GetAddr2 (), mode); |
454 if (rates.IsBasicRate (static_cast<uint32_t>(rate))) | 454 if (rates.IsBasicRate (static_cast<uint32_t> (rate))) |
455 { | 455 { |
456 m_stationManager->AddBasicMode (mode); | 456 m_stationManager->AddBasicMode (mode); |
457 } | 457 } |
458 } | 458 } |
459 } | 459 } |
460 } | 460 } |
461 } | 461 } |
462 else | 462 else |
463 { | 463 { |
464 m_stats.recvBytes += packet->GetSize (); | 464 m_stats.recvBytes += packet->GetSize (); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 m_stats.Print (os); | 545 m_stats.Print (os); |
546 os << "</Interface>" << std::endl; | 546 os << "</Interface>" << std::endl; |
547 } | 547 } |
548 void | 548 void |
549 MeshWifiInterfaceMac::ResetStats () | 549 MeshWifiInterfaceMac::ResetStats () |
550 { | 550 { |
551 m_stats = Statistics (); | 551 m_stats = Statistics (); |
552 } | 552 } |
553 | 553 |
554 void | 554 void |
555 MeshWifiInterfaceMac::FinishConfigureStandard (enum WifiPhyStandard standard) | 555 MeshWifiInterfaceMac::FinishConfigureStandard (WifiPhyStandard standard) |
556 { | 556 { |
557 RegularWifiMac::FinishConfigureStandard (standard); | 557 RegularWifiMac::FinishConfigureStandard (standard); |
558 m_standard = standard; | 558 m_standard = standard; |
559 | 559 |
560 // We use the single DCF provided by WifiMac for the purpose of | 560 // We use the single DCF provided by WifiMac for the purpose of |
561 // Beacon transmission. For this we need to reconfigure the channel | 561 // Beacon transmission. For this we need to reconfigure the channel |
562 // access parameters slightly, and do so here. | 562 // access parameters slightly, and do so here. |
563 m_dca->SetMinCw (0); | 563 m_dca->SetMinCw (0); |
564 m_dca->SetMaxCw (0); | 564 m_dca->SetMaxCw (0); |
565 m_dca->SetAifsn (1); | 565 m_dca->SetAifsn (1); |
566 } | 566 } |
567 WifiPhyStandard | 567 WifiPhyStandard |
568 MeshWifiInterfaceMac::GetPhyStandard () const | 568 MeshWifiInterfaceMac::GetPhyStandard () const |
569 { | 569 { |
570 return m_standard; | 570 return m_standard; |
571 } | 571 } |
572 } // namespace ns3 | 572 } // namespace ns3 |
573 | 573 |
LEFT | RIGHT |