Left: | ||
Right: |
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) 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", | 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", | 120 "Delay between two short frames transmitted on different freq uencies. NOTE: Unused now.", |
121 TimeValue (MicroSeconds (250)), | 121 TimeValue (MicroSeconds (250)), |
122 MakeTimeAccessor (&YansWifiPhy::m_channelSwitchDelay),· | 122 MakeTimeAccessor (&YansWifiPhy::m_channelSwitchDelay),· |
123 MakeTimeChecker ()) | 123 MakeTimeChecker ()) |
124 ; | 124 ; |
125 return tid; | 125 return tid; |
126 } | 126 } |
127 | 127 |
128 YansWifiPhy::YansWifiPhy () | 128 YansWifiPhy::YansWifiPhy () |
129 : m_endSyncEvent (), | 129 : m_endSyncEvent (), |
130 m_random (0.0, 1.0), | 130 m_random (0.0, 1.0), |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 } | 301 } |
302 void· | 302 void· |
303 YansWifiPhy::SetChannel (Ptr<YansWifiChannel> channel) | 303 YansWifiPhy::SetChannel (Ptr<YansWifiChannel> channel) |
304 { | 304 { |
305 m_channel = channel; | 305 m_channel = channel; |
306 m_channel->Add (this); | 306 m_channel->Add (this); |
307 m_channelId = 1; // always start on channel starting frequency (channel 1 ) | 307 m_channelId = 1; // always start on channel starting frequency (channel 1 ) |
308 } | 308 } |
309 | 309 |
310 void· | 310 void· |
311 YansWifiPhy::SetFrequencyChannel (uint16_t nch) | 311 YansWifiPhy::SetChannelNumber (uint16_t nch) |
312 { | 312 { |
313 Simulator::Schedule (m_channelSwitchDelay, &YansWifiPhy::DoSetChannelId, this, nch); | 313 // TODO implement channel switching state machine here |
Nicola Baldo
2009/07/06 09:52:57
Good to see that you model the channel switching d
Pavel Boyko
2009/07/06 11:27:35
Agree. Detailed model should notify MAC to pause (
Mathieu Lacage
2009/07/13 06:52:19
I think that it would be nice if:
1) the PHY could
| |
314 DoSetChannelNumber (nch); | |
314 } | 315 } |
315 | 316 |
316 void | 317 void |
317 YansWifiPhy::DoSetChannelId (uint16_t nch) | 318 YansWifiPhy::DoSetChannelNumber (uint16_t nch) |
318 { | 319 { |
319 NS_LOG_DEBUG("switching channel " << m_channelId << " -> " << nch); | 320 NS_LOG_DEBUG("switching channel " << m_channelId << " -> " << nch); |
320 m_channelId = nch; | 321 m_channelId = nch; |
321 } | 322 } |
322 | 323 |
323 uint16_t· | 324 uint16_t· |
324 YansWifiPhy::GetFrequencyChannel() const | 325 YansWifiPhy::GetChannelNumber() const |
325 { | 326 { |
326 return m_channelId; | 327 return m_channelId; |
327 } | 328 } |
328 | 329 |
329 double | 330 double |
330 YansWifiPhy::GetCenterFrequencyMhz() const | 331 YansWifiPhy::GetChannelFrequencyMhz() const |
331 { | 332 { |
332 return m_channelStartingFrequency + 5 * (GetFrequencyChannel() - 1); | 333 return m_channelStartingFrequency + 5 * (GetChannelNumber() - 1); |
333 } | 334 } |
334 | 335 |
335 void· | 336 void· |
336 YansWifiPhy::SetReceiveOkCallback (SyncOkCallback callback) | 337 YansWifiPhy::SetReceiveOkCallback (SyncOkCallback callback) |
337 { | 338 { |
338 m_state->SetReceiveOkCallback (callback); | 339 m_state->SetReceiveOkCallback (callback); |
339 } | 340 } |
340 | 341 |
341 void· | 342 void· |
342 YansWifiPhy::SetReceiveErrorCallback (SyncErrorCallback callback) | 343 YansWifiPhy::SetReceiveErrorCallback (SyncErrorCallback callback) |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
436 NS_ASSERT (!m_state->IsStateTx ()); | 437 NS_ASSERT (!m_state->IsStateTx ()); |
437 | 438 |
438 Time txDuration = CalculateTxDuration (packet->GetSize (), txMode, preamble); | 439 Time txDuration = CalculateTxDuration (packet->GetSize (), txMode, preamble); |
439 if (m_state->IsStateSync ()) | 440 if (m_state->IsStateSync ()) |
440 { | 441 { |
441 m_endSyncEvent.Cancel (); | 442 m_endSyncEvent.Cancel (); |
442 } | 443 } |
443 NotifyTxBegin (packet); | 444 NotifyTxBegin (packet); |
444 uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;··· | 445 uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000;··· |
445 bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble); | 446 bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble); |
446 NotifyPromiscSniffTx (packet, (uint16_t)GetCenterFrequencyMhz(), dataRate500Kb psUnits, isShortPreamble); | 447 NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz(), dataRate500K bpsUnits, isShortPreamble); |
447 m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower); | 448 m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower); |
448 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); |
449 } | 450 } |
450 | 451 |
451 uint32_t· | 452 uint32_t· |
452 YansWifiPhy::GetNModes (void) const | 453 YansWifiPhy::GetNModes (void) const |
453 { | 454 { |
454 return m_modes.size (); | 455 return m_modes.size (); |
455 } | 456 } |
456 WifiMode· | 457 WifiMode· |
(...skipping 28 matching lines...) Expand all Loading... | |
485 YansWifiPhy::Configure80211b (void) | 486 YansWifiPhy::Configure80211b (void) |
486 { | 487 { |
487 NS_LOG_FUNCTION (this); | 488 NS_LOG_FUNCTION (this); |
488 m_interference.Configure80211bParameters (); | 489 m_interference.Configure80211bParameters (); |
489 m_channelStartingFrequency = 2412; // 2.412 GHz· | 490 m_channelStartingFrequency = 2412; // 2.412 GHz· |
490 m_modes.push_back (WifiPhy::Get1mbb ()); | 491 m_modes.push_back (WifiPhy::Get1mbb ()); |
491 m_modes.push_back (WifiPhy::Get2mbb ()); | 492 m_modes.push_back (WifiPhy::Get2mbb ()); |
492 m_modes.push_back (WifiPhy::Get5_5mbb ()); | 493 m_modes.push_back (WifiPhy::Get5_5mbb ()); |
493 m_modes.push_back (WifiPhy::Get11mbb ()); | 494 m_modes.push_back (WifiPhy::Get11mbb ()); |
494 } | 495 } |
495 | 496 |
Nicola Baldo
2009/07/06 09:52:57
It would be good to add also Configure80211gParame
Pavel Boyko
2009/07/06 11:27:35
Please post this as enhancement to bugzilla.
| |
496 void | 497 void |
497 YansWifiPhy::ConfigureHolland (void) | 498 YansWifiPhy::ConfigureHolland (void) |
498 { | 499 { |
499 NS_LOG_FUNCTION (this); | 500 NS_LOG_FUNCTION (this); |
500 m_interference.Configure80211aParameters (); | 501 m_interference.Configure80211aParameters (); |
501 m_channelStartingFrequency = 5e3; // 5.000 GHz· | 502 m_channelStartingFrequency = 5e3; // 5.000 GHz· |
502 m_modes.push_back (WifiPhy::Get6mba ()); | 503 m_modes.push_back (WifiPhy::Get6mba ()); |
503 m_modes.push_back (WifiPhy::Get12mba ()); | 504 m_modes.push_back (WifiPhy::Get12mba ()); |
504 m_modes.push_back (WifiPhy::Get18mba ()); | 505 m_modes.push_back (WifiPhy::Get18mba ()); |
505 m_modes.push_back (WifiPhy::Get36mba ()); | 506 m_modes.push_back (WifiPhy::Get36mba ()); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
615 | 616 |
616 NS_LOG_DEBUG ("mode="<<(event->GetPayloadMode ().GetDataRate ())<< | 617 NS_LOG_DEBUG ("mode="<<(event->GetPayloadMode ().GetDataRate ())<< |
617 ", snr="<<snrPer.snr<<", per="<<snrPer.per<<", size="<<packet->G etSize ()); | 618 ", snr="<<snrPer.snr<<", per="<<snrPer.per<<", size="<<packet->G etSize ()); |
618 if (m_random.GetValue () > snrPer.per)· | 619 if (m_random.GetValue () > snrPer.per)· |
619 { | 620 { |
620 NotifyRxEnd (packet);· | 621 NotifyRxEnd (packet);· |
621 uint32_t dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () / 500000;··· | 622 uint32_t dataRate500KbpsUnits = event->GetPayloadMode ().GetDataRate () / 500000;··· |
622 bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());········ | 623 bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ());········ |
623 double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30; | 624 double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30; |
624 double noiseDbm = RatioToDb(event->GetRxPowerW() / snrPer.snr) - GetRxNois eFigure() + 30 ; | 625 double noiseDbm = RatioToDb(event->GetRxPowerW() / snrPer.snr) - GetRxNois eFigure() + 30 ; |
625 NotifyPromiscSniffRx (packet, (uint16_t)GetCenterFrequencyMhz(), dataRate5 00KbpsUnits, isShortPreamble, signalDbm, noiseDbm); | 626 NotifyPromiscSniffRx (packet, (uint16_t)GetChannelFrequencyMhz(), dataRate 500KbpsUnits, isShortPreamble, signalDbm, noiseDbm); |
626 m_state->SwitchFromSyncEndOk (packet, snrPer.snr, event->GetPayloadMode () , event->GetPreambleType ()); | 627 m_state->SwitchFromSyncEndOk (packet, snrPer.snr, event->GetPayloadMode () , event->GetPreambleType ()); |
627 }· | 628 }· |
628 else· | 629 else· |
629 { | 630 { |
630 /* failure. */ | 631 /* failure. */ |
631 NotifyRxDrop (packet); | 632 NotifyRxDrop (packet); |
632 m_state->SwitchFromSyncEndError (packet, snrPer.snr); | 633 m_state->SwitchFromSyncEndError (packet, snrPer.snr); |
633 } | 634 } |
634 } | 635 } |
635 } // namespace ns3 | 636 } // namespace ns3 |
LEFT | RIGHT |