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/multi-model-spectrum-channel.cc (-1 / +8 lines)
 Lines 134-139   MultiModelSpectrumChannel::GetTypeId (void) Link Here 
134
                     "reported in this trace. ",
134
                     "reported in this trace. ",
135
                     MakeTraceSourceAccessor (&MultiModelSpectrumChannel::m_pathLossTrace),
135
                     MakeTraceSourceAccessor (&MultiModelSpectrumChannel::m_pathLossTrace),
136
                     "ns3::SpectrumChannel::LossTracedCallback")
136
                     "ns3::SpectrumChannel::LossTracedCallback")
137
    .AddTraceSource ("TxSigParams",
138
                     "This trace is fired whenever a signal is transmitted. "
139
                     "The sole parameter is a pointer to a copy of the "
140
                     "SpectrumSignalParameters provided by the transmitter.",
141
                     MakeTraceSourceAccessor (&MultiModelSpectrumChannel::m_txSigParamsTrace),
142
                     "ns3::MultiModelSpectrumChannel::SignalParametersTracedCallback")
137
  ;
143
  ;
138
  return tid;
144
  return tid;
139
}
145
}
 Lines 261-267   MultiModelSpectrumChannel::StartTx (Ptr<SpectrumSignalParameters> txParams) Link Here 
261
267
262
  NS_ASSERT (txParams->txPhy);
268
  NS_ASSERT (txParams->txPhy);
263
  NS_ASSERT (txParams->psd);
269
  NS_ASSERT (txParams->psd);
264
270
  Ptr<SpectrumSignalParameters> txParamsTrace = txParams->Copy (); // copy it since traced value cannot be const (because of potential underlying DynamicCasts)
271
  m_txSigParamsTrace (txParamsTrace);
265
272
266
  Ptr<MobilityModel> txMobility = txParams->txPhy->GetMobility ();
273
  Ptr<MobilityModel> txMobility = txParams->txPhy->GetMobility ();
267
  SpectrumModelUid_t txSpectrumModelUid = txParams->psd->GetSpectrumModelUid ();
274
  SpectrumModelUid_t txSpectrumModelUid = txParams->psd->GetSpectrumModelUid ();
(-)a/src/spectrum/model/multi-model-spectrum-channel.h (+10 lines)
 Lines 133-138   public: Link Here 
133
   */
133
   */
134
  virtual Ptr<SpectrumPropagationLossModel> GetSpectrumPropagationLossModel (void);
134
  virtual Ptr<SpectrumPropagationLossModel> GetSpectrumPropagationLossModel (void);
135
135
136
  /**
137
   * TracedCallback signature for Ptr<const SpectrumSignalParameters>.
138
   *
139
   * \param [in] params SpectrumSignalParameters instance.
140
   */
141
  typedef void (* SignalParametersTracedCallback) (Ptr<SpectrumSignalParameters> params);
136
142
137
protected:
143
protected:
138
  void DoDispose ();
144
  void DoDispose ();
 Lines 207-212   private: Link Here 
207
   * in a future release.
213
   * in a future release.
208
   */
214
   */
209
  TracedCallback<Ptr<SpectrumPhy>, Ptr<SpectrumPhy>, double > m_pathLossTrace;
215
  TracedCallback<Ptr<SpectrumPhy>, Ptr<SpectrumPhy>, double > m_pathLossTrace;
216
  /**
217
   * Traced callback for SpectrumSignalParameters in StartTx requests
218
   */
219
  TracedCallback<Ptr<SpectrumSignalParameters> > m_txSigParamsTrace;
210
};
220
};
211
221
212
222
(-)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/constant-rate-wifi-manager.cc (-2 / +2 lines)
 Lines 117-130   WifiTxVector Link Here 
