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/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 (-8 / +26 lines)
 Lines 814-819   WifiRemoteStationManager::PrepareForQueue (Mac48Address address, const WifiMacHe Link Here 
814
}
814
}
815
815
816
WifiTxVector
816
WifiTxVector
817
WifiRemoteStationManager::AdjustChannelWidthToMode (WifiTxVector initialTxVector) const
818
{
819
  NS_LOG_FUNCTION (this << initialTxVector);
820
  WifiModulationClass modulationClass = initialTxVector.GetMode ().GetModulationClass ();
821
  uint8_t defaultChannelWidth = initialTxVector.GetChannelWidth ();
822
  if (defaultChannelWidth > 20 &&
823
      (modulationClass == WifiModulationClass::WIFI_MOD_CLASS_OFDM || // all non-HT OFDM control and management frames
824
       modulationClass == WifiModulationClass::WIFI_MOD_CLASS_ERP_OFDM)) // special case of beacons at 2.4 GHz
825
    {
826
      WifiTxVector updatedTxVector = initialTxVector;
827
      updatedTxVector.SetChannelWidth (20);
828
      NS_LOG_LOGIC ("Channel width in TXVECTOR has been updated to 20 MHz channel");
829
      return updatedTxVector;
830
    }
831
  return initialTxVector;
832
}
833
834
WifiTxVector
817
WifiRemoteStationManager::GetDataTxVector (Mac48Address address, const WifiMacHeader *header, Ptr<const Packet> packet)
835
WifiRemoteStationManager::GetDataTxVector (Mac48Address address, const WifiMacHeader *header, Ptr<const Packet> packet)
818
{
836
{
819
  NS_LOG_FUNCTION (this << address << *header << packet);
837
  NS_LOG_FUNCTION (this << address << *header << packet);
 Lines 829-835   WifiRemoteStationManager::GetDataTxVector (Mac48Address address, const WifiMacHe Link Here 
829
      v.SetNss (1);
847
      v.SetNss (1);
830
      v.SetNess (0);
848
      v.SetNess (0);
831
      v.SetStbc (m_wifiPhy->GetStbc ());
849
      v.SetStbc (m_wifiPhy->GetStbc ());
832
      return v;
850
      return AdjustChannelWidthToMode (v);
833
    }
851
    }
834
  if (!IsLowLatency ())
852
  if (!IsLowLatency ())
835
    {
853
    {
 Lines 840-848   WifiRemoteStationManager::GetDataTxVector (Mac48Address address, const WifiMacHe Link Here 
840
      //cast found to void, to suppress 'found' set but not used
858
      //cast found to void, to suppress 'found' set but not used
841
      //compiler warning
859
      //compiler warning
842
      (void) found;
860
      (void) found;
843
      return datatag.GetDataTxVector ();
861
      return AdjustChannelWidthToMode (datatag.GetDataTxVector ());
844
    }
862
    }
845
  return DoGetDataTxVector (Lookup (address, header));
863
  return AdjustChannelWidthToMode (DoGetDataTxVector (Lookup (address, header)));
846
}
864
}
847
865
848
WifiTxVector
866
WifiTxVector
 Lines 859-867   WifiRemoteStationManager::GetCtsToSelfTxVector (const WifiMacHeader *header, Link Here 
859
      //cast found to void, to suppress 'found' set but not used
877
      //cast found to void, to suppress 'found' set but not used
860
      //compiler warning
878
      //compiler warning
861
      (void) found;
879
      (void) found;
862
      return ctstoselftag.GetCtsToSelfTxVector ();
880
      return AdjustChannelWidthToMode (ctstoselftag.GetCtsToSelfTxVector ());
863
    }
881
    }
864
  return DoGetCtsToSelfTxVector ();
882
  return AdjustChannelWidthToMode (DoGetCtsToSelfTxVector ());
