A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
ofdm-validation.cc
Go to the documentation of this file.
1
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2010 The Boeing Company
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Gary Pei <guangyu.pei@boeing.com>
19
*/
20
#include "ns3/core-module.h"
21
#include "ns3/yans-error-rate-model.h"
22
#include "ns3/nist-error-rate-model.h"
23
#include "ns3/gnuplot.h"
24
25
#include <fstream>
26
#include <vector>
27
#include <cmath>
28
29
using namespace
ns3;
30
31
int
main
(
int
argc,
char
*argv[])
32
{
33
uint32_t FrameSize = 2000;
34
std::ofstream yansfile (
"yans-frame-success-rate.plt"
);
35
std::ofstream nistfile (
"nist-frame-success-rate.plt"
);
36
std::vector <std::string> modes;
37
38
modes.push_back (
"OfdmRate6Mbps"
);
39
modes.push_back (
"OfdmRate9Mbps"
);
40
modes.push_back (
"OfdmRate12Mbps"
);
41
modes.push_back (
"OfdmRate18Mbps"
);
42
modes.push_back (
"OfdmRate24Mbps"
);
43
modes.push_back (
"OfdmRate36Mbps"
);
44
modes.push_back (
"OfdmRate48Mbps"
);
45
modes.push_back (
"OfdmRate54Mbps"
);
46
47
CommandLine
cmd;
48
cmd.
AddValue
(
"FrameSize"
,
"The frame size"
, FrameSize);
49
cmd.
Parse
(argc, argv);
50
51
Gnuplot
yansplot =
Gnuplot
(
"yans-frame-success-rate.eps"
);
52
Gnuplot
nistplot =
Gnuplot
(
"nist-frame-success-rate.eps"
);
53
54
Ptr <YansErrorRateModel>
yans = CreateObject<YansErrorRateModel> ();
55
Ptr <NistErrorRateModel>
nist = CreateObject<NistErrorRateModel> ();
56
57
for
(uint32_t i = 0; i < modes.size (); i++)
58
{
59
std::cout << modes[i] << std::endl;
60
Gnuplot2dDataset
yansdataset (modes[i]);
61
Gnuplot2dDataset
nistdataset (modes[i]);
62
63
for
(
double
snr = -5.0; snr <= 30.0; snr += 0.1)
64
{
65
double
ps = yans->
GetChunkSuccessRate
(
WifiMode
(modes[i]), std::pow (10.0,snr/10.0), FrameSize*8);
66
yansdataset.
Add
(snr, ps);
67
ps = nist->GetChunkSuccessRate (
WifiMode
(modes[i]), std::pow (10.0,snr/10.0), FrameSize*8);
68
nistdataset.
Add
(snr, ps);
69
}
70
71
yansplot.
AddDataset
(yansdataset);
72
nistplot.
AddDataset
(nistdataset);
73
}
74
75
yansplot.
SetTerminal
(
"postscript eps color enh \"Times-BoldItalic\""
);
76
yansplot.
SetLegend
(
"SNR(dB)"
,
"Frame Success Rate"
);
77
yansplot.
SetExtra
(
"set xrange [-5:30]\n\
78
set yrange [0:1.2]\n\
79
set style line 1 linewidth 5\n\
80
set style line 2 linewidth 5\n\
81
set style line 3 linewidth 5\n\
82
set style line 4 linewidth 5\n\
83
set style line 5 linewidth 5\n\
84
set style line 6 linewidth 5\n\
85
set style line 7 linewidth 5\n\
86
set style line 8 linewidth 5\n\
87
set style increment user"
);
88
yansplot.
GenerateOutput
(yansfile);
89
yansfile.close ();
90
91
nistplot.
SetTerminal
(
"postscript eps color enh \"Times-BoldItalic\""
);
92
nistplot.
SetLegend
(
"SNR(dB)"
,
"Frame Success Rate"
);
93
nistplot.
SetExtra
(
"set xrange [-5:30]\n\
94
set yrange [0:1.2]\n\
95
set style line 1 linewidth 5\n\
96
set style line 2 linewidth 5\n\
97
set style line 3 linewidth 5\n\
98
set style line 4 linewidth 5\n\
99
set style line 5 linewidth 5\n\
100
set style line 6 linewidth 5\n\
101
set style line 7 linewidth 5\n\
102
set style line 8 linewidth 5\n\
103
set style increment user"
);
104
105
nistplot.
GenerateOutput
(nistfile);
106
nistfile.close ();
107
}
examples
wireless
ofdm-validation.cc
Generated on Fri Aug 30 2013 01:42:44 for ns-3 by
1.8.1.2