117
ConstantRateWifiManager::DoGetDataTxVector (WifiRemoteStation *st)
117
ConstantRateWifiManager::DoGetDataTxVector (WifiRemoteStation *st)
118
{
118
{
119
  NS_LOG_FUNCTION (this << st);
119
  NS_LOG_FUNCTION (this << st);
120
  return WifiTxVector (m_dataMode, GetDefaultTxPowerLevel (), GetLongRetryCount (st), GetPreambleForTransmission (m_dataMode, GetAddress (st)), ConvertGuardIntervalToNanoSeconds (m_dataMode, GetShortGuardInterval (st), NanoSeconds (GetGuardInterval (st))), GetNumberOfAntennas (), Min (GetMaxNumberOfTransmitStreams (), GetNumberOfSupportedStreams (st)), 0, GetChannelWidth (st), GetAggregation (st), false);
120
  return WifiTxVector (m_dataMode, GetDefaultTxPowerLevel (), GetLongRetryCount (st), GetPreambleForTransmission (m_dataMode, GetAddress (st)), ConvertGuardIntervalToNanoSeconds (m_dataMode, GetShortGuardInterval (st), NanoSeconds (GetGuardInterval (st))), GetNumberOfAntennas (), Min (GetMaxNumberOfTransmitStreams (), GetNumberOfSupportedStreams (st)), 0, GetChannelWidthForTransmission (m_dataMode, GetChannelWidth (st)), GetAggregation (st), false);
121
}
121
}
122
122
123
WifiTxVector
123
WifiTxVector
124
ConstantRateWifiManager::DoGetRtsTxVector (WifiRemoteStation *st)
124
ConstantRateWifiManager::DoGetRtsTxVector (WifiRemoteStation *st)
125
{
125
{
126
  NS_LOG_FUNCTION (this << st);
126
  NS_LOG_FUNCTION (this << st);
127
  return WifiTxVector (m_ctlMode, GetDefaultTxPowerLevel (), GetShortRetryCount (st), GetPreambleForTransmission (m_ctlMode, GetAddress (st)), ConvertGuardIntervalToNanoSeconds (m_ctlMode, GetShortGuardInterval (st), NanoSeconds (GetGuardInterval (st))), 1, 1, 0, GetChannelWidth (st), GetAggregation (st), false);
127
  return WifiTxVector (m_ctlMode, GetDefaultTxPowerLevel (), GetShortRetryCount (st), GetPreambleForTransmission (m_ctlMode, GetAddress (st)), ConvertGuardIntervalToNanoSeconds (m_ctlMode, GetShortGuardInterval (st), NanoSeconds (GetGuardInterval (st))), 1, 1, 0, GetChannelWidthForTransmission (m_ctlMode, GetChannelWidth (st)), GetAggregation (st), false);
128
}
128
}
129
129
130
bool
130
bool
(-)a/src/wifi/model/ideal-wifi-manager.cc (-1 / +1 lines)
 Lines 488-494   IdealWifiManager::DoGetDataTxVector (WifiRemoteStation *st) Link Here 
488
      NS_LOG_DEBUG ("New datarate: " << maxMode.GetDataRate (channelWidth, guardInterval, selectedNss));
488
      NS_LOG_DEBUG ("New datarate: " << maxMode.GetDataRate (channelWidth, guardInterval, selectedNss));
489
      m_currentRate = maxMode.GetDataRate (channelWidth, guardInterval, selectedNss);
489
      m_currentRate = maxMode.GetDataRate (channelWidth, guardInterval, selectedNss);
490
    }
490
    }
491
  return WifiTxVector (maxMode, GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetPreambleForTransmission (maxMode, GetAddress (station)), guardInterval, GetNumberOfAntennas (), selectedNss, 0, channelWidth, GetAggregation (station), false);
491
  return WifiTxVector (maxMode, GetDefaultTxPowerLevel (), GetLongRetryCount (station), GetPreambleForTransmission (maxMode, GetAddress (station)), guardInterval, GetNumberOfAntennas (), selectedNss, 0, GetChannelWidthForTransmission (maxMode, channelWidth), GetAggregation (station), false);
492
}
492
}
493
493
494
WifiTxVector
494
WifiTxVector
(-)a/src/wifi/model/minstrel-ht-wifi-manager.cc (-2 / +2 lines)
 Lines 931-937   MinstrelHtWifiManager::DoGetDataTxVector (WifiRemoteStation *st) Link Here 
931
        }
931
        }
932
      WifiMode mode = GetMcsSupported (station, mcsIndex);
932
      WifiMode mode = GetMcsSupported (station, mcsIndex);
933
      return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetLongRetryCount (station),
