bug 1758: Missing Yans and Nist error rate models for 5/6 code rate of 802.11n HT
authorSébastien Deronne <sebastien.deronne@gmail.com>
Sat, 29 Nov 2014 10:13:25 -0800
changeset 11079 fde91036410a
parent 11078 f7c64e56df22
child 11080 5a41f780e361
bug 1758: Missing Yans and Nist error rate models for 5/6 code rate of 802.11n HT
RELEASE_NOTES
examples/wireless/ofdm-ht-validation.cc
examples/wireless/wscript
src/wifi/doc/wifi.rst
src/wifi/model/nist-error-rate-model.cc
src/wifi/model/yans-error-rate-model.cc
--- a/RELEASE_NOTES	Sat Nov 29 09:57:24 2014 -0800
+++ b/RELEASE_NOTES	Sat Nov 29 10:13:25 2014 -0800
@@ -32,6 +32,7 @@
 ----------
 - Bug 1551 - NS_LOG_COMPONENT_DEFINE inside or outside of ns3 namespace?
 - Bug 1726 - WiFi Minstrel rate control algorithm doesn't save state
+- Bug 1758 - Yans and Nist error rate models for 5/6 code rate 802.11n HT
 - Bug 1791 - TCP Endpoint never deallocates when closing
 - Bug 1906 - 802.11n PHY configuration for 2.4GHz and 5GHz devices
 - Bug 1957 - UdpSocketImpl is stuck after a Close()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/wireless/ofdm-ht-validation.cc	Sat Nov 29 10:13:25 2014 -0800
@@ -0,0 +1,106 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Authors: Sébastien Deronne <sebastien.deronne@gmail.com>
+ */
+#include "ns3/core-module.h"
+#include "ns3/yans-error-rate-model.h"
+#include "ns3/nist-error-rate-model.h"
+#include "ns3/gnuplot.h"
+
+#include <fstream>
+#include <vector>
+#include <cmath>
+
+using namespace ns3;
+
+int main (int argc, char *argv[])
+{
+  uint32_t FrameSize = 2000;
+  std::ofstream yansfile ("yans-frame-success-rate-n.plt");
+  std::ofstream nistfile ("nist-frame-success-rate-n.plt");
+  std::vector <std::string> modes;
+
+  modes.push_back ("OfdmRate6_5MbpsBW20MHz");
+  modes.push_back ("OfdmRate13MbpsBW20MHz");
+  modes.push_back ("OfdmRate19_5MbpsBW20MHz");
+  modes.push_back ("OfdmRate26MbpsBW20MHz");
+  modes.push_back ("OfdmRate39MbpsBW20MHz");
+  modes.push_back ("OfdmRate52MbpsBW20MHz");
+  modes.push_back ("OfdmRate58_5MbpsBW20MHz");
+  modes.push_back ("OfdmRate65MbpsBW20MHz");
+
+  CommandLine cmd;
+  cmd.AddValue ("FrameSize", "The frame size", FrameSize);
+  cmd.Parse (argc, argv);
+
+  Gnuplot yansplot = Gnuplot ("yans-frame-success-rate-n.eps");
+  Gnuplot nistplot = Gnuplot ("nist-frame-success-rate-n.eps");
+
+  Ptr <YansErrorRateModel> yans = CreateObject<YansErrorRateModel> ();
+  Ptr <NistErrorRateModel> nist = CreateObject<NistErrorRateModel> ();
+
+  for (uint32_t i = 0; i < modes.size (); i++)
+    {
+      std::cout << modes[i] << std::endl;
+      Gnuplot2dDataset yansdataset (modes[i]);
+      Gnuplot2dDataset nistdataset (modes[i]);
+
+      for (double snr = -5.0; snr <= 30.0; snr += 0.1)
+        {
+          double ps = yans->GetChunkSuccessRate (WifiMode (modes[i]), std::pow (10.0,snr / 10.0), FrameSize * 8);
+          yansdataset.Add (snr, ps);
+          ps = nist->GetChunkSuccessRate (WifiMode (modes[i]), std::pow (10.0,snr / 10.0), FrameSize * 8);
+          nistdataset.Add (snr, ps);
+        }
+
+      yansplot.AddDataset (yansdataset);
+      nistplot.AddDataset (nistdataset);
+    }
+
+  yansplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\"");
+  yansplot.SetLegend ("SNR(dB)", "Frame Success Rate");
+  yansplot.SetExtra  ("set xrange [-5:30]\n\
+set yrange [0:1.2]\n\
+set style line 1 linewidth 5\n\
+set style line 2 linewidth 5\n\
+set style line 3 linewidth 5\n\
+set style line 4 linewidth 5\n\
+set style line 5 linewidth 5\n\
+set style line 6 linewidth 5\n\
+set style line 7 linewidth 5\n\
+set style line 8 linewidth 5\n\
+set style increment user"                                                                                                                                                                                                                                                                                                                                   );
+  yansplot.GenerateOutput (yansfile);
+  yansfile.close ();
+
+  nistplot.SetTerminal ("postscript eps color enh \"Times-BoldItalic\"");
+  nistplot.SetLegend ("SNR(dB)", "Frame Success Rate");
+  nistplot.SetExtra  ("set xrange [-5:30]\n\
+set yrange [0:1.2]\n\
+set style line 1 linewidth 5\n\
+set style line 2 linewidth 5\n\
+set style line 3 linewidth 5\n\
+set style line 4 linewidth 5\n\
+set style line 5 linewidth 5\n\
+set style line 6 linewidth 5\n\
+set style line 7 linewidth 5\n\
+set style line 8 linewidth 5\n\
+set style increment user"                                                                                                                                                                                                                                                                                                                                   );
+
+  nistplot.GenerateOutput (nistfile);
+  nistfile.close ();
+}
+
--- a/examples/wireless/wscript	Sat Nov 29 09:57:24 2014 -0800
+++ b/examples/wireless/wscript	Sat Nov 29 10:13:25 2014 -0800
@@ -46,6 +46,9 @@
     obj = bld.create_ns3_program('ofdm-validation', ['core', 'mobility', 'wifi', 'config-store', 'stats'])
     obj.source = 'ofdm-validation.cc'
 
