A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
wifi-ofdm-he-validation.cc
Go to the documentation of this file.
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* This program is free software; you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License version 2 as
5
* published by the Free Software Foundation;
6
*
7
* This program is distributed in the hope that it will be useful,
8
* but WITHOUT ANY WARRANTY; without even the implied warranty of
9
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
* GNU General Public License for more details.
11
*
12
* You should have received a copy of the GNU General Public License
13
* along with this program; if not, write to the Free Software
14
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
*
16
* Author: Sébastien Deronne <sebastien.deronne@gmail.com>
17
*/
18
19
// This example is used to validate Nist, Yans and Table-based error rate models for HE rates.
20
//
21
// It outputs plots of the Frame Success Rate versus the Signal-to-noise ratio for
22
// Nist, Yans and Table-based error rate models and for every HE MCS value.
23
24
#include <fstream>
25
#include <cmath>
26
#include "ns3/gnuplot.h"
27
#include "ns3/command-line.h"
28
#include "ns3/yans-error-rate-model.h"
29
#include "ns3/nist-error-rate-model.h"
30
#include "ns3/table-based-error-rate-model.h"
31
#include "ns3/wifi-tx-vector.h"
32
33
using namespace
ns3
;
34
35
int
main (
int
argc,
char
*argv[])
36
{
37
uint32_t FrameSize = 1500;
//bytes
38
std::ofstream yansfile (
"yans-frame-success-rate-ax.plt"
);
39
std::ofstream nistfile (
"nist-frame-success-rate-ax.plt"
);
40
std::ofstream tablefile (
"table-frame-success-rate-ax.plt"
);
41
std::vector <std::string> modes;
42
43
modes.push_back (
"HeMcs0"
);
44
modes.push_back (
"HeMcs1"
);
45
modes.push_back (
"HeMcs2"
);
46
modes.push_back (
"HeMcs3"
);
47
modes.push_back (
"HeMcs4"
);
48
modes.push_back (
"HeMcs5"
);
49
modes.push_back (
"HeMcs6"
);
50
modes.push_back (
"HeMcs7"
);
51
modes.push_back (
"HeMcs8"
);
52
modes.push_back (
"HeMcs9"
);
53
modes.push_back (
"HeMcs10"
);
54
modes.push_back (
"HeMcs11"
);
55
56
CommandLine
cmd
(__FILE__);
57
cmd
.AddValue (
"FrameSize"
,
"The frame size"
, FrameSize);
58
cmd
.Parse (argc, argv);
59
60
Gnuplot
yansplot =
Gnuplot
(
"yans-frame-success-rate-ax.eps"
);
61
Gnuplot
nistplot =
Gnuplot
(
"nist-frame-success-rate-ax.eps"
);
62
Gnuplot
tableplot =
Gnuplot
(
"table-frame-success-rate-ax.eps"
);
63
64
Ptr <YansErrorRateModel>
yans = CreateObject<YansErrorRateModel> ();
65
Ptr <NistErrorRateModel>
nist = CreateObject<NistErrorRateModel> ();
66
Ptr <TableBasedErrorRateModel>
table = CreateObject<TableBasedErrorRateModel> ();
67
WifiTxVector
txVector;
68
69
for
(uint32_t i = 0; i < modes.size (); i++)
70
{
71
std::cout << modes[i] << std::endl;
72
Gnuplot2dDataset
yansdataset (modes[i]);
73
Gnuplot2dDataset
nistdataset (modes[i]);
74
Gnuplot2dDataset
tabledataset (modes[i]);
75
txVector.
SetMode
(modes[i]);
76
77
for
(
double
snr = -5.0; snr <= 40.0; snr += 0.1)
78
{
79
double
ps = yans->
GetChunkSuccessRate
(
WifiMode
(modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
80
if
(ps < 0.0 || ps > 1.0)
81
{
82
//error
83
exit (1);
84
}
85
yansdataset.Add (snr, ps);
86
87
ps = nist->
GetChunkSuccessRate
(
WifiMode
(modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
88
if
(ps < 0.0 || ps > 1.0)
89
{
90
//error
91
exit (1);
92
}
93
nistdataset.Add (snr, ps);
94
95
ps = table->
GetChunkSuccessRate
(
WifiMode
(modes[i]), txVector, std::pow (10.0, snr / 10.0), FrameSize * 8);
96
if
(ps < 0.0 || ps > 1.0)
97
{
98
//error
99
exit (1);
100
}
101
tabledataset.Add (snr, ps);
102
}
103
104
yansplot.
AddDataset
(yansdataset);
105
nistplot.
AddDataset
(nistdataset);
106
tableplot.
AddDataset
(tabledataset);
107
}
108
109
yansplot.
SetTerminal
(
"postscript eps color enh \"Times-BoldItalic\""
);
110
yansplot.
SetLegend
(
"SNR(dB)"
,
"Frame Success Rate"
);
111
yansplot.
SetExtra
(
"set xrange [-5:55]\n\
112
set yrange [0:1]\n\
113
set style line 1 linewidth 5\n\
114
set style line 2 linewidth 5\n\
115
set style line 3 linewidth 5\n\
116
set style line 4 linewidth 5\n\
117
set style line 5 linewidth 5\n\
118
set style line 6 linewidth 5\n\
119
set style line 7 linewidth 5\n\
120
set style line 8 linewidth 5\n\
121
set style line 9 linewidth 5\n\
122
set style line 10 linewidth 5\n\
123
set style line 11 linewidth 5\n\
124
set style line 12 linewidth 5\n\
125
set style increment user"
);
126
yansplot.
GenerateOutput
(yansfile);
127
yansfile.close ();
128
129
nistplot.
SetTerminal
(
"postscript eps color enh \"Times-BoldItalic\""
);
130
nistplot.
SetLegend
(
"SNR(dB)"
,
"Frame Success Rate"
);
131
nistplot.
SetExtra
(
"set xrange [-5:55]\n\
132
set yrange [0:1]\n\
133
set style line 1 linewidth 5\n\
134
set style line 2 linewidth 5\n\
135
set style line 3 linewidth 5\n\
136
set style line 4 linewidth 5\n\
137
set style line 5 linewidth 5\n\
138
set style line 6 linewidth 5\n\
139
set style line 7 linewidth 5\n\
140
set style line 8 linewidth 5\n\
141
set style line 9 linewidth 5\n\
142
set style line 10 linewidth 5\n\
143
set style line 11 linewidth 5\n\
144
set style line 12 linewidth 5\n\
145
set style increment user"
);
146
147
nistplot.
GenerateOutput
(nistfile);
148
nistfile.close ();
149
150
tableplot.
SetTerminal
(
"postscript eps color enh \"Times-BoldItalic\""
);
151
tableplot.
SetLegend
(
"SNR(dB)"
,
"Frame Success Rate"
);
152
tableplot.
SetExtra
(
"set xrange [-5:55]\n\
153
set yrange [0:1]\n\
154
set style line 1 linewidth 5\n\
155
set style line 2 linewidth 5\n\
156
set style line 3 linewidth 5\n\
157
set style line 4 linewidth 5\n\
158
set style line 5 linewidth 5\n\
159
set style line 6 linewidth 5\n\
160
set style line 7 linewidth 5\n\
161
set style line 8 linewidth 5\n\
162
set style line 9 linewidth 5\n\
163
set style line 10 linewidth 5\n\
164
set style line 11 linewidth 5\n\
165
set style line 12 linewidth 5\n\
166
set style increment user"
);
167
168
tableplot.
GenerateOutput
(tablefile);
169
tablefile.close ();
170
}
ns3::CommandLine
Parse command-line arguments.
Definition:
command-line.h:228
ns3::Gnuplot::SetLegend
void SetLegend(const std::string &xLegend, const std::string &yLegend)
Definition:
gnuplot.cc:736
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Gnuplot
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
Definition:
gnuplot.h:372
ns3::Gnuplot::SetTerminal
void SetTerminal(const std::string &terminal)
Definition:
gnuplot.cc:724
ns3::WifiTxVector::SetMode
void SetMode(WifiMode mode)
Sets the selected payload transmission mode.
Definition:
wifi-tx-vector.cc:226
ns3::WifiTxVector
This class mimics the TXVECTOR which is to be passed to the PHY in order to define the parameters whi...
Definition:
wifi-tx-vector.h:71
ns3::Gnuplot::GenerateOutput
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
Definition:
gnuplot.cc:762
ns3::Gnuplot::SetExtra
void SetExtra(const std::string &extra)
Definition:
gnuplot.cc:743
ns3::Gnuplot2dDataset
Class to represent a 2D points plot.
Definition:
gnuplot.h:118
ns3::ErrorRateModel::GetChunkSuccessRate
double GetChunkSuccessRate(WifiMode mode, const WifiTxVector &txVector, double snr, uint64_t nbits, uint8_t numRxAntennas=1, WifiPpduField field=WIFI_PPDU_FIELD_DATA, uint16_t staId=SU_STA_ID) const
This method returns the probability that the given 'chunk' of the packet will be successfully receive...
Definition:
error-rate-model.cc:63
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:74
ns3::WifiMode
represent a single transmission mode
Definition:
wifi-mode.h:48
second.cmd
cmd
Definition:
second.py:35
ns3::Gnuplot::AddDataset
void AddDataset(const GnuplotDataset &dataset)
Definition:
gnuplot.cc:756
examples
wireless
wifi-ofdm-he-validation.cc
Generated on Fri Oct 1 2021 17:02:53 for ns-3 by
1.8.20