933
      return WifiTxVector (mode, GetDefaultTxPowerLevel (), GetLongRetryCount (station),
934
                           GetPreambleForTransmission (mode, GetAddress (station)), group.sgi ? 400 : 800, GetNumberOfAntennas (), group.streams, GetNess (station), group.chWidth, GetAggregation (station) && !station->m_isSampling, false);
934
                           GetPreambleForTransmission (mode, GetAddress (station)), group.sgi ? 400 : 800, GetNumberOfAntennas (), group.streams, GetNess (station), GetChannelWidthForTransmission (mode, group.chWidth), GetAggregation (station) && !station->m_isSampling, false);
935
    }
935
    }
936
}
936
}
937
937
 Lines 1007-1013   MinstrelHtWifiManager::DoGetRtsTxVector (WifiRemoteStation *st) Link Here 
1007
      NS_ASSERT (rateFound);
1007
      NS_ASSERT (rateFound);
1008
1008
1009
      return WifiTxVector (rtsRate, GetDefaultTxPowerLevel (), GetShortRetryCount (station), GetPreambleForTransmission (rtsRate, GetAddress (station)),
1009
      return WifiTxVector (rtsRate, GetDefaultTxPowerLevel (), GetShortRetryCount (station), GetPreambleForTransmission (rtsRate, GetAddress (station)),
1010
                           800, 1, 1, 0, GetChannelWidth (station), GetAggregation (station), false);
1010
                           800, 1, 1, 0, GetChannelWidthForTransmission (rtsRate, GetChannelWidth (station)), GetAggregation (station), false);
1011
    }
1011
    }
