src/lte/helper/phy-rx-stats-calculator.cc
author Peter D. Barnes, Jr. <barnes26@llnl.gov>
Wed, 05 Mar 2014 17:06:59 -0800
changeset 10652 dc18deba4502
parent 10411 f5916669dbe7
child 10967 597a9ec89e60
permissions -rw-r--r--
[doxygen] Revert r10410, r10411, r10412
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9519
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     1
/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     2
/*
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     3
 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     4
 *
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     8
 *
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    12
 * GNU General Public License for more details.
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    13
 *
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    17
 *
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    18
 * Author: Jaume Nin <jnin@cttc.es>
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    19
 * modified by: Marco Miozzo <mmiozzo@cttc.es>
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    20
 *        Convert MacStatsCalculator in PhyRxStatsCalculator
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    21
 */
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    22
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    23
#include "phy-rx-stats-calculator.h"
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    24
#include "ns3/string.h"
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    25
#include <ns3/simulator.h>
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    26
#include <ns3/log.h>
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    27
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    28
namespace ns3 {
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    29
10652
dc18deba4502 [doxygen] Revert r10410, r10411, r10412
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    30
NS_LOG_COMPONENT_DEFINE ("PhyRxStatsCalculator");
9519
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    31
10652
dc18deba4502 [doxygen] Revert r10410, r10411, r10412
Peter D. Barnes, Jr. <barnes26@llnl.gov>
parents: 10411
diff changeset
    32
NS_OBJECT_ENSURE_REGISTERED (PhyRxStatsCalculator);
9519
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    33
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    34
PhyRxStatsCalculator::PhyRxStatsCalculator ()
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    35
  : m_dlRxFirstWrite (true),
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    36
    m_ulRxFirstWrite (true)
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    37
{
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    38
  NS_LOG_FUNCTION (this);
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    39
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    40
}
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    41
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    42
PhyRxStatsCalculator::~PhyRxStatsCalculator ()
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    43
{
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    44
  NS_LOG_FUNCTION (this);
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    45
}
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    46
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    47
TypeId
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    48
PhyRxStatsCalculator::GetTypeId (void)
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    49
{
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    50
  static TypeId tid = TypeId ("ns3::PhyRxStatsCalculator")
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    51
    .SetParent<LteStatsCalculator> ()
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    52
    .AddConstructor<PhyRxStatsCalculator> ()
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    53
    .AddAttribute ("DlRxOutputFilename",
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    54
                   "Name of the file where the downlink results will be saved.",
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    55
                   StringValue ("DlRxPhyStats.txt"),
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    56
                   MakeStringAccessor (&PhyRxStatsCalculator::SetDlRxOutputFilename),
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    57
                   MakeStringChecker ())
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    58
    .AddAttribute ("UlRxOutputFilename",
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    59
                   "Name of the file where the uplink results will be saved.",
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    60
                   StringValue ("UlRxPhyStats.txt"),
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    61
                   MakeStringAccessor (&PhyRxStatsCalculator::SetUlRxOutputFilename),
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    62
                   MakeStringChecker ())
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    63
  ;
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    64
  return tid;
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    65
}
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    66
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    67
void
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    68
PhyRxStatsCalculator::SetUlRxOutputFilename (std::string outputFilename)
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    69
{
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    70
  LteStatsCalculator::SetUlOutputFilename (outputFilename);
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    71
}
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    72
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    73
std::string
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    74
PhyRxStatsCalculator::GetUlRxOutputFilename (void)
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    75
{
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    76
  return LteStatsCalculator::GetUlOutputFilename ();
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    77
}
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    78
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    79
void
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    80
PhyRxStatsCalculator::SetDlRxOutputFilename (std::string outputFilename)
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    81
{
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    82
  LteStatsCalculator::SetDlOutputFilename (outputFilename);
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    83
}
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    84
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    85
std::string
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    86
PhyRxStatsCalculator::GetDlRxOutputFilename (void)
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    87
{
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    88
  return LteStatsCalculator::GetDlOutputFilename ();
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    89
}
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    90
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    91
void
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    92
PhyRxStatsCalculator::DlPhyReception (PhyReceptionStatParameters params)
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    93
{
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    94
  NS_LOG_FUNCTION (this << params.m_cellId << params.m_imsi << params.m_timestamp << params.m_rnti << params.m_layer << params.m_mcs << params.m_size << params.m_rv << params.m_ndi << params.m_correctness);
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    95
  NS_LOG_INFO ("Write DL Rx Phy Stats in " << GetDlRxOutputFilename ().c_str ());
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    96
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    97
  std::ofstream outFile;
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    98
  if ( m_dlRxFirstWrite == true )
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
    99
    {
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   100
      outFile.open (GetDlRxOutputFilename ().c_str ());
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   101
      if (!outFile.is_open ())
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   102
        {
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   103
          NS_LOG_ERROR ("Can't open file " << GetDlRxOutputFilename ().c_str ());
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   104
          return;
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   105
        }
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   106
      m_dlRxFirstWrite = false;
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   107
      outFile << "% time\tcellId\tIMSI\tRNTI\ttxMode\tlayer\tmcs\tsize\trv\tndi\tcorrect";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   108
      outFile << std::endl;
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   109
    }
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   110
  else
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   111
    {
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   112
      outFile.open (GetDlRxOutputFilename ().c_str (),  std::ios_base::app);
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   113
      if (!outFile.is_open ())
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   114
        {
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   115
          NS_LOG_ERROR ("Can't open file " << GetDlRxOutputFilename ().c_str ());
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   116
          return;
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   117
        }
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   118
    }
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   119
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   120
//   outFile << Simulator::Now ().GetNanoSeconds () / (double) 1e9 << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   121
  outFile << params.m_timestamp << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   122
  outFile << (uint32_t) params.m_cellId << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   123
  outFile << params.m_imsi << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   124
  outFile << params.m_rnti << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   125
  outFile << (uint32_t) params.m_txMode << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   126
  outFile << (uint32_t) params.m_layer << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   127
  outFile << (uint32_t) params.m_mcs << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   128
  outFile << params.m_size << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   129
  outFile << (uint32_t) params.m_rv << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   130
  outFile << (uint32_t) params.m_ndi << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   131
  outFile << (uint32_t) params.m_correctness << std::endl;
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   132
  outFile.close ();
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   133
}
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   134
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   135
void
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   136
PhyRxStatsCalculator::UlPhyReception (PhyReceptionStatParameters params)
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   137
{
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   138
  NS_LOG_FUNCTION (this << params.m_cellId << params.m_imsi << params.m_timestamp << params.m_rnti << params.m_layer << params.m_mcs << params.m_size << params.m_rv << params.m_ndi << params.m_correctness);
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   139
  NS_LOG_INFO ("Write UL Rx Phy Stats in " << GetUlRxOutputFilename ().c_str ());
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   140
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   141
  std::ofstream outFile;
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   142
  if ( m_ulRxFirstWrite == true )
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   143
    {
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   144
      outFile.open (GetUlRxOutputFilename ().c_str ());
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   145
      if (!outFile.is_open ())
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   146
        {
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   147
          NS_LOG_ERROR ("Can't open file " << GetUlRxOutputFilename ().c_str ());
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   148
          return;
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   149
        }
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   150
      m_ulRxFirstWrite = false;
10049
042c652c18c6 Remove txMode parameter from UlRxPhyStats
Marco Miozzo <marco.miozzo@cttc.es>
parents: 9519
diff changeset
   151
      outFile << "% time\tcellId\tIMSI\tRNTI\tlayer\tmcs\tsize\trv\tndi\tcorrect";
9519
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   152
      outFile << std::endl;
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   153
    }
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   154
  else
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   155
    {
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   156
      outFile.open (GetUlRxOutputFilename ().c_str (),  std::ios_base::app);
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   157
      if (!outFile.is_open ())
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   158
        {
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   159
          NS_LOG_ERROR ("Can't open file " << GetUlRxOutputFilename ().c_str ());
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   160
          return;
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   161
        }
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   162
    }
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   163
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   164
//   outFile << Simulator::Now ().GetNanoSeconds () / (double) 1e9 << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   165
  outFile << params.m_timestamp << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   166
  outFile << (uint32_t) params.m_cellId << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   167
  outFile << params.m_imsi << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   168
  outFile << params.m_rnti << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   169
  outFile << (uint32_t) params.m_layer << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   170
  outFile << (uint32_t) params.m_mcs << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   171
  outFile << params.m_size << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   172
  outFile << (uint32_t) params.m_rv << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   173
  outFile << (uint32_t) params.m_ndi << "\t";
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   174
  outFile << (uint32_t) params.m_correctness << std::endl;
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   175
  outFile.close ();
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   176
}
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   177
10094
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   178
void
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   179
PhyRxStatsCalculator::DlPhyReceptionCallback (Ptr<PhyRxStatsCalculator> phyRxStats,
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   180
                      std::string path, PhyReceptionStatParameters params)
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   181
{
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   182
  NS_LOG_FUNCTION (phyRxStats << path);
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   183
  uint64_t imsi = 0;
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   184
  std::ostringstream pathAndRnti;
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   185
  pathAndRnti << path << "/" << params.m_rnti;
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   186
  if (phyRxStats->ExistsImsiPath (pathAndRnti.str ()) == true)
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   187
    {
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   188
      imsi = phyRxStats->GetImsiPath (pathAndRnti.str ());
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   189
    }
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   190
  else
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   191
    {
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   192
      imsi = FindImsiForUe (path, params.m_rnti);
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   193
      phyRxStats->SetImsiPath (pathAndRnti.str (), imsi);
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   194
    }
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   195
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   196
  params.m_imsi = imsi;
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   197
  phyRxStats->DlPhyReception (params);
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   198
}
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   199
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   200
void
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   201
PhyRxStatsCalculator::UlPhyReceptionCallback (Ptr<PhyRxStatsCalculator> phyRxStats,
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   202
                      std::string path, PhyReceptionStatParameters params)
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   203
{
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   204
  NS_LOG_FUNCTION (phyRxStats << path);
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   205
  uint64_t imsi = 0;
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   206
  std::ostringstream pathAndRnti;
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   207
  pathAndRnti << path << "/" << params.m_rnti;
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   208
  if (phyRxStats->ExistsImsiPath (pathAndRnti.str ()) == true)
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   209
    {
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   210
      imsi = phyRxStats->GetImsiPath (pathAndRnti.str ());
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   211
    }
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   212
  else
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   213
    {
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   214
      imsi = FindImsiForEnb (path, params.m_rnti);
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   215
      phyRxStats->SetImsiPath (pathAndRnti.str (), imsi);
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   216
    }
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   217
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   218
  params.m_imsi = imsi;
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   219
  phyRxStats->UlPhyReception (params);
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   220
}
6dec20ed6ed1 moved stats-related callbacks from LteHelper to the appropriate StatsCalculator
Nicola Baldo <nbaldo@cttc.es>
parents: 10049
diff changeset
   221
9519
fc6e45584ef4 Add DL and UL PHY traces on transmission and reception statistics
Marco Miozzo <marco.miozzo@cttc.es>
parents:
diff changeset
   222
} // namespace ns3