View | Details | Raw Unified | Return to bug 2460
Collapse All | Expand All

(-)a/src/wifi/model/spectrum-wifi-phy.cc (+8 lines)
 Lines 242-247   SpectrumWifiPhy::StartRx (Ptr<SpectrumSignalParameters> rxParams) Link Here 
242
242
243
  // Log the signal arrival to the trace source
243
  // Log the signal arrival to the trace source
244
  m_signalCb (wifiRxParams ? true : false, senderNodeId, WToDbm (rxPowerW), rxDuration);
244
  m_signalCb (wifiRxParams ? true : false, senderNodeId, WToDbm (rxPowerW), rxDuration);
245
246
  // Do no further processing if signal is too weak
247
  // Current implementation assumes constant rx power over the packet duration
248
  if (rxPowerW < GetRxSensitivity ())
249
    {
250
      NS_LOG_INFO ("Received signal too weak to process: " << WToDbm (rxPowerW) << " dBm");
251
      return;
252
    }
245
  if (wifiRxParams == 0)
253
  if (wifiRxParams == 0)
246
    {
254
    {
247
      NS_LOG_INFO ("Received non Wi-Fi signal");
255
      NS_LOG_INFO ("Received non Wi-Fi signal");
(-)a/src/wifi/model/wifi-phy.cc (-61 / +72 lines)
 Lines 183-193   WifiPhy::GetTypeId (void) Link Here 
183
                   "this threshold (dbm) to allow the PHY layer to detect the signal.",
183
                   "this threshold (dbm) to allow the PHY layer to detect the signal.",
184
                   DoubleValue (-96.0),
184
                   DoubleValue (-96.0),
185
                   MakeDoubleAccessor (&WifiPhy::SetEdThreshold),
185
                   MakeDoubleAccessor (&WifiPhy::SetEdThreshold),
186
                   MakeDoubleChecker<double> (),
187
                   TypeId::DEPRECATED, "Replaced by RxSensitivity")
188
    .AddAttribute ("RxSensitivity",
189
                   "The energy of a received signal should be higher than "
190
                   "this threshold (dBm) for the PHY to detect the signal.",
191
                   DoubleValue (-101.0),
192
                   MakeDoubleAccessor (&WifiPhy::SetRxSensitivity,
193
                                       &WifiPhy::GetRxSensitivity),
186
                   MakeDoubleChecker<double> ())
194
                   MakeDoubleChecker<double> ())
187
    .AddAttribute ("CcaMode1Threshold",
195
    .AddAttribute ("CcaMode1Threshold",
188
                   "The energy of a received signal should be higher than "
196
                   "The energy of a received signal should be higher than "
189
                   "this threshold (dbm) to allow the PHY layer to declare CCA BUSY state.",
197
                   "this threshold (dbm) to allow the PHY layer to declare CCA BUSY state.",
190
                   DoubleValue (-99.0),
198
                   DoubleValue (-62.0),
191
                   MakeDoubleAccessor (&WifiPhy::SetCcaMode1Threshold,
199
                   MakeDoubleAccessor (&WifiPhy::SetCcaMode1Threshold,
192
                                       &WifiPhy::GetCcaMode1Threshold),
200
                                       &WifiPhy::GetCcaMode1Threshold),
193
                   MakeDoubleChecker<double> ())
201
                   MakeDoubleChecker<double> ())
 Lines 476-481   WifiPhy::GetEdThreshold (void) const Link Here 
