NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: 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; -*- */
26 #ifndef NFD_DAEMON_FACE_HPP
27 #define NFD_DAEMON_FACE_HPP
28 
29 #include "transport.hpp"
30 #include "link-service.hpp"
31 #include "face-counters.hpp"
32 #include "face-log.hpp"
33 
34 namespace nfd {
35 namespace face {
36 
39 typedef uint64_t FaceId;
40 
42 const FaceId INVALID_FACEID = 0;
44 const FaceId FACEID_INTERNAL_FACE = 1;
46 const FaceId FACEID_CONTENT_STORE = 254;
48 const FaceId FACEID_NULL = 255;
50 const FaceId FACEID_RESERVED_MAX = 255;
51 
55 
67 class Face
68 #ifndef WITH_TESTS
69 final
70 #endif
71  : public enable_shared_from_this<Face>, noncopyable
72 {
73 public:
74  Face(unique_ptr<LinkService> service, unique_ptr<Transport> transport);
75 
77  getLinkService() const;
78 
79  Transport*
80  getTransport() const;
81 
82 public: // upper interface connected to forwarding
85  void
86  sendInterest(const Interest& interest);
87 
90  void
91  sendData(const Data& data);
92 
95  void
96  sendNack(const lp::Nack& nack);
97 
101 
105 
109 
110 public: // static properties
113  FaceId
114  getId() const;
115 
119  void
120  setId(FaceId id);
121 
122  void
123  setMetric(uint64_t metric);
124 
125  uint64_t
126  getMetric() const;
127 
130  FaceUri
131  getLocalUri() const;
132 
135  FaceUri
136  getRemoteUri() const;
137 
141  getScope() const;
142 
146  getPersistency() const;
147 
150  void
152 
156  getLinkType() const;
157 
158 public: // dynamic properties
161  FaceState
162  getState() const;
163 
166  signal::Signal<Transport, FaceState/*old*/, FaceState/*new*/>& afterStateChange;
167 
172  getExpirationTime() const;
173 
184  void
185  close();
186 
187  const FaceCounters&
188  getCounters() const;
189 
190 private:
191  FaceId m_id;
192  unique_ptr<LinkService> m_service;
193  unique_ptr<Transport> m_transport;
194  FaceCounters m_counters;
195  uint64_t m_metric;
196 };
197 
198 inline LinkService*
200 {
201  return m_service.get();
202 }
203 
204 inline Transport*
206 {
207  return m_transport.get();
208 }
209 
210 inline void
211 Face::sendInterest(const Interest& interest)
212 {
213  m_service->sendInterest(interest);
214 }
215 
216 inline void
217 Face::sendData(const Data& data)
218 {
219  m_service->sendData(data);
220 }
221 
222 inline void
224 {
225  m_service->sendNack(nack);
226 }
227 
228 inline FaceId
229 Face::getId() const
230 {
231  return m_id;
232 }
233 
234 inline void
235 Face::setId(FaceId id)
236 {
237  m_id = id;
238 }
239 
240 inline void
241 Face::setMetric(uint64_t metric)
242 {
243  m_metric = metric;
244 }
245 
246 inline uint64_t
248 {
249  return m_metric;
250 }
251 
252 inline FaceUri
254 {
255  return m_transport->getLocalUri();
256 }
257 
258 inline FaceUri
260 {
261  return m_transport->getRemoteUri();
262 }
263 
264 inline ndn::nfd::FaceScope
266 {
267  return m_transport->getScope();
268 }
269 
272 {
273  return m_transport->getPersistency();
274 }
275 
276 inline void
278 {
279  return m_transport->setPersistency(persistency);
280 }
281 
282 inline ndn::nfd::LinkType
284 {
285  return m_transport->getLinkType();
286 }
287 
288 inline FaceState
290 {
291  return m_transport->getState();
292 }
293 
296 {
297  return m_transport->getExpirationTime();
298 }
299 
300 inline void
302 {
303  m_transport->close();
304 }
305 
306 inline const FaceCounters&
308 {
309  return m_counters;
310 }
311 
312 std::ostream&
313 operator<<(std::ostream& os, const FaceLogHelper<Face>& flh);
314 
315 template<typename T>
316 typename std::enable_if<std::is_base_of<Face, T>::value, std::ostream&>::type
317 operator<<(std::ostream& os, const FaceLogHelper<T>& flh)
318 {
319  return os << FaceLogHelper<Face>(flh.obj);
320 }
321 
322 } // namespace face
323 
324 using face::FaceId;
325 using face::Face;
326 
327 } // namespace nfd
328 
329 #endif // NFD_DAEMON_FACE_HPP
time_point TimePoint
Definition: time.hpp:120
the upper part of a Face
generalization of a network interface
Definition: face.hpp:67
TransportState
indicates the state of a transport
Definition: transport.hpp:41
represents the underlying protocol and address used by a Face
Definition: face-uri.hpp:44
FaceState getState() const
Definition: face.hpp:289
const FaceId FACEID_INTERNAL_FACE
identifies the InternalFace used in management
Definition: face.hpp:44
represents an Interest packet
Definition: interest.hpp:42
Transport * getTransport() const
Definition: face.hpp:205
FaceUri getLocalUri() const
Definition: face.hpp:253
FaceUri getRemoteUri() const
Definition: face.hpp:259
LinkService * getLinkService() const
Definition: face.hpp:199
provides a lightweight signal / event system
void sendInterest(const Interest &interest)
sends Interest on Face
Definition: face.hpp:211
represents a Network Nack
Definition: nack.hpp:40
void setPersistency(ndn::nfd::FacePersistency persistency)
changes face persistency setting
Definition: face.hpp:277
time::steady_clock::TimePoint getExpirationTime() const
Definition: face.hpp:295
void sendData(const Data &data)
sends Data on Face
Definition: face.hpp:217
uint64_t getMetric() const
Definition: face.hpp:247
ndn::nfd::LinkType getLinkType() const
Definition: face.hpp:283
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
TransportState FaceState
indicates the state of a face
Definition: face.hpp:54
void setMetric(uint64_t metric)
Definition: face.hpp:241
FaceId getId() const
Definition: face.hpp:229
signal::Signal< LinkService, Data > & afterReceiveData
signals on Data received
Definition: face.hpp:104
const FaceId FACEID_RESERVED_MAX
upper bound of reserved FaceIds
Definition: face.hpp:50
ndn::nfd::FaceScope getScope() const
Definition: face.hpp:265
signal::Signal< Transport, FaceState, FaceState > & afterStateChange
signals after face state changed
Definition: face.hpp:166
signal::Signal< LinkService, Interest > & afterReceiveInterest
signals on Interest received
Definition: face.hpp:100
Face(unique_ptr< LinkService > service, unique_ptr< Transport > transport)
Definition: face.cpp:31
void setId(FaceId id)
sets face ID
Definition: face.hpp:235
ndn::nfd::FacePersistency getPersistency() const
Definition: face.hpp:271
void sendNack(const lp::Nack &nack)
sends Nack on Face
Definition: face.hpp:223
signal::Signal< LinkService, lp::Nack > & afterReceiveNack
signals on Nack received
Definition: face.hpp:108
void close()
request the face to be closed
Definition: face.hpp:301
const FaceId FACEID_NULL
identifies the NullFace that drops every packet
Definition: face.hpp:48
uint64_t FaceId
identifies a face
Definition: face.hpp:39
represents a Data packet
Definition: data.hpp:37
const FaceId FACEID_CONTENT_STORE
identifies a packet comes from the ContentStore
Definition: face.hpp:46
the lower part of a Face
Definition: transport.hpp:104
const FaceId INVALID_FACEID
indicates an invalid FaceId
Definition: face.hpp:42
const FaceCounters & getCounters() const
Definition: face.hpp:307
gives access to counters provided by Face