865
}
883
}
866
884
867
WifiTxVector
885
WifiTxVector
 Lines 1469-1475   WifiRemoteStationManager::GetCtsTxVector (Mac48Address address, WifiMode rtsMode Link Here 
1469
  v.SetNss (DoGetCtsTxNss (address, ctsMode));
1487
  v.SetNss (DoGetCtsTxNss (address, ctsMode));
1470
  v.SetNess (DoGetCtsTxNess (address, ctsMode));
1488
  v.SetNess (DoGetCtsTxNess (address, ctsMode));
1471
  v.SetStbc (m_wifiPhy->GetStbc ());
1489
  v.SetStbc (m_wifiPhy->GetStbc ());
1472
  return v;
1490
  return AdjustChannelWidthToMode (v);
1473
}
1491
}
1474
1492
1475
WifiTxVector
1493
WifiTxVector
 Lines 1486-1492   WifiRemoteStationManager::GetAckTxVector (Mac48Address address, WifiMode dataMod Link Here 
1486
  v.SetNss (DoGetAckTxNss (address, ackMode));
1504
  v.SetNss (DoGetAckTxNss (address, ackMode));
1487
  v.SetNess (DoGetAckTxNess (address, ackMode));
1505
  v.SetNess (DoGetAckTxNess (address, ackMode));
1488
  v.SetStbc (m_wifiPhy->GetStbc ());
1506
  v.SetStbc (m_wifiPhy->GetStbc ());
1489
  return v;
1507
  return AdjustChannelWidthToMode (v);
1490
}
1508
}
1491
1509
1492
WifiTxVector
1510
WifiTxVector
 Lines 1503-1509   WifiRemoteStationManager::GetBlockAckTxVector (Mac48Address address, WifiMode bl Link Here 
1503
  v.SetNss (DoGetBlockAckTxNss (address, blockAckMode));
1521
  v.SetNss (DoGetBlockAckTxNss (address, blockAckMode));
1504
  v.SetNess (DoGetBlockAckTxNess (address, blockAckMode));
1522
  v.SetNess (DoGetBlockAckTxNess (address, blockAckMode));
1505
  v.SetStbc (m_wifiPhy->GetStbc ());
1523
  v.SetStbc (m_wifiPhy->GetStbc ());
1506
  return v;
1524
  return AdjustChannelWidthToMode (v);
1507
}
1525
}
1508
1526
1509
uint8_t
1527
uint8_t
(-)a/src/wifi/model/wifi-remote-station-manager.h (+9 lines)
 Lines 1445-1450   private: Link Here 
1445
   * \return the number of fragments needed
1445
   * \return the number of fragments needed
1446
   */
1446
   */
1447
  uint32_t GetNFragments (const WifiMacHeader *header, Ptr<const Packet> packet);
1447
  uint32_t GetNFragments (const WifiMacHeader *header, Ptr<const Packet> packet);
1448
  /**
1449
   * Adjust the channel width to the selected mode (instead of letting the PHY's
1450
   * default channel width). This is especially useful when using non-HT modes
1451
   * with HT/VHT/HE capable stations (with default width above 20 MHz).
1452
   *
1453
   * \param initialTxVector TXVECTOR using the PHY's default channel width
1454
   * \return TXVECTOR with channel width adapted to the selected mode
1455
   */
1456
  WifiTxVector AdjustChannelWidthToMode (WifiTxVector initialTxVector) const;
1448
1457
1449
  /**
1458
  /**
1450
   * A vector of WifiRemoteStations
1459
   * A vector of WifiRemoteStations
(-)a/src/wifi/test/wifi-test.cc (+203 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/udp-client-server-helper.h"
44
#include "ns3/wifi-spectrum-signal-parameters.h"
45
#include "ns3/wifi-phy-tag.h"
46
#include "ns3/internet-stack-helper.h"
47
#include "ns3/ipv4-address-helper.h"
48
#include <tuple>
49
#include <vector>
40
50
41
using namespace ns3;
51
using namespace ns3;
42
52
 Lines 1154-1159   Bug2222TestCase::DoRun (void) Link Here 
1154
  NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!");
1164
  NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!");
1155
}
1165
}
1156
1166
1167
//-----------------------------------------------------------------------------
1168
/**
1169
 * Make sure that the correct channel width and center frequency have been set
1170
 * for OFDM basic rate transmissions and BSS channel widths larger than 20 MHz.
1171
 *
1172
 * The scenario considers a UDP transmission between a 40 MHz 802.11ac station and a
1173
 * 40 MHz 802.11ac access point. All transmission parameters are checked so as
1174
 * to ensure that only 2 {starting frequency, channelWidth, Number of subbands
1175
 * in SpectrumModel, modulation type} tuples are used.
1176
 *
1177
 * See \bugid{2483}
1178
 */
