NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
link-service.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_LINK_SERVICE_HPP
27 #define NFD_DAEMON_FACE_LINK_SERVICE_HPP
28 
29 #include "face-common.hpp"
30 #include "transport.hpp"
31 #include "common/counter.hpp"
32 
33 namespace nfd {
34 namespace face {
35 
41 {
42 public:
46 
50 
54 
58 
62 
66 
70 };
71 
75 class LinkService : protected virtual LinkServiceCounters, noncopyable
76 {
77 public:
81 
82 public:
83  LinkService();
84 
85  virtual
86  ~LinkService();
87 
91  void
92  setFaceAndTransport(Face& face, Transport& transport);
93 
96  const Face*
97  getFace() const;
98 
101  const Transport*
102  getTransport() const;
103 
106  Transport*
107  getTransport();
108 
109  virtual const Counters&
110  getCounters() const;
111 
112 public: // upper interface to be used by forwarding
116  void
117  sendInterest(const Interest& interest, const EndpointId& endpoint);
118 
122  void
123  sendData(const Data& data, const EndpointId& endpoint);
124 
128  void
129  sendNack(const ndn::lp::Nack& nack, const EndpointId& endpoint);
130 
134 
138 
142 
146 
150 
154 
158 
159 public: // lower interface to be invoked by Transport
162  void
163  receivePacket(const Block& packet, const EndpointId& endpoint);
164 
165 protected: // upper interface to be invoked in subclass (receive path termination)
168  void
169  receiveInterest(const Interest& interest, const EndpointId& endpoint);
170 
173  void
174  receiveData(const Data& data, const EndpointId& endpoint);
175 
178  void
179  receiveNack(const lp::Nack& nack, const EndpointId& endpoint);
180 
181 protected: // lower interface to be invoked in subclass (send path termination)
184  void
185  sendPacket(const Block& packet, const EndpointId& endpoint);
186 
187 protected:
188  void
189  notifyDroppedInterest(const Interest& packet);
190 
191 private: // upper interface to be overridden in subclass (send path entrypoint)
194  virtual void
195  doSendInterest(const Interest& interest, const EndpointId& endpoint) = 0;
196 
199  virtual void
200  doSendData(const Data& data, const EndpointId& endpoint) = 0;
201 
204  virtual void
205  doSendNack(const lp::Nack& nack, const EndpointId& endpoint) = 0;
206 
207 private: // lower interface to be overridden in subclass
208  virtual void
209  doReceivePacket(const Block& packet, const EndpointId& endpoint) = 0;
210 
211 private:
212  Face* m_face;
213  Transport* m_transport;
214 };
215 
216 inline const Face*
218 {
219  return m_face;
220 }
221 
222 inline const Transport*
224 {
225  return m_transport;
226 }
227 
228 inline Transport*
230 {
231  return m_transport;
232 }
233 
234 inline const LinkService::Counters&
236 {
237  return *this;
238 }
239 
240 inline void
241 LinkService::receivePacket(const Block& packet, const EndpointId& endpoint)
242 {
243  doReceivePacket(packet, endpoint);
244 }
245 
246 inline void
247 LinkService::sendPacket(const Block& packet, const EndpointId& endpoint)
248 {
249  m_transport->send(packet, endpoint);
250 }
251 
252 std::ostream&
253 operator<<(std::ostream& os, const FaceLogHelper<LinkService>& flh);
254 
255 template<typename T>
256 typename std::enable_if<std::is_base_of<LinkService, T>::value &&
257  !std::is_same<LinkService, T>::value, std::ostream&>::type
258 operator<<(std::ostream& os, const FaceLogHelper<T>& flh)
259 {
260  return os << FaceLogHelper<LinkService>(flh.obj);
261 }
262 
263 } // namespace face
264 } // namespace nfd
265 
266 #endif // NFD_DAEMON_FACE_LINK_SERVICE_HPP
nfd::face::LinkService::~LinkService
virtual ~LinkService()
Definition: link-service.cpp:40
nfd::face::LinkService::LinkService
LinkService()
Definition: link-service.cpp:34
nfd::face::LinkService::receiveData
void receiveData(const Data &data, const EndpointId &endpoint)
delivers received Data to forwarding
Definition: link-service.cpp:104
nfd::face::LinkService::sendInterest
void sendInterest(const Interest &interest, const EndpointId &endpoint)
Send Interest to endpoint.
Definition: link-service.cpp:55
nfd::face::LinkService::setFaceAndTransport
void setFaceAndTransport(Face &face, Transport &transport)
set Face and Transport for LinkService
Definition: link-service.cpp:45
nfd::face::LinkServiceCounters::nDroppedInterests
PacketCounter nDroppedInterests
count of Interests dropped by reliability system for exceeding allowed number of retx
Definition: link-service.hpp:53
nfd::face::LinkService::afterReceiveData
signal::Signal< LinkService, Data, EndpointId > afterReceiveData
signals on Data received
Definition: link-service.hpp:137
nfd::face::LinkService::notifyDroppedInterest
void notifyDroppedInterest(const Interest &packet)
Definition: link-service.cpp:124
nfd::face::LinkServiceCounters::nInNacks
PacketCounter nInNacks
count of incoming Nacks
Definition: link-service.hpp:65
nfd::face::LinkServiceCounters
counters provided by LinkService
Definition: link-service.hpp:41
face-common.hpp
nfd::face::LinkService::receiveInterest
void receiveInterest(const Interest &interest, const EndpointId &endpoint)
delivers received Interest to forwarding
Definition: link-service.cpp:94
transport.hpp
nfd::face::LinkServiceCounters::nInInterests
PacketCounter nInInterests
count of incoming Interests
Definition: link-service.hpp:45
nfd::face::LinkService::getCounters
virtual const Counters & getCounters() const
Definition: link-service.hpp:235
ndn::util::signal::Signal
provides a lightweight signal / event system
Definition: signal.hpp:52
nfd::face::LinkService::sendData
void sendData(const Data &data, const EndpointId &endpoint)
Send Data to endpoint.
Definition: link-service.cpp:68
nfd::face::LinkService::afterSendData
signal::Signal< LinkService, Data > afterSendData
signals on Data sent
Definition: link-service.hpp:153
nfd::face::LinkServiceCounters::nOutNacks
PacketCounter nOutNacks
count of outgoing Nacks
Definition: link-service.hpp:69
nfd::face::operator<<
std::ostream & operator<<(std::ostream &os, const Face &face)
Definition: ndn-common.hpp:87
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
nfd::face::LinkService::afterSendInterest
signal::Signal< LinkService, Interest > afterSendInterest
signals on Interest sent
Definition: link-service.hpp:149
nfd::face::LinkService
the upper part of a Face
Definition: link-service.hpp:76
nfd::face::Face
generalization of a network interface
Definition: face.hpp:53
nfd::face::LinkService::getFace
const Face * getFace() const
Definition: link-service.hpp:217
nfd::face::LinkService::afterReceiveInterest
signal::Signal< LinkService, Interest, EndpointId > afterReceiveInterest
signals on Interest received
Definition: link-service.hpp:133
nfd::face::LinkService::onDroppedInterest
signal::Signal< LinkService, Interest > onDroppedInterest
signals on Interest dropped by reliability system for exceeding allowed number of retx
Definition: link-service.hpp:145
nfd::face::Transport::send
void send(const Block &packet, const EndpointId &endpoint=0)
Send a link-layer packet.
Definition: transport.cpp:94
nfd::face::LinkService::afterReceiveNack
signal::Signal< LinkService, lp::Nack, EndpointId > afterReceiveNack
signals on Nack received
Definition: link-service.hpp:141
counter.hpp
nfd::face::LinkService::getTransport
const Transport * getTransport() const
Definition: link-service.hpp:223
ndn::Interest
Represents an Interest packet.
Definition: interest.hpp:44
nfd::face::LinkService::sendNack
void sendNack(const ndn::lp::Nack &nack, const EndpointId &endpoint)
Send Nack to endpoint.
Definition: link-service.cpp:81
nfd::face::LinkService::afterSendNack
signal::Signal< LinkService, lp::Nack > afterSendNack
signals on Nack sent
Definition: link-service.hpp:157
ndn::Data
Represents a Data packet.
Definition: data.hpp:36
nfd::face::LinkServiceCounters::nInData
PacketCounter nInData
count of incoming Data packets
Definition: link-service.hpp:57
nfd::face::LinkServiceCounters::nOutData
PacketCounter nOutData
count of outgoing Data packets
Definition: link-service.hpp:61
nfd::PacketCounter
represents a counter of number of packets
Definition: counter.hpp:67
ndn::Block
Represents a TLV element of NDN packet format.
Definition: block.hpp:43
ndn::lp::Nack
represents a Network Nack
Definition: nack.hpp:39
nfd::face::LinkService::sendPacket
void sendPacket(const Block &packet, const EndpointId &endpoint)
send a lower-layer packet via Transport to endpoint
Definition: link-service.hpp:247
nfd::face::EndpointId
uint64_t EndpointId
Identifies a remote endpoint on the link.
Definition: face-common.hpp:65
nfd::face::LinkService::receivePacket
void receivePacket(const Block &packet, const EndpointId &endpoint)
performs LinkService specific operations to receive a lower-layer packet
Definition: link-service.hpp:241
nfd::face::LinkService::receiveNack
void receiveNack(const lp::Nack &nack, const EndpointId &endpoint)
delivers received Nack to forwarding
Definition: link-service.cpp:114
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
nfd::face::LinkService::Counters
LinkServiceCounters Counters
counters provided by LinkService
Definition: link-service.hpp:80
nfd::face::LinkServiceCounters::nOutInterests
PacketCounter nOutInterests
count of outgoing Interests
Definition: link-service.hpp:49
nfd::face::FaceLogHelper::obj
const T & obj
Definition: face-common.hpp:102