476
}
484
}
477
485
478
void
486
void
487
WifiPhy::SetRxSensitivity (double threshold)
488
{
489
  NS_LOG_FUNCTION (this << threshold);
490
  m_rxSensitivityW = DbmToW (threshold);
491
}
492
493
double
494
WifiPhy::GetRxSensitivity (void) const
495
{
496
  return WToDbm (m_rxSensitivityW);
497
}
498
499
void
479
WifiPhy::SetCcaMode1Threshold (double threshold)
500
WifiPhy::SetCcaMode1Threshold (double threshold)
480
{
501
{
481
  NS_LOG_FUNCTION (this << threshold);
502
  NS_LOG_FUNCTION (this << threshold);
 Lines 3652-3727   void Link Here 
3652
WifiPhy::StartRx (Ptr<Packet> packet, WifiTxVector txVector, MpduType mpdutype, double rxPowerW, Time rxDuration, Ptr<Event> event)
3673
WifiPhy::StartRx (Ptr<Packet> packet, WifiTxVector txVector, MpduType mpdutype, double rxPowerW, Time rxDuration, Ptr<Event> event)
3653
{
3674
{
3654
  NS_LOG_FUNCTION (this << packet << txVector << +mpdutype << rxPowerW << rxDuration);
3675
  NS_LOG_FUNCTION (this << packet << txVector << +mpdutype << rxPowerW << rxDuration);
3655
  if (rxPowerW > m_edThresholdW) //checked here, no need to check in the payload reception (current implementation assumes constant rx power over the packet duration)
3676
3677
  AmpduTag ampduTag;
3678
  WifiPreamble preamble = txVector.GetPreambleType ();
3679
  if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess == false))
3656
    {
3680
    {
3657
      AmpduTag ampduTag;
3681
      m_plcpSuccess = false;
3658
      WifiPreamble preamble = txVector.GetPreambleType ();
3682
      m_mpdusNum = 0;
3659
      if (preamble == WIFI_PREAMBLE_NONE && (m_mpdusNum == 0 || m_plcpSuccess == false))
3683
      NS_LOG_DEBUG ("drop packet because no PLCP preamble/header has been received");
3660
        {
3684
      NotifyRxDrop (packet);
3661
          m_plcpSuccess = false;
3685
      MaybeCcaBusyDuration ();
3662
          m_mpdusNum = 0;
3686
      return;
3663
          NS_LOG_DEBUG ("drop packet because no PLCP preamble/header has been received");
3687
    }
3664
          NotifyRxDrop (packet);
3688
  else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum == 0)
3665
          MaybeCcaBusyDuration ();
3689
    {
3666
          return;
3690
      //received the first MPDU in an MPDU
3667
        }
3691
      m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
3668
      else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum == 0)
3692
      m_rxMpduReferenceNumber++;
3669
        {
3693
    }
3670
          //received the first MPDU in an MPDU
3694
  else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
3671
          m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
3695
    {
3672
          m_rxMpduReferenceNumber++;
3696
      //received the other MPDUs that are part of the A-MPDU
3673
        }
3697
      if (ampduTag.GetRemainingNbOfMpdus () < (m_mpdusNum - 1))
3674
      else if (preamble == WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
3675
        {
3676
          //received the other MPDUs that are part of the A-MPDU
3677
          if (ampduTag.GetRemainingNbOfMpdus () < (m_mpdusNum - 1))
3678
            {
3679
              NS_LOG_DEBUG ("Missing MPDU from the A-MPDU " << m_mpdusNum - ampduTag.GetRemainingNbOfMpdus ());
3680
              m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
3681
            }
3682
          else
3683
            {
3684
              m_mpdusNum--;
3685
            }
3686
        }
3687
      else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
3688
        {
3698
        {
3689
          NS_LOG_DEBUG ("New A-MPDU started while " << m_mpdusNum << " MPDUs from previous are lost");
3699
          NS_LOG_DEBUG ("Missing MPDU from the A-MPDU " << m_mpdusNum - ampduTag.GetRemainingNbOfMpdus ());
3690
          m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
3700
          m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
3691
        }
3701
        }
3692
      else if (preamble != WIFI_PREAMBLE_NONE && m_mpdusNum > 0 )
3702
      else
3693
        {
3703
        {
3694
          NS_LOG_DEBUG ("Didn't receive the last MPDUs from an A-MPDU " << m_mpdusNum);
3704
          m_mpdusNum--;
3695
          m_mpdusNum = 0;
3696
        }
3705
        }
3706
    }
3707
  else if (preamble != WIFI_PREAMBLE_NONE && packet->PeekPacketTag (ampduTag) && m_mpdusNum > 0)
3708
    {
3709
      NS_LOG_DEBUG ("New A-MPDU started while " << m_mpdusNum << " MPDUs from previous are lost");
3710
      m_mpdusNum = ampduTag.GetRemainingNbOfMpdus ();
3711
    }
3712
  else if (preamble != WIFI_PREAMBLE_NONE && m_mpdusNum > 0 )
3713
    {
3714
      NS_LOG_DEBUG ("Didn't receive the last MPDUs from an A-MPDU " << m_mpdusNum);
3715
      m_mpdusNum = 0;
3716
    }
3697
3717
3698
      NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)");
3718
  NS_LOG_DEBUG ("sync to signal (power=" << rxPowerW << "W)");
3699
      m_currentEvent = event;
3719
  m_currentEvent = event;
3700
      m_state->SwitchToRx (rxDuration);
3720
  m_state->SwitchToRx (rxDuration);
3701
      NS_ASSERT (m_endPlcpRxEvent.IsExpired ());
3721
  NS_ASSERT (m_endPlcpRxEvent.IsExpired ());
3702
      NotifyRxBegin (packet);
3722
  NotifyRxBegin (packet);
3703
      m_interference.NotifyRxStart ();
3723
  m_interference.NotifyRxStart ();
3704
3705
      if (preamble != WIFI_PREAMBLE_NONE)
3706
        {
3707
          NS_ASSERT (m_endPlcpRxEvent.IsExpired ());
3708
          Time preambleAndHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector);
3709
          m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &WifiPhy::StartReceivePacket, this,
3710
                                                  packet, txVector, mpdutype, event);
