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

(-)a/examples/wireless/wifi-spectrum-saturation-example.cc (-2 / +2 lines)
 Lines 198-205   int main (int argc, char *argv[]) Link Here 
198
          //Bug 2460: CcaMode1Threshold default should be set to -62 dBm when using Spectrum
198
          //Bug 2460: CcaMode1Threshold default should be set to -62 dBm when using Spectrum
199
          Config::SetDefault ("ns3::WifiPhy::CcaMode1Threshold", DoubleValue (-62.0));
199
          Config::SetDefault ("ns3::WifiPhy::CcaMode1Threshold", DoubleValue (-62.0));
200
200
201
          Ptr<SingleModelSpectrumChannel> spectrumChannel
201
          Ptr<MultiModelSpectrumChannel> spectrumChannel
202
            = CreateObject<SingleModelSpectrumChannel> ();
202
            = CreateObject<MultiModelSpectrumChannel> ();
203
          Ptr<FriisPropagationLossModel> lossModel
203
          Ptr<FriisPropagationLossModel> lossModel
204
            = CreateObject<FriisPropagationLossModel> ();
204
            = CreateObject<FriisPropagationLossModel> ();
205
          spectrumChannel->AddPropagationLossModel (lossModel);
205
          spectrumChannel->AddPropagationLossModel (lossModel);
(-)a/src/spectrum/model/wifi-spectrum-value-helper.cc (-1 / +3 lines)
 Lines 164-170   WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFreque Link Here 
164
  switch (channelWidth)
164
  switch (channelWidth)
165
    {
165
    {
166
    case 20:
166
    case 20:
167
    default:
168
      // 52 subcarriers (48 data + 4 pilot)
167
      // 52 subcarriers (48 data + 4 pilot)
169
      // skip guard band and 6 subbands, then place power in 26 subbands, then
168
      // skip guard band and 6 subbands, then place power in 26 subbands, then
170
      // skip the center subband, then place power in 26 subbands, then skip
169
      // skip the center subband, then place power in 26 subbands, then skip
 Lines 197-202   WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFreque Link Here 
197
      start2 = stop1 + 2;
196
      start2 = stop1 + 2;
198
      stop2 = start2 + 8 - 1;
197
      stop2 = start2 + 8 - 1;
199
      break;
198
      break;
199
    default:
200
      NS_FATAL_ERROR ("Channel width should be correctly set.");
201
      return 0;
200
    }
202
    }
201
  NS_LOG_DEBUG ("Power per band " << txPowerPerBand);
203
  NS_LOG_DEBUG ("Power per band " << txPowerPerBand);
202
  Values::iterator vit = c->ValuesBegin ();
204
  Values::iterator vit = c->ValuesBegin ();
(-)a/src/wifi/model/mac-low.cc (-5 / +28 lines)
 Lines 1039-1070   WifiTxVector Link Here 
