diff --git a/src/devices/mesh/mesh-wifi-interface-mac.cc b/src/devices/mesh/mesh-wifi-interface-mac.cc index 3ac6f77d4..f1d8e06e5 100644 --- a/src/devices/mesh/mesh-wifi-interface-mac.cc +++ b/src/devices/mesh/mesh-wifi-interface-mac.cc @@ -337,7 +337,7 @@ uint16_t MeshWifiInterfaceMac::GetFrequencyChannel () const Ptr phy = m_phy->GetObject (); if (phy != 0) - return phy->GetFrequencyChannel (); + return phy->GetChannelNumber (); else return 0; } @@ -360,7 +360,7 @@ void MeshWifiInterfaceMac::SwitchFrequencyChannel (uint16_t new_id) NS_ASSERT(CanSwitchChannel()); Ptr phy = m_phy->GetObject (); - phy->SetFrequencyChannel (new_id); + phy->SetChannelNumber (new_id); // Don't know NAV on new channel m_dcfManager->NotifyNavResetNow (Seconds (0)); } diff --git a/src/devices/wifi/wifi-phy.h b/src/devices/wifi/wifi-phy.h index e061827a9..83ca99f03 100644 --- a/src/devices/wifi/wifi-phy.h +++ b/src/devices/wifi/wifi-phy.h @@ -241,7 +241,19 @@ public: * the requested ber for the specified transmission mode. (W/W) */ virtual double CalculateSnr (WifiMode txMode, double ber) const = 0; - + + /** + * \brief Set channel number. + * + * Channel center frequency = Channel starting frequency + 5 MHz * (nch - 1) + * + * where Starting channel frequency is standard-dependent, see SetStandard() + * as defined in IEEE 802.11-2007 17.3.8.3.2. + */ + virtual void SetChannelNumber (uint16_t id) = 0; + /// Return current channel number, see SetChannelNumber() + virtual uint16_t GetChannelNumber () const = 0; + virtual Ptr GetChannel (void) const = 0; static WifiMode Get6mba (void); diff --git a/src/devices/wifi/yans-wifi-channel.cc b/src/devices/wifi/yans-wifi-channel.cc index 236882711..52ce25527 100644 --- a/src/devices/wifi/yans-wifi-channel.cc +++ b/src/devices/wifi/yans-wifi-channel.cc @@ -82,7 +82,7 @@ YansWifiChannel::Send (Ptr sender, Ptr packet, double if (sender != (*i)) { // For now don't account for inter channel interference - if ((*i)->GetFrequencyChannel() != sender->GetFrequencyChannel()) + if ((*i)->GetChannelNumber() != sender->GetChannelNumber()) continue; Ptr receiverMobility = (*i)->GetMobility ()->GetObject (); diff --git a/src/devices/wifi/yans-wifi-phy.cc b/src/devices/wifi/yans-wifi-phy.cc index 1ceaa5676..a30e4b6a6 100644 --- a/src/devices/wifi/yans-wifi-phy.cc +++ b/src/devices/wifi/yans-wifi-phy.cc @@ -308,28 +308,28 @@ YansWifiPhy::SetChannel (Ptr channel) } void -YansWifiPhy::SetFrequencyChannel (uint16_t nch) +YansWifiPhy::SetChannelNumber (uint16_t nch) { - Simulator::Schedule (m_channelSwitchDelay, &YansWifiPhy::DoSetChannelId, this, nch); + Simulator::Schedule (m_channelSwitchDelay, &YansWifiPhy::DoSetChannelNumber, this, nch); } void -YansWifiPhy::DoSetChannelId (uint16_t nch) +YansWifiPhy::DoSetChannelNumber (uint16_t nch) { NS_LOG_DEBUG("switching channel " << m_channelId << " -> " << nch); m_channelId = nch; } uint16_t -YansWifiPhy::GetFrequencyChannel() const +YansWifiPhy::GetChannelNumber() const { return m_channelId; } double -YansWifiPhy::GetCenterFrequencyMhz() const +YansWifiPhy::GetChannelFrequencyMhz() const { - return m_channelStartingFrequency + 5 * (GetFrequencyChannel() - 1); + return m_channelStartingFrequency + 5 * (GetChannelNumber() - 1); } void @@ -443,7 +443,7 @@ YansWifiPhy::SendPacket (Ptr packet, WifiMode txMode, WifiPreamble NotifyTxBegin (packet); uint32_t dataRate500KbpsUnits = txMode.GetDataRate () / 500000; bool isShortPreamble = (WIFI_PREAMBLE_SHORT == preamble); - NotifyPromiscSniffTx (packet, (uint16_t)GetCenterFrequencyMhz(), dataRate500KbpsUnits, isShortPreamble); + NotifyPromiscSniffTx (packet, (uint16_t)GetChannelFrequencyMhz(), dataRate500KbpsUnits, isShortPreamble); m_state->SwitchToTx (txDuration, packet, txMode, preamble, txPower); m_channel->Send (this, packet, GetPowerDbm (txPower) + m_txGainDb, txMode, preamble); } @@ -622,7 +622,7 @@ YansWifiPhy::EndSync (Ptr packet, Ptr event) bool isShortPreamble = (WIFI_PREAMBLE_SHORT == event->GetPreambleType ()); double signalDbm = RatioToDb (event->GetRxPowerW ()) + 30; double noiseDbm = RatioToDb(event->GetRxPowerW() / snrPer.snr) - GetRxNoiseFigure() + 30 ; - NotifyPromiscSniffRx (packet, (uint16_t)GetCenterFrequencyMhz(), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm); + NotifyPromiscSniffRx (packet, (uint16_t)GetChannelFrequencyMhz(), dataRate500KbpsUnits, isShortPreamble, signalDbm, noiseDbm); m_state->SwitchFromSyncEndOk (packet, snrPer.snr, event->GetPayloadMode (), event->GetPreambleType ()); } else diff --git a/src/devices/wifi/yans-wifi-phy.h b/src/devices/wifi/yans-wifi-phy.h index b9810b7e4..a23799245 100644 --- a/src/devices/wifi/yans-wifi-phy.h +++ b/src/devices/wifi/yans-wifi-phy.h @@ -78,11 +78,11 @@ public: * where Starting channel frequency is standard-dependent, see SetStandard() * as defined in IEEE 802.11-2007 17.3.8.3.2. */ - void SetFrequencyChannel (uint16_t id); - /// Return current channel ID, see SetChannelId() - uint16_t GetFrequencyChannel () const; - /// Return current center channel frequency in MHz, see SetFrequencyChannel() - double GetCenterFrequencyMhz() const; + void SetChannelNumber (uint16_t id); + /// Return current channel number, see SetChannelNumber() + uint16_t GetChannelNumber () const; + /// Return current center channel frequency in MHz, see SetСhannelNumber() + double GetChannelFrequencyMhz() const; void StartReceivePacket (Ptr packet, double rxPowerDbm, @@ -150,7 +150,7 @@ private: double RatioToDb (double ratio) const; double GetPowerDbm (uint8_t power) const; void EndSync (Ptr packet, Ptr event); - void DoSetChannelId(uint16_t id); + void DoSetChannelNumber(uint16_t id); private: double m_edThresholdW;