3711
        }
3712
3724
3713
      NS_ASSERT (m_endRxEvent.IsExpired ());
3725
  if (preamble != WIFI_PREAMBLE_NONE)
3714
      m_endRxEvent = Simulator::Schedule (rxDuration, &WifiPhy::EndReceive, this,
3715
                                          packet, preamble, mpdutype, event);
3716
    }
3717
  else
3718
    {
3726
    {
3719
      NS_LOG_DEBUG ("drop packet because signal power too Small (" <<
3727
      NS_ASSERT (m_endPlcpRxEvent.IsExpired ());
3720
                    rxPowerW << "<" << m_edThresholdW << ")");
3728
      Time preambleAndHeaderDuration = CalculatePlcpPreambleAndHeaderDuration (txVector);
3721
      NotifyRxDrop (packet);
3729
      m_endPlcpRxEvent = Simulator::Schedule (preambleAndHeaderDuration, &WifiPhy::StartReceivePacket, this,
3722
      m_plcpSuccess = false;
3730
                                              packet, txVector, mpdutype, event);
3723
      MaybeCcaBusyDuration ();
3724
    }
3731
    }
3732
3733
  NS_ASSERT (m_endRxEvent.IsExpired ());
3734
  m_endRxEvent = Simulator::Schedule (rxDuration, &WifiPhy::EndReceive, this,
3735
                                      packet, preamble, mpdutype, event);
3725
}
3736
}
3726
3737
3727
int64_t
3738
int64_t
(-)a/src/wifi/model/wifi-phy.h (+21 lines)
 Lines 23-28    Link Here 
23
#define WIFI_PHY_H
23
#define WIFI_PHY_H
24
24
25
#include "ns3/event-id.h"
25
#include "ns3/event-id.h"
26
#include "ns3/deprecated.h"
26
#include "wifi-mpdu-type.h"
27
#include "wifi-mpdu-type.h"
27
#include "wifi-phy-standard.h"
28
#include "wifi-phy-standard.h"
28
#include "interference-helper.h"
29
#include "interference-helper.h"
 Lines 1188-1203   public: Link Here 
1188
   * The energy of a received signal should be higher than
1189
   * The energy of a received signal should be higher than
1189
   * this threshold (dbm) to allow the PHY layer to detect the signal.
1190
   * this threshold (dbm) to allow the PHY layer to detect the signal.
1190
   *
1191
   *
1192
   * This parameter is being deprecated (renamed to RxSensitivity)
