NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
face-status.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2021 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_CXX_MGMT_NFD_FACE_STATUS_HPP
23 #define NDN_CXX_MGMT_NFD_FACE_STATUS_HPP
24 
27 #include "ndn-cxx/util/time.hpp"
28 
29 namespace ndn {
30 namespace nfd {
31 
37 class FaceStatus : public FaceTraits<FaceStatus>
38 {
39 public:
40  FaceStatus();
41 
42  explicit
43  FaceStatus(const Block& block);
44 
47  template<encoding::Tag TAG>
48  size_t
49  wireEncode(EncodingImpl<TAG>& encoder) const;
50 
53  const Block&
54  wireEncode() const;
55 
58  void
59  wireDecode(const Block& wire);
60 
61 public: // getters & setters
62  bool
64  {
65  return !!m_expirationPeriod;
66  }
67 
70  {
71  BOOST_ASSERT(hasExpirationPeriod());
72  return *m_expirationPeriod;
73  }
74 
75  FaceStatus&
76  setExpirationPeriod(time::milliseconds expirationPeriod);
77 
78  FaceStatus&
80 
81  bool
83  {
84  return !!m_baseCongestionMarkingInterval;
85  }
86 
89  {
90  BOOST_ASSERT(hasBaseCongestionMarkingInterval());
91  return *m_baseCongestionMarkingInterval;
92  }
93 
94  FaceStatus&
96 
97  FaceStatus&
99 
100  bool
102  {
103  return !!m_defaultCongestionThreshold;
104  }
105 
108  uint64_t
110  {
111  BOOST_ASSERT(hasDefaultCongestionThreshold());
112  return *m_defaultCongestionThreshold;
113  }
114 
117  FaceStatus&
118  setDefaultCongestionThreshold(uint64_t threshold);
119 
120  FaceStatus&
122 
123  bool
124  hasMtu() const
125  {
126  return !!m_mtu;
127  }
128 
133  uint64_t
134  getMtu() const
135  {
136  BOOST_ASSERT(hasMtu());
137  return *m_mtu;
138  }
139 
144  FaceStatus&
145  setMtu(uint64_t mtu);
146 
147  FaceStatus&
148  unsetMtu();
149 
150  uint64_t
152  {
153  return m_nInInterests;
154  }
155 
156  FaceStatus&
157  setNInInterests(uint64_t nInInterests);
158 
159  uint64_t
160  getNInData() const
161  {
162  return m_nInData;
163  }
164 
165  FaceStatus&
166  setNInData(uint64_t nInData);
167 
168  uint64_t
169  getNInNacks() const
170  {
171  return m_nInNacks;
172  }
173 
174  FaceStatus&
175  setNInNacks(uint64_t nInNacks);
176 
177  uint64_t
179  {
180  return m_nOutInterests;
181  }
182 
183  FaceStatus&
184  setNOutInterests(uint64_t nOutInterests);
185 
186  uint64_t
187  getNOutData() const
188  {
189  return m_nOutData;
190  }
191 
192  FaceStatus&
193  setNOutData(uint64_t nOutData);
194 
195  uint64_t
196  getNOutNacks() const
197  {
198  return m_nOutNacks;
199  }
200 
201  FaceStatus&
202  setNOutNacks(uint64_t nOutNacks);
203 
204  uint64_t
205  getNInBytes() const
206  {
207  return m_nInBytes;
208  }
209 
210  FaceStatus&
211  setNInBytes(uint64_t nInBytes);
212 
213  uint64_t
214  getNOutBytes() const
215  {
216  return m_nOutBytes;
217  }
218 
219  FaceStatus&
220  setNOutBytes(uint64_t nOutBytes);
221 
222 private:
223  optional<time::milliseconds> m_expirationPeriod;
224  optional<time::nanoseconds> m_baseCongestionMarkingInterval;
225  optional<uint64_t> m_defaultCongestionThreshold;
226  optional<uint64_t> m_mtu;
227  uint64_t m_nInInterests;
228  uint64_t m_nInData;
229  uint64_t m_nInNacks;
230  uint64_t m_nOutInterests;
231  uint64_t m_nOutData;
232  uint64_t m_nOutNacks;
233  uint64_t m_nInBytes;
234  uint64_t m_nOutBytes;
235 };
236 
238 
239 bool
240 operator==(const FaceStatus& a, const FaceStatus& b);
241 
242 inline bool
243 operator!=(const FaceStatus& a, const FaceStatus& b)
244 {
245  return !(a == b);
246 }
247 
248 std::ostream&
249 operator<<(std::ostream& os, const FaceStatus& status);
250 
251 } // namespace nfd
252 } // namespace ndn
253 
254 #endif // NDN_CXX_MGMT_NFD_FACE_STATUS_HPP
void wireDecode(const Block &wire)
decode FaceStatus
uint64_t getNOutInterests() const
time::milliseconds getExpirationPeriod() const
Definition: face-status.hpp:69
Copyright (c) 2011-2015 Regents of the University of California.
bool operator!=(const ChannelStatus &a, const ChannelStatus &b)
bool hasExpirationPeriod() const
Definition: face-status.hpp:63
uint64_t getNOutNacks() const
bool hasBaseCongestionMarkingInterval() const
Definition: face-status.hpp:82
uint64_t getNOutBytes() const
uint64_t getNInInterests() const
FaceStatus & unsetDefaultCongestionThreshold()
Represents a TLV element of the NDN packet format.
Definition: block.hpp:44
FaceStatus & setNOutBytes(uint64_t nOutBytes)
FaceStatus & setNOutInterests(uint64_t nOutInterests)
uint64_t getNOutData() const
FaceStatus & setExpirationPeriod(time::milliseconds expirationPeriod)
FaceStatus & setNInInterests(uint64_t nInInterests)
uint64_t getNInBytes() const
FaceStatus & setNInBytes(uint64_t nInBytes)
FaceStatus & unsetBaseCongestionMarkingInterval()
FaceStatus & unsetExpirationPeriod()
FaceStatus & setNInNacks(uint64_t nInNacks)
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:39
FaceStatus & setNOutData(uint64_t nOutData)
bool operator==(const ChannelStatus &a, const ChannelStatus &b)
represents an item in NFD Face dataset
Definition: face-status.hpp:37
time::nanoseconds getBaseCongestionMarkingInterval() const
Definition: face-status.hpp:88
std::ostream & operator<<(std::ostream &os, FaceScope faceScope)
FaceStatus & setMtu(uint64_t mtu)
set MTU (measured in bytes)
uint64_t getDefaultCongestionThreshold() const
get default congestion threshold (measured in bytes)
FaceStatus & setBaseCongestionMarkingInterval(time::nanoseconds interval)
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(ChannelStatus)
uint64_t getNInData() const
FaceStatus & setNOutNacks(uint64_t nOutNacks)
provides getters and setters for face information fields
Definition: face-traits.hpp:37
uint64_t getMtu() const
get MTU (measured in bytes)
const Block & wireEncode() const
encode FaceStatus
Definition: face-status.cpp:96
FaceStatus & setNInData(uint64_t nInData)
FaceStatus & unsetMtu()
bool hasDefaultCongestionThreshold() const
boost::chrono::nanoseconds nanoseconds
Definition: time.hpp:50
FaceStatus & setDefaultCongestionThreshold(uint64_t threshold)
set default congestion threshold (measured in bytes)
uint64_t getNInNacks() const
boost::chrono::milliseconds milliseconds
Definition: time.hpp:48