A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
athstats-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 CTTC
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Nicola Baldo <nbaldo@cttc.es>
18 */
19
20#ifndef ATHSTATS_HELPER_H
21#define ATHSTATS_HELPER_H
22
23#include "ns3/nstime.h"
24#include "ns3/object.h"
25#include "ns3/ptr.h"
26#include "ns3/type-id.h"
27#include "ns3/wifi-phy-common.h"
28#include "ns3/wifi-phy-state.h"
29
30#include <iosfwd>
31#include <stdint.h>
32#include <string>
33
34namespace ns3
35{
36
37class NetDevice;
38class NodeContainer;
39class NetDeviceContainer;
40class Packet;
41class Mac48Address;
42class WifiMode;
43
44/**
45 * @brief create AthstatsWifiTraceSink instances and connect them to wifi devices
46 *
47 *
48 */
50{
51 public:
53 /**
54 * Enable athstats
55 * \param filename the file name
56 * \param nodeid the node ID
57 * \param deviceid the device ID
58 */
59 void EnableAthstats(std::string filename, uint32_t nodeid, uint32_t deviceid);
60 /**
61 * Enable athstats
62 * \param filename the file name
63 * \param nd the device
64 */
65 void EnableAthstats(std::string filename, Ptr<NetDevice> nd);
66 /**
67 * Enable athstats
68 * \param filename the file name
69 * \param d the collection of devices
70 */
71 void EnableAthstats(std::string filename, NetDeviceContainer d);
72 /**
73 * Enable athstats
74 * \param filename the file name
75 * \param n the collection of nodes
76 */
77 void EnableAthstats(std::string filename, NodeContainer n);
78
79 private:
80 Time m_interval; ///< interval
81};
82
83/**
84 * @brief trace sink for wifi device that mimics madwifi's athstats tool.
85 *
86 * The AthstatsWifiTraceSink class is a trace sink to be connected to several of the traces
87 * available within a wifi device. The purpose of AthstatsWifiTraceSink is to
88 * mimic the behavior of the athstats tool distributed with the madwifi
89 * driver. In particular, the reproduced behavior is that obtained
90 * when executing athstats without parameters: a report written in
91 * text format is produced every fixed interval, based on the events
92 * observed by the wifi device.
93 *
94 * Differences with the "real" athstats:
95 *
96 * - AthstatsWifiTraceSink is expected to write its output to a file
97 * (not to stdout).
98 *
99 * - only a subset of the metrics supported by athstats is supported
100 * by AthstatsWifiTraceSink
101 *
102 * - AthstatsWifiTraceSink does never produce a cumulative report.
103 */
105{
106 public:
107 /**
108 * \brief Get the type ID.
109 * \return the object TypeId
110 */
111 static TypeId GetTypeId();
113 ~AthstatsWifiTraceSink() override;
114
115 /**
116 * function to be called when the net device transmits a packet
117 *
118 * @param context the calling context
119 * @param p the packet being transmitted
120 */
121 void DevTxTrace(std::string context, Ptr<const Packet> p);
122
123 /**
124 * function to be called when the net device receives a packet
125 *
126 * @param context the calling context
127 * @param p the packet being received
128 */
129 void DevRxTrace(std::string context, Ptr<const Packet> p);
130
131 /**
132 * Function to be called when a RTS frame transmission by the considered
133 * device has failed
134 *
135 * @param context the calling context
136 * @param address the MAC address of the remote station
137 */
138 void TxRtsFailedTrace(std::string context, Mac48Address address);
139
140 /**
141 * Function to be called when a data frame transmission by the considered
142 * device has failed
143 *
144 * @param context the calling context
145 * @param address the MAC address of the remote station
146 */
147 void TxDataFailedTrace(std::string context, Mac48Address address);
148
149 /**
150 * Function to be called when the transmission of a RTS frame has
151 * exceeded the retry limit
152 *
153 * @param context the calling context
154 * @param address the MAC address of the remote station
155 */
156 void TxFinalRtsFailedTrace(std::string context, Mac48Address address);
157
158 /**
159 * Function to be called when the transmission of a data frame has
160 * exceeded the retry limit
161 *
162 * @param context the calling context
163 * @param address the MAC address of the remote station
164 */
165 void TxFinalDataFailedTrace(std::string context, Mac48Address address);
166
167 /**
168 * Function to be called when the PHY layer of the considered
169 * device receives a frame
170 *
171 * @param context the calling context
172 * @param packet the packet
173 * @param snr the SNR in linear scale
174 * @param mode the WifiMode
175 * @param preamble the wifi preamble
176 */
177 void PhyRxOkTrace(std::string context,
178 Ptr<const Packet> packet,
179 double snr,
180 WifiMode mode,
181 WifiPreamble preamble);
182
183 /**
184 * Function to be called when a frame reception by the PHY
185 * layer of the considered device resulted in an error due to a failure in the CRC check of
186 * the frame
187 *
188 * @param context the calling context
189 * @param packet the packet
190 * @param snr the SNR in linear scale
191 */
192 void PhyRxErrorTrace(std::string context, Ptr<const Packet> packet, double snr);
193
194 /**
195 * Function to be called when a frame is being transmitted by the
196 * PHY layer of the considered device
197 *
198 * @param context the calling context
199 * @param packet the packet
200 * @param mode the WifiMode
201 * @param preamble the wifi preamble
202 * @param txPower the transmit power level
203 */
204 void PhyTxTrace(std::string context,
205 Ptr<const Packet> packet,
206 WifiMode mode,
207 WifiPreamble preamble,
208 uint8_t txPower);
209
210 /**
211 * Function to be called when the PHY layer of the considered device
212 * changes state
213 *
214 * @param context the calling context
215 * @param start the time at which the state changed
216 * @param duration the duration of the state
217 * @param state the PHY layer state
218 */
219 void PhyStateTrace(std::string context, Time start, Time duration, WifiPhyState state);
220
221 /**
222 * Open a file for output
223 *
224 * @param name the name of the file to be opened.
225 */
226 void Open(const std::string& name);
227
228 private:
229 /// Write status function
230 void WriteStats();
231 /// Reset counters function
232 void ResetCounters();
233
234 uint32_t m_txCount; ///< transmit count
235 uint32_t m_rxCount; ///< receive count
236 uint32_t m_shortRetryCount; ///< short retry count
237 uint32_t m_longRetryCount; ///< long retry count
238 uint32_t m_exceededRetryCount; ///< exceeded retry count
239 uint32_t m_phyRxOkCount; ///< PHY receive OK count
240 uint32_t m_phyRxErrorCount; ///< PHY receive error count
241 uint32_t m_phyTxCount; ///< PHY transmit count
242
243 std::ofstream* m_writer; ///< output stream
244
245 Time m_interval; ///< interval
246
247}; // class AthstatsWifiTraceSink
248
249} // namespace ns3
250
251#endif /* ATHSTATS_HELPER_H */
create AthstatsWifiTraceSink instances and connect them to wifi devices
Time m_interval
interval
void EnableAthstats(std::string filename, uint32_t nodeid, uint32_t deviceid)
Enable athstats.
trace sink for wifi device that mimics madwifi's athstats tool.
void TxFinalRtsFailedTrace(std::string context, Mac48Address address)
Function to be called when the transmission of a RTS frame has exceeded the retry limit.
void Open(const std::string &name)
Open a file for output.
static TypeId GetTypeId()
Get the type ID.
void TxFinalDataFailedTrace(std::string context, Mac48Address address)
Function to be called when the transmission of a data frame has exceeded the retry limit.
void PhyRxOkTrace(std::string context, Ptr< const Packet > packet, double snr, WifiMode mode, WifiPreamble preamble)
Function to be called when the PHY layer of the considered device receives a frame.
uint32_t m_txCount
transmit count
void DevRxTrace(std::string context, Ptr< const Packet > p)
function to be called when the net device receives a packet
std::ofstream * m_writer
output stream
uint32_t m_rxCount
receive count
uint32_t m_shortRetryCount
short retry count
void WriteStats()
Write status function.
void TxRtsFailedTrace(std::string context, Mac48Address address)
Function to be called when a RTS frame transmission by the considered device has failed.
void PhyStateTrace(std::string context, Time start, Time duration, WifiPhyState state)
Function to be called when the PHY layer of the considered device changes state.
void PhyRxErrorTrace(std::string context, Ptr< const Packet > packet, double snr)
Function to be called when a frame reception by the PHY layer of the considered device resulted in an...
void DevTxTrace(std::string context, Ptr< const Packet > p)
function to be called when the net device transmits a packet
uint32_t m_longRetryCount
long retry count
void PhyTxTrace(std::string context, Ptr< const Packet > packet, WifiMode mode, WifiPreamble preamble, uint8_t txPower)
Function to be called when a frame is being transmitted by the PHY layer of the considered device.
uint32_t m_phyTxCount
PHY transmit count.
void TxDataFailedTrace(std::string context, Mac48Address address)
Function to be called when a data frame transmission by the considered device has failed.
uint32_t m_phyRxOkCount
PHY receive OK count.
uint32_t m_phyRxErrorCount
PHY receive error count.
void ResetCounters()
Reset counters function.
uint32_t m_exceededRetryCount
exceeded retry count
an EUI-48 address
Definition: mac48-address.h:46
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
represent a single transmission mode
Definition: wifi-mode.h:51
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
WifiPhyState
The state of the PHY layer.