generic-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-2018, 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_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 
87 };
88 
93  , protected virtual GenericLinkServiceCounters
94 {
95 public:
98  class Options
99  {
100  public:
101  Options();
102 
103  public:
107 
111 
115 
119 
123 
127 
131 
134  time::nanoseconds baseCongestionMarkingInterval;
135 
139 
143  };
144 
148 
149  explicit
150  GenericLinkService(const Options& options = Options());
151 
154  const Options&
155  getOptions() const;
156 
159  void
160  setOptions(const Options& options);
161 
162  const Counters&
163  getCounters() const override;
164 
168  void
169  requestIdlePacket();
170 
174  void
175  sendLpPacket(lp::Packet&& pkt);
176 
179  void
180  doSendInterest(const Interest& interest) override;
181 
184  void
185  doSendData(const Data& data) override;
186 
189  void
190  doSendNack(const ndn::lp::Nack& nack) override;
191 
192 private: // send path
197  void
198  encodeLpFields(const ndn::PacketBase& netPkt, lp::Packet& lpPacket);
199 
204  void
205  sendNetPacket(lp::Packet&& pkt, bool isInterest);
206 
209  void
210  assignSequence(lp::Packet& pkt);
211 
214  void
215  assignSequences(std::vector<lp::Packet>& pkts);
216 
221  void
222  checkCongestionLevel(lp::Packet& pkt);
223 
224 private: // receive path
227  void
228  doReceivePacket(Transport::Packet&& packet) override;
229 
237  void
238  decodeNetPacket(const Block& netPkt, const lp::Packet& firstPkt);
239 
249  void
250  decodeInterest(const Block& netPkt, const lp::Packet& firstPkt);
251 
261  void
262  decodeData(const Block& netPkt, const lp::Packet& firstPkt);
263 
273  void
274  decodeNack(const Block& netPkt, const lp::Packet& firstPkt);
275 
277  Options m_options;
278  LpFragmenter m_fragmenter;
279  LpReassembler m_reassembler;
280  LpReliability m_reliability;
281  lp::Sequence m_lastSeqNo;
282 
285  static constexpr size_t CONGESTION_MARK_SIZE = 3 + 1 + sizeof(uint64_t);
287  time::steady_clock::TimePoint m_nextMarkTime;
289  time::steady_clock::TimePoint m_lastMarkTime;
291  size_t m_nMarkedSinceInMarkingState;
292 
293  friend class LpReliability;
294 };
295 
296 inline const GenericLinkService::Options&
298 {
299  return m_options;
300 }
301 
302 inline const GenericLinkService::Counters&
304 {
305  return *this;
306 }
307 
308 } // namespace face
309 } // namespace nfd
310 
311 #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:122
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.
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:40