View | Details | Raw Unified | Return to bug 1758
Collapse All | Expand All

(-)1d5abc727f83 (+106 lines)
Added Link Here 
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
 * Authors: Sébastien Deronne <sebastien.deronne@gmail.com>
17
 */
18
#include "ns3/core-module.h"
19
#include "ns3/yans-error-rate-model.h"
20
#include "ns3/nist-error-rate-model.h"
21
#include "ns3/gnuplot.h"
22
23
#include <fstream>
24
#include <vector>
25
#include <cmath>
26
27
using namespace ns3;
28
29
int main (int argc, char *argv[])
30
{
31
  uint32_t FrameSize = 2000;
32
  std::ofstream yansfile ("yans-frame-success-rate-n.plt");
33
  std::ofstream nistfile ("nist-frame-success-rate-n.plt");
34
  std::vector <std::string> modes;
35
36
  modes.push_back ("OfdmRate6_5MbpsBW20MHz");
37
  modes.push_back ("OfdmRate13MbpsBW20MHz");
38
  modes.push_back ("OfdmRate19_5MbpsBW20MHz");
39
  modes.push_back ("OfdmRate26MbpsBW20MHz");
40
  modes.push_back ("OfdmRate39MbpsBW20MHz");
41
  modes.push_back ("OfdmRate52MbpsBW20MHz");
42
  modes.push_back ("OfdmRate58_5MbpsBW20MHz");
43
  modes.push_back ("OfdmRate65MbpsBW20MHz");
44
45
  CommandLine cmd;
46
  cmd.AddValue ("FrameSize", "The frame size", FrameSize);
47
  cmd.Parse (argc, argv);
48
49
  Gnuplot yansplot = Gnuplot ("yans-frame-success-rate-n.eps");
50
  Gnuplot nistplot = Gnuplot ("nist-frame-success-rate-n.eps");
51
52
  Ptr <YansErrorRateModel> yans = CreateObject<YansErrorRateModel> ();
53
  Ptr <NistErrorRateModel> nist = CreateObject<NistErrorRateModel> ();
54
55
  for (uint32_t i = 0; i < modes.size (); i++)
56
    {
57
      std::cout << modes[i] << std::endl;
58
      Gnuplot2dDataset yansdataset (modes[i]);
59
      Gnuplot2dDataset nistdataset (modes[i]);
60
61
      for (double snr = -5.0; snr <= 30.0; snr += 0.1)
62
        {
63
          double ps = yans->GetChunkSuccessRate (WifiMode (modes[i]), std::pow (10.0,snr/10.0), FrameSize*8);
64
          yansdataset.Add (snr, ps);
65
          ps = nist->GetChunkSuccessRate (WifiMode (modes[i]), std::pow (10.0,snr/10.0), FrameSize*8);
66
          nistdataset.Add (snr, ps);
67
        }
68
69
      yansplot.AddDataset (yansdataset);
70
      nistplot.AddDataset (nistdataset);
71
    }
72
73
  yansplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\"");
74
  yansplot.SetLegend ("SNR(dB)", "Frame Success Rate");
75
  yansplot.SetExtra  ("set xrange [-5:30]\n\
76
set yrange [0:1.2]\n\
77
set style line 1 linewidth 5\n\
78
set style line 2 linewidth 5\n\
79
set style line 3 linewidth 5\n\
80
set style line 4 linewidth 5\n\
81
set style line 5 linewidth 5\n\
82
set style line 6 linewidth 5\n\
83
set style line 7 linewidth 5\n\
84
set style line 8 linewidth 5\n\
85
set style increment user"                                                                                                                                                                                                                                                                                                                                   );
86
  yansplot.GenerateOutput (yansfile);
87
  yansfile.close ();
88
89
  nistplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\"");
90
  nistplot.SetLegend ("SNR(dB)", "Frame Success Rate");
91
  nistplot.SetExtra  ("set xrange [-5:30]\n\
92
set yrange [0:1.2]\n\
93
set style line 1 linewidth 5\n\
94
set style line 2 linewidth 5\n\
95
set style line 3 linewidth 5\n\
96
set style line 4 linewidth 5\n\
97
set style line 5 linewidth 5\n\
98
set style line 6 linewidth 5\n\
99
set style line 7 linewidth 5\n\
100
set style line 8 linewidth 5\n\
101
set style increment user"                                                                                                                                                                                                                                                                                                                                   );
102
103
  nistplot.GenerateOutput (nistfile);
104
  nistfile.close ();
105
}
106
(-)a/src/wifi/doc/wifi.rst (-3 / +5 lines)
 Lines 521-529    Link Here 
521
   *SNIR function over time.*
521
   *SNIR function over time.*
522
522
523
From the SNIR function we can derive the Bit Error Rate (BER) and Packet Error Rate (PER) for
523
From the SNIR function we can derive the Bit Error Rate (BER) and Packet Error Rate (PER) for
524
the modulation and coding scheme being used for the transmission.  Please refer to [pei80211ofdm]_, [pei80211b]_ 
524
the modulation and coding scheme being used for the transmission.  Please refer to [pei80211ofdm]_, [pei80211b]_, [lacage2006yans]_, [Haccoun]_ and [Frenger]_ for a detailed description of the available BER/PER models.
525
and [lacage2006yans]_ for a detailed description of the available BER/PER models.
526
527
525
528
WifiChannel configuration
526
WifiChannel configuration
529
=========================
527
=========================
 Lines 721-726    Link Here 