1012
}
1012
}
1013
1013
(-)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
(-)a/src/wifi/model/wifi-remote-station-manager.cc (-5 / +20 lines)
 Lines 813-818   WifiRemoteStationManager::PrepareForQueue (Mac48Address address, const WifiMacHe Link Here 
813
  packet->AddPacketTag (ctstoselftag);
813
  packet->AddPacketTag (ctstoselftag);
814
}
814
}
815
815
816
uint8_t
817
WifiRemoteStationManager::GetChannelWidthForTransmission (WifiMode mode, uint8_t maxSupportedChannelWidth)
818
{
819
  NS_LOG_FUNCTION (mode << (uint16_t)maxSupportedChannelWidth);
820
  WifiModulationClass modulationClass = mode.GetModulationClass ();
821
  if (maxSupportedChannelWidth > 20 &&
822
      (modulationClass == WifiModulationClass::WIFI_MOD_CLASS_OFDM || // all non-HT OFDM control and management frames
823
       modulationClass == WifiModulationClass::WIFI_MOD_CLASS_ERP_OFDM)) // special case of beacons at 2.4 GHz
824
    {
825
      NS_LOG_LOGIC ("Channel width reduced to 20 MHz");
826
      return 20;
827
    }
828
  return maxSupportedChannelWidth;
829
}
830
816
WifiTxVector
831
WifiTxVector
817
WifiRemoteStationManager::GetDataTxVector (Mac48Address address, const WifiMacHeader *header, Ptr<const Packet> packet)
832
WifiRemoteStationManager::GetDataTxVector (Mac48Address address, const WifiMacHeader *header, Ptr<const Packet> packet)
818
{
833
{
 Lines 824-830   WifiRemoteStationManager::GetDataTxVector (Mac48Address address, const WifiMacHe Link Here 
824
      v.SetMode (mode);
839
      v.SetMode (mode);
825
      v.SetPreambleType (GetPreambleForTransmission (mode, address));
840
      v.SetPreambleType (GetPreambleForTransmission (mode, address));
826
      v.SetTxPowerLevel (m_defaultTxPowerLevel);
841
      v.SetTxPowerLevel (m_defaultTxPowerLevel);
827
      v.SetChannelWidth (m_wifiPhy->GetChannelWidth ());
842
      v.SetChannelWidth (GetChannelWidthForTransmission (mode, m_wifiPhy->GetChannelWidth ()));
828
      v.SetGuardInterval (ConvertGuardIntervalToNanoSeconds (mode, m_wifiPhy->GetShortGuardInterval (), m_wifiPhy->GetGuardInterval ()));
843
      v.SetGuardInterval (ConvertGuardIntervalToNanoSeconds (mode, m_wifiPhy->GetShortGuardInterval (), m_wifiPhy->GetGuardInterval ()));
829
      v.SetNss (1);
844
      v.SetNss (1);
830
      v.SetNess (0);
845
      v.SetNess (0);
 Lines 894-900   WifiRemoteStationManager::DoGetCtsToSelfTxVector (void) Link Here 
894
                       GetNumberOfAntennas (),
909
                       GetNumberOfAntennas (),
895
                       GetMaxNumberOfTransmitStreams (),
910
                       GetMaxNumberOfTransmitStreams (),
896
                       0,
911
                       0,
897
                       m_wifiPhy->GetChannelWidth (),
912
                       GetChannelWidthForTransmission (defaultMode, m_wifiPhy->GetChannelWidth ()),
898
                       false,
913
                       false,
899
                       false);
914
                       false);
900
}
915
}
 Lines 1464-1470   WifiRemoteStationManager::GetCtsTxVector (Mac48Address address, WifiMode rtsMode Link Here 
1464
  v.SetMode (ctsMode);
1479
  v.SetMode (ctsMode);
1465
  v.SetPreambleType (GetPreambleForTransmission (ctsMode, address));
1480
  v.SetPreambleType (GetPreambleForTransmission (ctsMode, address));
1466
  v.SetTxPowerLevel (DoGetCtsTxPowerLevel (address, ctsMode));
1481
  v.SetTxPowerLevel (DoGetCtsTxPowerLevel (address, ctsMode));
1467
  v.SetChannelWidth (DoGetCtsTxChannelWidth (address, ctsMode));
1482
  v.SetChannelWidth (GetChannelWidthForTransmission (ctsMode, DoGetCtsTxChannelWidth (address, ctsMode)));
1468
  v.SetGuardInterval (DoGetCtsTxGuardInterval (address, ctsMode));
1483
  v.SetGuardInterval (DoGetCtsTxGuardInterval (address, ctsMode));
1469
  v.SetNss (DoGetCtsTxNss (address, ctsMode));
1484
  v.SetNss (DoGetCtsTxNss (address, ctsMode));
1470
  v.SetNess (DoGetCtsTxNess (address, ctsMode));
1485
  v.SetNess (DoGetCtsTxNess (address, ctsMode));
 Lines 1481-1487   WifiRemoteStationManager::GetAckTxVector (Mac48Address address, WifiMode dataMod Link Here 
1481
  v.SetMode (ackMode);
1496
  v.SetMode (ackMode);
1482
  v.SetPreambleType (GetPreambleForTransmission (ackMode, address));
1497
  v.SetPreambleType (GetPreambleForTransmission (ackMode, address));
1483
  v.SetTxPowerLevel (DoGetAckTxPowerLevel (address, ackMode));
1498
  v.SetTxPowerLevel (DoGetAckTxPowerLevel (address, ackMode));
1484
  v.SetChannelWidth (DoGetAckTxChannelWidth (address, ackMode));
1499
  v.SetChannelWidth (GetChannelWidthForTransmission (ackMode, DoGetAckTxChannelWidth (address, ackMode)));
1485
  v.SetGuardInterval (DoGetAckTxGuardInterval (address, ackMode));
1500
  v.SetGuardInterval (DoGetAckTxGuardInterval (address, ackMode));
1486
  v.SetNss (DoGetAckTxNss (address, ackMode));
1501
  v.SetNss (DoGetAckTxNss (address, ackMode));
1487
  v.SetNess (DoGetAckTxNess (address, ackMode));
1502
  v.SetNess (DoGetAckTxNess (address, ackMode));
 Lines 1498-1504   WifiRemoteStationManager::GetBlockAckTxVector (Mac48Address address, WifiMode bl Link Here 
1498
  v.SetMode (blockAckMode);
1513
  v.SetMode (blockAckMode);
1499
  v.SetPreambleType (GetPreambleForTransmission (blockAckMode, address));
1514
  v.SetPreambleType (GetPreambleForTransmission (blockAckMode, address));
1500
  v.SetTxPowerLevel (DoGetBlockAckTxPowerLevel (address, blockAckMode));
1515
  v.SetTxPowerLevel (DoGetBlockAckTxPowerLevel (address, blockAckMode));
1501
  v.SetChannelWidth (DoGetBlockAckTxChannelWidth (address, blockAckMode));
1516
  v.SetChannelWidth (GetChannelWidthForTransmission (blockAckMode, DoGetBlockAckTxChannelWidth (address, blockAckMode)));
1502
  v.SetGuardInterval (DoGetBlockAckTxGuardInterval (address, blockAckMode));
1517
  v.SetGuardInterval (DoGetBlockAckTxGuardInterval (address, blockAckMode));
1503
  v.SetNss (DoGetBlockAckTxNss (address, blockAckMode));
1518
  v.SetNss (DoGetBlockAckTxNss (address, blockAckMode));
1504
  v.SetNess (DoGetBlockAckTxNess (address, blockAckMode));
1519
  v.SetNess (DoGetBlockAckTxNess (address, blockAckMode));
(-)a/src/wifi/model/wifi-remote-station-manager.h (+10 lines)
 Lines 1093-1098   protected: Link Here 
1093
   * \return the preamble to be used for the transmission
1093
   * \return the preamble to be used for the transmission
1094
   */
1094
   */
1095
  WifiPreamble GetPreambleForTransmission (WifiMode mode, Mac48Address dest);
1095
  WifiPreamble GetPreambleForTransmission (WifiMode mode, Mac48Address dest);
1096
  /**
1097
   * Return the channel width that corresponds to the selected mode (instead of
1098
   * letting the PHY's default channel width). This is especially useful when using
1099
   * non-HT modes with HT/VHT/HE capable stations (with default width above 20 MHz).
1100
   *
1101
   * \param mode selected WifiMode
1102
   * \param maxSupportedChannelWidth maximum channel width supported by the PHY layer
1103
   * \return channel width adapted to the selected mode
1104
   */
1105
  static uint8_t GetChannelWidthForTransmission (WifiMode mode, uint8_t maxSupportedChannelWidth);
1096
1106
1097
  /**
1107
  /**
1098
   * Return the WifiPhy.
1108
   * Return the WifiPhy.
(-)a/src/wifi/test/wifi-test.cc (+185 lines)
 Lines 37-42    Link Here 
37
#include "ns3/packet-socket-server.h"
37
#include "ns3/packet-socket-server.h"
38
#include "ns3/packet-socket-client.h"
38
#include "ns3/packet-socket-client.h"
39
#include "ns3/packet-socket-helper.h"
39
#include "ns3/packet-socket-helper.h"
40
#include "ns3/spectrum-wifi-helper.h"
41
#include "ns3/spectrum-value.h"
42
#include "ns3/multi-model-spectrum-channel.h"
43
#include "ns3/wifi-spectrum-signal-parameters.h"
44
#include "ns3/wifi-phy-tag.h"
45
#include <tuple>
46
#include <vector>
40
47
41
using namespace ns3;
48
using namespace ns3;
42
49
 Lines 1154-1159   Bug2222TestCase::DoRun (void) Link Here 
1154
  NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!");
1161
  NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!");
1155
}
1162
}
1156
1163
1164
//-----------------------------------------------------------------------------
1165
/**
1166
 * Make sure that the correct channel width and center frequency have been set
1167
 * for OFDM basic rate transmissions and BSS channel widths larger than 20 MHz.
1168
 *
1169
 * The scenario considers a UDP transmission between a 40 MHz 802.11ac station and a
1170
 * 40 MHz 802.11ac access point. All transmission parameters are checked so as
1171
 * to ensure that only 2 {starting frequency, channelWidth, Number of subbands
1172
 * in SpectrumModel, modulation type} tuples are used.
1173
 *
1174
 * See \bugid{2483}
1175
 */
1176
1177
class Bug2483TestCase : public TestCase
1178
{
1179
public:
1180
  Bug2483TestCase ();
1181
  virtual ~Bug2483TestCase ();
1182
  virtual void DoRun (void);
1183
1184
private:
1185
  /**
1186
   * A tuple of {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type}
1187
   */
1188
  typedef std::tuple<double, uint8_t, uint32_t, WifiModulationClass> FreqWidthSubbandModulationTuple;
1189
  std::vector<FreqWidthSubbandModulationTuple> m_distinctTuples; ///< vector of distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
1190
1191
  /**
1192
   * Stores the distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
1193
   * that have been used during the testcase run.
1194
   * \param txParams spectrum signal parameters set by transmitter
1195
   */
1196
  void StoreDistinctTuple (std::string context, Ptr<SpectrumSignalParameters> txParams);
1197
  /**
1198
   * Triggers the arrival of a burst of 1000 Byte-long packets in the source device
1199
   * \param numPackets number of packets in burst (maximum: 255)
1200
   * \param sourceDevice pointer to the source NetDevice
1201
   * \param destination address of the destination device
1202
   */
1203
  void SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const;
1204
};
1205
1206
Bug2483TestCase::Bug2483TestCase ()
1207
  : TestCase ("Test case for Bug 2483")
1208
{
1209
}
1210
1211
Bug2483TestCase::~Bug2483TestCase ()
1212
{
1213
}
1214
1215
void
1216
Bug2483TestCase::StoreDistinctTuple (std::string context,  Ptr<SpectrumSignalParameters> txParams)
1217
{
1218
  // Extract starting frequency and number of subbands
1219
  Ptr<const SpectrumModel> c = txParams->psd->GetSpectrumModel ();
1220
  uint32_t numBands = c->GetNumBands ();
1221
  double startingFreq = c->Begin ()->fl;
1222
1223
  // Get channel bandwidth and modulation class
1224
  Ptr<const WifiSpectrumSignalParameters> wifiTxParams = DynamicCast<WifiSpectrumSignalParameters> (txParams);
1225
  Ptr<Packet> packet = wifiTxParams->packet->Copy ();
1226
  WifiPhyTag tag;
1227
  if (!packet->RemovePacketTag (tag))
1228
    {
1229
      NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag");
1230
      return;
1231
    }
1232
  WifiTxVector txVector = tag.GetWifiTxVector ();
1233
  uint8_t channelWidth = txVector.GetChannelWidth ();
1234
  WifiModulationClass modulationClass = txVector.GetMode ().GetModulationClass ();
1235
1236
  // Build a tuple and check if seen before (if so store it)
1237
  FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingFreq, channelWidth,
1238
                                                                       numBands, modulationClass);
1239
  bool found = false;
1240
  for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_distinctTuples.begin (); it != m_distinctTuples.end (); it++)
1241
    {
1242
      if (*it == tupleForCurrentTx)
1243
        {
1244
          found = true;
1245
        }
1246
    }
1247
  if (!found)
1248
    {
1249
      m_distinctTuples.push_back (tupleForCurrentTx);
1250
    }
1251
}
1252
1253
void
1254
Bug2483TestCase::SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevice,
1255
                                  Address& destination) const