1039
MacLow::GetRtsTxVector (Ptr<const Packet> packet, const WifiMacHeader *hdr) const
1039
MacLow::GetRtsTxVector (Ptr<const Packet> packet, const WifiMacHeader *hdr) const
1040
{
1040
{
1041
  Mac48Address to = hdr->GetAddr1 ();
1041
  Mac48Address to = hdr->GetAddr1 ();
1042
  return m_stationManager->GetRtsTxVector (to, hdr, packet);
1042
  WifiTxVector txVector = m_stationManager->GetRtsTxVector (to, hdr, packet);
1043
  return AdjustChannelWidthToMode (txVector);
1043
}
1044
}
1044
1045
1045
WifiTxVector
1046
WifiTxVector
1046
MacLow::GetDataTxVector (Ptr<const Packet> packet, const WifiMacHeader *hdr) const
1047
MacLow::GetDataTxVector (Ptr<const Packet> packet, const WifiMacHeader *hdr) const
1047
{
1048
{
1048
  Mac48Address to = hdr->GetAddr1 ();
1049
  Mac48Address to = hdr->GetAddr1 ();
1049
  return m_stationManager->GetDataTxVector (to, hdr, packet);
1050
  WifiTxVector txVector = m_stationManager->GetDataTxVector (to, hdr, packet);
1051
  return AdjustChannelWidthToMode (txVector);
1050
}
1052
}
1051
1053
1052
WifiTxVector
1054
WifiTxVector
1053
MacLow::GetCtsTxVector (Mac48Address to, WifiMode rtsTxMode) const
1055
MacLow::GetCtsTxVector (Mac48Address to, WifiMode rtsTxMode) const
1054
{
1056
{
1055
  return m_stationManager->GetCtsTxVector (to, rtsTxMode);
1057
  WifiTxVector txVector = m_stationManager->GetCtsTxVector (to, rtsTxMode);
1058
  return AdjustChannelWidthToMode (txVector);
1056
}
1059
}
1057
1060
1058
WifiTxVector
1061
WifiTxVector
1059
MacLow::GetAckTxVector (Mac48Address to, WifiMode dataTxMode) const
1062
MacLow::GetAckTxVector (Mac48Address to, WifiMode dataTxMode) const
1060
{
1063
{
1061
  return m_stationManager->GetAckTxVector (to, dataTxMode);
1064
  WifiTxVector txVector = m_stationManager->GetAckTxVector (to, dataTxMode);
1065
  return AdjustChannelWidthToMode (txVector);
1062
}
1066
}
1063
1067
1064
WifiTxVector
1068
WifiTxVector
1065
MacLow::GetBlockAckTxVector (Mac48Address to, WifiMode dataTxMode) const
1069
MacLow::GetBlockAckTxVector (Mac48Address to, WifiMode dataTxMode) const
1066
{
1070
{
1067
  return m_stationManager->GetBlockAckTxVector (to, dataTxMode);
1071
  WifiTxVector txVector = m_stationManager->GetBlockAckTxVector (to, dataTxMode);
1072
  return AdjustChannelWidthToMode (txVector);
1068
}
1073
}
1069
1074
1070
WifiTxVector
1075
WifiTxVector
 Lines 1079-1084   MacLow::GetAckTxVectorForData (Mac48Address to, WifiMode dataTxMode) const Link Here 
1079
  return GetAckTxVector (to, dataTxMode);
1084
  return GetAckTxVector (to, dataTxMode);
