A Discrete-Event Network Simulator
API
wave-bsm-stats.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014 North Carolina State University
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: Scott E. Carpenter <scarpen@ncsu.edu>
18 *
19 */
20
21#include "ns3/wave-bsm-stats.h"
22
23#include "ns3/integer.h"
24#include "ns3/log.h"
25
26namespace ns3
27{
28
29NS_LOG_COMPONENT_DEFINE("WaveBsmStats");
30
32 : m_wavePktSendCount(0),
33 m_waveByteSendCount(0),
34 m_wavePktReceiveCount(0),
35 m_log(false)
36{
41}
42
43/* static */
46{
47 static TypeId tid = TypeId("ns3::WaveBsmStats")
49 .SetGroupName("Stats")
50 .AddConstructor<WaveBsmStats>();
51 return tid;
52}
53
54void
56{
58}
59
60int
62{
63 return m_wavePktSendCount;
64}
65
66void
68{
71}
72
73void
75{
77}
78
79void
81{
84}
85
86int
88{
90}
91
92int
94{
95 return m_wavePktExpectedReceiveCounts[index - 1];
96}
97
98int
100{
101 return m_wavePktInCoverageReceiveCounts[index - 1];
102}
103
104void
106{
107 m_wavePktSendCount = count;
108}
109
110void
112{
113 m_wavePktReceiveCount = count;
114}
115
116void
118{
119 m_waveByteSendCount += bytes;
120}
121
122int
124{
125 return m_waveByteSendCount;
126}
127
128double
130{
131 double pdr = 0.0;
132
133 if (m_wavePktExpectedReceiveCounts[index - 1] > 0)
134 {
135 pdr = (double)m_wavePktInCoverageReceiveCounts[index - 1] /
136 (double)m_wavePktExpectedReceiveCounts[index - 1];
137 // due to node movement, it is
138 // possible to receive a packet that is not slightly "within range" that was
139 // transmitted at the time when the nodes were slightly "out of range"
140 // thus, prevent overflow of PDR > 100%
141 if (pdr > 1.0)
142 {
143 pdr = 1.0;
144 }
145 }
146
147 return pdr;
148}
149
150double
152{
153 double pdr = 0.0;
154
155 if (m_waveTotalPktExpectedReceiveCounts[index - 1] > 0)
156 {
158 (double)m_waveTotalPktExpectedReceiveCounts[index - 1];
159 // due to node movement, it is
160 // possible to receive a packet that is not slightly "within range" that was
161 // transmitted at the time when the nodes were slightly "out of range"
162 // thus, prevent overflow of PDR > 100%
163 if (pdr > 1.0)
164 {
165 pdr = 1.0;
166 }
167 }
168
169 return pdr;
170}
171
172void
174{
175 m_log = log;
176}
177
178bool
180{
181 return m_log;
182}
183
184void
186{
187 m_wavePktExpectedReceiveCounts[index - 1] = count;
188}
189
190void
192{
193 m_wavePktInCoverageReceiveCounts[index - 1] = count;
194}
195
196void
198{
201}
202
203} // namespace ns3
A base class which provides memory management and object aggregation.
Definition: object.h:89
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
The WaveBsmStats class implements a stats collector for IEEE 1609 WAVE (Wireless Access in Vehicular ...
void IncTxByteCount(int bytes)
Increments the count of (application data) bytes transmitted not including MAC/PHY overhead.
void IncTxPktCount()
Increments the count of transmitted packets.
void SetExpectedRxPktCount(int index, int count)
Sets the count of packets expected to received.
WaveBsmStats()
Constructor.
std::vector< int > m_waveTotalPktInCoverageReceiveCounts
total packet in coverage receive counts
bool m_log
logging state
int GetTxByteCount() const
Returns the count of (application data) bytes transmitted not include MAC/PHY overhead.
void SetTxPktCount(int count)
Sets the count of packets transmitted.
void SetLogging(bool log)
Enables/disables logging.
int GetExpectedRxPktCount(int index)
Returns the count of expected packets received within range(index)
bool GetLogging() const
Gets logging state.
int m_wavePktReceiveCount
packet receive count
static TypeId GetTypeId()
Register this type.
void IncExpectedRxPktCount(int index)
Increments the count of (broadcast) packets expected to be received within the coverage area1.
void IncRxPktCount()
Increments the count of actual packets received (regardless of coverage area).
std::vector< int > m_wavePktInCoverageReceiveCounts
packet in coverage receive counts
int m_wavePktSendCount
packet sent count
int GetRxPktInRangeCount(int index)
Increments the count of actual packets received within range(index)
int GetRxPktCount() const
Returns the count of packets received.
double GetBsmPdr(int index)
Returns the BSM Packet Delivery Ratio (PDR) which is the percent of expected packets within range(ind...
void SetRxPktCount(int count)
Sets the count of packets received.
void IncRxPktInRangeCount(int index)
Increments the count of actual packets received within the coverage area(index).
double GetCumulativeBsmPdr(int index)
Returns the cumulative BSM Packet Delivery Ratio (PDR) which is the percent of cumulative expected pa...
int GetTxPktCount() const
Returns the count of transmitted packets.
std::vector< int > m_waveTotalPktExpectedReceiveCounts
total packet expected receive counts
int m_waveByteSendCount
byte sent count
std::vector< int > m_wavePktExpectedReceiveCounts
packet expected receive counts
void SetRxPktInRangeCount(int index, int count)
Sets the count of packets within range that are received.
void ResetTotalRxPktCounts(int index)
Resets the count of total packets expected and/or within range(index) that are received.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
Every class exported by the ns3 library is enclosed in the ns3 namespace.