1256
{
1257
  for (uint8_t i = 0; i < numPackets; i++)
1258
    {
1259
      Ptr<Packet> pkt = Create<Packet> (1000);  // 1000 dummy bytes of data
1260
      sourceDevice->Send (pkt, destination, 0);
1261
    }
1262
}
1263
1264
void
1265
Bug2483TestCase::DoRun (void)
1266
{
1267
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("500")); // so as to force RTS/CTS for data frames
1268
  Config::SetDefault ("ns3::WifiPhy::CcaMode1Threshold", DoubleValue (-62.0));
1269
1270
  NodeContainer wifiStaNode;
1271
  wifiStaNode.Create (1);
1272
1273
  NodeContainer wifiApNode;
1274
  wifiApNode.Create (1);
1275
1276
  SpectrumWifiPhyHelper spectrumPhy = SpectrumWifiPhyHelper::Default ();
1277
  Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel> ();
1278
  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> ();
1279
  lossModel->SetFrequency (5.180e9);
1280
  spectrumChannel->AddPropagationLossModel (lossModel);
1281
1282
  Ptr<ConstantSpeedPropagationDelayModel> delayModel
1283
  = CreateObject<ConstantSpeedPropagationDelayModel> ();
1284
  spectrumChannel->SetPropagationDelayModel (delayModel);
