35 #include "ns3/core-module.h"
36 #include "ns3/network-module.h"
37 #include "ns3/wifi-module.h"
38 #include "ns3/stats-module.h"
39 #include "ns3/mobility-module.h"
40 #include "ns3/propagation-module.h"
79 StandardInfo (std::string name,
enum WifiPhyStandard standard, uint32_t width,
bool sgi,
double snrLow,
double snrHigh,
double xMin,
double xMax,
double yMax)
81 m_standard (standard),
110 actualDataset.
Add (snr, currentRate);
117 int main (
int argc,
char *argv[])
119 std::vector <StandardInfo> standards;
121 uint32_t rtsThreshold = 65535;
122 uint32_t BE_MaxAmpduSize = 65535;
132 bool shortGuardInterval =
false;
133 uint32_t channelWidth = 20;
134 std::string standard (
"802.11b");
136 std::string outfileName (
"minstrel-ht-");
139 cmd.
AddValue (
"rtsThreshold",
"RTS threshold", rtsThreshold);
140 cmd.
AddValue (
"BE_MaxAmpduSize",
"BE Max A-MPDU size", BE_MaxAmpduSize);
141 cmd.
AddValue (
"stepSize",
"Power between steps (dBm)", stepSize);
142 cmd.
AddValue (
"stepTime",
"Time on each step (seconds)", stepTime);
143 cmd.
AddValue (
"broadcast",
"Send broadcast instead of unicast", broadcast);
144 cmd.
AddValue (
"channelWidth",
"Set channel width (valid only for 802.11n or ac)", channelWidth);
145 cmd.
AddValue (
"shortGuard",
"Set short guard interval (802.11n/ac)", shortGuardInterval);
146 cmd.
AddValue (
"nss",
"Set nss (valid only for 802.11n or ac)", nss);
147 cmd.
AddValue (
"standard",
"Set standard (02.11a, 802.11b, 802.11g, 802.11n-5GHz, 802.11n-2.4GHz, 802.11ac, 802.11-holland, 802.11-10MHz, 802.11-5MHz)", standard);
148 cmd.
Parse (argc, argv);
150 if (standard ==
"802.11b")
152 NS_ABORT_MSG_IF (channelWidth != 20 && channelWidth != 22,
"Invalid channel width for standard " << standard);
155 else if (standard ==
"802.11a" || standard ==
"802.11g")
157 NS_ABORT_MSG_IF (channelWidth != 20,
"Invalid channel width for standard " << standard);
160 else if (standard ==
"802.11n-5GHz" || standard ==
"802.11n-2.4GHz")
162 NS_ABORT_MSG_IF (channelWidth != 20 && channelWidth != 40,
"Invalid channel width for standard " << standard);
163 NS_ABORT_MSG_IF (nss == 0 || nss > 4,
"Invalid nss " << nss <<
" for standard " << standard);
165 else if (standard ==
"802.11ac")
167 NS_ABORT_MSG_IF (channelWidth != 20 && channelWidth != 40 && channelWidth != 80 && channelWidth != 160,
"Invalid channel width for standard " << standard);
168 NS_ABORT_MSG_IF (nss == 0 || nss > 4,
"Invalid nss " << nss <<
" for standard " << standard);
171 outfileName.append (standard);
172 if (standard ==
"802.11n-5GHz" || standard ==
"802.11n-2.4GHz" || standard ==
"802.11ac")
174 std::ostringstream oss;
176 if (shortGuardInterval)
184 oss <<
"-" << channelWidth <<
"MHz-" << gi <<
"-" <<nss <<
"SS";
185 outfileName += oss.str ();
187 std::string tmp = outfileName +
".plt";
188 std::ofstream outfile (tmp.c_str ());
189 tmp = outfileName +
".eps";
205 for (std::vector<StandardInfo>::size_type i = 0; i != standards.size (); i++)
207 if (standard == standards[i].m_name)
209 selectedStandard = standards[i];
213 std::cout <<
"Testing " << selectedStandard.
m_name <<
"..." << std::endl;
215 steps = std::abs ((
int) (selectedStandard.
m_snrHigh - selectedStandard.
m_snrLow ) / stepSize) + 1;
216 Ptr<Node> clientNode = CreateObject<Node> ();
217 Ptr<Node> serverNode = CreateObject<Node> ();
220 wifi.SetStandard (selectedStandard.
m_standard);
235 wifi.SetRemoteStationManager (
"ns3::MinstrelHtWifiManager",
"RtsCtsThreshold",
UintegerValue (rtsThreshold),
"PrintStats",
BooleanValue (
true));
242 wifiMac.
SetType (
"ns3::AdhocWifiMac",
244 serverDevice = wifi.Install (wifiPhy, wifiMac, serverNode);
245 clientDevice = wifi.Install (wifiPhy, wifiMac, clientNode);
253 positionAlloc->
Add (Vector (ap1_x, ap1_y, 0.0));
254 NS_LOG_INFO (
"Setting initial AP position to " << Vector (ap1_x, ap1_y, 0.0));
255 positionAlloc->
Add (Vector (sta1_x, sta1_y, 0.0));
256 NS_LOG_INFO (
"Setting initial STA position to " << Vector (sta1_x, sta1_y, 0.0));
275 wifiPhyPtrClient->SetNumberOfTransmitAntennas (nss);
276 wifiPhyPtrClient->SetNumberOfReceiveAntennas (nss);
278 NS_LOG_DEBUG (
"Channel width " << wifiPhyPtrClient->GetChannelWidth () <<
" noiseDbm " <<
noiseDbm);
287 wifiPhyPtrServer->SetNumberOfTransmitAntennas (nss);
288 wifiPhyPtrServer->SetNumberOfReceiveAntennas (nss);
291 rssLossModel->
SetRss (rssCurrent);
292 NS_LOG_INFO (
"Setting initial Rss to " << rssCurrent);
297 packetSocketHelper.
Install (serverNode);
298 packetSocketHelper.
Install (clientNode);
326 serverNode->AddApplication (server);
335 std::ostringstream xMinStr, xMaxStr, yMaxStr;
336 std::string xRangeStr (
"set xrange [");
337 xMinStr << selectedStandard.
m_xMin;
338 xRangeStr.append (xMinStr.str ());
339 xRangeStr.append (
":");
340 xMaxStr << selectedStandard.
m_xMax;
341 xRangeStr.append (xMaxStr.str ());
342 xRangeStr.append (
"]");
343 std::string yRangeStr (
"set yrange [0:");
344 yMaxStr << selectedStandard.
m_yMax;
345 yRangeStr.append (yMaxStr.str ());
346 yRangeStr.append (
"]");
348 std::ostringstream widthStrStr;
349 std::ostringstream nssStrStr;
350 std::string title (
"Wi-Fi Minstrel ht rate control: ");
351 title.append (standard);
352 title.append (
" channel width: ");
353 widthStrStr << selectedStandard.
m_width;
354 title.append (widthStrStr.str ());
355 title.append (
" MHz nss: ");
357 title.append (nssStrStr.str ());
358 if (shortGuardInterval ==
true)
360 title.append (
" shortGuard: true");
363 gnuplot.
SetTerminal (
"postscript eps color enh \"Times-BoldItalic\"");
364 gnuplot.
SetLegend (
"SNR (dB)",
"Rate (Mb/s)");
ERP-OFDM PHY (Clause 19, Section 19.5)
void Set(std::string name, const AttributeValue &v)
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
void PacketRx(Ptr< const Packet > pkt, const Address &addr)
void AppendExtra(const std::string &extra)
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
OFDM PHY for the 5 GHz band (Clause 17 with 5 MHz channel bandwidth)
AttributeValue implementation for Boolean.
void SetLocal(PacketSocketAddress addr)
set the local address and protocol to be used
HT OFDM PHY for the 5 GHz band (clause 20)
Class to represent a 2D points plot.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
Make it easy to create and manage PHY objects for the yans model.
void SetPropagationLossModel(Ptr< PropagationLossModel > loss)
an address for a packet socket
void SetPropagationDelayModel(Ptr< PropagationDelayModel > delay)
static void Run(void)
Run the simulation.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
OFDM PHY for the 5 GHz band (Clause 17 with 10 MHz channel bandwidth)
void AddDataset(const GnuplotDataset &dataset)
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
HT OFDM PHY for the 2.4 GHz band (clause 20)
static YansWifiPhyHelper Default(void)
Create a phy helper in a default working state.
helps to create WifiNetDevice objects
StandardInfo(std::string name, enum WifiPhyStandard standard, uint32_t width, bool sgi, double snrLow, double snrHigh, double xMin, double xMax, double yMax)
Give ns3::PacketSocket powers to ns3::Node.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
a polymophic address class
void SetChannel(Ptr< YansWifiChannel > channel)
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
Ptr< WifiPhy > GetPhy(void) const
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
AttributeValue implementation for Time.
void SetTitle(const std::string &title)
virtual void SetChannelWidth(uint32_t channelwidth)
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
Hold together all Wifi-related objects.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
void Add(double x, double y)
Parse command-line arguments.
void SetLegend(const std::string &xLegend, const std::string &yLegend)
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
This is intended to be the configuration used in this paper: Gavin Holland, Nitin Vaidya and Paramvir...
enum WifiPhyStandard m_standard
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
OFDM PHY for the 5 GHz band (Clause 17)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetPhysicalAddress(const Address address)
Set the destination address.
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
create MAC layers for a ns3::WifiNetDevice.
static Time Now(void)
Return the current simulation virtual time.
void SetExtra(const std::string &extra)
virtual void SetType(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue())
Helper class used to assign positions and mobility models to nodes.
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
void SetRemote(PacketSocketAddress addr)
set the remote address and protocol to be used
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
void ChangeSignalAndReportRate(Ptr< FixedRssLossModel > rssModel, struct Step step, double rss, Gnuplot2dDataset &rateDataset, Gnuplot2dDataset &actualDataset)
void SetProtocol(uint16_t protocol)
Set the protocol.
void Add(Vector v)
Add a position to the list of positions.
const double NOISE_DBM_Hz
void Parse(int argc, char *argv[])
Parse the program arguments.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
static const uint32_t packetSize
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
void SetTerminal(const std::string &terminal)
This class can be used to hold variables of floating point type such as 'double' or 'float'...
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
void SetStartTime(Time start)
Specify application start time.
void RateChange(uint64_t newVal, Mac48Address dest)