Left: | ||
Right: |
OLD | NEW |
---|---|
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) 2005,2006 INRIA | 3 * Copyright (c) 2005,2006 INRIA |
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 " and some PHY-specific constants.", | 109 " and some PHY-specific constants.", |
110 EnumValue (WIFI_PHY_STANDARD_80211a), | 110 EnumValue (WIFI_PHY_STANDARD_80211a), |
111 MakeEnumAccessor (&YansWifiPhy::SetStandard), | 111 MakeEnumAccessor (&YansWifiPhy::SetStandard), |
112 MakeEnumChecker (WIFI_PHY_STANDARD_80211a, "802.11a", | 112 MakeEnumChecker (WIFI_PHY_STANDARD_80211a, "802.11a", |
113 WIFI_PHY_STANDARD_80211b, "802.11b", | 113 WIFI_PHY_STANDARD_80211b, "802.11b", |
114 WIFI_PHY_STANDARD_holland, "holland")) | 114 WIFI_PHY_STANDARD_holland, "holland")) |
115 .AddAttribute ("State", "The state of the PHY layer", | 115 .AddAttribute ("State", "The state of the PHY layer", |
116 PointerValue (), | 116 PointerValue (), |
117 MakePointerAccessor (&YansWifiPhy::m_state), | 117 MakePointerAccessor (&YansWifiPhy::m_state), |
118 MakePointerChecker<WifiPhyStateHelper> ()) | 118 MakePointerChecker<WifiPhyStateHelper> ()) |
119 .AddAttribute ("ChannelSwitchDelay", | |
Mathieu Lacage
2009/07/16 11:06:34
you forgot to remove this attribute as well as the
Pavel Boyko
2009/07/16 12:07:05
Nope, I just reserved it for future switching mode
| |
120 "Delay between two short frames transmitted on different freq uencies. NOTE: Unused now.", | |
121 TimeValue (MicroSeconds (250)), | |
122 MakeTimeAccessor (&YansWifiPhy::m_channelSwitchDelay),· | |
123 MakeTimeChecker ()) | |
119 ; | 124 ; |
120 return tid; | 125 return tid; |
121 } | 126 } |
122 | 127 |
123 YansWifiPhy::YansWifiPhy () | 128 YansWifiPhy::YansWifiPhy () |
124 : m_channelFreqMhz(2437), | 129 : m_endSyncEvent (), |
125 m_endSyncEvent (), | 130 m_random (0.0, 1.0), |
126 m_random (0.0, 1.0) | 131 m_channelStartingFrequency (0) |
127 | |
128 { | 132 { |
129 NS_LOG_FUNCTION (this); | 133 NS_LOG_FUNCTION (this); |
130 m_state = CreateObject<WifiPhyStateHelper> (); | 134 m_state = CreateObject<WifiPhyStateHelper> (); |
131 } | 135 } |
132 | 136 |
133 YansWifiPhy::~YansWifiPhy () | 137 YansWifiPhy::~YansWifiPhy () |
134 { | 138 { |
135 NS_LOG_FUNCTION (this); | 139 NS_LOG_FUNCTION (this); |
136 } | 140 } |
137 | 141 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 Ptr<WifiChannel>· | 297 Ptr<WifiChannel>· |
294 YansWifiPhy::GetChannel (void) const | 298 YansWifiPhy::GetChannel (void) const |
295 { | 299 { |
296 return m_channel; | 300 return m_channel; |
297 } | 301 } |
298 void· | 302 void· |
299 YansWifiPhy::SetChannel (Ptr<YansWifiChannel> channel) | 303 YansWifiPhy::SetChannel (Ptr<YansWifiChannel> channel) |
300 { | 304 { |
301 m_channel = channel; | 305 m_channel = channel; |
302 m_channel->Add (this); | 306 m_channel->Add (this); |
307 m_channelId = 1; // always start on channel starting frequency (channel 1 ) | |
303 } | 308 } |
304 | 309 |
305 void· | 310 void· |
311 YansWifiPhy::SetChannelNumber (uint16_t nch) | |
312 { | |
313 // TODO implement channel switching state machine here | |
314 DoSetChannelNumber (nch); | |
315 } | |
316 | |
317 void | |
318 YansWifiPhy::DoSetChannelNumber (uint16_t nch) | |
319 { | |
320 NS_LOG_DEBUG("switching channel " << m_channelId << " -> " << nch); | |
321 m_channelId = nch; | |
322 } | |
323 | |
324 uint16_t· | |
325 YansWifiPhy::GetChannelNumber() const | |
326 { | |
327 return m_channelId; | |
328 } | |
329 | |
330 double | |
331 YansWifiPhy::GetChannelFrequencyMhz() const | |
332 { | |
333 return m_channelStartingFrequency + 5 * (GetChannelNumber() - 1); | |
334 } | |
335 | |
336 void· | |
306 YansWifiPhy::SetReceiveOkCallback (SyncOkCallback callback) | 337 YansWifiPhy::SetReceiveOkCallback (SyncOkCallback callback) |
307 { | 338 { |
308 m_state->SetReceiveOkCallback (callback); | 339 m_state->SetReceiveOkCallback (callback); |
309 } | 340 } |
341 | |
310 void· | 342 void· |
311 YansWifiPhy::SetReceiveErrorCallback (SyncErrorCallback callback) | 343 YansWifiPhy::SetReceiveErrorCallback (SyncErrorCallback callback) |
312 { | 344 { |
313 m_state->SetReceiveErrorCallback (callback); | 345 m_state->SetReceiveErrorCallback (callback); |
314 } | 346 } |
315 void· | 347 void· |
316 YansWifiPhy::StartReceivePacket (Ptr<Packet> packet,· | 348 YansWifiPhy::StartReceivePacket (Ptr<Packet> packet,· |
317 double rxPowerDbm, | 349 double rxPowerDbm, |
318 WifiMode txMode, | 350 WifiMode txMode, |
319 enum WifiPreamble preamble) | 351 enum WifiPreamble preamble) |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 NS_ASSERT (!m_state->IsStateTx ()); | 437 NS_ASSERT (!m_state->IsStateTx ()); |
406 | 438 |
407 Time txDuration = CalculateTxDuration (packet->GetSize (), txMode, preamble); | 439 Time txDuration = CalculateTxDuration (packet->GetSize (), txMode, preamble); |
408 if (m_state->IsStateSync ()) | 440 if (m_state->IsStateSync ()) |
409 { | 441 { |
410 m_endSyncEvent.Cancel (); | 442 m_endSyncEvent.Cancel (); |
411 } | 443 } |
412 NotifyTxBegin (packet); | 444 NotifyTxBegin (packet); |
413 uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;··· | 445 uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;··· |
414 bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble); | 446 bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble); |
415 NotifyPromiscSniffTx (packet, m_channelFreqMhz, dataRate500KbpsUnits, isShortP reamble); | 447 NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz(), dataRate500K bpsUnits, isShortPreamble); |
416 m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower); | 448 m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower); |
417 m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, pre amble); | 449 m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, pre amble); |
418 } | 450 } |
419 | 451 |
420 uint32_t· | 452 uint32_t· |
421 YansWifiPhy::GetNModes (void) const | 453 YansWifiPhy::GetNModes (void) const |
422 { | 454 { |
423 return m_modes.size (); | 455 return m_modes.size (); |
424 } | 456 } |
425 WifiMode· | 457 WifiMode· |
426 YansWifiPhy::GetMode (uint32_t mode) const | 458 YansWifiPhy::GetMode (uint32_t mode) const |
427 { | 459 { |
428 return m_modes[mode]; | 460 return m_modes[mode]; |
429 } | 461 } |
430 uint32_t· | 462 uint32_t· |
431 YansWifiPhy::GetNTxPower (void) const | 463 YansWifiPhy::GetNTxPower (void) const |
432 { | 464 { |
433 return m_nTxPower; | 465 return m_nTxPower; |
434 } | 466 } |
435 | 467 |
436 void | 468 void |
437 YansWifiPhy::Configure80211a (void) | 469 YansWifiPhy::Configure80211a (void) |
438 { | 470 { |
439 NS_LOG_FUNCTION (this); | 471 NS_LOG_FUNCTION (this); |
440 m_interference.Configure80211aParameters (); | 472 m_interference.Configure80211aParameters (); |
473 m_channelStartingFrequency = 5e3; // 5.000 GHz· | |
441 m_modes.push_back (WifiPhy::Get6mba ()); | 474 m_modes.push_back (WifiPhy::Get6mba ()); |
442 m_modes.push_back (WifiPhy::Get9mba ()); | 475 m_modes.push_back (WifiPhy::Get9mba ()); |
443 m_modes.push_back (WifiPhy::Get12mba ()); | 476 m_modes.push_back (WifiPhy::Get12mba ()); |
444 m_modes.push_back (WifiPhy::Get18mba ()); | 477 m_modes.push_back (WifiPhy::Get18mba ()); |
445 m_modes.push_back (WifiPhy::Get24mba ()); | 478 m_modes.push_back (WifiPhy::Get24mba ()); |
446 m_modes.push_back (WifiPhy::Get36mba ()); | 479 m_modes.push_back (WifiPhy::Get36mba ()); |
447 m_modes.push_back (WifiPhy::Get48mba ()); | 480 m_modes.push_back (WifiPhy::Get48mba ()); |
448 m_modes.push_back (WifiPhy::Get54mba ()); | 481 m_modes.push_back (WifiPhy::Get54mba ()); |
449 } | 482 } |
450 | 483 |
451 | 484 |
452 void | 485 void |
453 YansWifiPhy::Configure80211b (void) | 486 YansWifiPhy::Configure80211b (void) |
454 { | 487 { |
455 NS_LOG_FUNCTION (this); | 488 NS_LOG_FUNCTION (this); |
456 m_interference.Configure80211bParameters (); | 489 m_interference.Configure80211bParameters (); |
490 m_channelStartingFrequency = 2412; // 2.412 GHz· | |
457 m_modes.push_back (WifiPhy::Get1mbb ()); | 491 m_modes.push_back (WifiPhy::Get1mbb ()); |
458 m_modes.push_back (WifiPhy::Get2mbb ()); | 492 m_modes.push_back (WifiPhy::Get2mbb ()); |
459 m_modes.push_back (WifiPhy::Get5_5mbb ()); | 493 m_modes.push_back (WifiPhy::Get5_5mbb ()); |
460 m_modes.push_back (WifiPhy::Get11mbb ()); | 494 m_modes.push_back (WifiPhy::Get11mbb ()); |
461 } | 495 } |
462 | 496 |
463 void | 497 void |
464 YansWifiPhy::ConfigureHolland (void) | 498 YansWifiPhy::ConfigureHolland (void) |
465 { | 499 { |
466 NS_LOG_FUNCTION (this); | 500 NS_LOG_FUNCTION (this); |
467 m_interference.Configure80211aParameters (); | 501 m_interference.Configure80211aParameters (); |
502 m_channelStartingFrequency = 5e3; // 5.000 GHz· | |
468 m_modes.push_back (WifiPhy::Get6mba ()); | 503 m_modes.push_back (WifiPhy::Get6mba ()); |
469 m_modes.push_back (WifiPhy::Get12mba ()); | 504 m_modes.push_back (WifiPhy::Get12mba ()); |
470 m_modes.push_back (WifiPhy::Get18mba ()); | 505 m_modes.push_back (WifiPhy::Get18mba ()); |
471 m_modes.push_back (WifiPhy::Get36mba ()); | 506 m_modes.push_back (WifiPhy::Get36mba ()); |
472 m_modes.push_back (WifiPhy::Get54mba ()); | 507 m_modes.push_back (WifiPhy::Get54mba ()); |
473 } | 508 } |
474 | 509 |
475 void· | 510 void· |
476 YansWifiPhy::RegisterListener (WifiPhyListener *listener) | 511 YansWifiPhy::RegisterListener (WifiPhyListener *listener) |
477 { | 512 { |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
581 | 616 |
582 NS_LOG_DEBUG ("mode="<<(event->GetPayloadMode ().GetDataRate ())<< | 617 NS_LOG_DEBUG ("mode="<<(event->GetPayloadMode ().GetDataRate ())<< |
583 ", snr="<<snrPer.snr<<", per="<<snrPer.per<<", size="<<packet->G etSize ()); | 618 ", snr="<<snrPer.snr<<", per="<<snrPer.per<<", size="<<packet->G etSize ()); |
584 if (m_random.GetValue () > snrPer.per)· | 619 if (m_random.GetValue () > snrPer.per)· |
585 { | 620 { |
586 NotifyRxEnd (packet);· | 621 NotifyRxEnd (packet);· |
587 uint32_t dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () / 500000;··· | 622 uint32_t dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () / 500000;··· |
588 bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());········ | 623 bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());········ |
589 double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30; | 624 double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30; |
590 double noiseDbm = RatioToDb(event->GetRxPowerW() / snrPer.snr) - GetRxNois eFigure() + 30 ; | 625 double noiseDbm = RatioToDb(event->GetRxPowerW() / snrPer.snr) - GetRxNois eFigure() + 30 ; |
591 NotifyPromiscSniffRx (packet, m_channelFreqMhz, dataRate500KbpsUnits, isSh ortPreamble, signalDbm, noiseDbm); | 626 NotifyPromiscSniffRx (packet, (uint16_t)GetChannelFrequencyMhz(), dataRate 500KbpsUnits, isShortPreamble, signalDbm, noiseDbm); |
592 m_state->SwitchFromSyncEndOk (packet, snrPer.snr, event->GetPayloadMode () , event->GetPreambleType ()); | 627 m_state->SwitchFromSyncEndOk (packet, snrPer.snr, event->GetPayloadMode () , event->GetPreambleType ()); |
593 }· | 628 }· |
594 else· | 629 else· |
595 { | 630 { |
596 /* failure. */ | 631 /* failure. */ |
597 NotifyRxDrop (packet); | 632 NotifyRxDrop (packet); |
598 m_state->SwitchFromSyncEndError (packet, snrPer.snr); | 633 m_state->SwitchFromSyncEndError (packet, snrPer.snr); |
599 } | 634 } |
600 } | 635 } |
601 } // namespace ns3 | 636 } // namespace ns3 |
OLD | NEW |