src/test/ns3wifi/wifi-interference-test-suite.cc
changeset 10139 17a71cd49da3
parent 9266 d26408b17360
child 10968 2d29fee2b7b8
equal deleted inserted replaced
10138:2f8e35b43d11 10139:17a71cd49da3
    59   virtual void DoRun (void);
    59   virtual void DoRun (void);
    60   void ReceivePacket (Ptr<Socket> socket);
    60   void ReceivePacket (Ptr<Socket> socket);
    61   static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval);
    61   static void GenerateTraffic (Ptr<Socket> socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval);
    62   void PrintEndSync (std::string context, uint32_t dataRate, double snr, double per);
    62   void PrintEndSync (std::string context, uint32_t dataRate, double snr, double per);
    63   double WifiSimpleInterference (std::string phyMode, double Prss, double Irss, double delta, uint32_t PpacketSize, 
    63   double WifiSimpleInterference (std::string phyMode, double Prss, double Irss, double delta, uint32_t PpacketSize, 
    64                                  uint32_t IpacketSize, bool verbose, InternetStackHelper internet);
    64                                  uint32_t IpacketSize, bool verbose, InternetStackHelper internet, WifiPhyStandard wifiStandard);
    65   double m_PER;
    65   double m_PER;
    66   double m_SNR;
    66   double m_SNR;
    67   uint32_t m_DataRate;
    67   uint32_t m_DataRate;
    68 };
    68 };
    69 
    69 
   118   m_SNR = snr;
   118   m_SNR = snr;
   119   m_DataRate = dataRate;
   119   m_DataRate = dataRate;
   120 }
   120 }
   121 
   121 
   122 double 
   122 double 
   123 WifiInterferenceTestCase::WifiSimpleInterference (std::string phyMode,double Prss, double Irss, double delta, uint32_t PpacketSize, uint32_t IpacketSize, bool verbose, InternetStackHelper internet)
   123 WifiInterferenceTestCase::WifiSimpleInterference (std::string phyMode,double Prss, double Irss, double delta, uint32_t PpacketSize, uint32_t IpacketSize, bool verbose, InternetStackHelper internet, WifiPhyStandard wifiStandard)
   124 {
   124 {
   125 
   125 
   126   uint32_t numPackets = 1;
   126   uint32_t numPackets = 1;
   127   double interval = 1.0; // seconds
   127   double interval = 1.0; // seconds
   128   double startTime = 10.0; // seconds
   128   double startTime = 10.0; // seconds
   149   NodeContainer c;
   149   NodeContainer c;
   150   c.Create (3);
   150   c.Create (3);
   151 
   151 
   152   // The below set of helpers will help us to put together the wifi NICs we want
   152   // The below set of helpers will help us to put together the wifi NICs we want
   153   WifiHelper wifi;
   153   WifiHelper wifi;
   154   wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
   154   wifi.SetStandard (wifiStandard);
   155 
   155 
   156   YansWifiPhyHelper wifiPhy =  YansWifiPhyHelper::Default ();
   156   YansWifiPhyHelper wifiPhy =  YansWifiPhyHelper::Default ();
   157   // This is one parameter that matters when using FixedRssLossModel
   157   // This is one parameter that matters when using FixedRssLossModel
   158   // set it to zero; otherwise, gain will be added
   158   // set it to zero; otherwise, gain will be added
   159   wifiPhy.Set ("RxGain", DoubleValue (0) ); 
   159   wifiPhy.Set ("RxGain", DoubleValue (0) ); 
   239 void
   239 void
   240 WifiInterferenceTestCase::DoRun (void)
   240 WifiInterferenceTestCase::DoRun (void)
   241 {
   241 {
   242 
   242 
   243   std::string phyMode ("DsssRate1Mbps");
   243   std::string phyMode ("DsssRate1Mbps");
       
   244   WifiPhyStandard wifiStandard=WIFI_PHY_STANDARD_80211b;
   244   double Prss = -90;  // -dBm
   245   double Prss = -90;  // -dBm
   245   double Irss = -90;  // -dBm
   246   double Irss = -90;  // -dBm
   246   double delta = 0;  // microseconds
   247   double delta = 0;  // microseconds
   247   uint32_t PpacketSize = 1000; // bytes
   248   uint32_t PpacketSize = 1000; // bytes
   248   uint32_t IpacketSize = 1000; // bytes
   249   uint32_t IpacketSize = 1000; // bytes
   251   InternetStackHelper internet;
   252   InternetStackHelper internet;
   252 
   253 
   253   // Compute the packet error rate (PER) when delta=0 microseconds.  This
   254   // Compute the packet error rate (PER) when delta=0 microseconds.  This
   254   // means that the interferer arrives at exactly the same time as the
   255   // means that the interferer arrives at exactly the same time as the
   255   // intended packet
   256   // intended packet
   256   PER = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
   257   PER = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet,wifiStandard);
   257 
   258 
   258   // Now rerun this test case and compute the PER when the delta time between
   259   // Now rerun this test case and compute the PER when the delta time between
   259   // arrival of the intended frame and interferer is 1 microsecond.
   260   // arrival of the intended frame and interferer is 1 microsecond.
   260   delta = 1;
   261   delta = 1;
   261   PER1 = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
   262   PER1 = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet,wifiStandard);
   262 
   263 
   263   // Now rerun this test case and compute the PER when the delta time between
   264   // Now rerun this test case and compute the PER when the delta time between
   264   // arrival of the intended frame and interferer is 2 microseconds.
   265   // arrival of the intended frame and interferer is 2 microseconds.
   265   delta = 2;
   266   delta = 2;
   266   PER2 = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet);
   267   PER2 = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet,wifiStandard);
   267 
   268 
   268   double PERDiff1 = PER - PER1;
   269   double PERDiff1 = PER - PER1;
   269 
   270 
   270   double PERDiff2 = PER1 - PER2;
   271   double PERDiff2 = PER1 - PER2;
   271 
   272 
   272   NS_TEST_ASSERT_MSG_EQ (PERDiff1, PERDiff2, 
   273   NS_TEST_ASSERT_MSG_EQ (PERDiff1, PERDiff2, 
   273                          "The PER difference due to 1 microsecond difference in arrival shouldn't depend on absolute arrival");
   274                          "The PER difference due to 1 microsecond difference in arrival shouldn't depend on absolute arrival");
       
   275   //Now rerun for 11n
       
   276   wifiStandard=WIFI_PHY_STANDARD_80211n_2_4GHZ;
       
   277   // Compute the packet error rate (PER) when delta=0 microseconds.  This
       
   278   // means that the interferer arrives at exactly the same time as the
       
   279   // intended packet
       
   280   PER = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet,wifiStandard);
       
   281 
       
   282   // Now rerun this test case and compute the PER when the delta time between
       
   283   // arrival of the intended frame and interferer is 1 microsecond.
       
   284   delta = 1;
       
   285   PER1 = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet,wifiStandard);
       
   286 
       
   287   // Now rerun this test case and compute the PER when the delta time between
       
   288   // arrival of the intended frame and interferer is 2 microseconds.
       
   289   delta = 2;
       
   290   PER2 = WifiSimpleInterference (phyMode,Prss,Irss,delta,PpacketSize,IpacketSize,verbose,internet,wifiStandard);
       
   291 
       
   292   PERDiff1 = PER - PER1;
       
   293 
       
   294   PERDiff2 = PER1 - PER2;
       
   295 
       
   296   NS_TEST_ASSERT_MSG_EQ (PERDiff1, PERDiff2, 
       
   297                          "The PER difference due to 1 microsecond difference in arrival shouldn't depend on absolute arrival");
       
   298 
   274 }
   299 }
   275 
   300 
   276 class WifiInterferenceTestSuite : public TestSuite
   301 class WifiInterferenceTestSuite : public TestSuite
   277 {
   302 {
   278 public:
   303 public: