wifi: Modify wifi-trans-example to handle fix for bug 2826

This commit is contained in:
Getachew Redieteab
2018-03-07 22:22:25 +01:00
parent 08e8241a0e
commit 96f280cdfe

View File

@@ -31,8 +31,8 @@ using namespace ns3;
/**
* This example (inspired from tv-trans-example) enables to generate the transmitted spectra of
* Wi-Fi stations, so as to model transmit mask imperfections of OFDM-based Wi-Fi standards.
* Only the first moments of an association procedure of a station to an access point have been
* considered to reduce execution time.
* Only one data packet is sent from access point to station (once association has been performed)
* so as to reduce execution time.
*
* A spectrum analyzer is used to measure the transmitted spectra from Wi-Fi stations.
* The file "spectrum-analyzer-wifi-[standard]-[bandwidth]MHz-sim-2-0.tr" contains its
@@ -41,6 +41,14 @@ using namespace ns3;
* The wifi-trans-example.sh script runs this example for all combinations, plots transmitted spectra,
* and puts resulting png images in wifi-trans-results folder.
*/
void
SendPacket (Ptr<NetDevice> sourceDevice, Address& destination)
{
Ptr<Packet> pkt = Create<Packet> (100); // dummy bytes of data
sourceDevice->Send (pkt, destination, 0);
}
int main (int argc, char** argv)
{
std::string standard = "11a";
@@ -60,6 +68,8 @@ int main (int argc, char** argv)
Ssid ssid;
std::string dataRate;
int freq;
Time dataStartTime = MicroSeconds (800); // leaving enough time for beacon and association procedure
Time dataDuration = MicroSeconds (300); // leaving enough time for data transfer (+ acknowledgment)
if (standard == "11a")
{
wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
@@ -76,8 +86,10 @@ int main (int argc, char** argv)
{
wifi.SetStandard (WIFI_PHY_STANDARD_80211_10MHZ);
ssid = Ssid ("ns380211_10MHZ");
dataRate = "OfdmRate6Mbps";
dataRate = "OfdmRate3MbpsBW10MHz";
freq = 5860;
dataStartTime = MicroSeconds (1400);
dataDuration = MicroSeconds (600);
if (bw != 10)
{
std::cout << "Bandwidth is not compatible with standard" << std::endl;
@@ -88,8 +100,10 @@ int main (int argc, char** argv)
{
wifi.SetStandard (WIFI_PHY_STANDARD_80211_5MHZ);
ssid = Ssid ("ns380211_5MHZ");
dataRate = "OfdmRate6Mbps";
dataRate = "OfdmRate1_5MbpsBW5MHz";
freq = 5860;
dataStartTime = MicroSeconds (2500);
dataDuration = MicroSeconds (1200);
if (bw != 5)
{
std::cout << "Bandwidth is not compatible with standard" << std::endl;
@@ -102,6 +116,8 @@ int main (int argc, char** argv)
ssid = Ssid ("ns380211n_2_4GHZ");
dataRate = "HtMcs0";
freq = 2402 + (bw / 2); //so as to have 2412/2422 for 20/40
dataStartTime = MicroSeconds (4700);
dataDuration = MicroSeconds (400);
if (bw != 20 && bw != 40)
{
std::cout << "Bandwidth is not compatible with standard" << std::endl;
@@ -114,6 +130,7 @@ int main (int argc, char** argv)
ssid = Ssid ("ns380211n_5GHZ");
dataRate = "HtMcs0";
freq = 5170 + (bw / 2); //so as to have 5180/5190 for 20/40
dataStartTime = MicroSeconds (1000);
if (bw != 20 && bw != 40)
{
std::cout << "Bandwidth is not compatible with standard" << std::endl;
@@ -126,6 +143,8 @@ int main (int argc, char** argv)
ssid = Ssid ("ns380211ac");
dataRate = "VhtMcs0";
freq = 5170 + (bw / 2); //so as to have 5180/5190/5210/5250 for 20/40/80/160
dataStartTime = MicroSeconds (1100);
dataDuration += MicroSeconds (400); //account for ADDBA procedure
if (bw != 20 && bw != 40 && bw != 80 && bw != 160)
{
std::cout << "Bandwidth is not compatible with standard" << std::endl;
@@ -138,6 +157,8 @@ int main (int argc, char** argv)
ssid = Ssid ("ns380211ax_2_4GHZ");
dataRate = "HeMcs0";
freq = 2402 + (bw / 2); //so as to have 2412/2422/2442 for 20/40/80
dataStartTime = MicroSeconds (5500);
dataDuration += MicroSeconds (2000); //account for ADDBA procedure
if (bw != 20 && bw != 40 && bw != 80)
{
std::cout << "Bandwidth is not compatible with standard" << std::endl;
@@ -150,6 +171,8 @@ int main (int argc, char** argv)
ssid = Ssid ("ns380211ax_5GHZ");
dataRate = "HeMcs0";
freq = 5170 + (bw / 2); //so as to have 5180/5190/5210/5250 for 20/40/80/160
dataStartTime = MicroSeconds (1200);
dataDuration += MicroSeconds (500); //account for ADDBA procedure
if (bw != 20 && bw != 40 && bw != 80 && bw != 160)
{
std::cout << "Bandwidth is not compatible with standard" << std::endl;
@@ -164,10 +187,9 @@ int main (int argc, char** argv)
if (verbose)
{
LogComponentEnableAll (LOG_PREFIX_ALL);
LogComponentEnable ("WifiSpectrumValueHelper", LOG_LEVEL_ALL);
LogComponentEnable ("WifiSpectrumValueHelper", LOG_PREFIX_ALL);
LogComponentEnable ("SpectrumWifiPhy", LOG_LEVEL_ALL);
LogComponentEnable ("SpectrumWifiPhy", LOG_PREFIX_ALL);
}
/* nodes and positions */
@@ -214,7 +236,6 @@ int main (int argc, char** argv)
"EnableBeaconJitter", BooleanValue (false)); // so as to be sure that first beacon arrives quickly
NetDeviceContainer apDevice = wifi.Install (spectrumPhy, mac, wifiApNode);
MobilityHelper mobility;
Ptr<ListPositionAllocator> nodePositionList = CreateObject<ListPositionAllocator> ();
nodePositionList->Add (Vector (0.0, 1.0, 0.0)); // AP
@@ -224,7 +245,9 @@ int main (int argc, char** argv)
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (allNodes);
/* No need to have Internet stack nor applications because beacon/association frames shall illustrate principle */
/* Need to send data packet because beacon and association frames shall be sent using lowest rate */
// Send one data packet (this packet is sent using data rate / MCS defined above) once association is done (otherwise dropped)
Simulator::Schedule (dataStartTime, &SendPacket, apDevice.Get (0), staDevice.Get (0)->GetAddress ());
/* frequency range for spectrum analyzer */
std::vector<double> freqs;
@@ -246,15 +269,8 @@ int main (int argc, char** argv)
spectrumAnalyzerHelper.EnableAsciiAll (ossFileName.str ());
NetDeviceContainer spectrumAnalyzerDevices = spectrumAnalyzerHelper.Install (spectrumAnalyzerNodes);
/* Let enough time for beacon (even in 2.4 GHz, i.e. DSSS) and association procedure */
if (freq > 5000)
{
Simulator::Stop (MicroSeconds (1500));
}
else
{
Simulator::Stop (MicroSeconds (2500)); //beacon in DSSS takes more time
}
/* Let enough time for first beacon, association procedure, and first data (+acknowledgment and eventually preceding ADDBA procedure) */
Simulator::Stop (dataStartTime + dataDuration);
Simulator::Run ();