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

(-)a/src/wifi/model/interference-helper.cc (-2 / +4 lines)
 Lines 260-268    Link Here 
260
    }
260
    }
261
  uint64_t rate = mode.GetPhyRate (txVector);
261
  uint64_t rate = mode.GetPhyRate (txVector);
262
  uint64_t nbits = static_cast<uint64_t> (rate * duration.GetSeconds ());
262
  uint64_t nbits = static_cast<uint64_t> (rate * duration.GetSeconds ());
263
  if (txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT || txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_VHT || txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HE)
263
  if ((txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT ||
264
       txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_VHT ||
265
       txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HE) &&
266
      txVector.GetNss () == 1)
264
    {
267
    {
265
      nbits /= txVector.GetNss (); //divide effective number of bits by NSS to achieve same chunk error rate as SISO for AWGN
266
      double gain = (txVector.GetNTx () * m_numRxAntennas); //compute gain offered by MIMO, SIMO or MISO compared to SISO for AWGN
268
      double gain = (txVector.GetNTx () * m_numRxAntennas); //compute gain offered by MIMO, SIMO or MISO compared to SISO for AWGN
267
      NS_LOG_DEBUG ("TX=" << +txVector.GetNTx () <<
269
      NS_LOG_DEBUG ("TX=" << +txVector.GetNTx () <<
268
                    ", RX=" << +m_numRxAntennas <<
270
                    ", RX=" << +m_numRxAntennas <<
(-)a/src/wifi/model/interference-helper.h (+2 lines)
 Lines 285-291    Link Here 
285
   *
285
   *
286
   * \return the success rate
286
   * \return the success rate
287
   */
287
   */
288
public:
288
  double CalculateChunkSuccessRate (double snir, Time duration, WifiMode mode, WifiTxVector txVector) const;
289
  double CalculateChunkSuccessRate (double snir, Time duration, WifiMode mode, WifiTxVector txVector) const;
290
private:
289
  /**
291
  /**
290
   * Calculate the error rate of the given plcp payload. The plcp payload can be divided into
292
   * Calculate the error rate of the given plcp payload. The plcp payload can be divided into
291
   * multiple chunks (e.g. due to interference from other transmissions).
293
   * multiple chunks (e.g. due to interference from other transmissions).
(-)a/src/wifi/test/wifi-error-rate-models-test.cc (-1 / +116 lines)
 Lines 23-28    Link Here 
23
#include "ns3/nist-error-rate-model.h"
23
#include "ns3/nist-error-rate-model.h"
24
#include "ns3/dsss-error-rate-model.h"
24
#include "ns3/dsss-error-rate-model.h"
25
#include "ns3/wifi-tx-vector.h"
25
#include "ns3/wifi-tx-vector.h"
26
#include "ns3/wifi-mode.h"
27
#include "ns3/wifi-phy.h"
28
#include "ns3/wifi-utils.h"
29
#include "ns3/interference-helper.h"
26
30
27
using namespace ns3;
31
using namespace ns3;
28
32
 Lines 295-300    Link Here 
295
 * \ingroup wifi-test
299
 * \ingroup wifi-test
296
 * \ingroup tests
300
 * \ingroup tests
297
 *
301
 *
302
 * \brief Wifi Error Rate Models check MIMO abstraction
303
 */
304
class WifiErrorRateModelsTestCaseMimo : public TestCase
305
{
306
public:
307
  WifiErrorRateModelsTestCaseMimo ();
308
  virtual ~WifiErrorRateModelsTestCaseMimo ();
309
310
private:
311
  virtual void DoRun (void);
312
};
313
314
WifiErrorRateModelsTestCaseMimo::WifiErrorRateModelsTestCaseMimo ()
315
  : TestCase ("WifiErrorRateModel test case MIMO abstraction")
316
{
317
}
318
319
WifiErrorRateModelsTestCaseMimo::~WifiErrorRateModelsTestCaseMimo ()
320
{
321
}
322
323
void
324
WifiErrorRateModelsTestCaseMimo::DoRun (void)
325
{
326
  InterferenceHelper interference;
327
  WifiMode mode = WifiPhy::GetHtMcs0 ();
328
  WifiTxVector txVector;
329
330
  txVector.SetMode (mode);
331
  txVector.SetTxPowerLevel (0);
332
  txVector.SetChannelWidth (20);
333
  txVector.SetNss (1);
334
  txVector.SetNTx (1);
335
336
  interference.SetNumberOfReceiveAntennas (1);
337
  Ptr<NistErrorRateModel> nist = CreateObject<NistErrorRateModel> ();
338
  interference.SetErrorRateModel (nist);
339
340
  // Set the SNR so as to obtain a chunk success ratio of between 0 and 1
341
  // 4 dB SNR at HtMcs0 and 2 ms duration yields a success probability of
342
  // 0.820266 with this OFDM error model
343
  double snr = DbToRatio (4);
344
  double baselineSnr = snr;
345
  Time baselineDuration = MilliSeconds (2);
346
  double chunkSuccess = interference.CalculateChunkSuccessRate (snr, baselineDuration, mode, txVector);
347
  NS_TEST_ASSERT_MSG_EQ_TOL (chunkSuccess, 0.820266, 0.000001, "Attempt to set baseline to known value failed");
348
  double baselineChunkSuccess = chunkSuccess;
349
350
  // MIMO 1x2 spatial diversity
351
  // Increase number of receive antennas to 2; expect that required SNR drops
352
  // by factor of 3 dB to maintain the same success ratio
353
  interference.SetNumberOfReceiveAntennas (2);
354
  snr = baselineSnr / 2;  // -3 dB
355
  chunkSuccess = interference.CalculateChunkSuccessRate (snr, baselineDuration, mode, txVector);
356
  NS_TEST_ASSERT_MSG_EQ_TOL (chunkSuccess, baselineChunkSuccess, 0.000001, "Not equal within tolerance for 1x2 spatial diversity");
357
358
  // MIMO 2x1 spatial diversity
359
  // Set number of transmit antennas to 2, receive to 1; expect that
360
  // required SNR drops by factor of 3 dB to maintain the same success ratio
361
  interference.SetNumberOfReceiveAntennas (1);
362
  txVector.SetNTx (2);
363
  snr = baselineSnr / 2;  // -3 dB
364
  chunkSuccess = interference.CalculateChunkSuccessRate (snr, baselineDuration, mode, txVector);
365
  NS_TEST_ASSERT_MSG_EQ_TOL (chunkSuccess, baselineChunkSuccess, 0.000001, "Not equal within tolerance for 2x1 spatial diversity");
366
367
  // MIMO 2x2 spatial diversity
368
  // Set number of transmit antennas to 2, receive to 2; expect that
369
  // required SNR drops by factor of 6 dB to maintain the same success ratio
370
  interference.SetNumberOfReceiveAntennas (2);
371
  txVector.SetNTx (2);
372
  snr = baselineSnr / 4;  // -6 dB
373
  chunkSuccess = interference.CalculateChunkSuccessRate (snr, baselineDuration, mode, txVector);
374
  NS_TEST_ASSERT_MSG_EQ_TOL (chunkSuccess, baselineChunkSuccess, 0.000001, "Not equal within tolerance for 2x2 spatial diversity");
375
376
  // MIMO 3x1 spatial diversity
377
  // Set number of transmit antennas to 3, receive to 1; expect that
378
  // required SNR drops by factor of 3 to maintain the same success ratio
379
  interference.SetNumberOfReceiveAntennas (3);
380
  txVector.SetNTx (1);
381
  snr = baselineSnr / 3;
382
  chunkSuccess = interference.CalculateChunkSuccessRate (snr, baselineDuration, mode, txVector);
383
  NS_TEST_ASSERT_MSG_EQ_TOL (chunkSuccess, baselineChunkSuccess, 0.000001, "Not equal within tolerance for 3x1 spatial diversity");
384
385
  // MIMO 1x3 spatial diversity
386
  // Set number of transmit antennas to 1, receive to 3; expect that
387
  // required SNR drops by factor of 3 to maintain the same success ratio
388
  interference.SetNumberOfReceiveAntennas (1);
389
  txVector.SetNTx (3);
390
  snr = baselineSnr / 3;
391
  chunkSuccess = interference.CalculateChunkSuccessRate (snr, baselineDuration, mode, txVector);
392
  NS_TEST_ASSERT_MSG_EQ_TOL (chunkSuccess, baselineChunkSuccess, 0.000001, "Not equal within tolerance for 1x3 spatial diversity");
393
394
  // MIMO 2x2 with two spatial streams
395
  // Set number of transmit antennas to 2, receive to 2; set HtMcs8
396
  // The data rate will double (HtMcs8) but for a given frame, spread across
397
  // two spatial streams, the duration will be cut in half.  The required SNR
398
  // to maintain the same chunkSuccess should be the same as 1x1 at MCS0
399
  mode = WifiPhy::GetHtMcs8 ();
400
  txVector.SetMode (mode);
401
  interference.SetNumberOfReceiveAntennas (2);
402
  txVector.SetNTx (2);
403
  txVector.SetNss (2);
404
  snr = baselineSnr;
405
  chunkSuccess = interference.CalculateChunkSuccessRate (snr, baselineDuration / 2, mode, txVector);
406
  NS_TEST_ASSERT_MSG_EQ_TOL (chunkSuccess, baselineChunkSuccess, 0.000001, "Not equal within tolerance for 2 spatial streams");
407
}
408
409
/**
410
 * \ingroup wifi-test
411
 * \ingroup tests
412
 *
298
 * \brief Wifi Error Rate Models Test Suite
413
 * \brief Wifi Error Rate Models Test Suite
299
 */
414
 */
300
class WifiErrorRateModelsTestSuite : public TestSuite
415
class WifiErrorRateModelsTestSuite : public TestSuite
 Lines 308-314    Link Here 
308
{
423
{
309
  AddTestCase (new WifiErrorRateModelsTestCaseDsss, TestCase::QUICK);
424
  AddTestCase (new WifiErrorRateModelsTestCaseDsss, TestCase::QUICK);
310
  AddTestCase (new WifiErrorRateModelsTestCaseNist, TestCase::QUICK);
425
  AddTestCase (new WifiErrorRateModelsTestCaseNist, TestCase::QUICK);
426
  AddTestCase (new WifiErrorRateModelsTestCaseMimo, TestCase::QUICK);
311
}
427
}
312
428
313
static WifiErrorRateModelsTestSuite wifiErrorRateModelsTestSuite; ///< the test suite
429
static WifiErrorRateModelsTestSuite wifiErrorRateModelsTestSuite; ///< the test suite
314

Return to bug 3011