A Discrete-Event Network Simulator
API
wave-bsm-stats.cc
Go to the documentation of this file.
1/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2014 North Carolina State University
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Scott E. Carpenter <scarpen@ncsu.edu>
19 *
20 */
21
22
23#include "ns3/wave-bsm-stats.h"
24#include "ns3/integer.h"
25#include "ns3/log.h"
26
27namespace ns3 {
28
29NS_LOG_COMPONENT_DEFINE ("WaveBsmStats");
30
32 : m_wavePktSendCount (0),
33 m_waveByteSendCount (0),
34 m_wavePktReceiveCount (0),
35 m_log (0)
36{
37 m_wavePktExpectedReceiveCounts.resize (10, 0);
41}
42
43/* static */
46{
47 static TypeId tid = TypeId ("ns3::WaveBsmStats")
48 .SetParent<Object> ()
49 .SetGroupName ("Stats")
50 .AddConstructor<WaveBsmStats> ()
51 ;
52 return tid;
53}
54
55void
57{
59}
60
61int
63{
64 return m_wavePktSendCount;
65}
66
67void
69{
72}
73
74void
76{
78}
79
80void
82{
85}
86
87int
89{
91}
92
93int
95{
96 return m_wavePktExpectedReceiveCounts[index - 1];
97}
98
99int
101{
102 return m_wavePktInCoverageReceiveCounts[index - 1];
103}
104
105void
107{
108 m_wavePktSendCount = count;
109}
110
111void
113{
114 m_wavePktReceiveCount = count;
115}
116
117void
119{
120 m_waveByteSendCount += bytes;
121}
122
123int
125{
126 return m_waveByteSendCount;
127}
128
129double
131{
132 double pdr = 0.0;
133
134 if (m_wavePktExpectedReceiveCounts[index - 1] > 0)
135 {
136 pdr = (double) m_wavePktInCoverageReceiveCounts[index - 1] / (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 // due to node movement, it is
159 // possible to receive a packet that is not slightly "within range" that was
160 // transmitted at the time when the nodes were slightly "out of range"
161 // thus, prevent overflow of PDR > 100%
162 if (pdr > 1.0)
163 {
164 pdr = 1.0;
165 }
166 }
167
168 return pdr;
169}
170
171void
173{
174 m_log = log;
175}
176
177int
179{
180 return m_log;
181}
182
183void
185{
186 m_wavePktExpectedReceiveCounts[index - 1] = count;
187}
188
189void
191{
192 m_wavePktInCoverageReceiveCounts[index - 1] = count;
193}
194
195void
197{
200}
201
202} // namespace ns3
A base class which provides memory management and object aggregation.
Definition: object.h:88
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
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.
int GetRxPktCount()
Returns the count of packets received.
WaveBsmStats()
Constructor.
std::vector< int > m_waveTotalPktInCoverageReceiveCounts
total packet in coverage receive counts
static TypeId GetTypeId(void)
Register this type.
void SetTxPktCount(int count)
Sets the count of packets transmitted.
int GetLogging()
Gets logging state.
int GetExpectedRxPktCount(int index)
Returns the count of expected packets received within range(index)
int m_wavePktReceiveCount
packet receive count
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 ceoverage receive counts
int m_wavePktSendCount
packet sent count
int GetRxPktInRangeCount(int index)
Increments the count of actual packets received within range(index)
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 GetTxByteCount()
Returns the count of (application data) bytes transmitted not include MAC/PHY overhead.
int GetTxPktCount()
Returns the count of transmitted packets.
std::vector< int > m_waveTotalPktExpectedReceiveCounts
total packet expected receive counts
void SetLogging(int log)
Enables/disables logging.
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:205
Every class exported by the ns3 library is enclosed in the ns3 namespace.