721
719
722
.. [lacage2006yans] \M. Lacage and T. Henderson, `Yet another Network Simulator <http://cutebugs.net/files/wns2-yans.pdf>`__ 
720
.. [lacage2006yans] \M. Lacage and T. Henderson, `Yet another Network Simulator <http://cutebugs.net/files/wns2-yans.pdf>`__ 
723
721
722
.. [Haccoun] \D. Haccoun and G. Begin, *High-Rate Punctured Convolutional Codes for Viterbi Sequential Decoding*, IEEE Transactions on Communications, Vol. 32, Issue 3, pp.315-319.
723
724
.. [Frenger] \Pâl Frenger et al., "Multi-rate Convolutional Codes".
725
724
.. [ji2004sslswn] \Z. Ji, J. Zhou, M. Takai and R. Bagrodia, *Scalable simulation of large-scale wireless networks with bounded inaccuracies*, in Proc. of the Seventh ACM Symposium on Modeling, Analysis and Simulation of Wireless and Mobile Systems, October 2004.
726
.. [ji2004sslswn] \Z. Ji, J. Zhou, M. Takai and R. Bagrodia, *Scalable simulation of large-scale wireless networks with bounded inaccuracies*, in Proc. of the Seventh ACM Symposium on Modeling, Analysis and Simulation of Wireless and Mobile Systems, October 2004.
725
727
726
.. [linuxminstrel] `minstrel linux wireless <http://wireless.kernel.org/en/developers/Documentation/mac80211/RateControl/minstrel>`_
728
.. [linuxminstrel] `minstrel linux wireless <http://wireless.kernel.org/en/developers/Documentation/mac80211/RateControl/minstrel>`_
(-)a/src/wifi/model/nist-error-rate-model.cc (-8 / +33 lines)
 Lines 15-21    Link Here 
15
 * along with this program; if not, write to the Free Software
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
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 *
17
 *
18
 * Author: Gary Pei <guangyu.pei@boeing.com>
18
 * Authors: Gary Pei <guangyu.pei@boeing.com>
19
 *          Sébastien Deronne <sebastien.deronne@gmail.com>
19
 */
20
 */
20
21
21
#include <cmath>
22
#include <cmath>
 Lines 154-159    Link Here 
154
          + 428005675.0 * std::pow (D, 14)
155
          + 428005675.0 * std::pow (D, 14)
155
        );
156
        );
156
    }
157
    }
158
  else if (bValue == 5)
159
    {
160
      // code rate 5/6, use table V from D. Haccoun and G. Begin, "High-Rate Punctured Convolutional Codes 
161
      // for Viterbi Sequential Decoding", IEEE Transactions on Communications, Vol. 32, Issue 3, pp.315-319.
162
      pe = 1.0 / (2.0 * bValue) *
163
        ( 92.0 * std::pow (D, 4.0)
164
          + 528.0 * std::pow (D, 5.0)
165
          + 8694.0 * std::pow (D, 6.0)
166
          + 79453.0 * std::pow (D, 7.0)
167
          + 792114.0 * std::pow (D, 8.0)
168
          + 7375573.0 * std::pow (D, 9.0)
169
          + 67884974.0 * std::pow (D, 10.0)
170
          + 610875423.0 * std::pow (D, 11.0)
171
          + 5427275376.0 * std::pow (D, 12.0)
172
          + 47664215639.0 * std::pow (D, 13.0)
173
        );
174
    }
157
  else
175
  else
158
    {
176
    {
159
      NS_ASSERT (false);
177
      NS_ASSERT (false);
 Lines 255-267    Link Here 
255
                                     2 // b value
273
                                     2 // b value
256
                                     );
274
                                     );
257
            }
275
            }
258
          else
276
          else if (mode.GetCodeRate () == WIFI_CODE_RATE_5_6)
259
            {
277
                 {
260
              return GetFec64QamBer (snr,
278
                   return GetFec64QamBer (snr,
261
                                     nbits,
279
                                          nbits,
262
                                     3 // b value
280
                                          5 // b value
263
                                     );
281
                                          );
264
            }
282
                 }
283
               else
284
                 {
285
                   return GetFec64QamBer (snr,
286
                                          nbits,
287
                                          3 // b value
288
                                          );
289
                 }
265
        }
290
        }
266
    }
291
    }
267
  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS)
292
  else if (mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS)
(-)a/src/wifi/model/yans-error-rate-model.cc (-1 / +16 lines)
 Lines 16-21    Link Here 
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 *
17
 *
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
 *          Sébastien Deronne <sebastien.deronne@gmail.com>
19
 */
20
 */
20
21
21
#include <cmath>
22
#include <cmath>
 Lines 176-182    Link Here 
176
YansErrorRateModel::GetChunkSuccessRate (WifiMode mode, double snr, uint32_t nbits) const
177
YansErrorRateModel::GetChunkSuccessRate (WifiMode mode, double snr, uint32_t nbits) const
177
{
178
{
178
  if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM
179
  if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM
179
      || mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
180
      || mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM
181
      || mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
180
    {
182
    {
181
      if (mode.GetConstellationSize () == 2)
183
      if (mode.GetConstellationSize () == 2)
182
        {
184
        {
 Lines 269-274    Link Here 
269
                                   16  // adFreePlusOne
271
                                   16  // adFreePlusOne
270
                                   );
272
                                   );
271
            }
273
            }
274
          if (mode.GetCodeRate () == WIFI_CODE_RATE_5_6)
275
            {
276
              //Table B.32  in Pâl Frenger et al., "Multi-rate Convolutional Codes".
277
              return GetFecQamBer (snr,
278
                                   nbits,
279
                                   mode.GetBandwidth (), // signal spread
280
                                   mode.GetPhyRate (), // phy rate
281
                                   64, // m
282
                                   4,  // dFree
283
                                   14,  // adFree
284
                                   69  // adFreePlusOne
285
                                   );
286
            }
272
          else
287
          else
273
            {
288
            {
274
              return GetFecQamBer (snr,
289
              return GetFecQamBer (snr,

Return to bug 1758