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 void
45 {
47 }
48 
49 int
51 {
52  return m_wavePktSendCount;
53 }
54 
55 void
57 {
58  m_wavePktExpectedReceiveCounts[index - 1]++;
60 }
61 
62 void
64 {
66 }
67 
68 void
70 {
73 }
74 
75 int
77 {
78  return m_wavePktReceiveCount;
79 }
80 
81 int
83 {
84  return m_wavePktExpectedReceiveCounts[index - 1];
85 }
86 
87 int
89 {
90  return m_wavePktInCoverageReceiveCounts[index - 1];
91 }
92 
93 void
95 {
96  m_wavePktSendCount = count;
97 }
98 
99 void
101 {
102  m_wavePktReceiveCount = count;
103 }
104 
105 void
107 {
108  m_waveByteSendCount += bytes;
109 }
110 
111 int
113 {
114  return m_waveByteSendCount;
115 }
116 
117 double
119 {
120  double pdr = 0.0;
121 
122  if (m_wavePktExpectedReceiveCounts[index - 1] > 0)
123  {
124  pdr = (double) m_wavePktInCoverageReceiveCounts[index - 1] / (double) m_wavePktExpectedReceiveCounts[index - 1];
125  // due to node movement, it is
126  // possible to receive a packet that is not slightly "within range" that was
127  // transmitted at the time when the nodes were slightly "out of range"
128  // thus, prevent overflow of PDR > 100%
129  if (pdr > 1.0)
130  {
131  pdr = 1.0;
132  }
133  }
134 
135  return pdr;
136 }
137 
138 double
140 {
141  double pdr = 0.0;
142 
143  if (m_waveTotalPktExpectedReceiveCounts[index - 1] > 0)
144  {
145  pdr = (double) m_waveTotalPktInCoverageReceiveCounts[index - 1] / (double) m_waveTotalPktExpectedReceiveCounts[index - 1];
146  // due to node movement, it is
147  // possible to receive a packet that is not slightly "within range" that was
148  // transmitted at the time when the nodes were slightly "out of range"
149  // thus, prevent overflow of PDR > 100%
150  if (pdr > 1.0)
151  {
152  pdr = 1.0;
153  }
154  }
155 
156  return pdr;
157 }
158 
159 void
161 {
162  m_log = log;
163 }
164 
165 int
167 {
168  return m_log;
169 }
170 
171 void
173 {
174  m_wavePktExpectedReceiveCounts[index - 1] = count;
175 }
176 
177 void
179 {
180  m_wavePktInCoverageReceiveCounts[index - 1] = count;
181 }
182 
183 void
185 {
188 }
189 
190 } // 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.
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...
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
std::vector< int > m_wavePktInCoverageReceiveCounts
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.
std::vector< int > m_wavePktExpectedReceiveCounts
std::vector< int > m_waveTotalPktExpectedReceiveCounts
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...