generic-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_GENERIC_LINK_SERVICE_HPP
27 #define NFD_DAEMON_FACE_GENERIC_LINK_SERVICE_HPP
28 
29 #include "link-service.hpp"
30 #include "lp-fragmenter.hpp"
31 #include "lp-reassembler.hpp"
32 #include "lp-reliability.hpp"
33 
34 namespace nfd {
35 namespace face {
36 
42 {
43 public:
47 
53 
57 
61 
65 
69 
73 
78 
83 };
84 
89  , protected virtual GenericLinkServiceCounters
90 {
91 public:
94  class Options
95  {
96  public:
97  Options();
98 
99  public:
103 
107 
111 
115 
119 
123  };
124 
128 
129  explicit
130  GenericLinkService(const Options& options = Options());
131 
134  const Options&
135  getOptions() const;
136 
139  void
140  setOptions(const Options& options);
141 
142  const Counters&
143  getCounters() const override;
144 
148  void
149  requestIdlePacket();
150 
154  void
155  sendLpPacket(lp::Packet&& pkt);
156 
159  void
160  doSendInterest(const Interest& interest) override;
161 
164  void
165  doSendData(const Data& data) override;
166 
169  void
170  doSendNack(const ndn::lp::Nack& nack) override;
171 
172 private: // send path
177  void
178  encodeLpFields(const ndn::TagHost& netPkt, lp::Packet& lpPacket);
179 
183  void
184  sendNetPacket(lp::Packet&& pkt);
185 
188  void
189  assignSequence(lp::Packet& pkt);
190 
193  void
194  assignSequences(std::vector<lp::Packet>& pkts);
195 
196 private: // receive path
199  void
200  doReceivePacket(Transport::Packet&& packet) override;
201 
209  void
210  decodeNetPacket(const Block& netPkt, const lp::Packet& firstPkt);
211 
221  void
222  decodeInterest(const Block& netPkt, const lp::Packet& firstPkt);
223 
233  void
234  decodeData(const Block& netPkt, const lp::Packet& firstPkt);
235 
245  void
246  decodeNack(const Block& netPkt, const lp::Packet& firstPkt);
247 
249  Options m_options;
250  LpFragmenter m_fragmenter;
251  LpReassembler m_reassembler;
252  LpReliability m_reliability;
253  lp::Sequence m_lastSeqNo;
254 
255  friend class LpReliability;
256 };
257 
258 inline const GenericLinkService::Options&
260 {
261  return m_options;
262 }
263 
264 inline const GenericLinkService::Counters&
266 {
267  return *this;
268 }
269 
270 } // namespace face
271 } // namespace nfd
272 
273 #endif // NFD_DAEMON_FACE_GENERIC_LINK_SERVICE_HPP
provides a counter that observes the size of a table
Definition: counter.hpp:114
stores a packet along with the remote endpoint
Definition: transport.hpp:113
represents a counter of number of packets
Definition: counter.hpp:77
#define PROTECTED_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:41
Options that control the behavior of LpReassembler.
provides for reliable sending and receiving of link-layer packets
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
Definition: algorithm.hpp:32
fragments network-layer packets into NDNLPv2 link-layer packets
reassembles fragmented network-layer packets
Options that control the behavior of LpFragmenter.