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 
27 namespace ns3 {
28 
29 NS_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);
38  m_wavePktInCoverageReceiveCounts.resize (10, 0);
41 }
42 
43 /* static */
44 TypeId
46 {
47  static TypeId tid = TypeId ("ns3::WaveBsmStats")
48  .SetParent<Object> ()
49  .SetGroupName ("Stats")
50  .AddConstructor<WaveBsmStats> ()
51  ;
52  return tid;
53 }
54 
55 void
57 {
59 }
60 
61 int
63 {
64  return m_wavePktSendCount;
65 }
66 
67 void
69 {
70  m_wavePktExpectedReceiveCounts[index - 1]++;
72 }
73 
74 void
76 {
78 }
79 
80 void
82 {
85 }
86 
87 int
89 {
90  return m_wavePktReceiveCount;
91 }
92 
93 int
95 {
96  return m_wavePktExpectedReceiveCounts[index - 1];
97 }
98 
99 int
101 {
102  return m_wavePktInCoverageReceiveCounts[index - 1];
103 }
104 
105 void
107 {
108  m_wavePktSendCount = count;
109 }
110 
111 void
113 {
114  m_wavePktReceiveCount = count;
115 }
116 
117 void
119 {
120  m_waveByteSendCount += bytes;
121 }
122 
123 int
125 {
126  return m_waveByteSendCount;
127 }
128 
129 double
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 
150 double
152 {
153  double pdr = 0.0;
154 
155  if (m_waveTotalPktExpectedReceiveCounts[index - 1] > 0)
156  {
157  pdr = (double) m_waveTotalPktInCoverageReceiveCounts[index - 1] / (double) m_waveTotalPktExpectedReceiveCounts[index - 1];
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 
171 void
173 {
174  m_log = log;
175 }
176 
177 int
179 {
180  return m_log;
181 }
182 
183 void
185 {
186  m_wavePktExpectedReceiveCounts[index - 1] = count;
187 }
188 
189 void
191 {
192  m_wavePktInCoverageReceiveCounts[index - 1] = count;
193 }
194 
195 void
197 {
200 }
201 
202 } // namespace ns3
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::WaveBsmStats::ResetTotalRxPktCounts
void ResetTotalRxPktCounts(int index)
Resets the count of total packets expected and/or within range(index) that are received.
Definition: wave-bsm-stats.cc:196
ns3::WaveBsmStats::GetTxPktCount
int GetTxPktCount()
Returns the count of transmitted packets.
Definition: wave-bsm-stats.cc:62
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WaveBsmStats::IncRxPktInRangeCount
void IncRxPktInRangeCount(int index)
Increments the count of actual packets received within the coverage area(index).
Definition: wave-bsm-stats.cc:81
ns3::WaveBsmStats::m_waveTotalPktInCoverageReceiveCounts
std::vector< int > m_waveTotalPktInCoverageReceiveCounts
total packet in coverage receive counts
Definition: wave-bsm-stats.h:230
ns3::WaveBsmStats::m_wavePktExpectedReceiveCounts
std::vector< int > m_wavePktExpectedReceiveCounts
packet expected receive counts
Definition: wave-bsm-stats.h:229
ns3::WaveBsmStats::GetLogging
int GetLogging()
Gets logging state.
Definition: wave-bsm-stats.cc:178
ns3::WaveBsmStats::SetTxPktCount
void SetTxPktCount(int count)
Sets the count of packets transmitted.
Definition: wave-bsm-stats.cc:106
ns3::WaveBsmStats::GetExpectedRxPktCount
int GetExpectedRxPktCount(int index)
Returns the count of expected packets received within range(index)
Definition: wave-bsm-stats.cc:94
ns3::WaveBsmStats::GetRxPktCount
int GetRxPktCount()
Returns the count of packets received.
Definition: wave-bsm-stats.cc:88
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::WaveBsmStats::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition: wave-bsm-stats.cc:45
ns3::WaveBsmStats::m_waveTotalPktExpectedReceiveCounts
std::vector< int > m_waveTotalPktExpectedReceiveCounts
total packet expected receive counts
Definition: wave-bsm-stats.h:231
ns3::WaveBsmStats::WaveBsmStats
WaveBsmStats()
Constructor.
Definition: wave-bsm-stats.cc:31
ns3::WaveBsmStats
The WaveBsmStats class implements a stats collector for IEEE 1609 WAVE (Wireless Access in Vehicular ...
Definition: wave-bsm-stats.h:50
ns3::WaveBsmStats::m_wavePktSendCount
int m_wavePktSendCount
packet sent count
Definition: wave-bsm-stats.h:225
ns3::WaveBsmStats::SetRxPktCount
void SetRxPktCount(int count)
Sets the count of packets received.
Definition: wave-bsm-stats.cc:112
ns3::WaveBsmStats::m_log
int m_log
log
Definition: wave-bsm-stats.h:232
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::WaveBsmStats::m_wavePktReceiveCount
int m_wavePktReceiveCount
packet receive count
Definition: wave-bsm-stats.h:227
ns3::WaveBsmStats::SetRxPktInRangeCount
void SetRxPktInRangeCount(int index, int count)
Sets the count of packets within range that are received.
Definition: wave-bsm-stats.cc:190
ns3::WaveBsmStats::SetLogging
void SetLogging(int log)
Enables/disables logging.
Definition: wave-bsm-stats.cc:172
ns3::WaveBsmStats::IncRxPktCount
void IncRxPktCount()
Increments the count of actual packets received (regardless of coverage area).
Definition: wave-bsm-stats.cc:75
ns3::WaveBsmStats::GetCumulativeBsmPdr
double GetCumulativeBsmPdr(int index)
Returns the cumulative BSM Packet Delivery Ratio (PDR) which is the percent of cumulative expected pa...
Definition: wave-bsm-stats.cc:151
ns3::WaveBsmStats::IncTxPktCount
void IncTxPktCount()
Increments the count of transmitted packets.
Definition: wave-bsm-stats.cc:56
ns3::WaveBsmStats::SetExpectedRxPktCount
void SetExpectedRxPktCount(int index, int count)
Sets the count of packets expected to received.
Definition: wave-bsm-stats.cc:184
ns3::WaveBsmStats::GetRxPktInRangeCount
int GetRxPktInRangeCount(int index)
Increments the count of actual packets received within range(index)
Definition: wave-bsm-stats.cc:100
ns3::WaveBsmStats::m_waveByteSendCount
int m_waveByteSendCount
byte sent count
Definition: wave-bsm-stats.h:226
ns3::WaveBsmStats::IncTxByteCount
void IncTxByteCount(int bytes)
Increments the count of (application data) bytes transmitted not including MAC/PHY overhead.
Definition: wave-bsm-stats.cc:118
ns3::WaveBsmStats::GetTxByteCount
int GetTxByteCount()
Returns the count of (application data) bytes transmitted not include MAC/PHY overhead.
Definition: wave-bsm-stats.cc:124
ns3::WaveBsmStats::IncExpectedRxPktCount
void IncExpectedRxPktCount(int index)
Increments the count of (broadcast) packets expected to be received within the coverage area1.
Definition: wave-bsm-stats.cc:68
ns3::WaveBsmStats::m_wavePktInCoverageReceiveCounts
std::vector< int > m_wavePktInCoverageReceiveCounts
packet in ceoverage receive counts
Definition: wave-bsm-stats.h:228
ns3::WaveBsmStats::GetBsmPdr
double GetBsmPdr(int index)
Returns the BSM Packet Delivery Ratio (PDR) which is the percent of expected packets within range(ind...
Definition: wave-bsm-stats.cc:130