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-2017, 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 "core/counter.hpp"
30 #include "face-log.hpp"
31 #include "transport.hpp"
32 
33 namespace nfd {
34 namespace face {
35 
36 class Face;
37 
43 {
44 public:
48 
52 
56 
60 
64 
68 
72 };
73 
77 class LinkService : protected virtual LinkServiceCounters, noncopyable
78 {
79 public:
83 
84 public:
85  LinkService();
86 
87  virtual
88  ~LinkService();
89 
93  void
94  setFaceAndTransport(Face& face, Transport& transport);
95 
98  const Face*
99  getFace() const;
100 
103  const Transport*
104  getTransport() const;
105 
108  Transport*
109  getTransport();
110 
111  virtual const Counters&
112  getCounters() const;
113 
114 public: // upper interface to be used by forwarding
118  void
119  sendInterest(const Interest& interest);
120 
124  void
125  sendData(const Data& data);
126 
130  void
131  sendNack(const ndn::lp::Nack& nack);
132 
136 
140 
144 
148 
152 
156 
160 
161 public: // lower interface to be invoked by Transport
164  void
166 
167 protected: // upper interface to be invoked in subclass (receive path termination)
170  void
171  receiveInterest(const Interest& interest);
172 
175  void
176  receiveData(const Data& data);
177 
180  void
181  receiveNack(const lp::Nack& nack);
182 
183 protected: // lower interface to be invoked in subclass (send path termination)
186  void
187  sendPacket(Transport::Packet&& packet);
188 
189 protected:
190  void
191  notifyDroppedInterest(const Interest& packet);
192 
193 private: // upper interface to be overridden in subclass (send path entrypoint)
196  virtual void
197  doSendInterest(const Interest& interest) = 0;
198 
201  virtual void
202  doSendData(const Data& data) = 0;
203 
206  virtual void
207  doSendNack(const lp::Nack& nack) = 0;
208 
209 private: // lower interface to be overridden in subclass
210  virtual void
211  doReceivePacket(Transport::Packet&& packet) = 0;
212 
213 private:
214  Face* m_face;
215  Transport* m_transport;
216 };
217 
218 inline const Face*
220 {
221  return m_face;
222 }
223 
224 inline const Transport*
226 {
227  return m_transport;
228 }
229 
230 inline Transport*
232 {
233  return m_transport;
234 }
235 
236 inline const LinkService::Counters&
238 {
239  return *this;
240 }
241 
242 inline void
244 {
245  doReceivePacket(std::move(packet));
246 }
247 
248 inline void
250 {
251  m_transport->send(std::move(packet));
252 }
253 
254 std::ostream&
255 operator<<(std::ostream& os, const FaceLogHelper<LinkService>& flh);
256 
257 template<typename T>
258 typename std::enable_if<std::is_base_of<LinkService, T>::value &&
259  !std::is_same<LinkService, T>::value, std::ostream&>::type
260 operator<<(std::ostream& os, const FaceLogHelper<T>& flh)
261 {
262  return os << FaceLogHelper<LinkService>(flh.obj);
263 }
264 
265 } // namespace face
266 } // namespace nfd
267 
268 #endif // NFD_DAEMON_FACE_LINK_SERVICE_HPP
signal::Signal< LinkService, Data > afterReceiveData
signals on Data received
void sendInterest(const Interest &interest)
send Interest
the upper part of a Face
PacketCounter nOutData
count of outgoing Data packets
void sendData(const Data &data)
send Data
PacketCounter nInInterests
count of incoming Interests
generalization of a network interface
Definition: face.hpp:67
void notifyDroppedInterest(const Interest &packet)
const Transport * getTransport() const
const Face * getFace() const
stores a packet along with the remote endpoint
Definition: transport.hpp:122
PacketCounter nInNacks
count of incoming Nacks
represents an Interest packet
Definition: interest.hpp:42
represents a counter of number of packets
Definition: counter.hpp:77
void sendPacket(Transport::Packet &&packet)
sends a lower-layer packet via Transport
provides a lightweight signal / event system
Definition: signal.hpp:50
PacketCounter nDroppedInterests
count of Interests dropped by reliability system for exceeding allowed number of retx ...
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:40
void send(Packet &&packet)
send a link-layer packet
Definition: transport.cpp:98
ndn Face
Definition: face-impl.hpp:41
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
signal::Signal< LinkService, lp::Nack > afterReceiveNack
signals on Nack received
void receivePacket(Transport::Packet &&packet)
performs LinkService specific operations to receive a lower-layer packet
void receiveNack(const lp::Nack &nack)
delivers received Nack to forwarding
counters provided by LinkService
PacketCounter nOutInterests
count of outgoing Interests
LinkServiceCounters Counters
counters provided by LinkService
signal::Signal< LinkService, Interest > afterSendInterest
signals on Interest sent
PacketCounter nInData
count of incoming Data packets
virtual const Counters & getCounters() const
PacketCounter nOutNacks
count of outgoing Nacks
void receiveData(const Data &data)
delivers received Data to forwarding
void sendNack(const ndn::lp::Nack &nack)
send Nack
void setFaceAndTransport(Face &face, Transport &transport)
set Face and Transport for LinkService
Represents a Data packet.
Definition: data.hpp:35
the lower part of a Face
Definition: transport.hpp:113
signal::Signal< LinkService, lp::Nack > afterSendNack
signals on Nack sent
signal::Signal< LinkService, Data > afterSendData
signals on Data sent
signal::Signal< LinkService, Interest > afterReceiveInterest
signals on Interest received
void receiveInterest(const Interest &interest)
delivers received Interest to forwarding