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-2021, 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 
37 class Channel;
38 
42 
54 class Face NFD_FINAL_UNLESS_WITH_TESTS : public std::enable_shared_from_this<Face>, noncopyable
55 {
56 public:
57  Face(unique_ptr<LinkService> service, unique_ptr<Transport> transport);
58 
60  getLinkService() const;
61 
62  Transport*
63  getTransport() const;
64 
74  void
75  close();
76 
77 public: // upper interface connected to forwarding
80  void
81  sendInterest(const Interest& interest);
82 
85  void
86  sendData(const Data& data);
87 
90  void
91  sendNack(const lp::Nack& nack);
92 
96 
100 
104 
108 
109 public: // properties
112  FaceId
113  getId() const;
114 
118  void
119  setId(FaceId id);
120 
121  void
122  setMetric(uint64_t metric);
123 
124  uint64_t
125  getMetric() const;
126 
129  FaceUri
130  getLocalUri() const;
131 
134  FaceUri
135  getRemoteUri() const;
136 
140  getScope() const;
141 
145  getPersistency() const;
146 
149  void
150  setPersistency(ndn::nfd::FacePersistency persistency);
151 
155  getLinkType() const;
156 
161  ssize_t
162  getMtu() const;
163 
166  FaceState
167  getState() const;
168 
171  signal::Signal<Transport, FaceState/*old*/, FaceState/*new*/>& afterStateChange;
172 
177  getExpirationTime() const;
178 
179  const FaceCounters&
180  getCounters() const
181  {
182  return m_counters;
183  }
184 
185  FaceCounters&
187  {
188  return m_counters;
189  }
190 
194  weak_ptr<Channel>
195  getChannel() const
196  {
197  return m_channel;
198  }
199 
203  void
204  setChannel(weak_ptr<Channel> channel)
205  {
206  m_channel = std::move(channel);
207  }
208 
209 private:
210  FaceId m_id;
211  unique_ptr<LinkService> m_service;
212  unique_ptr<Transport> m_transport;
213  FaceCounters m_counters;
214  weak_ptr<Channel> m_channel;
215  uint64_t m_metric;
216 };
217 
218 inline LinkService*
219 Face::getLinkService() const
220 {
221  return m_service.get();
222 }
223 
224 inline Transport*
225 Face::getTransport() const
226 {
227  return m_transport.get();
228 }
229 
230 inline void
231 Face::close()
232 {
233  m_transport->close();
234 }
235 
236 inline void
237 Face::sendInterest(const Interest& interest)
238 {
239  m_service->sendInterest(interest);
240 }
241 
242 inline void
243 Face::sendData(const Data& data)
244 {
245  m_service->sendData(data);
246 }
247 
248 inline void
249 Face::sendNack(const lp::Nack& nack)
250 {
251  m_service->sendNack(nack);
252 }
253 
254 inline FaceId
255 Face::getId() const
256 {
257  return m_id;
258 }
259 
260 inline void
261 Face::setId(FaceId id)
262 {
263  m_id = id;
264 }
265 
266 inline void
267 Face::setMetric(uint64_t metric)
268 {
269  m_metric = metric;
270 }
271 
272 inline uint64_t
273 Face::getMetric() const
274 {
275  return m_metric;
276 }
277 
278 inline FaceUri
279 Face::getLocalUri() const
280 {
281  return m_transport->getLocalUri();
282 }
283 
284 inline FaceUri
285 Face::getRemoteUri() const
286 {
287  return m_transport->getRemoteUri();
288 }
289 
290 inline ndn::nfd::FaceScope
291 Face::getScope() const
292 {
293  return m_transport->getScope();
294 }
295 
297 Face::getPersistency() const
298 {
299  return m_transport->getPersistency();
300 }
301 
302 inline void
303 Face::setPersistency(ndn::nfd::FacePersistency persistency)
304 {
305  return m_transport->setPersistency(persistency);
306 }
307 
308 inline ndn::nfd::LinkType
309 Face::getLinkType() const
310 {
311  return m_transport->getLinkType();
312 }
313 
314 inline ssize_t
315 Face::getMtu() const
316 {
317  return m_service->getEffectiveMtu();
318 }
319 
320 inline FaceState
321 Face::getState() const
322 {
323  return m_transport->getState();
324 }
325 
327 Face::getExpirationTime() const
328 {
329  return m_transport->getExpirationTime();
330 }
331 
332 std::ostream&
333 operator<<(std::ostream& os, const FaceLogHelper<Face>& flh);
334 
335 } // namespace face
336 
337 using face::Face;
338 
339 } // namespace nfd
340 
341 #endif // NFD_DAEMON_FACE_FACE_HPP
signal::Signal< LinkService, Data, EndpointId > & afterReceiveData
signals on Data received
Definition: face.hpp:99
weak_ptr< Channel > getChannel() const
Get channel on which face was created (unicast) or the associated channel (multicast) ...
Definition: face.hpp:195
the upper part of a Face
Represents a channel that listens on a local endpoint.
Definition: channel.hpp:41
TransportState
Indicates the state of a transport.
Definition: transport.hpp:37
signal::Signal< LinkService, Interest > & onDroppedInterest
signals on Interest dropped by reliability system for exceeding allowed number of retx ...
Definition: face.hpp:107
Represents an Interest packet.
Definition: interest.hpp:48
provides a lightweight signal / event system
Definition: signal.hpp:52
generalization of a network interface
Definition: face.hpp:54
represents a Network Nack
Definition: nack.hpp:38
ndn Face
Definition: face-impl.hpp:42
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:39
TransportState FaceState
indicates the state of a face
Definition: face.hpp:37
signal::Signal< LinkService, Interest, EndpointId > & afterReceiveInterest
signals on Interest received
Definition: face.hpp:95
void setChannel(weak_ptr< Channel > channel)
Set channel on which face was created (unicast) or the associated channel (multicast) ...
Definition: face.hpp:204
ndn::nfd::LinkType getLinkType(const std::string &ifName)
Obtain information about WiFi link type.
void close(T *e, websocketpp::connection_hdl hdl)
represents the underlying protocol and address used by a Face
Definition: face-uri.hpp:44
signal::Signal< LinkService, lp::Nack, EndpointId > & afterReceiveNack
signals on Nack received
Definition: face.hpp:103
signal::Signal< Transport, FaceState, FaceState > & afterStateChange
signals after face state changed
Definition: face.hpp:171
const FaceCounters & getCounters() const
Definition: face.hpp:180
Represents a Data packet.
Definition: data.hpp:37
uint64_t FaceId
Identifies a face.
Definition: face-common.hpp:44
The lower half of a Face.
Definition: transport.hpp:108
gives access to counters provided by Face
time_point TimePoint
Definition: time.hpp:233