|
|
| 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 |
|
|
|
| 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 |
|
|
| 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 |
|
|
|