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-2019, 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 };
90 
95  , protected virtual GenericLinkServiceCounters
96 {
97 public:
100  class Options
101  {
102  public:
103  Options() noexcept
104  {
105  }
106 
107  public:
110  bool allowLocalFields = false;
111 
114  bool allowFragmentation = false;
115 
119 
122  bool allowReassembly = false;
123 
127 
131 
135 
142  time::nanoseconds baseCongestionMarkingInterval = 100_ms;
143 
151 
154  bool allowSelfLearning = true;
155 
160  std::function<std::shared_ptr<ndn::lp::GeoTag>()> enableGeoTags;
161  };
162 
166 
167  explicit
168  GenericLinkService(const Options& options = {});
169 
172  const Options&
173  getOptions() const;
174 
177  void
178  setOptions(const Options& options);
179 
180  const Counters&
182 
186  void
187  requestIdlePacket(const EndpointId& endpointId);
188 
191  void
192  sendLpPacket(lp::Packet&& pkt, const EndpointId& endpointId);
193 
196  void
197  doSendInterest(const Interest& interest, const EndpointId& endpointId) OVERRIDE_WITH_TESTS_ELSE_FINAL;
198 
201  void
202  doSendData(const Data& data, const EndpointId& endpointId) OVERRIDE_WITH_TESTS_ELSE_FINAL;
203 
206  void
207  doSendNack(const ndn::lp::Nack& nack, const EndpointId& endpointId) OVERRIDE_WITH_TESTS_ELSE_FINAL;
208 
209 private: // send path
214  void
215  encodeLpFields(const ndn::PacketBase& netPkt, lp::Packet& lpPacket);
216 
222  void
223  sendNetPacket(lp::Packet&& pkt, const EndpointId& endpointId, bool isInterest);
224 
227  void
228  assignSequence(lp::Packet& pkt);
229 
232  void
233  assignSequences(std::vector<lp::Packet>& pkts);
234 
239  void
240  checkCongestionLevel(lp::Packet& pkt);
241 
242 private: // receive path
245  void
246  doReceivePacket(const Block& packet, const EndpointId& endpoint) OVERRIDE_WITH_TESTS_ELSE_FINAL;
247 
256  void
257  decodeNetPacket(const Block& netPkt, const lp::Packet& firstPkt, const EndpointId& endpointId);
258 
269  void
270  decodeInterest(const Block& netPkt, const lp::Packet& firstPkt, const EndpointId& endpointId);
271 
282  void
283  decodeData(const Block& netPkt, const lp::Packet& firstPkt, const EndpointId& endpointId);
284 
295  void
296  decodeNack(const Block& netPkt, const lp::Packet& firstPkt, const EndpointId& endpointId);
297 
299  Options m_options;
300  LpFragmenter m_fragmenter;
301  LpReassembler m_reassembler;
302  LpReliability m_reliability;
303  lp::Sequence m_lastSeqNo;
304 
307  time::steady_clock::TimePoint m_nextMarkTime;
309  size_t m_nMarkedSinceInMarkingState;
310 
311  friend class LpReliability;
312 };
313 
314 inline const GenericLinkService::Options&
316 {
317  return m_options;
318 }
319 
320 inline const GenericLinkService::Counters&
322 {
323  return *this;
324 }
325 
326 } // namespace face
327 } // namespace nfd
328 
329 #endif // NFD_DAEMON_FACE_GENERIC_LINK_SERVICE_HPP
PUBLIC_WITH_TESTS_ELSE_PRIVATE
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:41
nfd::face::GenericLinkService::getOptions
const Options & getOptions() const
get Options used by GenericLinkService
Definition: generic-link-service.hpp:315
ndn::lp::tlv::Nack
@ Nack
Definition: tlv.hpp:42
nfd::face::LpReliability
provides for reliable sending and receiving of link-layer packets
Definition: lp-reliability.hpp:46
nfd::face::GenericLinkService::setOptions
void setOptions(const Options &options)
sets Options used by GenericLinkService
Definition: generic-link-service.cpp:57
nfd::face::GenericLinkService::getCounters
const Counters & getCounters() const OVERRIDE_WITH_TESTS_ELSE_FINAL
Definition: generic-link-service.hpp:321
nfd::face::LpFragmenter::Options
Options that control the behavior of LpFragmenter.
Definition: lp-fragmenter.hpp:45
nfd::face::GenericLinkService::Options::allowCongestionMarking
bool allowCongestionMarking
enables send queue congestion detection and marking
Definition: generic-link-service.hpp:134
nfd::face::GenericLinkService::Options::allowSelfLearning
bool allowSelfLearning
enables self-learning forwarding support
Definition: generic-link-service.hpp:154
nfd::face::GenericLinkService::Options::allowFragmentation
bool allowFragmentation
enables fragmentation
Definition: generic-link-service.hpp:114
nfd::face::GenericLinkServiceCounters::nReassembling
SizeCounter< LpReassembler > nReassembling
count of network-layer packets currently being reassembled
Definition: generic-link-service.hpp:62
nfd::face::LinkServiceCounters
counters provided by LinkService
Definition: link-service.hpp:41
nfd::face::GenericLinkServiceCounters::nFragmentationErrors
PacketCounter nFragmentationErrors
count of failed fragmentations
Definition: generic-link-service.hpp:48
nfd::face::GenericLinkService::GenericLinkService
GenericLinkService(const Options &options={})
Definition: generic-link-service.cpp:42
nfd::face::GenericLinkService::Options::defaultCongestionThreshold
size_t defaultCongestionThreshold
default congestion threshold in bytes
Definition: generic-link-service.hpp:150
nfd::face::LpReassembler::Options
Options that control the behavior of LpReassembler.
Definition: lp-reassembler.hpp:45
nfd::face::GenericLinkServiceCounters::nReassemblyTimeouts
PacketCounter nReassemblyTimeouts
count of dropped partial network-layer packets due to reassembly timeout
Definition: generic-link-service.hpp:66
nfd::face::GenericLinkService::Options::fragmenterOptions
LpFragmenter::Options fragmenterOptions
options for fragmentation
Definition: generic-link-service.hpp:118
lp-fragmenter.hpp
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
nfd::face::LinkService
the upper part of a Face
Definition: link-service.hpp:76
OVERRIDE_WITH_TESTS_ELSE_FINAL
#define OVERRIDE_WITH_TESTS_ELSE_FINAL
Definition: common.hpp:43
nfd::face::GenericLinkServiceCounters
counters provided by GenericLinkService
Definition: generic-link-service.hpp:44
ndn::time
Definition: time-custom-clock.hpp:28
nfd::SizeCounter
provides a counter that observes the size of a table
Definition: counter.hpp:104
nfd::face::GenericLinkService::Options::allowLocalFields
bool allowLocalFields
enables encoding of IncomingFaceId, and decoding of NextHopFaceId and CachePolicy
Definition: generic-link-service.hpp:110
nfd::face::GenericLinkServiceCounters::nInNetInvalid
PacketCounter nInNetInvalid
count of invalid reassembled network-layer packets dropped
Definition: generic-link-service.hpp:70
nfd::face::GenericLinkService::Options
Options that control the behavior of GenericLinkService.
Definition: generic-link-service.hpp:101
nfd::face::GenericLinkService::Options::reassemblerOptions
LpReassembler::Options reassemblerOptions
options for reassembly
Definition: generic-link-service.hpp:126
nfd::face::GenericLinkServiceCounters::nAcknowledged
PacketCounter nAcknowledged
count of network-layer packets that did not require retransmission of a fragment
Definition: generic-link-service.hpp:74
nfd::face::LpFragmenter
fragments network-layer packets into NDNLPv2 link-layer packets
Definition: lp-fragmenter.hpp:40
nfd::face::GenericLinkServiceCounters::nInLpInvalid
PacketCounter nInLpInvalid
count of invalid LpPackets dropped before reassembly
Definition: generic-link-service.hpp:58
nfd::face::LpReassembler
reassembles fragmented network-layer packets
Definition: lp-reassembler.hpp:40
ndn::Interest
Represents an Interest packet.
Definition: interest.hpp:44
ndn::Data
Represents a Data packet.
Definition: data.hpp:36
lp-reassembler.hpp
nfd::face::GenericLinkService::Counters
GenericLinkServiceCounters Counters
counters provided by GenericLinkService
Definition: generic-link-service.hpp:165
nfd::face::LpReliability::Options
Definition: lp-reliability.hpp:49
nfd::face::GenericLinkServiceCounters::nRetxExhausted
PacketCounter nRetxExhausted
count of network-layer packets dropped because a fragment reached the maximum number of retransmissio...
Definition: generic-link-service.hpp:84
nfd::face::GenericLinkService
GenericLinkService is a LinkService that implements the NDNLPv2 protocol.
Definition: generic-link-service.hpp:96
nfd::face::GenericLinkService::Options::reliabilityOptions
LpReliability::Options reliabilityOptions
options for reliability
Definition: generic-link-service.hpp:130
nfd::face::GenericLinkService::Options::baseCongestionMarkingInterval
time::nanoseconds baseCongestionMarkingInterval
starting value for congestion marking interval
Definition: generic-link-service.hpp:142
nfd::PacketCounter
represents a counter of number of packets
Definition: counter.hpp:67
ndn::Block
Represents a TLV element of NDN packet format.
Definition: block.hpp:43
nfd::face::GenericLinkServiceCounters::nOutOverMtu
PacketCounter nOutOverMtu
count of outgoing LpPackets dropped due to exceeding MTU limit
Definition: generic-link-service.hpp:54
PROTECTED_WITH_TESTS_ELSE_PRIVATE
#define PROTECTED_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:42
nfd::face::GenericLinkServiceCounters::nRetransmitted
PacketCounter nRetransmitted
count of network-layer packets that had at least one fragment retransmitted, but were eventually rece...
Definition: generic-link-service.hpp:79
nfd::face::GenericLinkServiceCounters::nCongestionMarked
PacketCounter nCongestionMarked
count of outgoing LpPackets that were marked with congestion marks
Definition: generic-link-service.hpp:88
tags.hpp
ndn::lp
Definition: cache-policy.cpp:28
nfd::face::EndpointId
uint64_t EndpointId
Identifies a remote endpoint on the link.
Definition: face-common.hpp:65
nfd::face::GenericLinkService::Options::allowReassembly
bool allowReassembly
enables reassembly
Definition: generic-link-service.hpp:122
nfd::face::GenericLinkService::Options::enableGeoTags
std::function< std::shared_ptr< ndn::lp::GeoTag >)> enableGeoTags
Enable encoding and decoding of GeoTags.
Definition: generic-link-service.hpp:160
lp-reliability.hpp
ndn::lp::Sequence
uint64_t Sequence
represents a sequence number
Definition: sequence.hpp:35
nfd::face::GenericLinkService::Options::Options
Options() noexcept
Definition: generic-link-service.hpp:103
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34
FINAL_UNLESS_WITH_TESTS
#define FINAL_UNLESS_WITH_TESTS
Definition: common.hpp:44