Junxiao Shi | 33152f1 | 2014-07-16 19:54:32 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Eric Newberry | 41aba10 | 2017-11-01 16:42:13 -0700 | [diff] [blame] | 2 | /* |
Davide Pesavento | b7bfcb9 | 2022-05-22 23:55:23 -0400 | [diff] [blame] | 3 | * Copyright (c) 2014-2022, Regents of the University of California, |
Junxiao Shi | 57df288 | 2015-11-11 06:12:35 -0700 | [diff] [blame] | 4 | * Arizona Board of Regents, |
| 5 | * Colorado State University, |
| 6 | * University Pierre & Marie Curie, Sorbonne University, |
| 7 | * Washington University in St. Louis, |
| 8 | * Beijing Institute of Technology, |
| 9 | * The University of Memphis. |
Junxiao Shi | 33152f1 | 2014-07-16 19:54:32 -0700 | [diff] [blame] | 10 | * |
| 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). |
| 12 | * See AUTHORS.md for complete list of NFD authors and contributors. |
| 13 | * |
| 14 | * NFD is free software: you can redistribute it and/or modify it under the terms |
| 15 | * of the GNU General Public License as published by the Free Software Foundation, |
| 16 | * either version 3 of the License, or (at your option) any later version. |
| 17 | * |
| 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 20 | * PURPOSE. See the GNU General Public License for more details. |
| 21 | * |
| 22 | * You should have received a copy of the GNU General Public License along with |
| 23 | * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 24 | */ |
| 25 | |
| 26 | #ifndef NFD_DAEMON_FACE_FACE_COUNTERS_HPP |
| 27 | #define NFD_DAEMON_FACE_FACE_COUNTERS_HPP |
| 28 | |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 29 | #include "link-service.hpp" |
| 30 | #include "transport.hpp" |
Junxiao Shi | 33152f1 | 2014-07-16 19:54:32 -0700 | [diff] [blame] | 31 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame^] | 32 | namespace nfd::face { |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 33 | |
| 34 | /** \brief gives access to counters provided by Face |
| 35 | * |
| 36 | * This type is a facade that exposes common counters of a Face. |
| 37 | * |
| 38 | * get<T>() can be used to access extended counters provided by |
| 39 | * LinkService or Transport of the Face. |
Junxiao Shi | 33152f1 | 2014-07-16 19:54:32 -0700 | [diff] [blame] | 40 | */ |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 41 | class FaceCounters |
Junxiao Shi | 33152f1 | 2014-07-16 19:54:32 -0700 | [diff] [blame] | 42 | { |
| 43 | public: |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 44 | FaceCounters(const LinkService::Counters& linkServiceCounters, |
| 45 | const Transport::Counters& transportCounters); |
Junxiao Shi | 33152f1 | 2014-07-16 19:54:32 -0700 | [diff] [blame] | 46 | |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 47 | /** \return counters provided by LinkService |
| 48 | * \tparam T LinkService counters type |
| 49 | * \throw std::bad_cast counters type mismatch |
| 50 | */ |
| 51 | template<typename T> |
Davide Pesavento | b7bfcb9 | 2022-05-22 23:55:23 -0400 | [diff] [blame] | 52 | std::enable_if_t<std::is_base_of_v<LinkService::Counters, T>, const T&> |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 53 | get() const |
Junxiao Shi | 632a620 | 2014-07-20 01:14:30 -0700 | [diff] [blame] | 54 | { |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 55 | return dynamic_cast<const T&>(m_linkServiceCounters); |
Junxiao Shi | 632a620 | 2014-07-20 01:14:30 -0700 | [diff] [blame] | 56 | } |
| 57 | |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 58 | /** \return counters provided by Transport |
| 59 | * \tparam T Transport counters type |
| 60 | * \throw std::bad_cast counters type mismatch |
| 61 | */ |
| 62 | template<typename T> |
Davide Pesavento | b7bfcb9 | 2022-05-22 23:55:23 -0400 | [diff] [blame] | 63 | std::enable_if_t<std::is_base_of_v<Transport::Counters, T>, const T&> |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 64 | get() const |
| 65 | { |
| 66 | return dynamic_cast<const T&>(m_transportCounters); |
| 67 | } |
| 68 | |
| 69 | public: |
| 70 | const PacketCounter& nInInterests; |
| 71 | const PacketCounter& nOutInterests; |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 72 | const PacketCounter& nInterestsExceededRetx; |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 73 | const PacketCounter& nInData; |
| 74 | const PacketCounter& nOutData; |
| 75 | const PacketCounter& nInNacks; |
| 76 | const PacketCounter& nOutNacks; |
| 77 | |
| 78 | const PacketCounter& nInPackets; |
| 79 | const PacketCounter& nOutPackets; |
| 80 | const ByteCounter& nInBytes; |
| 81 | const ByteCounter& nOutBytes; |
| 82 | |
Eric Newberry | 9d283ad | 2020-04-12 23:37:17 -0700 | [diff] [blame] | 83 | /** \brief count of incoming Interests dropped due to HopLimit == 0 |
| 84 | */ |
| 85 | PacketCounter nInHopLimitZero; |
| 86 | |
| 87 | /** \brief count of outgoing Interests dropped due to HopLimit == 0 on non-local faces |
| 88 | */ |
| 89 | PacketCounter nOutHopLimitZero; |
| 90 | |
Junxiao Shi | 33152f1 | 2014-07-16 19:54:32 -0700 | [diff] [blame] | 91 | private: |
Junxiao Shi | da93f1f | 2015-11-11 06:13:16 -0700 | [diff] [blame] | 92 | const LinkService::Counters& m_linkServiceCounters; |
| 93 | const Transport::Counters& m_transportCounters; |
Junxiao Shi | 33152f1 | 2014-07-16 19:54:32 -0700 | [diff] [blame] | 94 | }; |
| 95 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame^] | 96 | } // namespace nfd::face |
Junxiao Shi | 33152f1 | 2014-07-16 19:54:32 -0700 | [diff] [blame] | 97 | |
| 98 | #endif // NFD_DAEMON_FACE_FACE_COUNTERS_HPP |