NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: 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; -*- */
26 #ifndef NFD_DAEMON_FACE_LINK_SERVICE_HPP
27 #define NFD_DAEMON_FACE_LINK_SERVICE_HPP
28 
29 #include "core/counter.hpp"
30 #include "transport.hpp"
31 #include "face-log.hpp"
32 
33 namespace nfd {
34 namespace face {
35 
36 class Face;
37 
43 {
44 public:
48 
52 
56 
60 
64 
68 };
69 
73 class LinkService : protected virtual LinkServiceCounters, noncopyable
74 {
75 public:
79 
80 public:
81  LinkService();
82 
83  virtual
84  ~LinkService();
85 
89  void
90  setFaceAndTransport(Face& face, Transport& transport);
91 
94  const Face*
95  getFace() const;
96 
99  const Transport*
100  getTransport() const;
101 
104  Transport*
105  getTransport();
106 
107  virtual const Counters&
108  getCounters() const;
109 
110 public: // upper interface to be used by forwarding
114  void
115  sendInterest(const Interest& interest);
116 
120  void
121  sendData(const Data& data);
122 
126  void
127  sendNack(const ndn::lp::Nack& nack);
128 
132 
136 
140 
144 
148 
152 
153 public: // lower interface to be invoked by Transport
156  void
157  receivePacket(Transport::Packet&& packet);
158 
159 protected: // upper interface to be invoked in subclass (receive path termination)
162  void
163  receiveInterest(const Interest& interest);
164 
167  void
168  receiveData(const Data& data);
169 
172  void
173  receiveNack(const lp::Nack& nack);
174 
175 protected: // lower interface to be invoked in subclass (send path termination)
178  void
179  sendPacket(Transport::Packet&& packet);
180 
181 private: // upper interface to be overridden in subclass (send path entrypoint)
184  virtual void
185  doSendInterest(const Interest& interest) = 0;
186 
189  virtual void
190  doSendData(const Data& data) = 0;
191 
194  virtual void
195  doSendNack(const lp::Nack& nack) = 0;
196 
197 private: // lower interface to be overridden in subclass
198  virtual void
199  doReceivePacket(Transport::Packet&& packet) = 0;
200 
201 private:
202  Face* m_face;
203  Transport* m_transport;
204 };
205 
206 inline const Face*
208 {
209  return m_face;
210 }
211 
212 inline const Transport*
214 {
215  return m_transport;
216 }
217 
218 inline Transport*
220 {
221  return m_transport;
222 }
223 
224 inline const LinkService::Counters&
226 {
227  return *this;
228 }
229 
230 inline void
232 {
233  doReceivePacket(std::move(packet));
234 }
235 
236 inline void
238 {
239  m_transport->send(std::move(packet));
240 }
241 
242 std::ostream&
243 operator<<(std::ostream& os, const FaceLogHelper<LinkService>& flh);
244 
245 template<typename T>
246 typename std::enable_if<std::is_base_of<LinkService, T>::value &&
247  !std::is_same<LinkService, T>::value, std::ostream&>::type
248 operator<<(std::ostream& os, const FaceLogHelper<T>& flh)
249 {
250  return os << FaceLogHelper<LinkService>(flh.obj);
251 }
252 
253 } // namespace face
254 } // namespace nfd
255 
256 #endif // NFD_DAEMON_FACE_LINK_SERVICE_HPP
signal::Signal< LinkService, Data > afterReceiveData
signals on Data received
the upper part of a Face
PacketCounter nOutData
count of outgoing Data
PacketCounter nInInterests
count of incoming Interests
const Transport * getTransport() const
const Face * getFace() const
stores a packet along with the remote endpoint
Definition: transport.hpp:113
PacketCounter nInNacks
count of incoming Nacks
represents an Interest packet
Definition: interest.hpp:45
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
represents a Network Nack
Definition: nack.hpp:40
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
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
virtual const Counters & getCounters() const
PacketCounter nOutNacks
count of outgoing Nacks
represents a Data packet
Definition: data.hpp:39
the lower part of a Face
Definition: transport.hpp:104
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