blob: a3f85769c1f89cd4d986860f8901d864436584fd [file] [log] [blame]
Junxiao Shi33152f12014-07-16 19:54:32 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
Eric Newberry41aba102017-11-01 16:42:13 -07002/*
Davide Pesaventob7bfcb92022-05-22 23:55:23 -04003 * Copyright (c) 2014-2022, Regents of the University of California,
Junxiao Shi57df2882015-11-11 06:12:35 -07004 * 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 Shi33152f12014-07-16 19:54:32 -070010 *
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 Shida93f1f2015-11-11 06:13:16 -070029#include "link-service.hpp"
30#include "transport.hpp"
Junxiao Shi33152f12014-07-16 19:54:32 -070031
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040032namespace nfd::face {
Junxiao Shida93f1f2015-11-11 06:13:16 -070033
Davide Pesaventoaa9e3b22022-10-21 17:00:07 -040034/** \brief Gives access to counters provided by Face.
Junxiao Shida93f1f2015-11-11 06:13:16 -070035 *
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 Shi33152f12014-07-16 19:54:32 -070040 */
Junxiao Shida93f1f2015-11-11 06:13:16 -070041class FaceCounters
Junxiao Shi33152f12014-07-16 19:54:32 -070042{
43public:
Junxiao Shida93f1f2015-11-11 06:13:16 -070044 FaceCounters(const LinkService::Counters& linkServiceCounters,
45 const Transport::Counters& transportCounters);
Junxiao Shi33152f12014-07-16 19:54:32 -070046
Junxiao Shida93f1f2015-11-11 06:13:16 -070047 /** \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 Pesaventob7bfcb92022-05-22 23:55:23 -040052 std::enable_if_t<std::is_base_of_v<LinkService::Counters, T>, const T&>
Junxiao Shida93f1f2015-11-11 06:13:16 -070053 get() const
Junxiao Shi632a6202014-07-20 01:14:30 -070054 {
Junxiao Shida93f1f2015-11-11 06:13:16 -070055 return dynamic_cast<const T&>(m_linkServiceCounters);
Junxiao Shi632a6202014-07-20 01:14:30 -070056 }
57
Junxiao Shida93f1f2015-11-11 06:13:16 -070058 /** \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 Pesaventob7bfcb92022-05-22 23:55:23 -040063 std::enable_if_t<std::is_base_of_v<Transport::Counters, T>, const T&>
Junxiao Shida93f1f2015-11-11 06:13:16 -070064 get() const
65 {
66 return dynamic_cast<const T&>(m_transportCounters);
67 }
68
69public:
70 const PacketCounter& nInInterests;
71 const PacketCounter& nOutInterests;
Eric Newberry9d283ad2020-04-12 23:37:17 -070072 const PacketCounter& nInterestsExceededRetx;
Junxiao Shida93f1f2015-11-11 06:13:16 -070073 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
Davide Pesaventoaa9e3b22022-10-21 17:00:07 -040083 /** \brief Count of incoming Interests dropped due to HopLimit == 0.
Eric Newberry9d283ad2020-04-12 23:37:17 -070084 */
85 PacketCounter nInHopLimitZero;
86
Davide Pesaventoaa9e3b22022-10-21 17:00:07 -040087 /** \brief Count of outgoing Interests dropped due to HopLimit == 0 on non-local faces.
Eric Newberry9d283ad2020-04-12 23:37:17 -070088 */
89 PacketCounter nOutHopLimitZero;
90
Junxiao Shi33152f12014-07-16 19:54:32 -070091private:
Junxiao Shida93f1f2015-11-11 06:13:16 -070092 const LinkService::Counters& m_linkServiceCounters;
93 const Transport::Counters& m_transportCounters;
Junxiao Shi33152f12014-07-16 19:54:32 -070094};
95
Davide Pesaventoe422f9e2022-06-03 01:30:23 -040096} // namespace nfd::face
Junxiao Shi33152f12014-07-16 19:54:32 -070097
98#endif // NFD_DAEMON_FACE_FACE_COUNTERS_HPP