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
void SetLogging(int log)
Enables/disables logging.
void SetExpectedRxPktCount(int index, int count)
Sets the count of packets expected to received.
double GetBsmPdr(int index)
Returns the BSM Packet Delivery Ratio (PDR) which is the percent of expected packets within range(ind...
int GetRxPktInRangeCount(int index)
Increments the count of actual packets recevied within range(index)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
int GetTxByteCount()
Returns the count of (application data) bytes transmitted not include MAC/PHY overhead.
void SetRxPktInRangeCount(int index, int count)
Sets the count of packets within range that are received.
int m_wavePktReceiveCount
packet receive count
void IncTxByteCount(int bytes)
Increments the count of (application data) bytes transmitted not including MAC/PHY overhead...
void ResetTotalRxPktCounts(int index)
Resets the count of total packets expected and/or within range(index) that are received.
void IncTxPktCount()
Increments the count of transmitted packets.
int GetRxPktCount()
Returns the count of packets received.
int GetTxPktCount()
Returns the count of transmitted packets.
void IncExpectedRxPktCount(int index)
Increments the count of (broadcast) packets expected to be received within the coverage area1...
int m_waveByteSendCount
byte sent count
The WaveBsmStats class implements a stats collector for IEEE 1609 WAVE (Wireless Access in Vehicular ...
void SetRxPktCount(int count)
Sets the count of packets received.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
int GetExpectedRxPktCount(int index)
Returns the count of expected packets received within range(index)
std::vector< int > m_waveTotalPktInCoverageReceiveCounts
total packet in coverage receive counts
std::vector< int > m_wavePktInCoverageReceiveCounts
packet in ceoverage receive counts
WaveBsmStats()
Constructor.
void IncRxPktCount()
Increments the count of actual packets received (regardless of coverage area).
void SetTxPktCount(int count)
Sets the count of packets transmitted.
int m_wavePktSendCount
packet sent count
std::vector< int > m_wavePktExpectedReceiveCounts
packet expected receive counts
std::vector< int > m_waveTotalPktExpectedReceiveCounts
total packet expected receive counts
void IncRxPktInRangeCount(int index)
Increments the count of actual packets received within the coverage area(index).
int GetLogging()
Gets logging state.
double GetCumulativeBsmPdr(int index)
Returns the cumulative BSM Packet Delivery Ratio (PDR) which is the percent of cumulative expected pa...
A base class which provides memory management and object aggregation.
Definition: object.h:87
static TypeId GetTypeId(void)
Register this type.
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:914