added AthstatsWifiTraceSink and AthstatsHelper
authorNicola Baldo <nbaldo@cttc.es>
Mon Aug 24 13:32:06 2009 +0200 (5 months ago)
changeset 47340b29285cc1af
parent 4733 96a3881940c4
child 4735 f011cf863e07
added AthstatsWifiTraceSink and AthstatsHelper
examples/wifi-ap.cc
src/helper/athstats-helper.cc
src/helper/athstats-helper.h
src/helper/wscript
     1.1 --- a/examples/wifi-ap.cc	Mon Aug 24 13:09:32 2009 +0200
     1.2 +++ b/examples/wifi-ap.cc	Mon Aug 24 13:32:06 2009 +0200
     1.3 @@ -26,6 +26,7 @@
     1.4  #include "ns3/mobility-module.h"
     1.5  #include "ns3/contrib-module.h"
     1.6  #include "ns3/wifi-module.h"
     1.7 +#include "ns3/athstats-helper.h"
     1.8  
     1.9  #include <iostream>
    1.10  
    1.11 @@ -110,6 +111,9 @@
    1.12  
    1.13  int main (int argc, char *argv[])
    1.14  {
    1.15 +  CommandLine cmd;
    1.16 +   cmd.Parse (argc, argv);
    1.17 +   
    1.18    Packet::EnablePrinting ();
    1.19  
    1.20    // enable rts cts all the time.
    1.21 @@ -175,6 +179,10 @@
    1.22    Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/RxError", MakeCallback (&PhyRxErrorTrace));
    1.23    Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/Tx", MakeCallback (&PhyTxTrace));
    1.24    Config::Connect ("/NodeList/*/DeviceList/*/Phy/State/State", MakeCallback (&PhyStateTrace));
    1.25 +  
    1.26 +  AthstatsHelper athstats;
    1.27 +  athstats.EnableAthstats("athstats-sta", stas);
    1.28 +  athstats.EnableAthstats("athstats-ap", ap);
    1.29  
    1.30    Simulator::Run ();
    1.31  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/helper/athstats-helper.cc	Mon Aug 24 13:32:06 2009 +0200
     2.3 @@ -0,0 +1,309 @@
     2.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
     2.5 +/*
     2.6 + * Copyright (c) 2009 CTTC
     2.7 + *
     2.8 + * This program is free software; you can redistribute it and/or modify
     2.9 + * it under the terms of the GNU General Public License version 2 as 
    2.10 + * published by the Free Software Foundation;
    2.11 + *
    2.12 + * This program is distributed in the hope that it will be useful,
    2.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    2.15 + * GNU General Public License for more details.
    2.16 + *
    2.17 + * You should have received a copy of the GNU General Public License
    2.18 + * along with this program; if not, write to the Free Software
    2.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2.20 + *
    2.21 + * Author: Nicola Baldo <nbaldo@cttc.es>
    2.22 + */
    2.23 +
    2.24 +#include "ns3/log.h"
    2.25 +#include "ns3/assert.h"
    2.26 +#include "ns3/abort.h"
    2.27 +#include "ns3/simulator.h"
    2.28 +#include "ns3/nstime.h"
    2.29 +#include "ns3/config.h"
    2.30 +#include "athstats-helper.h"
    2.31 +#include <iomanip>
    2.32 +#include <iostream>
    2.33 +#include <fstream>
    2.34 +
    2.35 +
    2.36 +NS_LOG_COMPONENT_DEFINE("Athstats");
    2.37 +
    2.38 +namespace ns3 {
    2.39 +
    2.40 +
    2.41 +AthstatsHelper::AthstatsHelper ()
    2.42 +  : m_interval (Seconds (1.0))
    2.43 +{
    2.44 +}
    2.45 +
    2.46 +void
    2.47 +AthstatsHelper::EnableAthstats (std::string filename,  uint32_t nodeid, uint32_t deviceid)
    2.48 +{
    2.49 +   Ptr<AthstatsWifiTraceSink> athstats = CreateObject<AthstatsWifiTraceSink> ();
    2.50 +  std::ostringstream oss;
    2.51 +  oss << filename
    2.52 +      << "_" << std::setfill ('0') << std::setw (3) << std::right <<  nodeid 
    2.53 +      << "_" << std::setfill ('0') << std::setw (3) << std::right << deviceid;
    2.54 +  athstats->Open (oss.str ());
    2.55 +
    2.56 +  oss.str ("");
    2.57 +  oss << "/NodeList/" << nodeid << "/DeviceList/" << deviceid;
    2.58 +  std::string devicepath = oss.str ();
    2.59 +
    2.60 +  Config::Connect (devicepath + "/Mac/MacTx", MakeCallback (&AthstatsWifiTraceSink::DevTxTrace, athstats));
    2.61 +  Config::Connect (devicepath + "/Mac/MacRx", MakeCallback (&AthstatsWifiTraceSink::DevRxTrace, athstats));
    2.62 +
    2.63 +  Config::Connect (devicepath + "/RemoteStationManager/TxRtsFailed", MakeCallback (&AthstatsWifiTraceSink::TxRtsFailedTrace, athstats));
    2.64 +  Config::Connect (devicepath + "/RemoteStationManager/MacTxDataFailed", MakeCallback (&AthstatsWifiTraceSink::TxDataFailedTrace, athstats));
    2.65 +  Config::Connect (devicepath + "/RemoteStationManager/MacTxFinalRtsFailed", MakeCallback (&AthstatsWifiTraceSink::TxFinalRtsFailedTrace, athstats));
    2.66 +  Config::Connect (devicepath + "/RemoteStationManager/MacTxFinalDataFailed", MakeCallback (&AthstatsWifiTraceSink::TxFinalDataFailedTrace, athstats));
    2.67 +
    2.68 +  Config::Connect (devicepath + "/Phy/State/RxOk", MakeCallback (&AthstatsWifiTraceSink::PhyRxOkTrace, athstats));
    2.69 +  Config::Connect (devicepath + "/Phy/State/RxError", MakeCallback (&AthstatsWifiTraceSink::PhyRxErrorTrace, athstats));
    2.70 +  Config::Connect (devicepath + "/Phy/State/Tx", MakeCallback (&AthstatsWifiTraceSink::PhyTxTrace, athstats));
    2.71 +  Config::Connect (devicepath + "/Phy/State/State", MakeCallback (&AthstatsWifiTraceSink::PhyStateTrace, athstats));
    2.72 +}
    2.73 +
    2.74 +void
    2.75 +AthstatsHelper::EnableAthstats (std::string filename, Ptr<NetDevice> nd)
    2.76 +{
    2.77 +  EnableAthstats (filename, nd->GetNode ()->GetId (), nd->GetIfIndex ());
    2.78 +}
    2.79 +
    2.80 +
    2.81 +void 
    2.82 +AthstatsHelper::EnableAthstats (std::string filename, NetDeviceContainer d)
    2.83 +{
    2.84 +  for (NetDeviceContainer::Iterator i = d.Begin (); i != d.End (); ++i)
    2.85 +    {
    2.86 +      Ptr<NetDevice> dev = *i;
    2.87 +      EnableAthstats (filename, dev->GetNode ()->GetId (), dev->GetIfIndex ());
    2.88 +    }
    2.89 +}
    2.90 +
    2.91 +
    2.92 +void
    2.93 +AthstatsHelper::EnableAthstats (std::string filename, NodeContainer n)
    2.94 +{
    2.95 +  NetDeviceContainer devs;
    2.96 +  for (NodeContainer::Iterator i = n.Begin (); i != n.End (); ++i)
    2.97 +    {
    2.98 +      Ptr<Node> node = *i;
    2.99 +      for (uint32_t j = 0; j < node->GetNDevices (); ++j)
   2.100 +        {
   2.101 +          devs.Add (node->GetDevice (j));
   2.102 +        }
   2.103 +    }
   2.104 +  EnableAthstats (filename, devs);
   2.105 +}
   2.106 +
   2.107 +
   2.108 +
   2.109 +
   2.110 +
   2.111 +NS_OBJECT_ENSURE_REGISTERED (AthstatsWifiTraceSink);
   2.112 +
   2.113 +TypeId 
   2.114 +AthstatsWifiTraceSink::GetTypeId (void)
   2.115 +{
   2.116 +  static TypeId tid = TypeId ("ns3::AthstatsWifiTraceSink")
   2.117 +    .SetParent<Object> ()
   2.118 +    .AddConstructor<AthstatsWifiTraceSink> ()
   2.119 +    .AddAttribute ("Interval",
   2.120 +                   "Time interval between reports",
   2.121 +                   TimeValue (Seconds(1.0)),
   2.122 +                   MakeTimeAccessor (&AthstatsWifiTraceSink::m_interval),
   2.123 +                   MakeTimeChecker ())
   2.124 +    ;
   2.125 +  return tid;
   2.126 +}
   2.127 +
   2.128 +AthstatsWifiTraceSink::AthstatsWifiTraceSink ()
   2.129 +  :   m_txCount (0),
   2.130 +      m_rxCount (0),
   2.131 +      m_shortRetryCount (0),
   2.132 +      m_longRetryCount (0),
   2.133 +      m_exceededRetryCount (0),
   2.134 +      m_phyRxOkCount (0),
   2.135 +      m_phyRxErrorCount (0),
   2.136 +      m_phyTxCount (0),
   2.137 +      m_writer (0)
   2.138 +{
   2.139 +  Simulator::ScheduleNow (&AthstatsWifiTraceSink::WriteStats, this);
   2.140 +}
   2.141 +
   2.142 +AthstatsWifiTraceSink::~AthstatsWifiTraceSink ()
   2.143 +{
   2.144 +  NS_LOG_FUNCTION (this);
   2.145 +
   2.146 +  if (m_writer != 0)
   2.147 +    {
   2.148 +      NS_LOG_LOGIC ("m_writer nonzero " << m_writer);
   2.149 +      if (m_writer->is_open ())
   2.150 +        {
   2.151 +          NS_LOG_LOGIC ("m_writer open.  Closing " << m_writer);
   2.152 +          m_writer->close ();
   2.153 +        }
   2.154 +
   2.155 +      NS_LOG_LOGIC ("Deleting writer " << m_writer);
   2.156 +      delete m_writer;
   2.157 +
   2.158 +      NS_LOG_LOGIC ("m_writer = 0");
   2.159 +      m_writer = 0;
   2.160 +    }
   2.161 +  else
   2.162 +    {
   2.163 +      NS_LOG_LOGIC ("m_writer == 0");
   2.164 +    }
   2.165 +}
   2.166 +
   2.167 +void    
   2.168 +AthstatsWifiTraceSink::ResetCounters ()
   2.169 +{
   2.170 +  m_txCount = 0;
   2.171 +  m_rxCount = 0;
   2.172 +  m_shortRetryCount = 0;
   2.173 +  m_longRetryCount = 0;
   2.174 +  m_exceededRetryCount = 0;
   2.175 +  m_phyRxOkCount = 0;
   2.176 +  m_phyRxErrorCount = 0;
   2.177 +  m_phyTxCount = 0;
   2.178 +}
   2.179 +
   2.180 +void
   2.181 +AthstatsWifiTraceSink::DevTxTrace (std::string context, Ptr<const Packet> p)
   2.182 +{
   2.183 +  NS_LOG_FUNCTION (this << context <<p);
   2.184 +  ++m_txCount;
   2.185 +}
   2.186 +
   2.187 +void
   2.188 +AthstatsWifiTraceSink::DevRxTrace (std::string context, Ptr<const Packet> p)
   2.189 +{
   2.190 +  NS_LOG_FUNCTION (this << context <<p);
   2.191 +  ++m_rxCount;
   2.192 +}
   2.193 +
   2.194 +
   2.195 +void
   2.196 +AthstatsWifiTraceSink::TxRtsFailedTrace (std::string context, Mac48Address address)
   2.197 +{
   2.198 +  NS_LOG_FUNCTION (this << context << address);
   2.199 +  ++m_shortRetryCount;
   2.200 +}
   2.201 +
   2.202 +void
   2.203 +AthstatsWifiTraceSink::TxDataFailedTrace (std::string context, Mac48Address address)
   2.204 +{
   2.205 +  NS_LOG_FUNCTION (this << context << address);
   2.206 +  ++m_longRetryCount;
   2.207 +}
   2.208 +
   2.209 +void
   2.210 +AthstatsWifiTraceSink::TxFinalRtsFailedTrace (std::string context, Mac48Address address)
   2.211 +{
   2.212 +  NS_LOG_FUNCTION (this << context << address);
   2.213 +  ++m_exceededRetryCount;
   2.214 +}
   2.215 +
   2.216 +void
   2.217 +AthstatsWifiTraceSink::TxFinalDataFailedTrace (std::string context, Mac48Address address)
   2.218 +{
   2.219 +  NS_LOG_FUNCTION (this << context << address);
   2.220 +  ++m_exceededRetryCount;
   2.221 +}
   2.222 +
   2.223 +
   2.224 +
   2.225 +void
   2.226 +AthstatsWifiTraceSink::PhyRxOkTrace (std::string context, Ptr<const Packet> packet, double snr, WifiMode mode, enum WifiPreamble preamble)
   2.227 +{
   2.228 +  NS_LOG_FUNCTION (this << context <<packet<< " mode=" << mode << " snr=" << snr );
   2.229 +  ++m_phyRxOkCount;
   2.230 +}
   2.231 +
   2.232 +void
   2.233 +AthstatsWifiTraceSink::PhyRxErrorTrace (std::string context, Ptr<const Packet> packet, double snr)
   2.234 +{
   2.235 +  NS_LOG_FUNCTION (this << context <<packet <<" snr=" << snr );
   2.236 +  ++m_phyRxErrorCount;
   2.237 +}
   2.238 +
   2.239 +void
   2.240 +AthstatsWifiTraceSink::PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower)
   2.241 +{
   2.242 +  NS_LOG_FUNCTION (this << context << packet << "PHYTX mode=" << mode );
   2.243 +  ++m_phyTxCount;
   2.244 +}
   2.245 +
   2.246 +
   2.247 +void
   2.248 +AthstatsWifiTraceSink::PhyStateTrace (std::string context, Time start, Time duration, enum WifiPhy::State state)
   2.249 +{
   2.250 +  NS_LOG_FUNCTION (this << context << start << duration << state);
   2.251 +
   2.252 +}
   2.253 +
   2.254 +
   2.255 +
   2.256 +void
   2.257 +AthstatsWifiTraceSink::Open (std::string const &name)
   2.258 +{
   2.259 +  NS_LOG_FUNCTION (this << name);
   2.260 +  NS_ABORT_MSG_UNLESS (m_writer == 0, "AthstatsWifiTraceSink::Open (): m_writer already allocated (std::ofstream leak detected)");
   2.261 +
   2.262 +  m_writer = new std::ofstream ();
   2.263 +  NS_ABORT_MSG_UNLESS (m_writer, "AthstatsWifiTraceSink::Open (): Cannot allocate m_writer");
   2.264 +
   2.265 +  NS_LOG_LOGIC ("Created writer " << m_writer);
   2.266 +
   2.267 +  m_writer->open (name.c_str (), std::ios_base::binary | std::ios_base::out);
   2.268 +  NS_ABORT_MSG_IF (m_writer->fail (), "AthstatsWifiTraceSink::Open (): m_writer->open (" << name.c_str () << ") failed");
   2.269 +
   2.270 +  NS_ASSERT_MSG (m_writer->is_open (), "AthstatsWifiTraceSink::Open (): m_writer not open");
   2.271 +
   2.272 +  NS_LOG_LOGIC ("Writer opened successfully");
   2.273 +}
   2.274 +
   2.275 +
   2.276 +void
   2.277 +AthstatsWifiTraceSink::WriteStats ()
   2.278 +{
   2.279 +  NS_ABORT_MSG_UNLESS (this, "function called with null this pointer, now=" << Now () );
   2.280 +  // the comments below refer to how each value maps to madwifi's athstats
   2.281 +  // I know C strings are ugly but that's the quickest way to use exactly the same format as in madwifi
   2.282 +  char str[200];
   2.283 +  snprintf (str, 200, "%8u %8u %7u %7u %7u %6u %6u %6u %7u %4u %3uM\n",
   2.284 +           m_txCount, // /proc/net/dev transmitted packets to which we should subract mgmt frames
   2.285 +           m_rxCount, // /proc/net/dev received packets but subracts mgmt frames from it
   2.286 +           0,         // ast_tx_altrate,
   2.287 +           m_shortRetryCount,     // ast_tx_shortretry,
   2.288 +           m_longRetryCount,      // ast_tx_longretry,
   2.289 +           m_exceededRetryCount,  // ast_tx_xretries,
   2.290 +           m_phyRxErrorCount,     // ast_rx_crcerr,
   2.291 +           0,         // ast_rx_badcrypt,
   2.292 +           0,         // ast_rx_phyerr,
   2.293 +           0,         // ast_rx_rssi,
   2.294 +           0          // rate
   2.295 +           );
   2.296 +
   2.297 +  if (m_writer)
   2.298 +    {
   2.299 +      
   2.300 +      *m_writer << str;
   2.301 +      
   2.302 +      ResetCounters ();
   2.303 +      Simulator::Schedule (m_interval, &AthstatsWifiTraceSink::WriteStats, this);
   2.304 +    }
   2.305 +}
   2.306 +
   2.307 +
   2.308 +
   2.309 +
   2.310 +} // namespace ns3
   2.311 +
   2.312 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/helper/athstats-helper.h	Mon Aug 24 13:32:06 2009 +0200
     3.3 @@ -0,0 +1,226 @@
     3.4 +/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
     3.5 +/*
     3.6 + * Copyright (c) 2009 CTTC
     3.7 + *
     3.8 + * This program is free software; you can redistribute it and/or modify
     3.9 + * it under the terms of the GNU General Public License version 2 as 
    3.10 + * published by the Free Software Foundation;
    3.11 + *
    3.12 + * This program is distributed in the hope that it will be useful,
    3.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    3.15 + * GNU General Public License for more details.
    3.16 + *
    3.17 + * You should have received a copy of the GNU General Public License
    3.18 + * along with this program; if not, write to the Free Software
    3.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    3.20 + *
    3.21 + * Author: Nicola Baldo <nbaldo@cttc.es>
    3.22 + */
    3.23 +
    3.24 +#ifndef ATHSTATS_HELPER_H
    3.25 +#define ATHSTATS_HELPER_H
    3.26 +
    3.27 +#include<string>
    3.28 +#include "ns3/object.h"
    3.29 +#include "ns3/attribute.h"
    3.30 +#include "ns3/object-factory.h"
    3.31 +#include "ns3/node-container.h"
    3.32 +#include "ns3/net-device-container.h"
    3.33 +#include "ns3/nstime.h"
    3.34 +#include "ns3/wifi-phy.h"
    3.35 +#include "ns3/double.h"
    3.36 +#include "ns3/mac48-address.h"
    3.37 +
    3.38 +namespace ns3 {
    3.39 +
    3.40 +
    3.41 +class NetDevice;
    3.42 +
    3.43 +/**
    3.44 + * @brief create AthstatsWifiTraceSink instances and connect them to wifi devices
    3.45 + *
    3.46 + * 
    3.47 + */
    3.48 +class AthstatsHelper
    3.49 +{
    3.50 +public:
    3.51 +  AthstatsHelper ();
    3.52 +  void EnableAthstats (std::string filename,  uint32_t nodeid, uint32_t deviceid);
    3.53 +  void EnableAthstats (std::string filename, Ptr<NetDevice> nd);
    3.54 +  void EnableAthstats (std::string filename, NetDeviceContainer d);
    3.55 +  void EnableAthstats (std::string filename, NodeContainer n);
    3.56 +  
    3.57 +private:
    3.58 +  Time m_interval;    
    3.59 +};
    3.60 +
    3.61 +
    3.62 +
    3.63 +
    3.64 +/**
    3.65 + * @brief trace sink for wifi device that mimics madwifi's athstats tool.
    3.66 + *
    3.67 + * The AthstatsWifiTraceSink class is a trace sink to be connected to several of the traces
    3.68 + * available within a wifi device. The purpose of AthstatsWifiTraceSink is to
    3.69 + * mimic the behavior of the athstats tool distributed wih the madwifi
    3.70 + * driver. In particular, the reproduced behavior is that obtained
    3.71 + * when executing athstats without parameters: a report written in
    3.72 + * text format is produced every fixed interval, based on the events
    3.73 + * observed by the wifi device. 
    3.74 + * 
    3.75 + * Differences with the "real" athstats:
    3.76 + *
    3.77 + * - AthstatsWifiTraceSink is expected to write its output to a file
    3.78 + *   (not to stdout).
    3.79 + *
    3.80 + * - only a subset of the metrics supported by athstats is supported
    3.81 + *   by AthstatsWifiTraceSink
    3.82 + * 
    3.83 + * - AthstatsWifiTraceSink does never produce a cumulative report.
    3.84 + */
    3.85 +class AthstatsWifiTraceSink  : public Object
    3.86 +{
    3.87 +public: 
    3.88 +  static TypeId GetTypeId (void);
    3.89 +  AthstatsWifiTraceSink ();
    3.90 +  virtual ~AthstatsWifiTraceSink ();
    3.91 +    
    3.92 +
    3.93 +  /** 
    3.94 +   * function to be called when the net device transmittes a packet
    3.95 +   * 
    3.96 +   * @param context 
    3.97 +   * @param p the packet being transmitted
    3.98 +   */
    3.99 +  void DevTxTrace (std::string context, Ptr<const Packet> p);
   3.100 +
   3.101 +  /** 
   3.102 +   * function to be called when the net device receives a packet
   3.103 +   * 
   3.104 +   * @param context 
   3.105 +   * @param p the packet being received
   3.106 +   */
   3.107 +  void DevRxTrace (std::string context, Ptr<const Packet> p);
   3.108 +
   3.109 +  /** 
   3.110 +   * Function to be called when a RTS frame transmission by the considered
   3.111 +   * device has failed
   3.112 +   * 
   3.113 +   * @param context 
   3.114 +   * @param address the MAC address of the remote station
   3.115 +   */
   3.116 +  void TxRtsFailedTrace (std::string context, Mac48Address address);  
   3.117 +
   3.118 +  /** 
   3.119 +   * Function to be called when a data frame transmission by the considered
   3.120 +   * device has failed
   3.121 +   * 
   3.122 +   * @param context 
   3.123 +   * @param address the MAC address of the remote station
   3.124 +   */
   3.125 +  void TxDataFailedTrace (std::string context, Mac48Address address);  
   3.126 +
   3.127 +  /** 
   3.128 +   * Function to be called when the transmission of a RTS frame has
   3.129 +   * exceeded the retry limit
   3.130 +   * 
   3.131 +   * @param context 
   3.132 +   * @param address the MAC address of the remote station
   3.133 +   */
   3.134 +  void TxFinalRtsFailedTrace (std::string context, Mac48Address address);  
   3.135 +
   3.136 +  /** 
   3.137 +   * Function to be called when the transmission of a data frame has
   3.138 +   * exceeded the retry limit
   3.139 +   * 
   3.140 +   * @param context 
   3.141 +   * @param address the MAC address of the remote station
   3.142 +   */  
   3.143 +  void TxFinalDataFailedTrace (std::string context, Mac48Address address);    
   3.144 +
   3.145 +
   3.146 +  /** 
   3.147 +   * Function to be called when the PHY layer  of the considered
   3.148 +   * device receives a frame
   3.149 +   * 
   3.150 +   * @param context 
   3.151 +   * @param packet 
   3.152 +   * @param snr 
   3.153 +   * @param mode 
   3.154 +   * @param preamble 
   3.155 +   */
   3.156 +  void PhyRxOkTrace (std::string context, Ptr<const Packet> packet, double snr, WifiMode mode, enum WifiPreamble preamble);
   3.157 +
   3.158 +  /** 
   3.159 +   * Function to be called when a frame reception by the PHY
   3.160 +   * layer  of the considered device resulted in an error due to a failure in the CRC check of
   3.161 +   * the frame
   3.162 +   * 
   3.163 +   * @param context 
   3.164 +   * @param packet 
   3.165 +   * @param snr 
   3.166 +   */
   3.167 +  void PhyRxErrorTrace (std::string context, Ptr<const Packet> packet, double snr);
   3.168 +
   3.169 +  /** 
   3.170 +   * Function to be called when a frame is being transmitted by the
   3.171 +   * PHY layer of the considered device
   3.172 +   * 
   3.173 +   * @param context 
   3.174 +   * @param packet 
   3.175 +   * @param mode 
   3.176 +   * @param preamble 
   3.177 +   * @param txPower 
   3.178 +   */
   3.179 +  void PhyTxTrace (std::string context, Ptr<const Packet> packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower);
   3.180 +
   3.181 +  /** 
   3.182 +   * Function to be called when the PHY layer of the considered device
   3.183 +   * changes state
   3.184 +   * 
   3.185 +   * @param context 
   3.186 +   * @param start 
   3.187 +   * @param duration 
   3.188 +   * @param state 
   3.189 +   */
   3.190 +  void PhyStateTrace (std::string context, Time start, Time duration, enum WifiPhy::State state);
   3.191 +
   3.192 +  /** 
   3.193 +   * Open a file for output
   3.194 +   * 
   3.195 +   * @param name the name of the file to be opened.
   3.196 +   */
   3.197 +  void Open (std::string const& name);
   3.198 +
   3.199 +private:
   3.200 +
   3.201 +  void WriteStats ();
   3.202 +  void ResetCounters ();
   3.203 +
   3.204 +
   3.205 +  uint32_t m_txCount;
   3.206 +  uint32_t m_rxCount;
   3.207 +  uint32_t m_shortRetryCount;
   3.208 +  uint32_t m_longRetryCount;
   3.209 +  uint32_t m_exceededRetryCount;
   3.210 +  uint32_t m_phyRxOkCount;
   3.211 +  uint32_t m_phyRxErrorCount;
   3.212 +  uint32_t m_phyTxCount;
   3.213 +
   3.214 +  std::ofstream *m_writer;
   3.215 +
   3.216 +  Time m_interval;    
   3.217 +
   3.218 +
   3.219 +}; // class AthstatsWifiTraceSink
   3.220 +
   3.221 +
   3.222 +
   3.223 +  
   3.224 +} // namespace ns3
   3.225 +
   3.226 +
   3.227 +
   3.228 +
   3.229 +#endif /* ATHSTATS_HELPER_H */
     4.1 --- a/src/helper/wscript	Mon Aug 24 13:09:32 2009 +0200
     4.2 +++ b/src/helper/wscript	Mon Aug 24 13:32:06 2009 +0200
     4.3 @@ -28,6 +28,7 @@
     4.4          'ipv4-global-routing-helper.cc',
     4.5          'ipv4-list-routing-helper.cc',
     4.6          'ipv4-routing-helper.cc',
     4.7 +        'athstats-helper.cc',
     4.8          'ipv6-address-helper.cc',
     4.9          'ipv6-interface-container.cc',
    4.10          'ipv6-static-routing-helper.cc',
    4.11 @@ -64,6 +65,7 @@
    4.12          'ipv4-global-routing-helper.h',
    4.13          'ipv4-list-routing-helper.h',
    4.14          'ipv4-routing-helper.h',
    4.15 +        'athstats-helper.h',
    4.16          'ipv6-address-helper.h',
    4.17          'ipv6-interface-container.h',
    4.18          'ipv6-static-routing-helper.h',