+    obj = bld.create_ns3_program('ofdm-ht-validation', ['core', 'mobility', 'wifi', 'config-store', 'stats'])
+    obj.source = 'ofdm-ht-validation.cc'
+
     obj = bld.create_ns3_program('wifi-hidden-terminal', ['internet', 'mobility', 'wifi', 'applications', 'propagation', 'flow-monitor'])
     obj.source = 'wifi-hidden-terminal.cc'
 
--- a/src/wifi/doc/wifi.rst	Sat Nov 29 09:57:24 2014 -0800
+++ b/src/wifi/doc/wifi.rst	Sat Nov 29 10:13:25 2014 -0800
@@ -521,9 +521,7 @@
    *SNIR function over time.*
 
 From the SNIR function we can derive the Bit Error Rate (BER) and Packet Error Rate (PER) for
-the modulation and coding scheme being used for the transmission.  Please refer to [pei80211ofdm]_, [pei80211b]_ 
-and [lacage2006yans]_ for a detailed description of the available BER/PER models.
-
+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.
 
 WifiChannel configuration
 =========================
@@ -721,6 +719,10 @@
 
 .. [lacage2006yans] \M. Lacage and T. Henderson, `Yet another Network Simulator <http://cutebugs.net/files/wns2-yans.pdf>`__ 
 
+.. [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.
+
+.. [Frenger] \Pâl Frenger et al., "Multi-rate Convolutional Codes".
+
 .. [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.
 
 .. [linuxminstrel] `minstrel linux wireless <http://wireless.kernel.org/en/developers/Documentation/mac80211/RateControl/minstrel>`_
--- a/src/wifi/model/nist-error-rate-model.cc	Sat Nov 29 09:57:24 2014 -0800
+++ b/src/wifi/model/nist-error-rate-model.cc	Sat Nov 29 10:13:25 2014 -0800
@@ -15,7 +15,8 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * Author: Gary Pei <guangyu.pei@boeing.com>
+ * Authors: Gary Pei <guangyu.pei@boeing.com>
+ *          Sébastien Deronne <sebastien.deronne@gmail.com>
  */
 
 #include <cmath>
@@ -154,6 +155,23 @@
           + 428005675.0 * std::pow (D, 14)
         );
     }
+  else if (bValue == 5)
+    {
+      // code rate 5/6, use table V from 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.
+      pe = 1.0 / (2.0 * bValue) *
+        ( 92.0 * std::pow (D, 4.0)
+          + 528.0 * std::pow (D, 5.0)
+          + 8694.0 * std::pow (D, 6.0)
+          + 79453.0 * std::pow (D, 7.0)
+          + 792114.0 * std::pow (D, 8.0)
+          + 7375573.0 * std::pow (D, 9.0)
+          + 67884974.0 * std::pow (D, 10.0)
+          + 610875423.0 * std::pow (D, 11.0)
+          + 5427275376.0 * std::pow (D, 12.0)
+          + 47664215639.0 * std::pow (D, 13.0)
+        );
+    }
   else
     {
       NS_ASSERT (false);
@@ -255,13 +273,20 @@
                                      2 // b value
                                      );
             }
-          else
-            {
-              return GetFec64QamBer (snr,
-                                     nbits,
-                                     3 // b value
-                                     );
-            }
+          else if (mode.GetCodeRate () == WIFI_CODE_RATE_5_6)
+                 {
+                   return GetFec64QamBer (snr,
+                                          nbits,
+                                          5 // b value
+                                          );
+                 }
+               else
+                 {
+                   return GetFec64QamBer (snr,
+                                          nbits,
+                                          3 // b value
+                                          );
+                 }
         }
     }
   else if (mode.GetModulationClass () == WIFI_MOD_CLASS_DSSS)
--- a/src/wifi/model/yans-error-rate-model.cc	Sat Nov 29 09:57:24 2014 -0800
+++ b/src/wifi/model/yans-error-rate-model.cc	Sat Nov 29 10:13:25 2014 -0800
@@ -16,6 +16,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ *          Sébastien Deronne <sebastien.deronne@gmail.com>
  */
 
 #include <cmath>
@@ -176,7 +177,8 @@
 YansErrorRateModel::GetChunkSuccessRate (WifiMode mode, double snr, uint32_t nbits) const
 {
   if (mode.GetModulationClass () == WIFI_MOD_CLASS_ERP_OFDM
-      || mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM)
+      || mode.GetModulationClass () == WIFI_MOD_CLASS_OFDM
+      || mode.GetModulationClass () == WIFI_MOD_CLASS_HT)
     {
       if (mode.GetConstellationSize () == 2)
         {
@@ -269,6 +271,19 @@
                                    16  // adFreePlusOne
                                    );
             }
+          if (mode.GetCodeRate () == WIFI_CODE_RATE_5_6)
+            {
+              //Table B.32  in Pâl Frenger et al., "Multi-rate Convolutional Codes".
+              return GetFecQamBer (snr,
+                                   nbits,
+                                   mode.GetBandwidth (), // signal spread
+                                   mode.GetPhyRate (), // phy rate
+                                   64, // m
+                                   4,  // dFree
+                                   14,  // adFree
+                                   69  // adFreePlusOne
+                                   );
+            }
           else
             {
               return GetFecQamBer (snr,