1080
}
1085
}
1081
1086
1087
WifiTxVector
1088
MacLow::AdjustChannelWidthToMode (WifiTxVector initialTxVector) const
1089
{
1090
  NS_LOG_FUNCTION (this << initialTxVector);
1091
  WifiModulationClass modulationClass = initialTxVector.GetMode ().GetModulationClass ();
1092
  uint8_t defaultChannelWidth = initialTxVector.GetChannelWidth ();
1093
  if (defaultChannelWidth > 20 &&
1094
      (modulationClass == WifiModulationClass::WIFI_MOD_CLASS_OFDM || // all non-HT OFDM control and management frames
1095
       modulationClass == WifiModulationClass::WIFI_MOD_CLASS_ERP_OFDM)) // special case of beacons at 2.4 GHz
1096
    {
1097
      WifiTxVector updatedTxVector = initialTxVector;
1098
      updatedTxVector.SetChannelWidth (20);
1099
      NS_LOG_LOGIC ("Channel width in TXVECTOR has been updated to 20 MHz channel");
1100
      return updatedTxVector;
1101
    }
1102
  return initialTxVector;
1103
}
1104
1082
Time
1105
Time
1083
MacLow::CalculateOverallTxTime (Ptr<const Packet> packet,
1106
MacLow::CalculateOverallTxTime (Ptr<const Packet> packet,
1084
                                const WifiMacHeader* hdr,
1107
                                const WifiMacHeader* hdr,
(-)a/src/wifi/model/mac-low.h (+9 lines)
 Lines 497-502   private: Link Here 
497
   */
497
   */
498
  WifiTxVector GetAckTxVectorForData (Mac48Address to, WifiMode dataTxMode) const;
498
  WifiTxVector GetAckTxVectorForData (Mac48Address to, WifiMode dataTxMode) const;
499
  /**
499
  /**
500
   * Adjust the channel width to the selected mode (instead of letting the PHY's
501
   * default channel width). This is especially useful when using non-HT modes
502
   * with HT/VHT/HE capable stations (with default width above 20 MHz).
503
   *
504
   * \param initialTxVector TXVECTOR returned by the WifiRemoteStationManager using the PHY's default channel width
505
   * \return TXVECTOR with channel width adapted to the selected mode
506
   */
507
  WifiTxVector AdjustChannelWidthToMode (WifiTxVector initialTxVector) const;
508
  /**
500
   * Return the time required to transmit the CTS (including preamble and FCS).
509
   * Return the time required to transmit the CTS (including preamble and FCS).
501
   *
510
   *
502
   * \param ctsTxVector
511
   * \param ctsTxVector
(-)a/src/wifi/model/spectrum-wifi-phy.cc (-1 / +16 lines)
 Lines 312-323   SpectrumWifiPhy::GetTxPowerSpectralDensity (uint16_t centerFrequency, uint8_t ch Link Here 
312
  return v;
312
  return v;
313
}
313
}
314
314
315
uint32_t
316
SpectrumWifiPhy::GetCenterFrequencyForChannelWidth (WifiTxVector txVector) const
317
{
318
  NS_LOG_FUNCTION (txVector);
319
  uint32_t centerFrequencyForSupportedWidth = GetFrequency ();
320
  uint32_t supportedWidth = static_cast<uint32_t> (GetChannelWidth ());
321
  uint32_t currentWidth = static_cast<uint32_t> (txVector.GetChannelWidth ());
322
  if (currentWidth != supportedWidth)
323
    {
324
      uint32_t startingFrequency = centerFrequencyForSupportedWidth - (supportedWidth / 2);
325
      return startingFrequency + (currentWidth / 2); // primary channel is in the lower part (for the time being)
326
    }
327
  return centerFrequencyForSupportedWidth;
328
}
329
315
void
330
void
316
SpectrumWifiPhy::StartTx (Ptr<Packet> packet, WifiTxVector txVector, Time txDuration)
331
SpectrumWifiPhy::StartTx (Ptr<Packet> packet, WifiTxVector txVector, Time txDuration)
317
{
332
{
318
  NS_LOG_DEBUG ("Start transmission: signal power before antenna gain=" << GetPowerDbm (txVector.GetTxPowerLevel ()) << "dBm");
333
  NS_LOG_DEBUG ("Start transmission: signal power before antenna gain=" << GetPowerDbm (txVector.GetTxPowerLevel ()) << "dBm");
319
  double txPowerWatts = DbmToW (GetPowerDbm (txVector.GetTxPowerLevel ()) + GetTxGain ());
334
  double txPowerWatts = DbmToW (GetPowerDbm (txVector.GetTxPowerLevel ()) + GetTxGain ());
320
  Ptr<SpectrumValue> txPowerSpectrum = GetTxPowerSpectralDensity (GetFrequency (), GetChannelWidth (), txPowerWatts, txVector.GetMode ().GetModulationClass ());
335
  Ptr<SpectrumValue> txPowerSpectrum = GetTxPowerSpectralDensity (GetCenterFrequencyForChannelWidth (txVector), txVector.GetChannelWidth (), txPowerWatts, txVector.GetMode ().GetModulationClass ());
321
  Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
336
  Ptr<WifiSpectrumSignalParameters> txParams = Create<WifiSpectrumSignalParameters> ();
322
  txParams->duration = txDuration;
337
  txParams->duration = txDuration;
323
  txParams->psd = txPowerSpectrum;
338
  txParams->psd = txPowerSpectrum;
(-)a/src/wifi/model/spectrum-wifi-phy.h (+9 lines)
 Lines 100-105   public: Link Here 
100
   * \param txDuration duration of the transmission.
100
   * \param txDuration duration of the transmission.
101
   */
101
   */
102
  void StartTx (Ptr<Packet> packet, WifiTxVector txVector, Time txDuration);
102
  void StartTx (Ptr<Packet> packet, WifiTxVector txVector, Time txDuration);
103
  /**
104
   * Get the center frequency of the channel corresponding the current TxVector rather than
105
   * that of the supported channel width.
106
   * Consider that this "primary channel" is on the lower part for the time being.
107
   *
108
   * \param txVector the TXVECTOR that has the channel width that is to be used
109
   * \return the center frequency corresponding to the channel width to be used
110
   */
111
  uint32_t GetCenterFrequencyForChannelWidth (WifiTxVector txVector) const;
103
112
104
  /**
113
  /**
105
   * Method to encapsulate the creation of the WifiSpectrumPhyInterface
114
   * Method to encapsulate the creation of the WifiSpectrumPhyInterface

Return to bug 2843