NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
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-2021, 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 #include <ndn-cxx/lp/tags.hpp>
35 
36 namespace nfd {
37 namespace face {
38 
44 {
45 public:
49 
55 
59 
63 
67 
71 
75 
80 
85 
89 
93 };
94 
99  , protected virtual GenericLinkServiceCounters
100 {
101 public:
104  class Options
105  {
106  public:
107  Options() noexcept
108  {
109  }
110 
111  public:
114  bool allowLocalFields = false;
115 
118  bool allowFragmentation = false;
119 
123 
126  bool allowReassembly = false;
127 
131 
135 
138  bool allowCongestionMarking = false;
139 
146  time::nanoseconds baseCongestionMarkingInterval = 100_ms;
147 
154  size_t defaultCongestionThreshold = 65536;
155 
158  bool allowSelfLearning = true;
159 
168  ssize_t overrideMtu = std::numeric_limits<ssize_t>::max();
169 
174  std::function<std::shared_ptr<ndn::lp::GeoTag>()> enableGeoTags;
175  };
176 
180 
181  explicit
182  GenericLinkService(const Options& options = {});
183 
186  const Options&
187  getOptions() const;
188 
191  void
192  setOptions(const Options& options);
193 
194  const Counters&
195  getCounters() const NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL;
196 
197  ssize_t
198  getEffectiveMtu() const NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL;
199 
204  bool
205  canOverrideMtuTo(ssize_t mtu) const;
206 
210  void
211  requestIdlePacket();
212 
215  void
216  sendLpPacket(lp::Packet&& pkt);
217 
218  void
219  doSendInterest(const Interest& interest) NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL;
220 
221  void
222  doSendData(const Data& data) NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL;
223 
224  void
225  doSendNack(const ndn::lp::Nack& nack) NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL;
226 
229  void
230  assignSequences(std::vector<lp::Packet>& pkts);
231 
232 private: // send path
237  void
238  encodeLpFields(const ndn::PacketBase& netPkt, lp::Packet& lpPacket);
239 
244  void
245  sendNetPacket(lp::Packet&& pkt, bool isInterest);
246 
251  void
252  checkCongestionLevel(lp::Packet& pkt);
253 
254 private: // receive path
255  void
256  doReceivePacket(const Block& packet, const EndpointId& endpoint) NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL;
257 
266  void
267  decodeNetPacket(const Block& netPkt, const lp::Packet& firstPkt, const EndpointId& endpointId);
268 
279  void
280  decodeInterest(const Block& netPkt, const lp::Packet& firstPkt, const EndpointId& endpointId);
281 
292  void
293  decodeData(const Block& netPkt, const lp::Packet& firstPkt, const EndpointId& endpointId);
294 
305  void
306  decodeNack(const Block& netPkt, const lp::Packet& firstPkt, const EndpointId& endpointId);
307 
309  Options m_options;
310  LpFragmenter m_fragmenter;
311  LpReassembler m_reassembler;
312  LpReliability m_reliability;
313  lp::Sequence m_lastSeqNo;
314 
317  time::steady_clock::TimePoint m_nextMarkTime;
319  size_t m_nMarkedSinceInMarkingState;
320 
321  friend class LpReliability;
322 };
323 
324 inline const GenericLinkService::Options&
325 GenericLinkService::getOptions() const
326 {
327  return m_options;
328 }
329 
330 inline const GenericLinkService::Counters&
331 GenericLinkService::getCounters() const
332 {
333  return *this;
334 }
335 
336 } // namespace face
337 } // namespace nfd
338 
339 #endif // NFD_DAEMON_FACE_GENERIC_LINK_SERVICE_HPP
#define NFD_PROTECTED_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:42
Options that control the behavior of GenericLinkService.
Options that control the behavior of LpFragmenter.
the upper part of a Face
Options that control the behavior of LpReassembler.
PacketCounter nRetxExhausted
count of network-layer packets dropped because a fragment reached the maximum number of retransmissio...
LpReliability::Options reliabilityOptions
options for reliability
PacketCounter nCongestionMarked
count of outgoing LpPackets that were marked with congestion marks
PacketCounter nReassemblyTimeouts
count of dropped partial network-layer packets due to reassembly timeout
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
PacketCounter nDuplicateSequence
count of LpPackets dropped due to duplicate Sequence numbers
generalization of a network interface
Definition: face.hpp:54
uint64_t EndpointId
Identifies a remote endpoint on the link.
Definition: face-common.hpp:71
PacketCounter nRetransmitted
count of network-layer packets that had at least one fragment retransmitted, but were eventually rece...
uint64_t Sequence
represents a sequence number
Definition: sequence.hpp:35
represents a Network Nack
Definition: nack.hpp:38
LpFragmenter::Options fragmenterOptions
options for fragmentation
PacketCounter nOutOverMtu
count of outgoing LpPackets dropped due to exceeding MTU limit
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:39
#define NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:41
#define NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL
Definition: common.hpp:43
base class to allow simple management of packet tags
Definition: packet-base.hpp:31
counters provided by LinkService
reassembles fragmented network-layer packets
SizeCounter< LpReassembler > nReassembling
count of network-layer packets currently being reassembled
LpReassembler::Options reassemblerOptions
options for reassembly
provides a counter that observes the size of a table
Definition: counter.hpp:103
counters provided by GenericLinkService
PacketCounter nAcknowledged
count of network-layer packets that did not require retransmission of a fragment
PacketCounter nInNetInvalid
count of invalid reassembled network-layer packets dropped
Represents a Data packet.
Definition: data.hpp:37
boost::chrono::nanoseconds nanoseconds
Definition: time.hpp:50
provides for reliable sending and receiving of link-layer packets
fragments network-layer packets into NDNLPv2 link-layer packets
PacketCounter nInLpInvalid
count of invalid LpPackets dropped before reassembly
time_point TimePoint
Definition: time.hpp:233
PacketCounter nFragmentationErrors
count of failed fragmentations