blob: 90cf10600541405dfdae9af567a1ce008e7e4ec8 [file] [log] [blame]
Junxiao Shi33152f12014-07-16 19:54:32 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Junxiao Shi57df2882015-11-11 06:12:35 -07003 * Copyright (c) 2014-2015, Regents of the University of California,
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 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 Shi57df2882015-11-11 06:12:35 -070029#include "core/counter.hpp"
Junxiao Shi33152f12014-07-16 19:54:32 -070030
31namespace nfd {
32
Junxiao Shi33152f12014-07-16 19:54:32 -070033/** \brief contains network layer packet counters
34 */
35class NetworkLayerCounters : noncopyable
36{
37public:
38 /// incoming Interest
39 const PacketCounter&
40 getNInInterests() const
41 {
42 return m_nInInterests;
43 }
44
45 PacketCounter&
46 getNInInterests()
47 {
48 return m_nInInterests;
49 }
50
51 /// incoming Data
52 const PacketCounter&
53 getNInDatas() const
54 {
55 return m_nInDatas;
56 }
57
58 PacketCounter&
59 getNInDatas()
60 {
61 return m_nInDatas;
62 }
63
64 /// outgoing Interest
65 const PacketCounter&
66 getNOutInterests() const
67 {
68 return m_nOutInterests;
69 }
70
71 PacketCounter&
72 getNOutInterests()
73 {
74 return m_nOutInterests;
75 }
76
77 /// outgoing Data
78 const PacketCounter&
79 getNOutDatas() const
80 {
81 return m_nOutDatas;
82 }
83
84 PacketCounter&
85 getNOutDatas()
86 {
87 return m_nOutDatas;
88 }
89
Junxiao Shi632a6202014-07-20 01:14:30 -070090protected:
91 /** \brief copy current obseverations to a struct
92 * \param recipient an object with set methods for counters
93 */
94 template<typename R>
95 void
96 copyTo(R& recipient) const
97 {
98 recipient.setNInInterests(this->getNInInterests());
99 recipient.setNInDatas(this->getNInDatas());
100 recipient.setNOutInterests(this->getNOutInterests());
101 recipient.setNOutDatas(this->getNOutDatas());
102 }
103
Junxiao Shi33152f12014-07-16 19:54:32 -0700104private:
105 PacketCounter m_nInInterests;
106 PacketCounter m_nInDatas;
107 PacketCounter m_nOutInterests;
108 PacketCounter m_nOutDatas;
109};
110
Junxiao Shi33152f12014-07-16 19:54:32 -0700111/** \brief contains link layer byte counters
112 */
113class LinkLayerCounters : noncopyable
114{
115public:
116 /// received bytes
117 const ByteCounter&
118 getNInBytes() const
119 {
120 return m_nInBytes;
121 }
122
123 ByteCounter&
124 getNInBytes()
125 {
126 return m_nInBytes;
127 }
128
129 /// sent bytes
130 const ByteCounter&
131 getNOutBytes() const
132 {
133 return m_nOutBytes;
134 }
135
136 ByteCounter&
137 getNOutBytes()
138 {
139 return m_nOutBytes;
140 }
141
Junxiao Shi632a6202014-07-20 01:14:30 -0700142protected:
143 /** \brief copy current obseverations to a struct
144 * \param recipient an object with set methods for counters
145 */
146 template<typename R>
147 void
148 copyTo(R& recipient) const
149 {
150 recipient.setNInBytes(this->getNInBytes());
151 recipient.setNOutBytes(this->getNOutBytes());
152 }
153
Junxiao Shi33152f12014-07-16 19:54:32 -0700154private:
155 ByteCounter m_nInBytes;
156 ByteCounter m_nOutBytes;
157};
158
Junxiao Shi33152f12014-07-16 19:54:32 -0700159/** \brief contains counters on face
160 */
161class FaceCounters : public NetworkLayerCounters, public LinkLayerCounters
162{
Junxiao Shi632a6202014-07-20 01:14:30 -0700163public:
164 /** \brief copy current obseverations to a struct
165 * \param recipient an object with set methods for counters
166 */
167 template<typename R>
168 void
169 copyTo(R& recipient) const
170 {
171 this->NetworkLayerCounters::copyTo(recipient);
172 this->LinkLayerCounters::copyTo(recipient);
173 }
Junxiao Shi33152f12014-07-16 19:54:32 -0700174};
175
176} // namespace nfd
177
178#endif // NFD_DAEMON_FACE_FACE_COUNTERS_HPP