|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #include "ns3/simulator.h"
23 #include "ns3/config.h"
24 #include "ns3/wifi-mode.h"
25 #include "ns3/wifi-phy-common.h"
26 #include "ns3/wifi-phy-state.h"
27 #include "ns3/net-device-container.h"
28 #include "ns3/node-container.h"
46 std::ostringstream oss;
48 <<
"_" << std::setfill (
'0') << std::setw (3) << std::right << nodeid
49 <<
"_" << std::setfill (
'0') << std::setw (3) << std::right << deviceid;
50 athstats->Open (oss.str ());
53 oss <<
"/NodeList/" << nodeid <<
"/DeviceList/" << deviceid;
54 std::string devicepath = oss.str ();
93 for (std::size_t j = 0; j < node->
GetNDevices (); ++j)
106 static TypeId tid =
TypeId (
"ns3::AthstatsWifiTraceSink")
108 .SetGroupName (
"Wifi")
110 .AddAttribute (
"Interval",
111 "Time interval between reports",
122 m_shortRetryCount (0),
123 m_longRetryCount (0),
124 m_exceededRetryCount (0),
126 m_phyRxErrorCount (0),
216 NS_LOG_FUNCTION (
this << context << packet <<
" mode=" << mode <<
" snr=" << snr <<
"preamble=" << preamble);
230 NS_LOG_FUNCTION (
this << context << packet <<
"PHYTX mode=" << mode <<
"Preamble=" << preamble <<
"Power=" << txPower);
251 m_writer->open (name.c_str (), std::ios_base::binary | std::ios_base::out);
252 NS_ABORT_MSG_IF (
m_writer->fail (),
"AthstatsWifiTraceSink::Open (): m_writer->open (" << name.c_str () <<
") failed");
266 snprintf (str, 200,
"%8u %8u %7u %7u %7u %6u %6u %6u %7u %4u %3uM\n",
holds a vector of ns3::NetDevice pointers
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint32_t m_rxCount
receive count
trace sink for wifi device that mimics madwifi's athstats tool.
void TxRtsFailedTrace(std::string context, Mac48Address address)
Function to be called when a RTS frame transmission by the considered device has failed.
void TxDataFailedTrace(std::string context, Mac48Address address)
Function to be called when a data frame transmission by the considered device has failed.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
void EnableAthstats(std::string filename, uint32_t nodeid, uint32_t deviceid)
Enable athstats.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
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 GetId(void) const
uint32_t m_phyRxErrorCount
PHY receive error count.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static TypeId GetTypeId(void)
Get the type ID.
void WriteStats()
Write status function.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
uint32_t m_shortRetryCount
short retry count
uint32_t m_longRetryCount
long retry count
void DevRxTrace(std::string context, Ptr< const Packet > p)
function to be called when the net device receives a packet
Smart pointer class similar to boost::intrusive_ptr.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
represent a single transmission mode
A base class which provides memory management and object aggregation.
virtual Ptr< Node > GetNode(void) const =0
uint32_t m_txCount
transmit count
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
void TxFinalRtsFailedTrace(std::string context, Mac48Address address)
Function to be called when the transmission of a RTS frame has exceeded the retry limit.
Simulation virtual time values and global simulation resolution.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
WifiPhyState
The state of the PHY layer.
WifiPreamble
The type of preamble to be used by an IEEE 802.11 transmission.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
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.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
void Connect(std::string path, const CallbackBase &cb)
uint32_t m_exceededRetryCount
exceeded retry count
Time Seconds(double value)
Construct a Time in the indicated unit.
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
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...
std::ofstream * m_writer
output stream
void TxFinalDataFailedTrace(std::string context, Mac48Address address)
Function to be called when the transmission of a data frame has exceeded the retry limit.
keep track of a set of node pointers.
virtual ~AthstatsWifiTraceSink()
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.
void ResetCounters()
Reset counters function.
uint32_t GetNDevices(void) const
void Open(std::string const &name)
Open a file for output.
void DevTxTrace(std::string context, Ptr< const Packet > p)
function to be called when the net device transmits a packet
virtual uint32_t GetIfIndex(void) const =0
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
uint32_t m_phyTxCount
PHY transmit count.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
uint32_t m_phyRxOkCount
PHY receive OK count.