1179
1180
class Bug2483TestCase : public TestCase
1181
{
1182
public:
1183
  Bug2483TestCase ();
1184
  virtual ~Bug2483TestCase ();
1185
  virtual void DoRun (void);
1186
1187
private:
1188
  /**
1189
   * A tuple of {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type}
1190
   */
1191
  typedef std::tuple<double, uint8_t, uint32_t, WifiModulationClass> FreqWidthSubbandModulationTuple;
1192
  std::vector<FreqWidthSubbandModulationTuple> m_distinctTuples; ///< vector of distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
1193
1194
  /**
1195
   * Stores the distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
1196
   * that have been used during the testcase run.
1197
   * \param txParams spectrum signal parameters set by transmitter
1198
   */
1199
  void StoreDistinctTuple (std::string context, Ptr<SpectrumSignalParameters> txParams);
1200
1201
};
1202
1203
Bug2483TestCase::Bug2483TestCase ()
1204
  : TestCase ("Test case for Bug 2483")
1205
{
1206
}
1207
1208
Bug2483TestCase::~Bug2483TestCase ()
1209
{
1210
}
1211
1212
void
1213
Bug2483TestCase::StoreDistinctTuple (std::string context,  Ptr<SpectrumSignalParameters> txParams)
1214
{
1215
  // Extract starting frequency and number of subbands
1216
  Ptr<const SpectrumModel> c = txParams->psd->GetSpectrumModel ();
1217
  uint32_t numBands = c->GetNumBands ();
1218
  double startingFreq = c->Begin ()->fl;
1219
1220
  // Get channel bandwidth and modulation class
1221
  Ptr<const WifiSpectrumSignalParameters> wifiTxParams = DynamicCast<WifiSpectrumSignalParameters> (txParams);
1222
  Ptr<Packet> packet = wifiTxParams->packet->Copy ();
1223
  WifiPhyTag tag;
1224
  if (!packet->RemovePacketTag (tag))
1225
    {
1226
      NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag");
1227
      return;
1228
    }
1229
  WifiTxVector txVector = tag.GetWifiTxVector ();
1230
  uint8_t channelWidth = txVector.GetChannelWidth ();
1231
  WifiModulationClass modulationClass = txVector.GetMode ().GetModulationClass ();
1232
1233
  // Build a tuple and check if seen before (if so store it)
1234
  FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingFreq, channelWidth,
1235
                                                                       numBands, modulationClass);
1236
  bool found = false;
1237
  for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_distinctTuples.begin (); it != m_distinctTuples.end (); it++)
1238
    {
1239
      if (*it == tupleForCurrentTx)
1240
        {
1241
          found = true;
1242
        }
1243
    }
1244
  if (!found)
1245
    {
1246
      m_distinctTuples.push_back (tupleForCurrentTx);
1247
    }
1248
}
1249
1250
1251
void
1252
Bug2483TestCase::DoRun (void)
1253
{
1254
  Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("500")); // so as to force RTS/CTS for data frames
1255
  Config::SetDefault ("ns3::WifiPhy::CcaMode1Threshold", DoubleValue (-62.0));
1256
1257
  NodeContainer wifiStaNode;
1258
  wifiStaNode.Create (1);
1259
1260
  NodeContainer wifiApNode;
1261
  wifiApNode.Create (1);
1262
1263
  SpectrumWifiPhyHelper spectrumPhy = SpectrumWifiPhyHelper::Default ();
1264
  Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectrumChannel> ();
1265
  Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossModel> ();
1266
  lossModel->SetFrequency (5.180e9);
1267
  spectrumChannel->AddPropagationLossModel (lossModel);
1268
1269
  Ptr<ConstantSpeedPropagationDelayModel> delayModel
1270
  = CreateObject<ConstantSpeedPropagationDelayModel> ();
1271
  spectrumChannel->SetPropagationDelayModel (delayModel);
1272
1273
  spectrumPhy.SetChannel (spectrumChannel);
1274
  spectrumPhy.SetErrorRateModel ("ns3::NistErrorRateModel");
1275
  spectrumPhy.Set ("Frequency", UintegerValue (5180));
1276
  spectrumPhy.Set ("ChannelWidth", UintegerValue (40)); // at least 40 MHz expected here
1277
  spectrumPhy.Set ("TxPowerStart", DoubleValue (10));
1278
  spectrumPhy.Set ("TxPowerEnd", DoubleValue (10));
1279
1280
  WifiHelper wifi;
1281
  wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);
1282
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
1283
                                "DataMode", StringValue ("VhtMcs8"),
1284
                                "ControlMode", StringValue ("VhtMcs8"));
