make wifi tests more robust to random variable perturbations

This commit is contained in:
Tom Henderson
2013-09-08 09:57:13 -07:00
parent c5971345d1
commit 2d06f4dbc8

View File

@@ -38,9 +38,42 @@
#include "ns3/mac-rx-middle.h"
#include "ns3/pointer.h"
#include "ns3/rng-seed-manager.h"
#include "ns3/edca-txop-n.h"
namespace ns3 {
// helper function to assign streams to random variables, to control
// randomness in the tests
static void
AssignWifiRandomStreams (Ptr<WifiMac> mac, int64_t stream)
{
int64_t currentStream = stream;
Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac);
if (rmac)
{
PointerValue ptr;
rmac->GetAttribute ("DcaTxop", ptr);
Ptr<DcaTxop> dcaTxop = ptr.Get<DcaTxop> ();
currentStream += dcaTxop->AssignStreams (currentStream);
rmac->GetAttribute ("VO_EdcaTxopN", ptr);
Ptr<EdcaTxopN> vo_edcaTxopN = ptr.Get<EdcaTxopN> ();
currentStream += vo_edcaTxopN->AssignStreams (currentStream);
rmac->GetAttribute ("VI_EdcaTxopN", ptr);
Ptr<EdcaTxopN> vi_edcaTxopN = ptr.Get<EdcaTxopN> ();
currentStream += vi_edcaTxopN->AssignStreams (currentStream);
rmac->GetAttribute ("BE_EdcaTxopN", ptr);
Ptr<EdcaTxopN> be_edcaTxopN = ptr.Get<EdcaTxopN> ();
currentStream += be_edcaTxopN->AssignStreams (currentStream);
rmac->GetAttribute ("BK_EdcaTxopN", ptr);
Ptr<EdcaTxopN> bk_edcaTxopN = ptr.Get<EdcaTxopN> ();
currentStream += bk_edcaTxopN->AssignStreams (currentStream);
}
}
class WifiTest : public TestCase
{
public:
@@ -378,7 +411,8 @@ Bug555TestCase::DoRun (void)
m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel");
m_manager.SetTypeId ("ns3::ConstantRateWifiManager");
//The simulation with the following seed and run numbers expe
// Assign a seed and run number, and later fix the assignment of streams to
// WiFi random variables, so that the first backoff used is zero slots
RngSeedManager::SetSeed (1);
RngSeedManager::SetRun (17);
@@ -392,6 +426,11 @@ Bug555TestCase::DoRun (void)
Ptr<WifiNetDevice> txDev = CreateObject<WifiNetDevice> ();
Ptr<WifiMac> txMac = m_mac.Create<WifiMac> ();
txMac->ConfigureStandard (WIFI_PHY_STANDARD_80211a);
// Fix the stream assignment to the Dcf Txop objects (backoffs)
// The below stream assignment will result in the DcaTxop object
// using a backoff value of zero for this test when the
// DcaTxop::EndTxNoAck() calls to StartBackoffNow()
AssignWifiRandomStreams (txMac, 23);
Ptr<ConstantPositionMobilityModel> txMobility = CreateObject<ConstantPositionMobilityModel> ();
Ptr<YansWifiPhy> txPhy = CreateObject<YansWifiPhy> ();