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-2020, 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  virtual ssize_t
113  getEffectiveMtu() const;
114 
115 public: // upper interface to be used by forwarding
119  void
120  sendInterest(const Interest& interest);
121 
125  void
126  sendData(const Data& data);
127 
131  void
132  sendNack(const ndn::lp::Nack& nack);
133 
137 
141 
145 
149 
153 
157 
161 
162 public: // lower interface to be invoked by Transport
165  void
166  receivePacket(const Block& packet, const EndpointId& endpoint);
167 
168 protected: // upper interface to be invoked in subclass (receive path termination)
171  void
172  receiveInterest(const Interest& interest, const EndpointId& endpoint);
173 
176  void
177  receiveData(const Data& data, const EndpointId& endpoint);
178 
181  void
182  receiveNack(const lp::Nack& nack, const EndpointId& endpoint);
183 
184 protected: // lower interface to be invoked in subclass (send path termination)
187  void
188  sendPacket(const Block& packet);
189 
190 protected:
191  void
192  notifyDroppedInterest(const Interest& packet);
193 
194 private: // upper interface to be overridden in subclass (send path entrypoint)
197  virtual void
198  doSendInterest(const Interest& interest) = 0;
199 
202  virtual void
203  doSendData(const Data& data) = 0;
204 
207  virtual void
208  doSendNack(const lp::Nack& nack) = 0;
209 
210 private: // lower interface to be overridden in subclass
211  virtual void
212  doReceivePacket(const Block& packet, const EndpointId& endpoint) = 0;
213 
214 private:
215  Face* m_face;
216  Transport* m_transport;
217 };
218 
219 inline const Face*
221 {
222  return m_face;
223 }
224 
225 inline const Transport*
227 {
228  return m_transport;
229 }
230 
231 inline Transport*
233 {
234  return m_transport;
235 }
236 
237 inline const LinkService::Counters&
239 {
240  return *this;
241 }
242 
243 inline ssize_t
245 {
246  return m_transport->getMtu();
247 }
248 
249 inline void
250 LinkService::receivePacket(const Block& packet, const EndpointId& endpoint)
251 {
252  doReceivePacket(packet, endpoint);
253 }
254 
255 inline void
257 {
258  m_transport->send(packet);
259 }
260 
261 std::ostream&
262 operator<<(std::ostream& os, const FaceLogHelper<LinkService>& flh);
263 
264 template<typename T>
266  !std::is_same<LinkService, T>::value, std::ostream&>::type
267 operator<<(std::ostream& os, const FaceLogHelper<T>& flh)
268 {
269  return os << FaceLogHelper<LinkService>(flh.obj);
270 }
271 
272 } // namespace face
273 } // namespace nfd
274 
275 #endif // NFD_DAEMON_FACE_LINK_SERVICE_HPP
virtual ssize_t getEffectiveMtu() const
the upper part of a Face
PacketCounter nOutData
count of outgoing Data packets
PacketCounter nInInterests
count of incoming Interests
void receivePacket(const Block &packet, const EndpointId &endpoint)
performs LinkService specific operations to receive a lower-layer packet
const Transport * getTransport() const
const Face * getFace() const
PacketCounter nInterestsExceededRetx
count of Interests dropped by reliability system for exceeding allowed number of retx ...
PacketCounter nInNacks
count of incoming Nacks
Represents a TLV element of the NDN packet format.
Definition: block.hpp:44
Represents an Interest packet.
Definition: interest.hpp:48
represents a counter of number of packets
Definition: counter.hpp:66
provides a lightweight signal / event system
Definition: signal.hpp:52
uint64_t EndpointId
Identifies a remote endpoint on the link.
Definition: face-common.hpp:71
signal::Signal< LinkService, lp::Nack, EndpointId > afterReceiveNack
signals on Nack received
signal::Signal< LinkService, Interest > onDroppedInterest
signals on Interest dropped by reliability system for exceeding allowed number of retx ...
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
counters provided by LinkService
signal::Signal< LinkService, Interest, EndpointId > afterReceiveInterest
signals on Interest received
PacketCounter nOutInterests
count of outgoing Interests
LinkServiceCounters Counters
counters provided by LinkService
signal::Signal< LinkService, Interest > afterSendInterest
signals on Interest sent
signal::Signal< LinkService, Data, EndpointId > afterReceiveData
signals on Data received
PacketCounter nInData
count of incoming Data packets
virtual const Counters & getCounters() const
PacketCounter nOutNacks
count of outgoing Nacks
void sendPacket(const Block &packet)
send a lower-layer packet via Transport
Represents a Data packet.
Definition: data.hpp:37
The lower half of a Face.
Definition: transport.hpp:108
signal::Signal< LinkService, lp::Nack > afterSendNack
signals on Nack sent
signal::Signal< LinkService, Data > afterSendData
signals on Data sent