1285
1286
  spectrumPhy.SetChannel (spectrumChannel);
1287
  spectrumPhy.SetErrorRateModel ("ns3::NistErrorRateModel");
1288
  spectrumPhy.Set ("Frequency", UintegerValue (5180));
1289
  spectrumPhy.Set ("ChannelWidth", UintegerValue (40)); // at least 40 MHz expected here
1290
  spectrumPhy.Set ("TxPowerStart", DoubleValue (10));
1291
  spectrumPhy.Set ("TxPowerEnd", DoubleValue (10));
1292
1293
  WifiHelper wifi;
1294
  wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);
1295
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1296
                                "DataMode", StringValue ("VhtMcs8"),
1297
                                "ControlMode", StringValue ("VhtMcs8"));
1298
1299
  WifiMacHelper mac;
1300
  mac.SetType ("ns3::StaWifiMac");
1301
  NetDeviceContainer staDevice;
1302
  staDevice = wifi.Install (spectrumPhy, mac, wifiStaNode);
1303
1304
  mac.SetType ("ns3::ApWifiMac");
1305
  NetDeviceContainer apDevice;
1306
  apDevice = wifi.Install (spectrumPhy, mac, wifiApNode);
1307
1308
  MobilityHelper mobility;
1309
  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1310
  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1311
  positionAlloc->Add (Vector (1.0, 0.0, 0.0)); // put close enough in order to use MCS