1285
1286
  WifiMacHelper mac;
1287
  Ssid ssid = Ssid ("ns-3-ssid");
1288
  mac.SetType ("ns3::StaWifiMac",
1289
               "Ssid", SsidValue (ssid),
1290
               "ActiveProbing", BooleanValue (false));
1291
1292
  NetDeviceContainer staDevice;
1293
  staDevice = wifi.Install (spectrumPhy, mac, wifiStaNode);
1294
1295
  mac.SetType ("ns3::ApWifiMac",
1296
               "Ssid", SsidValue (ssid),
1297
               "BeaconGeneration", BooleanValue (true));
1298
1299
  NetDeviceContainer apDevice;
1300
  apDevice = wifi.Install (spectrumPhy, mac, wifiApNode);
1301
1302
  MobilityHelper mobility;
1303
  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
1304
1305
  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
1306
  positionAlloc->Add (Vector (1.0, 0.0, 0.0)); // put close enough in order to use MCS
1307
  mobility.SetPositionAllocator (positionAlloc);
1308
1309
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
1310
  mobility.Install (wifiApNode);
1311
  mobility.Install (wifiStaNode);
1312
1313
  InternetStackHelper stack;
1314
  stack.Install (wifiApNode);
1315
  stack.Install (wifiStaNode);
1316
1317
  Ipv4AddressHelper address;
1318
  address.SetBase ("192.168.1.0", "255.255.255.0");
1319
  Ipv4InterfaceContainer staNodeInterface;
1320
  Ipv4InterfaceContainer apNodeInterface;
1321
1322
  staNodeInterface = address.Assign (staDevice);
1323
  apNodeInterface = address.Assign (apDevice);
1324
1325
  ApplicationContainer serverApp;
1326
  uint16_t port = 9;
1327
  UdpServerHelper server (port);
1328
  serverApp = server.Install (wifiStaNode.Get (0));
1329
  serverApp.Start (Seconds (0.0));
1330
  serverApp.Stop (Seconds (1.0));
1331
1332
  UdpClientHelper client (staNodeInterface.GetAddress (0), port);
1333
  client.SetAttribute ("MaxPackets", UintegerValue (10)); // so as to have a short run
1334
  client.SetAttribute ("Interval", TimeValue (Time ("0.00001")));
1335
  client.SetAttribute ("PacketSize", UintegerValue (1000));
1336
  ApplicationContainer clientApp = client.Install (wifiApNode.Get (0));
1337
  clientApp.Start (Seconds (0.5));
1338
  clientApp.Stop (Seconds (1.0));
1339
1340
  Config::Connect ("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams", MakeCallback (&Bug2483TestCase::StoreDistinctTuple, this));
1341
1342
  Simulator::Stop (Seconds (1.1));
1343
  Simulator::Run ();
1344
1345
  Simulator::Destroy ();
1346
1347
  // {starting frequency, channelWidth, Number of subbands in SpectrumModel, modulation type} tuples
1348
  uint8_t numberTuples = m_distinctTuples.size ();
1349
  NS_TEST_ASSERT_MSG_EQ (numberTuples, 2, "Only two distinct tuples expected");
1350
  // Note that the first tuple should the one initiated by the beacon
1351
  NS_TEST_ASSERT_MSG_EQ (std::get<0> (m_distinctTuples[0]), std::get<0> (m_distinctTuples[1]), "Both tuples should have same starting frequency");
1352
  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");
1353
  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)");
1354
  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)");
1355
  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[0]), WifiModulationClass::WIFI_MOD_CLASS_OFDM, "First tuple should be OFDM");
1356
  NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[1]), WifiModulationClass::WIFI_MOD_CLASS_VHT, "Second tuple should be VHT_OFDM");
1357
}
1358
1157
/**
1359
/**
1158
 * \ingroup wifi-test
1360
 * \ingroup wifi-test
1159
 * \ingroup tests
1361
 * \ingroup tests
 Lines 1176-1181   WifiTestSuite::WifiTestSuite () Link Here 
1176
  AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730
1378
  AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730
1177
  AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK);
1379
  AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK);
1178
  AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222
1380
  AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222
1381
  AddTestCase (new Bug2483TestCase, TestCase::QUICK); //Bug 2483
1179
}
1382
}
1180
1383
1181
static WifiTestSuite g_wifiTestSuite; ///< the test suite
1384
static WifiTestSuite g_wifiTestSuite; ///< the test suite

Return to bug 2843