LEFT | RIGHT |
(no file at all) | |
| 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 #ifndef WAVE_BSM_STATS_H |
| 23 #define WAVE_BSM_STATS_H |
| 24 |
| 25 #include "ns3/object.h" |
| 26 #include <vector> |
| 27 |
| 28 namespace ns3 { |
| 29 class WaveBsmStats : public Object |
| 30 /** |
| 31 * \ingroup wave |
| 32 * \brief The WaveBsmStats class implements a stats collector for· |
| 33 * IEEE 1609 WAVE (Wireless Access in Vehicular Environments)· |
| 34 * Basic Safety Messages (BSMs). The BSM is a ~200-byte packet that is· |
| 35 * generally broadcast from every vehicle at a nominal rate of 10 Hz.· |
| 36 */ |
| 37 /* |
| 38 * Note: This class collects data elements and accessors |
| 39 * along with methods that calculate metrics from the data· |
| 40 * elements. The data and metrics calculation algorithms |
| 41 * are collected together here purely to keep them together. |
| 42 * Future work may need to add additional metric calculations, |
| 43 * and for now, we are trying to keep all related data and· |
| 44 * algorithms together, although these could easily be |
| 45 * refactored in the future and moved to separate classes. |
| 46 * However, it seems that for now, moving the data elements |
| 47 * or the algorithms separately into different classes could |
| 48 * lead to confusion over usage. |
| 49 */ |
| 50 { |
| 51 public: |
| 52 /** |
| 53 * \brief Constructor |
| 54 * \return none |
| 55 */ |
| 56 WaveBsmStats (); |
| 57 |
| 58 /** |
| 59 * \brief Increments the count of transmitted packets |
| 60 * \return none |
| 61 */ |
| 62 void IncTxPktCount (); |
| 63 |
| 64 /** |
| 65 * \brief Returns the count of transmitted packets |
| 66 * \return count of packets transmitted |
| 67 */ |
| 68 int GetTxPktCount (); |
| 69 |
| 70 /*· |
| 71 * Note: |
| 72 * The WAVE Basic Safety Message (BSM) is broadcast and |
| 73 * unacknowledged. In order to calculate packet delivery |
| 74 * ratio (PDR), we must count i) the packets that are· |
| 75 * actually received and ii) the transmitted packets that· |
| 76 * are expected to be received. Both are relative to a· |
| 77 * specified (circular) coverage area. |
| 78 * |
| 79 * For example: Say we have three nodes, A, B, and C, each |
| 80 * separated by 40m, as follows: |
| 81 * |
| 82 * A --<40m>-- B --<40m>-- C |
| 83 * |
| 84 * Let's assume that the transmission range is 50m, and only |
| 85 * A is transmitting (i.e. broadcasting). B can receive A's· |
| 86 * broadcasts, while C cannot. Let's assume no dropped packets. |
| 87 * If we set the coverage area to 100m, then the PDR is 50%,· |
| 88 * because B receives every transmission from A, while C receives |
| 89 * none of them. However, if we change the effective |
| 90 * coverage area to 75m then the PDR improves to 100%, because |
| 91 * B receives 100% of A's transmissions, and C is outside of the |
| 92 * coverage area, and so does not factor in to the PDR. |
| 93 */ |
| 94 |
| 95 /** |
| 96 * \brief Increments the count of (broadcast) packets expected· |
| 97 * to be received within the coverage area1. Broadcast packets· |
| 98 * (i.e. WAVE Basic Safety Messages) are not ACK'd. For packet |
| 99 * delivery ratio (PDR), we need to count transmitted packets that |
| 100 * are expected to be received within the coverage area, even |
| 101 * though they may not be physically received (due to collisions· |
| 102 * or receiver power thresholds). |
| 103 * \return none |
| 104 */ |
| 105 void IncExpectedRxPktCount (int index); |
| 106 |
| 107 /** |
| 108 * \brief Increments the count of actual packets received |
| 109 * (regardless of coverage area). |
| 110 * \return none |
| 111 */ |
| 112 void IncRxPktCount (); |
| 113 |
| 114 /** |
| 115 * \brief Increments the count of actual packets received within |
| 116 * the coverage area(index). Broadcast packets· |
| 117 * (i.e. WAVE Basic Safety Messages) are not ACK'd. For packet |
| 118 * delivery ratio (PDR), we need to count only those received packets |
| 119 * that are actually received within the (circular) coverage area.· |
| 120 * \return none |
| 121 */ |
| 122 void IncRxPktInRangeCount (int index); |
| 123 |
| 124 /** |
| 125 * \brief Returns the count of packets received |
| 126 * \return the count of packets received |
| 127 */ |
| 128 int GetRxPktCount (); |
| 129 |
| 130 /** |
| 131 * \brief Returns the count of expected packets received within range(index) |
| 132 * \return the count of expected packets received within range(index) |
| 133 */ |
| 134 int GetExpectedRxPktCount (int index); |
| 135 |
| 136 /** |
| 137 * \brief Increments the count of actual packets recevied within range(index) |
| 138 * \return the count of actual packets received within range(index) |
| 139 */ |
| 140 int GetRxPktInRangeCount (int index); |
| 141 |
| 142 /** |
| 143 * \brief Sets the count of packets transmitted |
| 144 * \param count the count of packets transmitted |
| 145 * \return none |
| 146 */ |
| 147 void SetTxPktCount (int count); |
| 148 |
| 149 /** |
| 150 * \brief Sets the count of packets received |
| 151 * \param count the count of packets received |
| 152 * \return none |
| 153 */ |
| 154 void SetRxPktCount (int count); |
| 155 |
| 156 /** |
| 157 * \brief Increments the count of (application data) bytes transmitted |
| 158 * not including MAC/PHY overhead |
| 159 * \param bytes the bytes of application-data transmitted |
| 160 * \return none |
| 161 */ |
| 162 void IncTxByteCount (int bytes); |
| 163 |
| 164 /** |
| 165 * \brief Returns the count of (application data) bytes transmitted |
| 166 * not include MAC/PHY overhead |
| 167 * \return number of bytes of application-data transmitted |
| 168 */ |
| 169 int GetTxByteCount (); |
| 170 |
| 171 /** |
| 172 * \brief Returns the BSM Packet Delivery Ratio (PDR) |
| 173 * which is the percent of expected packets within range(index) that· |
| 174 * are actually received |
| 175 * \return the packet delivery ratio (PDR) of BSMs. |
| 176 */ |
| 177 double GetBsmPdr (int index); |
| 178 |
| 179 /** |
| 180 * \brief Enables/disables logging |
| 181 * \return none |
| 182 */ |
| 183 void SetLogging (int log); |
| 184 |
| 185 /** |
| 186 * \brief Gets logging state |
| 187 * \return logging state |
| 188 */ |
| 189 int GetLogging (); |
| 190 |
| 191 private: |
| 192 int m_wavePktSendCount; |
| 193 int m_waveByteSendCount; |
| 194 int m_wavePktReceiveCount; |
| 195 std::vector <int> m_wavePktInCoverageReceiveCounts; |
| 196 std::vector <int> m_wavePktExpectedReceiveCounts; |
| 197 int m_log; |
| 198 }; |
| 199 |
| 200 } // namespace ns3 |
| 201 |
| 202 #endif /* WAVE_BSM_STATS_H*/ |
LEFT | RIGHT |