NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
face.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014-2019, 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.
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_HPP
27 #define NFD_DAEMON_FACE_FACE_HPP
28 
29 #include "face-common.hpp"
30 #include "face-counters.hpp"
31 #include "link-service.hpp"
32 #include "transport.hpp"
33 
34 namespace nfd {
35 namespace face {
36 
40 
52 class Face FINAL_UNLESS_WITH_TESTS : public std::enable_shared_from_this<Face>, noncopyable
53 {
54 public:
55  Face(unique_ptr<LinkService> service, unique_ptr<Transport> transport);
56 
58  getLinkService() const;
59 
60  Transport*
61  getTransport() const;
62 
63 public: // upper interface connected to forwarding
66  void
67  sendInterest(const Interest& interest, const EndpointId& endpointId);
68 
71  void
72  sendData(const Data& data, const EndpointId& endpointId);
73 
76  void
77  sendNack(const lp::Nack& nack, const EndpointId& endpointId);
78 
82 
86 
90 
94 
95 public: // static properties
98  FaceId
99  getId() const;
100 
104  void
105  setId(FaceId id);
106 
107  void
108  setMetric(uint64_t metric);
109 
110  uint64_t
111  getMetric() const;
112 
115  FaceUri
116  getLocalUri() const;
117 
120  FaceUri
121  getRemoteUri() const;
122 
126  getScope() const;
127 
131  getPersistency() const;
132 
135  void
137 
141  getLinkType() const;
142 
143 public: // dynamic properties
146  FaceState
147  getState() const;
148 
152 
157  getExpirationTime() const;
158 
169  void
170  close();
171 
172  const FaceCounters&
173  getCounters() const;
174 
175 private:
176  FaceId m_id;
177  unique_ptr<LinkService> m_service;
178  unique_ptr<Transport> m_transport;
179  FaceCounters m_counters;
180  uint64_t m_metric;
181 };
182 
183 inline LinkService*
185 {
186  return m_service.get();
187 }
188 
189 inline Transport*
191 {
192  return m_transport.get();
193 }
194 
195 inline void
196 Face::sendInterest(const Interest& interest, const EndpointId& endpointId)
197 {
198  m_service->sendInterest(interest, endpointId);
199 }
200 
201 inline void
202 Face::sendData(const Data& data, const EndpointId& endpointId)
203 {
204  m_service->sendData(data, endpointId);
205 }
206 
207 inline void
208 Face::sendNack(const lp::Nack& nack, const EndpointId& endpointId)
209 {
210  m_service->sendNack(nack, endpointId);
211 }
212 
213 inline FaceId
214 Face::getId() const
215 {
216  return m_id;
217 }
218 
219 inline void
221 {
222  m_id = id;
223 }
224 
225 inline void
226 Face::setMetric(uint64_t metric)
227 {
228  m_metric = metric;
229 }
230 
231 inline uint64_t
233 {
234  return m_metric;
235 }
236 
237 inline FaceUri
239 {
240  return m_transport->getLocalUri();
241 }
242 
243 inline FaceUri
245 {
246  return m_transport->getRemoteUri();
247 }
248 
249 inline ndn::nfd::FaceScope
251 {
252  return m_transport->getScope();
253 }
254 
257 {
258  return m_transport->getPersistency();
259 }
260 
261 inline void
263 {
264  return m_transport->setPersistency(persistency);
265 }
266 
267 inline ndn::nfd::LinkType
269 {
270  return m_transport->getLinkType();
271 }
272 
273 inline FaceState
275 {
276  return m_transport->getState();
277 }
278 
281 {
282  return m_transport->getExpirationTime();
283 }
284 
285 inline void
287 {
288  m_transport->close();
289 }
290 
291 inline const FaceCounters&
293 {
294  return m_counters;
295 }
296 
297 std::ostream&
298 operator<<(std::ostream& os, const FaceLogHelper<Face>& flh);
299 
300 } // namespace face
301 
302 using face::Face;
303 
304 } // namespace nfd
305 
306 #endif // NFD_DAEMON_FACE_FACE_HPP
nfd::face::TransportState
TransportState
Indicates the state of a transport.
Definition: transport.hpp:37
nfd::face::Face::getCounters
const FaceCounters & getCounters() const
Definition: face.hpp:292
nfd::face::Face::getMetric
uint64_t getMetric() const
Definition: face.hpp:232
nfd::face::Face::afterReceiveNack
signal::Signal< LinkService, lp::Nack, EndpointId > & afterReceiveNack
signals on Nack received
Definition: face.hpp:89
nfd::face::Face::getTransport
Transport * getTransport() const
Definition: face.hpp:190
ndn::FaceUri
represents the underlying protocol and address used by a Face
Definition: face-uri.hpp:45
nfd::face::FaceState
TransportState FaceState
indicates the state of a face
Definition: face.hpp:39
nfd::face::Face::sendNack
void sendNack(const lp::Nack &nack, const EndpointId &endpointId)
send Nack to endpointId
Definition: face.hpp:208
nfd::face::Face::afterReceiveInterest
signal::Signal< LinkService, Interest, EndpointId > & afterReceiveInterest
signals on Interest received
Definition: face.hpp:81
ndn::nfd::LinkType
LinkType
Definition: nfd-constants.hpp:57
face-common.hpp
transport.hpp
nfd::face::FaceCounters
gives access to counters provided by Face
Definition: face-counters.hpp:43
face-counters.hpp
nfd::face::Face::onDroppedInterest
signal::Signal< LinkService, Interest > & onDroppedInterest
signals on Interest dropped by reliability system for exceeding allowed number of retx
Definition: face.hpp:93
nfd::face::Face::getLocalUri
FaceUri getLocalUri() const
Definition: face.hpp:238
ndn::nfd::FacePersistency
FacePersistency
Definition: nfd-constants.hpp:45
ndn::util::signal::Signal
provides a lightweight signal / event system
Definition: signal.hpp:52
nfd::face::operator<<
std::ostream & operator<<(std::ostream &os, const Face &face)
Definition: ndn-common.hpp:87
nfd::face::Face::close
void close()
request the face to be closed
Definition: face.hpp:286
nfd::face::Face::sendData
void sendData(const Data &data, const EndpointId &endpointId)
send Data to endpointId
Definition: face.hpp:202
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
nfd::face::LinkService
the upper part of a Face
Definition: link-service.hpp:76
nfd::face::Face::getRemoteUri
FaceUri getRemoteUri() const
Definition: face.hpp:244
nfd::face::Face::getPersistency
ndn::nfd::FacePersistency getPersistency() const
Definition: face.hpp:256
nfd::face::Face::setId
void setId(FaceId id)
sets face ID
Definition: face.hpp:220
nfd::face::Face::getExpirationTime
time::steady_clock::TimePoint getExpirationTime() const
Definition: face.hpp:280
nfd::face::FaceId
uint64_t FaceId
Identifies a face.
Definition: face-common.hpp:44
nfd::face::Face
generalization of a network interface
Definition: face.hpp:53
nfd::face::Face::afterStateChange
signal::Signal< Transport, FaceState, FaceState > & afterStateChange
signals after face state changed
Definition: face.hpp:151
nfd::face::Face::getState
FaceState getState() const
Definition: face.hpp:274
nfd::face::Face::getLinkService
LinkService * getLinkService() const
Definition: face.hpp:184
nfd::face::Face::Face
Face(unique_ptr< LinkService > service, unique_ptr< Transport > transport)
Definition: face.cpp:31
ndn::Interest
Represents an Interest packet.
Definition: interest.hpp:44
nfd::face::Face::getId
FaceId getId() const
Definition: face.hpp:214
ndn::Data
Represents a Data packet.
Definition: data.hpp:36
nfd::face::Transport
Transport
Definition: transport.cpp:32
ndn::time::steady_clock::TimePoint
time_point TimePoint
Definition: time.hpp:225
Face
ndn Face
Definition: face-impl.hpp:41
nfd::face::Face::getScope
ndn::nfd::FaceScope getScope() const
Definition: face.hpp:250
ndn::lp::Nack
represents a Network Nack
Definition: nack.hpp:39
nfd::face::Face::setPersistency
void setPersistency(ndn::nfd::FacePersistency persistency)
changes face persistency setting
Definition: face.hpp:262
nfd::face::Face::sendInterest
void sendInterest(const Interest &interest, const EndpointId &endpointId)
send Interest to endpointId
Definition: face.hpp:196
nfd::face::Face::getLinkType
ndn::nfd::LinkType getLinkType() const
Definition: face.hpp:268
nfd::face::EndpointId
uint64_t EndpointId
Identifies a remote endpoint on the link.
Definition: face-common.hpp:65
nfd::face::Face::afterReceiveData
signal::Signal< LinkService, Data, EndpointId > & afterReceiveData
signals on Data received
Definition: face.hpp:85
ndn::nfd::FaceScope
FaceScope
Definition: nfd-constants.hpp:34
nfd::face::Face::setMetric
void setMetric(uint64_t metric)
Definition: face.hpp:226
nfd::face::FaceLogHelper
For internal use by FaceLogging macros.
Definition: face-common.hpp:93
nfd::face::Transport
The lower half of a Face.
Definition: transport.hpp:109
FINAL_UNLESS_WITH_TESTS
#define FINAL_UNLESS_WITH_TESTS
Definition: common.hpp:44