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-2018, 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-counters.hpp"
30 #include "face-log.hpp"
31 #include "link-service.hpp"
32 #include "transport.hpp"
33 
34 namespace nfd {
35 namespace face {
36 
39 typedef uint64_t FaceId;
40 
48 const FaceId FACEID_NULL = 255;
51 
55 
67 class Face
68 #ifndef WITH_TESTS
69 final
70 #endif
71  : public std::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 
113 
114 public: // static properties
117  FaceId
118  getId() const;
119 
123  void
124  setId(FaceId id);
125 
126  void
127  setMetric(uint64_t metric);
128 
129  uint64_t
130  getMetric() const;
131 
134  FaceUri
135  getLocalUri() const;
136 
139  FaceUri
140  getRemoteUri() const;
141 
145  getScope() const;
146 
150  getPersistency() const;
151 
154  void
156 
160  getLinkType() const;
161 
162 public: // dynamic properties
165  FaceState
166  getState() const;
167 
171 
176  getExpirationTime() const;
177 
188  void
189  close();
190 
191  const FaceCounters&
192  getCounters() const;
193 
194 private:
195  FaceId m_id;
196  unique_ptr<LinkService> m_service;
197  unique_ptr<Transport> m_transport;
198  FaceCounters m_counters;
199  uint64_t m_metric;
200 };
201 
202 inline LinkService*
204 {
205  return m_service.get();
206 }
207 
208 inline Transport*
210 {
211  return m_transport.get();
212 }
213 
214 inline void
215 Face::sendInterest(const Interest& interest)
216 {
217  m_service->sendInterest(interest);
218 }
219 
220 inline void
221 Face::sendData(const Data& data)
222 {
223  m_service->sendData(data);
224 }
225 
226 inline void
228 {
229  m_service->sendNack(nack);
230 }
231 
232 inline FaceId
233 Face::getId() const
234 {
235  return m_id;
236 }
237 
238 inline void
240 {
241  m_id = id;
242 }
243 
244 inline void
245 Face::setMetric(uint64_t metric)
246 {
247  m_metric = metric;
248 }
249 
250 inline uint64_t
252 {
253  return m_metric;
254 }
255 
256 inline FaceUri
258 {
259  return m_transport->getLocalUri();
260 }
261 
262 inline FaceUri
264 {
265  return m_transport->getRemoteUri();
266 }
267 
268 inline ndn::nfd::FaceScope
270 {
271  return m_transport->getScope();
272 }
273 
276 {
277  return m_transport->getPersistency();
278 }
279 
280 inline void
282 {
283  return m_transport->setPersistency(persistency);
284 }
285 
286 inline ndn::nfd::LinkType
288 {
289  return m_transport->getLinkType();
290 }
291 
292 inline FaceState
294 {
295  return m_transport->getState();
296 }
297 
300 {
301  return m_transport->getExpirationTime();
302 }
303 
304 inline void
306 {
307  m_transport->close();
308 }
309 
310 inline const FaceCounters&
312 {
313  return m_counters;
314 }
315 
316 std::ostream&
317 operator<<(std::ostream& os, const FaceLogHelper<Face>& flh);
318 
319 } // namespace face
320 
321 using face::FaceId;
322 using face::Face;
323 
324 } // namespace nfd
325 
326 #endif // NFD_DAEMON_FACE_FACE_HPP
signal::Signal< LinkService, Interest > & onDroppedInterest
signals on Interest dropped by reliability system for exceeding allowed number of retx
Definition: face.hpp:112
time_point TimePoint
Definition: time.hpp:225
the upper part of a Face
generalization of a network interface
Definition: face.hpp:67
std::ostream & operator<<(std::ostream &os, const Face &face)
Definition: ndn-common.hpp:89
TransportState
indicates the state of a transport
Definition: transport.hpp:42
FaceState getState() const
Definition: face.hpp:293
const FaceId FACEID_INTERNAL_FACE
identifies the InternalFace used in management
Definition: face.hpp:44
Represents an Interest packet.
Definition: interest.hpp:44
Transport * getTransport() const
Definition: face.hpp:209
FaceUri getLocalUri() const
Definition: face.hpp:257
FaceUri getRemoteUri() const
Definition: face.hpp:263
LinkService * getLinkService() const
Definition: face.hpp:203
provides a lightweight signal / event system
Definition: signal.hpp:51
void sendInterest(const Interest &interest)
sends Interest on Face
Definition: face.hpp:215
represents a Network Nack
Definition: nack.hpp:38
void setPersistency(ndn::nfd::FacePersistency persistency)
changes face persistency setting
Definition: face.hpp:281
time::steady_clock::TimePoint getExpirationTime() const
Definition: face.hpp:299
ndn Face
Definition: face-impl.hpp:42
void sendData(const Data &data)
sends Data on Face
Definition: face.hpp:221
uint64_t getMetric() const
Definition: face.hpp:251
ndn::nfd::LinkType getLinkType() const
Definition: face.hpp:287
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:245
FaceId getId() const
Definition: face.hpp:233
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:269
signal::Signal< Transport, FaceState, FaceState > & afterStateChange
signals after face state changed
Definition: face.hpp:170
signal::Signal< LinkService, Interest > & afterReceiveInterest
signals on Interest received
Definition: face.hpp:100
represents the underlying protocol and address used by a Face
Definition: face-uri.hpp:44
Face(unique_ptr< LinkService > service, unique_ptr< Transport > transport)
Definition: face.cpp:31
void setId(FaceId id)
sets face ID
Definition: face.hpp:239
ndn::nfd::FacePersistency getPersistency() const
Definition: face.hpp:275
void sendNack(const lp::Nack &nack)
sends Nack on Face
Definition: face.hpp:227
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:305
for internal use by FaceLogging macros
Definition: face-log.hpp:43
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:35
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:113
const FaceId INVALID_FACEID
indicates an invalid FaceId
Definition: face.hpp:42
const FaceCounters & getCounters() const
Definition: face.hpp:311
gives access to counters provided by Face