diff --git a/src/wifi/model/yans-wifi-phy.cc b/src/wifi/model/yans-wifi-phy.cc index 842013fef..2f8b0f339 100644 --- a/src/wifi/model/yans-wifi-phy.cc +++ b/src/wifi/model/yans-wifi-phy.cc @@ -452,7 +452,7 @@ YansWifiPhy::StartReceivePacket (Ptr packet, rxPowerDbm += m_rxGainDb; double rxPowerW = DbmToW (rxPowerDbm); Time rxDuration = CalculateTxDuration (packet->GetSize (), txVector, preamble); -WifiMode txMode=txVector.GetMode(); + WifiMode txMode = txVector.GetMode(); Time endRx = Simulator::Now () + rxDuration; Ptr event; @@ -509,15 +509,24 @@ WifiMode txMode=txVector.GetMode(); case YansWifiPhy::IDLE: if (rxPowerW > m_edThresholdW) { - NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)"); - // sync to signal - m_state->SwitchToRx (rxDuration); - NS_ASSERT (m_endRxEvent.IsExpired ()); - NotifyRxBegin (packet); - m_interference.NotifyRxStart (); - m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this, - packet, - event); + if (IsModeSupported (txMode)) + { + NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)"); + // sync to signal + m_state->SwitchToRx (rxDuration); + NS_ASSERT (m_endRxEvent.IsExpired ()); + NotifyRxBegin (packet); + m_interference.NotifyRxStart (); + m_endRxEvent = Simulator::Schedule (rxDuration, &YansWifiPhy::EndReceive, this, + packet, + event); + } + else + { + NS_LOG_DEBUG ("drop packet because it was sent using an unsupported mode (" << txMode << ")"); + NotifyRxDrop (packet); + goto maybeCcaBusy; + } } else { @@ -580,6 +589,18 @@ YansWifiPhy::GetMode (uint32_t mode) const { return m_deviceRateSet[mode]; } +bool +YansWifiPhy::IsModeSupported (WifiMode mode) const +{ + for (uint32_t i = 0; i < GetNModes (); i++) + { + if (mode == GetMode (i)) + { + return true; + } + } + return false; +} uint32_t YansWifiPhy::GetNTxPower (void) const { diff --git a/src/wifi/model/yans-wifi-phy.h b/src/wifi/model/yans-wifi-phy.h index 7b93ad095..6eeb86d9b 100644 --- a/src/wifi/model/yans-wifi-phy.h +++ b/src/wifi/model/yans-wifi-phy.h @@ -260,6 +260,7 @@ public: virtual Time GetLastRxStartTime (void) const; virtual uint32_t GetNModes (void) const; virtual WifiMode GetMode (uint32_t mode) const; + virtual bool IsModeSupported (WifiMode mode) const; virtual double CalculateSnr (WifiMode txMode, double ber) const; virtual Ptr GetChannel (void) const;