1193
   *
1191
   * \param threshold the energy detection threshold in dBm
1194
   * \param threshold the energy detection threshold in dBm
1192
   */
1195
   */
1193
  void SetEdThreshold (double threshold);
1196
  void SetEdThreshold (double threshold);
1194
  /**
1197
  /**
1195
   * Return the energy detection threshold (dBm).
1198
   * Return the energy detection threshold (dBm).
1196
   *
1199
   *
1200
   * This parameter is being deprecated (renamed to RxSensitivity)
1201
   *
1197
   * \return the energy detection threshold in dBm
1202
   * \return the energy detection threshold in dBm
1198
   */
1203
   */
1204
  NS_DEPRECATED
1199
  double GetEdThreshold (void) const;
1205
  double GetEdThreshold (void) const;
1200
  /**
1206
  /**
1207
   * Sets the receive sensitivity threshold (dBm).
1208
   * The energy of a received signal should be higher than
1209
   * this threshold to allow the PHY layer to detect the signal.
1210
   *
1211
   * \param threshold the receive sensitivity threshold in dBm
1212
   */
1213
  void SetRxSensitivity (double threshold);
1214
  /**
1215
   * Return the receive sensitivity threshold (dBm).
1216
   *
1217
   * \return the receive sensitivity threshold in dBm
1218
   */
1219
  double GetRxSensitivity (void) const;
1220
  /**
1201
   * Sets the CCA threshold (dBm). The energy of a received signal
1221
   * Sets the CCA threshold (dBm). The energy of a received signal
1202
   * should be higher than this threshold to allow the PHY
1222
   * should be higher than this threshold to allow the PHY
1203
   * layer to declare CCA BUSY state.
1223
   * layer to declare CCA BUSY state.
 Lines 1743-1748   private: Link Here 
1743
  uint16_t m_channelWidth;                  //!< Channel width
1763
  uint16_t m_channelWidth;                  //!< Channel width
1744
1764
1745
  double   m_edThresholdW;        //!< Energy detection threshold in watts
1765
  double   m_edThresholdW;        //!< Energy detection threshold in watts
1766
  double   m_rxSensitivityW;      //!< Receive sensitivity threshold in watts
1746
  double   m_ccaMode1ThresholdW;  //!< Clear channel assessment (CCA) threshold in watts
1767
  double   m_ccaMode1ThresholdW;  //!< Clear channel assessment (CCA) threshold in watts
1747
  double   m_txGainDb;            //!< Transmission gain (dB)
1768
  double   m_txGainDb;            //!< Transmission gain (dB)
1748
  double   m_rxGainDb;            //!< Reception gain (dB)
1769
  double   m_rxGainDb;            //!< Reception gain (dB)
(-)a/src/wifi/model/yans-wifi-channel.cc (+7 lines)
 Lines 125-130   void Link Here 
125
YansWifiChannel::Receive (Ptr<YansWifiPhy> phy, Ptr<Packet> packet, double rxPowerDbm, Time duration)
125
YansWifiChannel::Receive (Ptr<YansWifiPhy> phy, Ptr<Packet> packet, double rxPowerDbm, Time duration)
126
{
126
{
127
  NS_LOG_FUNCTION (phy << packet << rxPowerDbm << duration.GetSeconds ());
127
  NS_LOG_FUNCTION (phy << packet << rxPowerDbm << duration.GetSeconds ());
128
  // Do no further processing if signal is too weak
129
  // Current implementation assumes constant rx power over the packet duration
130
  if ((rxPowerDbm + phy->GetRxGain ()) < phy->GetRxSensitivity ())
131
    {
132
      NS_LOG_INFO ("Received signal too weak to process: " << rxPowerDbm << " dBm");
133
      return;
134
    }
128
  phy->StartReceivePreambleAndHeader (packet, DbmToW (rxPowerDbm + phy->GetRxGain ()), duration);
135
  phy->StartReceivePreambleAndHeader (packet, DbmToW (rxPowerDbm + phy->GetRxGain ()), duration);
129
}
136
}
130
137

Return to bug 2460