Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(571)

Unified Diff: src/wave/helper/wave-bsm-stats.cc

Issue 103470050: new WAVE example VANET routing compare
Patch Set: additional code review changes Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wave/helper/wave-bsm-stats.h ('k') | src/wave/wscript » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wave/helper/wave-bsm-stats.cc
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/wave/helper/wave-bsm-stats.cc
@@ -0,0 +1,139 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014 North Carolina State University
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Scott E. Carpenter <scarpen@ncsu.edu>
+ *
+ */
+
+
+#include "ns3/wave-bsm-stats.h"
+#include "ns3/integer.h"
+#include "ns3/log.h"
+
+namespace ns3 {
+
+NS_LOG_COMPONENT_DEFINE ("WaveBsmStats");
+
+WaveBsmStats::WaveBsmStats ()
+ : m_wavePktSendCount (0),
+ m_waveByteSendCount (0),
+ m_wavePktReceiveCount (0),
+ m_log (0)
+{
+ m_wavePktExpectedReceiveCounts.resize (10, 0);
+ m_wavePktExpectedReceiveCounts.resize (10, 0);
+ m_wavePktInCoverageReceiveCounts.resize (10, 0);
+}
+
+void
+WaveBsmStats::IncTxPktCount ()
+{
+ m_wavePktSendCount++;
+}
+
+int
+WaveBsmStats::GetTxPktCount ()
+{
+ return m_wavePktSendCount;
+}
+
+void
+WaveBsmStats::IncExpectedRxPktCount (int index)
+{
+ m_wavePktExpectedReceiveCounts[index - 1]++;
+}
+
+void
+WaveBsmStats::IncRxPktCount ()
+{
+ m_wavePktReceiveCount++;
+}
+
+void
+WaveBsmStats::IncRxPktInRangeCount (int index)
+{
+ m_wavePktInCoverageReceiveCounts[index - 1]++;
+}
+
+int
+WaveBsmStats::GetRxPktCount ()
+{
+ return m_wavePktReceiveCount;
+}
+
+int
+WaveBsmStats::GetExpectedRxPktCount (int index)
+{
+ return m_wavePktExpectedReceiveCounts[index - 1];
+}
+
+int
+WaveBsmStats::GetRxPktInRangeCount (int index)
+{
+ return m_wavePktInCoverageReceiveCounts[index - 1];
+}
+
+void
+WaveBsmStats::SetTxPktCount (int count)
+{
+ m_wavePktSendCount = count;
+}
+
+void
+WaveBsmStats::SetRxPktCount (int count)
+{
+ m_wavePktReceiveCount = count;
+}
+
+void
+WaveBsmStats::IncTxByteCount (int bytes)
+{
+ m_waveByteSendCount += bytes;
+}
+
+int
+WaveBsmStats::GetTxByteCount ()
+{
+ return m_waveByteSendCount;
+}
+
+double
+WaveBsmStats::GetBsmPdr (int index)
+{
+ double pdr = 0.0;
+
+ if (m_wavePktExpectedReceiveCounts[index - 1] > 0)
+ {
+ pdr = (double) m_wavePktInCoverageReceiveCounts[index - 1] / (double) m_wavePktExpectedReceiveCounts[index - 1];
+ }
+
+ return pdr;
+}
+
+void
+WaveBsmStats::SetLogging (int log)
+{
+ m_log = log;
+}
+
+int
+WaveBsmStats::GetLogging ()
+{
+ return m_log;
+}
+
+} // namespace ns3
« no previous file with comments | « src/wave/helper/wave-bsm-stats.h ('k') | src/wave/wscript » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b