Add helper to convert mcs values into datarate values

This commit is contained in:
Sébastien Deronne
2015-09-05 11:37:49 +02:00
parent e10f0cd061
commit 1746c079c2
6 changed files with 47 additions and 25 deletions

View File

@@ -87,19 +87,12 @@ int main (int argc, char *argv[])
wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
HtWifiMacHelper mac = HtWifiMacHelper::Default ();
Ssid ssid = Ssid ("ns380211n");
std::stringstream sstmp;
std::string strtmp, dataRate;
StringValue DataRate;
sstmp << i;
sstmp >> strtmp;
dataRate = "HtMcs" + strtmp;
DataRate = StringValue (dataRate);
StringValue DataRate = HtWifiMacHelper::DataRateForMcs (i);
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager","DataMode", DataRate,
"ControlMode", DataRate);
Ssid ssid = Ssid ("ns3-80211n");
mac.SetType ("ns3::StaWifiMac",
"Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));
@@ -206,7 +199,7 @@ int main (int argc, char *argv[])
uint32_t totalPacketsThrough = DynamicCast<PacketSink> (sinkApp.Get (0))->GetTotalRx ();
throughput = totalPacketsThrough * 8 / (simulationTime * 1000000.0); //Mbit/s
}
std::cout << dataRate << "\t\t\t" << j << " MHz\t\t\t" << k << "\t\t\t" << throughput << " Mbit/s" << std::endl;
std::cout << i << "\t\t\t" << j << " MHz\t\t\t" << k << "\t\t\t" << throughput << " Mbit/s" << std::endl;
}
j *= 2;
}

View File

@@ -90,20 +90,13 @@ int main (int argc, char *argv[])
WifiHelper wifi = WifiHelper::Default ();
wifi.SetStandard (WIFI_PHY_STANDARD_80211ac);
VhtWifiMacHelper mac = VhtWifiMacHelper::Default ();
Ssid ssid = Ssid ("ns380211ac");
std::stringstream sstmp;
std::string strtmp, dataRate;
StringValue DataRate;
sstmp << i;
sstmp >> strtmp;
dataRate = "VhtMcs" + strtmp;
DataRate = StringValue (dataRate);
StringValue DataRate = VhtWifiMacHelper::DataRateForMcs (i);
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager","DataMode", DataRate,
"ControlMode", DataRate);
Ssid ssid = Ssid ("ns3-80211ac");
mac.SetType ("ns3::StaWifiMac",
"Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));
@@ -210,7 +203,7 @@ int main (int argc, char *argv[])
uint32_t totalPacketsThrough = DynamicCast<PacketSink> (sinkApp.Get (0))->GetTotalRx ();
throughput = totalPacketsThrough * 8 / (simulationTime * 1000000.0); //Mbit/s
}
std::cout << dataRate << "\t\t\t" << j << " MHz\t\t\t" << k << "\t\t\t" << throughput << " Mbit/s" << std::endl;
std::cout << i << "\t\t\t" << j << " MHz\t\t\t" << k << "\t\t\t" << throughput << " Mbit/s" << std::endl;
}
j *= 2;
}

View File

@@ -47,4 +47,17 @@ HtWifiMacHelper::Default (void)
return helper;
}
StringValue
HtWifiMacHelper::DataRateForMcs (int mcs)
{
std::stringstream sstmp;
std::string strtmp, dataRate;
sstmp << mcs;
sstmp >> strtmp;
dataRate = "HtMcs" + strtmp;
return StringValue (dataRate);
}
} //namespace ns3

View File

@@ -21,6 +21,7 @@
#ifndef HT_WIFI_MAC_HELPER_H
#define HT_WIFI_MAC_HELPER_H
#include "ns3/string.h"
#include "wifi-helper.h"
#include "ns3/qos-utils.h"
#include "qos-wifi-mac-helper.h"
@@ -53,6 +54,10 @@ public:
*/
static HtWifiMacHelper Default (void);
/**
* Converts a HT MCS value into a DataRate value
*/
static StringValue DataRateForMcs (int mcs);
};
} //namespace ns3

View File

@@ -54,4 +54,17 @@ VhtWifiMacHelper::Default (void)
return helper;
}
StringValue
VhtWifiMacHelper::DataRateForMcs (int mcs)
{
std::stringstream sstmp;
std::string strtmp, dataRate;
sstmp << mcs;
sstmp >> strtmp;
dataRate = "VhtMcs" + strtmp;
return StringValue (dataRate);
}
} //namespace ns3

View File

@@ -21,6 +21,7 @@
#ifndef VHT_WIFI_MAC_HELPER_H
#define VHT_WIFI_MAC_HELPER_H
#include "ns3/string.h"
#include "wifi-helper.h"
#include "ns3/qos-utils.h"
#include "qos-wifi-mac-helper.h"
@@ -54,6 +55,10 @@ public:
*/
static VhtWifiMacHelper Default (void);
/**
* Converts a VHT MCS value into a DataRate value
*/
static StringValue DataRateForMcs (int mcs);
};
} //namespace ns3