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

(-)a/src/wifi/model/interference-helper.cc (-2 / +1 lines)
 Lines 262-269    Link Here 
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 || txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_VHT || txVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HE)
264
    {
264
    {
265
      nbits /= txVector.GetNss (); //divide effective number of bits by NSS to achieve same chunk error rate as SISO for AWGN
265
      double gain = std::pow (2, txVector.GetNTx () + m_numRxAntennas - 2 * txVector.GetNss ()); //compute gain offered by MIMO, 3dB per redundant radio chain
266
      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 () <<
266
      NS_LOG_DEBUG ("TX=" << +txVector.GetNTx () <<
268
                    ", RX=" << +m_numRxAntennas <<
267
                    ", RX=" << +m_numRxAntennas <<
269
                    ", SNIR improvement=+" << 10 * std::log10 (gain) << "dB");
268
                    ", SNIR improvement=+" << 10 * std::log10 (gain) << "dB");
(-)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 / +98 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 2x2 with two spatial streams
377
  // Set number of transmit antennas to 2, receive to 2; set HtMcs8 
378
  // The data rate will double (HtMcs8) but for a given frame, spread across
379
  // two spatial streams, the duration will be cut in half.  The required SNR 
380
  // to maintain the same chunkSuccess should be the same as 1x1 at MCS0
381
  mode = WifiPhy::GetHtMcs8 ();
382
  txVector.SetMode (mode);
383
  interference.SetNumberOfReceiveAntennas (2);
384
  txVector.SetNTx (2);
385
  txVector.SetNss (2);
386
  snr = baselineSnr;
387
  chunkSuccess = interference.CalculateChunkSuccessRate (snr, baselineDuration / 2, mode, txVector);
388
  NS_TEST_ASSERT_MSG_EQ_TOL (chunkSuccess, baselineChunkSuccess, 0.000001, "Not equal within tolerance for 2 spatial streams");
389
}
390
391
/**
392
 * \ingroup wifi-test
393
 * \ingroup tests
394
 *
298
 * \brief Wifi Error Rate Models Test Suite
395
 * \brief Wifi Error Rate Models Test Suite
299
 */
396
 */
300
class WifiErrorRateModelsTestSuite : public TestSuite
397
class WifiErrorRateModelsTestSuite : public TestSuite
 Lines 308-314    Link Here 
308
{
405
{
309
  AddTestCase (new WifiErrorRateModelsTestCaseDsss, TestCase::QUICK);
406
  AddTestCase (new WifiErrorRateModelsTestCaseDsss, TestCase::QUICK);
310
  AddTestCase (new WifiErrorRateModelsTestCaseNist, TestCase::QUICK);
407
  AddTestCase (new WifiErrorRateModelsTestCaseNist, TestCase::QUICK);
408
  AddTestCase (new WifiErrorRateModelsTestCaseMimo, TestCase::QUICK);
311
}
409
}
312
410
313
static WifiErrorRateModelsTestSuite wifiErrorRateModelsTestSuite; ///< the test suite
411
static WifiErrorRateModelsTestSuite wifiErrorRateModelsTestSuite; ///< the test suite
314

Return to bug 3011