1312
  mobility.SetPositionAllocator (positionAlloc);
1313
1314
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1315
  mobility.Install (wifiApNode);
1316
  mobility.Install (wifiStaNode);
1317
1318
  // Send two 5 packet-bursts
1319
  Simulator::Schedule (Seconds (0.5), &Bug2483TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1320
  Simulator::Schedule (Seconds (0.6), &Bug2483TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
1321
1322
  Config::Connect ("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams", MakeCallback (&Bug2483TestCase::StoreDistinctTuple, this));
1323
1324
  Simulator::Stop (Seconds (0.8));
1325
  Simulator::Run ();
1326
1327
  Simulator::Destroy ();
1328
1329
  // {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
1330
  uint8_t numberTuples = m_distinctTuples.size ();
1331
  NS_TEST_ASSERT_MSG_EQ (numberTuples, 2, "Only two distinct tuples expected");
1332
  // Note that the first tuple should the one initiated by the beacon
1333
  NS_TEST_ASSERT_MSG_EQ (std::get<0> (m_distinctTuples[0]), std::get<0> (m_distinctTuples[1]), "Both tuples should have same starting frequency");
1334
  NS_TEST_ASSERT_MSG_EQ (2 * std::get<1> (m_distinctTuples[0]), std::get<1> (m_distinctTuples[1]), "Second tuple's channel width should be double that of first");
1335
  NS_TEST_ASSERT_MSG_EQ (std::get<2> (m_distinctTuples[0]), 129, "First tuple should have 129 subbands (64+DC, 20MHz+DC, inband and 32*2 out-of-band, 10MHz on each side)");
1336
  NS_TEST_ASSERT_MSG_EQ (std::get<2> (m_distinctTuples[1]), 193, "Second tuple should have 193 subbands (128+DC, 40MHz+DC, inband and 32*2 out-of-band, 10MHz on each side)");
1337
  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[0]), WifiModulationClass::WIFI_MOD_CLASS_OFDM, "First tuple should be OFDM");
1338
  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[1]), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Second tuple should be VHT_OFDM");
1339
}
1340
1157
/**
1341
/**
1158
 * \ingroup wifi-test
1342
 * \ingroup wifi-test
1159
 * \ingroup tests
1343
 * \ingroup tests
 Lines 1176-1181   WifiTestSuite::WifiTestSuite () Link Here 
1176
  AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730
1360
  AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730
1177
  AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK);
1361
  AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK);
1178
  AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222
1362
  AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222
1363
  AddTestCase (new Bug2483TestCase, TestCase::QUICK); //Bug 2483
1179
}
1364
}
1180
1365
1181
static WifiTestSuite g_wifiTestSuite; ///< the test suite
1366
static WifiTestSuite g_wifiTestSuite; ///< the test suite

Return to bug 2843