From 1746c079c29b78649c9bcf4d24a7c01aa3afa375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Sat, 5 Sep 2015 11:37:49 +0200 Subject: [PATCH] Add helper to convert mcs values into datarate values --- examples/wireless/ht-wifi-network.cc | 17 +++++------------ examples/wireless/vht-wifi-network.cc | 19 ++++++------------- src/wifi/helper/ht-wifi-mac-helper.cc | 13 +++++++++++++ src/wifi/helper/ht-wifi-mac-helper.h | 5 +++++ src/wifi/helper/vht-wifi-mac-helper.cc | 13 +++++++++++++ src/wifi/helper/vht-wifi-mac-helper.h | 5 +++++ 6 files changed, 47 insertions(+), 25 deletions(-) diff --git a/examples/wireless/ht-wifi-network.cc b/examples/wireless/ht-wifi-network.cc index 0f0fa782b..4c0bc0481 100644 --- a/examples/wireless/ht-wifi-network.cc +++ b/examples/wireless/ht-wifi-network.cc @@ -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 (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; } diff --git a/examples/wireless/vht-wifi-network.cc b/examples/wireless/vht-wifi-network.cc index 33bb20ad9..d46f310df 100644 --- a/examples/wireless/vht-wifi-network.cc +++ b/examples/wireless/vht-wifi-network.cc @@ -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 (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; } diff --git a/src/wifi/helper/ht-wifi-mac-helper.cc b/src/wifi/helper/ht-wifi-mac-helper.cc index c0fc80988..0375b452e 100644 --- a/src/wifi/helper/ht-wifi-mac-helper.cc +++ b/src/wifi/helper/ht-wifi-mac-helper.cc @@ -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 diff --git a/src/wifi/helper/ht-wifi-mac-helper.h b/src/wifi/helper/ht-wifi-mac-helper.h index b69abaa01..965bab7e0 100644 --- a/src/wifi/helper/ht-wifi-mac-helper.h +++ b/src/wifi/helper/ht-wifi-mac-helper.h @@ -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 diff --git a/src/wifi/helper/vht-wifi-mac-helper.cc b/src/wifi/helper/vht-wifi-mac-helper.cc index da62ab36f..801e7d6df 100644 --- a/src/wifi/helper/vht-wifi-mac-helper.cc +++ b/src/wifi/helper/vht-wifi-mac-helper.cc @@ -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 diff --git a/src/wifi/helper/vht-wifi-mac-helper.h b/src/wifi/helper/vht-wifi-mac-helper.h index e1b3545ee..449dca90f 100644 --- a/src/wifi/helper/vht-wifi-mac-helper.h +++ b/src/wifi/helper/vht-wifi-mac-helper.h @@ -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