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 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  constexpr
102  Options() noexcept
103  {
104  }
105 
106  public:
109  bool allowLocalFields = false;
110 
113  bool allowFragmentation = false;
114 
118 
121  bool allowReassembly = false;
122 
126 
130 
134 
139  time::nanoseconds baseCongestionMarkingInterval = 100_ms;
140 
146 
149  bool allowSelfLearning = true;
150  };
151 
155 
156  explicit
157  GenericLinkService(const Options& options = {});
158 
161  const Options&
162  getOptions() const;
163 
166  void
167  setOptions(const Options& options);
168 
169  const Counters&
170  getCounters() const override;
171 
175  void
176  requestIdlePacket();
177 
181  void
182  sendLpPacket(lp::Packet&& pkt);
183 
186  void
187  doSendInterest(const Interest& interest) override;
188 
191  void
192  doSendData(const Data& data) override;
193 
196  void
197  doSendNack(const ndn::lp::Nack& nack) override;
198 
199 private: // send path
204  void
205  encodeLpFields(const ndn::PacketBase& netPkt, lp::Packet& lpPacket);
206 
211  void
212  sendNetPacket(lp::Packet&& pkt, bool isInterest);
213 
216  void
217  assignSequence(lp::Packet& pkt);
218 
221  void
222  assignSequences(std::vector<lp::Packet>& pkts);
223 
228  void
229  checkCongestionLevel(lp::Packet& pkt);
230 
231 private: // receive path
234  void
235  doReceivePacket(Transport::Packet&& packet) override;
236 
244  void
245  decodeNetPacket(const Block& netPkt, const lp::Packet& firstPkt);
246 
256  void
257  decodeInterest(const Block& netPkt, const lp::Packet& firstPkt);
258 
268  void
269  decodeData(const Block& netPkt, const lp::Packet& firstPkt);
270 
280  void
281  decodeNack(const Block& netPkt, const lp::Packet& firstPkt);
282 
284  Options m_options;
285  LpFragmenter m_fragmenter;
286  LpReassembler m_reassembler;
287  LpReliability m_reliability;
288  lp::Sequence m_lastSeqNo;
289 
292  static constexpr size_t CONGESTION_MARK_SIZE = 3 + 1 + sizeof(uint64_t);
293 
295  time::steady_clock::TimePoint m_nextMarkTime;
297  time::steady_clock::TimePoint m_lastMarkTime;
299  size_t m_nMarkedSinceInMarkingState;
300 
301  friend class LpReliability;
302 };
303 
304 inline const GenericLinkService::Options&
306 {
307  return m_options;
308 }
309 
310 inline const GenericLinkService::Counters&
312 {
313  return *this;
314 }
315 
316 } // namespace face
317 } // namespace nfd
318 
319 #endif // NFD_DAEMON_FACE_GENERIC_LINK_SERVICE_HPP
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:40
LpFragmenter::Options fragmenterOptions
options for fragmentation
time_point TimePoint
Definition: time.hpp:225
GenericLinkService is a LinkService that implements the NDNLPv2 protocol.
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...
bool allowLocalFields
enables encoding of IncomingFaceId, and decoding of NextHopFaceId and CachePolicy
PacketCounter nCongestionMarked
count of outgoing LpPackets that were marked with congestion marks
size_t defaultCongestionThreshold
default congestion threshold in bytes
stores a packet along with the remote endpoint
Definition: transport.hpp:122
PacketCounter nReassemblyTimeouts
count of dropped partial network-layer packets due to reassembly timeout
LpReliability::Options reliabilityOptions
options for reliability
const Counters & getCounters() const override
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
Represents an Interest packet.
Definition: interest.hpp:44
represents a counter of number of packets
Definition: counter.hpp:77
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
GenericLinkService(const Options &options={})
PacketCounter nOutOverMtu
count of outgoing LpPackets dropped due to exceeding MTU limit
bool allowSelfLearning
enables self-learning forwarding support
bool allowCongestionMarking
enables send queue congestion detection and marking
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
time::nanoseconds baseCongestionMarkingInterval
starting value for congestion marking interval
GenericLinkServiceCounters Counters
counters provided by GenericLinkService
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
void setOptions(const Options &options)
sets Options used by GenericLinkService
provides a counter that observes the size of a table
Definition: counter.hpp:114
counters provided by GenericLinkService
Options that control the behavior of 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
#define PROTECTED_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:41
const Options & getOptions() const
get Options used by GenericLinkService
LpReassembler::Options reassemblerOptions
options for reassembly
Represents a Data packet.
Definition: data.hpp:35
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
PacketCounter nFragmentationErrors
count of failed fragmentations