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-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
#define PUBLIC_WITH_TESTS_ELSE_PRIVATE
Definition: common.hpp:40
LpFragmenter::Options fragmenterOptions
options for fragmentation
time_point TimePoint
Definition: time.hpp:226
GenericLinkService is a LinkService that implements the NDNLPv2 protocol.
the upper part of a Face
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:42
represents a counter of number of packets
Definition: counter.hpp:77
Options that control the behavior of LpFragmenter.
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:40
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
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
Options that control the behavior of LpReassembler.
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
GenericLinkService(const Options &options=Options())
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