NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
generic-link-service.cpp
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 #include "generic-link-service.hpp"
27 
28 #include <ndn-cxx/lp/pit-token.hpp>
29 #include <ndn-cxx/lp/tags.hpp>
30 
31 #include <cmath>
32 
33 namespace nfd {
34 namespace face {
35 
37 
39  tlv::sizeOfVarNumber(sizeof(uint64_t)) + // length
40  tlv::sizeOfNonNegativeInteger(UINT64_MAX); // value
41 
43  : m_options(options)
44  , m_fragmenter(m_options.fragmenterOptions, this)
45  , m_reassembler(m_options.reassemblerOptions, this)
46  , m_reliability(m_options.reliabilityOptions, this)
47  , m_lastSeqNo(-2)
48  , m_nextMarkTime(time::steady_clock::TimePoint::max())
49  , m_nMarkedSinceInMarkingState(0)
50 {
51  m_reassembler.beforeTimeout.connect([this] (auto...) { ++this->nReassemblyTimeouts; });
52  m_reliability.onDroppedInterest.connect([this] (const auto& i) { this->notifyDroppedInterest(i); });
53  nReassembling.observe(&m_reassembler);
54 }
55 
56 void
58 {
59  m_options = options;
60  m_fragmenter.setOptions(m_options.fragmenterOptions);
61  m_reassembler.setOptions(m_options.reassemblerOptions);
62  m_reliability.setOptions(m_options.reliabilityOptions);
63 }
64 
65 void
66 GenericLinkService::requestIdlePacket(const EndpointId& endpointId)
67 {
68  // No need to request Acks to attach to this packet from LpReliability, as they are already
69  // attached in sendLpPacket
70  this->sendLpPacket({}, endpointId);
71 }
72 
73 void
74 GenericLinkService::sendLpPacket(lp::Packet&& pkt, const EndpointId& endpointId)
75 {
76  const ssize_t mtu = this->getTransport()->getMtu();
77 
78  if (m_options.reliabilityOptions.isEnabled) {
79  m_reliability.piggyback(pkt, mtu);
80  }
81 
82  if (m_options.allowCongestionMarking) {
83  checkCongestionLevel(pkt);
84  }
85 
86  auto block = pkt.wireEncode();
87  if (mtu != MTU_UNLIMITED && block.size() > static_cast<size_t>(mtu)) {
88  ++this->nOutOverMtu;
89  NFD_LOG_FACE_WARN("attempted to send packet over MTU limit");
90  return;
91  }
92  this->sendPacket(block, endpointId);
93 }
94 
95 void
96 GenericLinkService::doSendInterest(const Interest& interest, const EndpointId& endpointId)
97 {
98  lp::Packet lpPacket(interest.wireEncode());
99 
100  encodeLpFields(interest, lpPacket);
101 
102  this->sendNetPacket(std::move(lpPacket), endpointId, true);
103 }
104 
105 void
106 GenericLinkService::doSendData(const Data& data, const EndpointId& endpointId)
107 {
108  lp::Packet lpPacket(data.wireEncode());
109 
110  encodeLpFields(data, lpPacket);
111 
112  this->sendNetPacket(std::move(lpPacket), endpointId, false);
113 }
114 
115 void
116 GenericLinkService::doSendNack(const lp::Nack& nack, const EndpointId& endpointId)
117 {
118  lp::Packet lpPacket(nack.getInterest().wireEncode());
119  lpPacket.add<lp::NackField>(nack.getHeader());
120 
121  encodeLpFields(nack, lpPacket);
122 
123  this->sendNetPacket(std::move(lpPacket), endpointId, false);
124 }
125 
126 void
127 GenericLinkService::encodeLpFields(const ndn::PacketBase& netPkt, lp::Packet& lpPacket)
128 {
129  if (m_options.allowLocalFields) {
130  auto incomingFaceIdTag = netPkt.getTag<lp::IncomingFaceIdTag>();
131  if (incomingFaceIdTag != nullptr) {
132  lpPacket.add<lp::IncomingFaceIdField>(*incomingFaceIdTag);
133  }
134  }
135 
136  auto congestionMarkTag = netPkt.getTag<lp::CongestionMarkTag>();
137  if (congestionMarkTag != nullptr) {
138  lpPacket.add<lp::CongestionMarkField>(*congestionMarkTag);
139  }
140 
141  if (m_options.allowSelfLearning) {
142  auto nonDiscoveryTag = netPkt.getTag<lp::NonDiscoveryTag>();
143  if (nonDiscoveryTag != nullptr) {
144  lpPacket.add<lp::NonDiscoveryField>(*nonDiscoveryTag);
145  }
146 
147  auto prefixAnnouncementTag = netPkt.getTag<lp::PrefixAnnouncementTag>();
148  if (prefixAnnouncementTag != nullptr) {
149  lpPacket.add<lp::PrefixAnnouncementField>(*prefixAnnouncementTag);
150  }
151  }
152 
153  auto pitToken = netPkt.getTag<lp::PitToken>();
154  if (pitToken != nullptr) {
155  lpPacket.add<lp::PitTokenField>(*pitToken);
156  }
157 
158  shared_ptr<lp::HopCountTag> hopCountTag = netPkt.getTag<lp::HopCountTag>();
159  if (hopCountTag != nullptr) {
160  lpPacket.add<lp::HopCountTagField>(*hopCountTag);
161  }
162  else {
163  lpPacket.add<lp::HopCountTagField>(0);
164  }
165 
166  if (m_options.enableGeoTags) {
167  auto geoTag = m_options.enableGeoTags();
168  if (geoTag != nullptr) {
169  lpPacket.add<lp::GeoTagField>(*geoTag);
170  }
171  }
172 }
173 
174 void
175 GenericLinkService::sendNetPacket(lp::Packet&& pkt, const EndpointId& endpointId, bool isInterest)
176 {
177  std::vector<lp::Packet> frags;
178  ssize_t mtu = this->getTransport()->getMtu();
179 
180  // Make space for feature fields in fragments
181  if (m_options.reliabilityOptions.isEnabled && mtu != MTU_UNLIMITED) {
183  }
184 
185  if (m_options.allowCongestionMarking && mtu != MTU_UNLIMITED) {
186  mtu -= CONGESTION_MARK_SIZE;
187  }
188 
189  BOOST_ASSERT(mtu == MTU_UNLIMITED || mtu > 0);
190 
191  if (m_options.allowFragmentation && mtu != MTU_UNLIMITED) {
192  bool isOk = false;
193  std::tie(isOk, frags) = m_fragmenter.fragmentPacket(pkt, mtu);
194  if (!isOk) {
195  // fragmentation failed (warning is logged by LpFragmenter)
196  ++this->nFragmentationErrors;
197  return;
198  }
199  }
200  else {
201  if (m_options.reliabilityOptions.isEnabled) {
202  frags.push_back(pkt);
203  }
204  else {
205  frags.push_back(std::move(pkt));
206  }
207  }
208 
209  if (frags.size() == 1) {
210  // even if indexed fragmentation is enabled, the fragmenter should not
211  // fragment the packet if it can fit in MTU
212  BOOST_ASSERT(!frags.front().has<lp::FragIndexField>());
213  BOOST_ASSERT(!frags.front().has<lp::FragCountField>());
214  }
215 
216  // Only assign sequences to fragments if packet contains more than 1 fragment
217  if (frags.size() > 1) {
218  // Assign sequences to all fragments
219  this->assignSequences(frags);
220  }
221 
222  if (m_options.reliabilityOptions.isEnabled && frags.front().has<lp::FragmentField>()) {
223  m_reliability.handleOutgoing(frags, std::move(pkt), isInterest);
224  }
225 
226  for (lp::Packet& frag : frags) {
227  this->sendLpPacket(std::move(frag), endpointId);
228  }
229 }
230 
231 void
232 GenericLinkService::assignSequence(lp::Packet& pkt)
233 {
234  pkt.set<lp::SequenceField>(++m_lastSeqNo);
235 }
236 
237 void
238 GenericLinkService::assignSequences(std::vector<lp::Packet>& pkts)
239 {
240  std::for_each(pkts.begin(), pkts.end(), [this] (auto& pkt) { this->assignSequence(pkt); });
241 }
242 
243 void
244 GenericLinkService::checkCongestionLevel(lp::Packet& pkt)
245 {
246  ssize_t sendQueueLength = getTransport()->getSendQueueLength();
247  // The transport must support retrieving the current send queue length
248  if (sendQueueLength < 0) {
249  return;
250  }
251 
252  if (sendQueueLength > 0) {
253  NFD_LOG_FACE_TRACE("txqlen=" << sendQueueLength << " threshold=" <<
254  m_options.defaultCongestionThreshold << " capacity=" <<
255  getTransport()->getSendQueueCapacity());
256  }
257 
258  // sendQueue is above target
259  if (static_cast<size_t>(sendQueueLength) > m_options.defaultCongestionThreshold) {
260  const auto now = time::steady_clock::now();
261 
262  if (m_nextMarkTime == time::steady_clock::TimePoint::max()) {
263  m_nextMarkTime = now + m_options.baseCongestionMarkingInterval;
264  }
265  // Mark packet if sendQueue stays above target for one interval
266  else if (now >= m_nextMarkTime) {
269  NFD_LOG_FACE_DEBUG("LpPacket was marked as congested");
270 
271  ++m_nMarkedSinceInMarkingState;
272  // Decrease the marking interval by the inverse of the square root of the number of packets
273  // marked in this incident of congestion
274  time::nanoseconds interval(static_cast<time::nanoseconds::rep>(
275  m_options.baseCongestionMarkingInterval.count() /
276  std::sqrt(m_nMarkedSinceInMarkingState + 1)));
277  m_nextMarkTime += interval;
278  }
279  }
280  else if (m_nextMarkTime != time::steady_clock::TimePoint::max()) {
281  // Congestion incident has ended, so reset
282  NFD_LOG_FACE_DEBUG("Send queue length dropped below congestion threshold");
283  m_nextMarkTime = time::steady_clock::TimePoint::max();
284  m_nMarkedSinceInMarkingState = 0;
285  }
286 }
287 
288 void
289 GenericLinkService::doReceivePacket(const Block& packet, const EndpointId& endpoint)
290 {
291  try {
292  lp::Packet pkt(packet);
293 
294  if (m_options.reliabilityOptions.isEnabled) {
295  m_reliability.processIncomingPacket(pkt);
296  }
297 
298  if (!pkt.has<lp::FragmentField>()) {
299  NFD_LOG_FACE_TRACE("received IDLE packet: DROP");
300  return;
301  }
302 
303  if ((pkt.has<lp::FragIndexField>() || pkt.has<lp::FragCountField>()) &&
304  !m_options.allowReassembly) {
305  NFD_LOG_FACE_WARN("received fragment, but reassembly disabled: DROP");
306  return;
307  }
308 
309  bool isReassembled = false;
310  Block netPkt;
311  lp::Packet firstPkt;
312  std::tie(isReassembled, netPkt, firstPkt) = m_reassembler.receiveFragment(endpoint, pkt);
313  if (isReassembled) {
314  this->decodeNetPacket(netPkt, firstPkt, endpoint);
315  }
316  }
317  catch (const tlv::Error& e) {
318  ++this->nInLpInvalid;
319  NFD_LOG_FACE_WARN("packet parse error (" << e.what() << "): DROP");
320  }
321 }
322 
323 void
324 GenericLinkService::decodeNetPacket(const Block& netPkt, const lp::Packet& firstPkt,
325  const EndpointId& endpointId)
326 {
327  try {
328  switch (netPkt.type()) {
329  case tlv::Interest:
330  if (firstPkt.has<lp::NackField>()) {
331  this->decodeNack(netPkt, firstPkt, endpointId);
332  }
333  else {
334  this->decodeInterest(netPkt, firstPkt, endpointId);
335  }
336  break;
337  case tlv::Data:
338  this->decodeData(netPkt, firstPkt, endpointId);
339  break;
340  default:
341  ++this->nInNetInvalid;
342  NFD_LOG_FACE_WARN("unrecognized network-layer packet TLV-TYPE " << netPkt.type() << ": DROP");
343  return;
344  }
345  }
346  catch (const tlv::Error& e) {
347  ++this->nInNetInvalid;
348  NFD_LOG_FACE_WARN("packet parse error (" << e.what() << "): DROP");
349  }
350 }
351 
352 void
353 GenericLinkService::decodeInterest(const Block& netPkt, const lp::Packet& firstPkt,
354  const EndpointId& endpointId)
355 {
356  BOOST_ASSERT(netPkt.type() == tlv::Interest);
357  BOOST_ASSERT(!firstPkt.has<lp::NackField>());
358 
359  // forwarding expects Interest to be created with make_shared
360  auto interest = make_shared<Interest>(netPkt);
361 
362  // Increment HopCount
363  if (firstPkt.has<lp::HopCountTagField>()) {
364  interest->setTag(make_shared<lp::HopCountTag>(firstPkt.get<lp::HopCountTagField>() + 1));
365  }
366 
367  if (m_options.enableGeoTags && firstPkt.has<lp::GeoTagField>()) {
368  interest->setTag(make_shared<lp::GeoTag>(firstPkt.get<lp::GeoTagField>()));
369  }
370 
371  if (firstPkt.has<lp::NextHopFaceIdField>()) {
372  if (m_options.allowLocalFields) {
373  interest->setTag(make_shared<lp::NextHopFaceIdTag>(firstPkt.get<lp::NextHopFaceIdField>()));
374  }
375  else {
376  NFD_LOG_FACE_WARN("received NextHopFaceId, but local fields disabled: DROP");
377  return;
378  }
379  }
380 
381  if (firstPkt.has<lp::CachePolicyField>()) {
382  ++this->nInNetInvalid;
383  NFD_LOG_FACE_WARN("received CachePolicy with Interest: DROP");
384  return;
385  }
386 
387  if (firstPkt.has<lp::IncomingFaceIdField>()) {
388  NFD_LOG_FACE_WARN("received IncomingFaceId: IGNORE");
389  }
390 
391  if (firstPkt.has<lp::CongestionMarkField>()) {
392  interest->setTag(make_shared<lp::CongestionMarkTag>(firstPkt.get<lp::CongestionMarkField>()));
393  }
394 
395  if (firstPkt.has<lp::NonDiscoveryField>()) {
396  if (m_options.allowSelfLearning) {
397  interest->setTag(make_shared<lp::NonDiscoveryTag>(firstPkt.get<lp::NonDiscoveryField>()));
398  }
399  else {
400  NFD_LOG_FACE_WARN("received NonDiscovery, but self-learning disabled: IGNORE");
401  }
402  }
403 
404  if (firstPkt.has<lp::PrefixAnnouncementField>()) {
405  ++this->nInNetInvalid;
406  NFD_LOG_FACE_WARN("received PrefixAnnouncement with Interest: DROP");
407  return;
408  }
409 
410  if (firstPkt.has<lp::PitTokenField>()) {
411  interest->setTag(make_shared<lp::PitToken>(firstPkt.get<lp::PitTokenField>()));
412  }
413 
414  this->receiveInterest(*interest, endpointId);
415 }
416 
417 void
418 GenericLinkService::decodeData(const Block& netPkt, const lp::Packet& firstPkt,
419  const EndpointId& endpointId)
420 {
421  BOOST_ASSERT(netPkt.type() == tlv::Data);
422 
423  // forwarding expects Data to be created with make_shared
424  auto data = make_shared<Data>(netPkt);
425 
426  if (firstPkt.has<lp::HopCountTagField>()) {
427  data->setTag(make_shared<lp::HopCountTag>(firstPkt.get<lp::HopCountTagField>() + 1));
428  }
429 
430  if (m_options.enableGeoTags && firstPkt.has<lp::GeoTagField>()) {
431  data->setTag(make_shared<lp::GeoTag>(firstPkt.get<lp::GeoTagField>()));
432  }
433 
434  if (firstPkt.has<lp::NackField>()) {
435  ++this->nInNetInvalid;
436  NFD_LOG_FACE_WARN("received Nack with Data: DROP");
437  return;
438  }
439 
440  if (firstPkt.has<lp::NextHopFaceIdField>()) {
441  ++this->nInNetInvalid;
442  NFD_LOG_FACE_WARN("received NextHopFaceId with Data: DROP");
443  return;
444  }
445 
446  if (firstPkt.has<lp::CachePolicyField>()) {
447  // CachePolicy is unprivileged and does not require allowLocalFields option.
448  // In case of an invalid CachePolicyType, get<lp::CachePolicyField> will throw,
449  // so it's unnecessary to check here.
450  data->setTag(make_shared<lp::CachePolicyTag>(firstPkt.get<lp::CachePolicyField>()));
451  }
452 
453  if (firstPkt.has<lp::IncomingFaceIdField>()) {
454  NFD_LOG_FACE_WARN("received IncomingFaceId: IGNORE");
455  }
456 
457  if (firstPkt.has<lp::CongestionMarkField>()) {
458  data->setTag(make_shared<lp::CongestionMarkTag>(firstPkt.get<lp::CongestionMarkField>()));
459  }
460 
461  if (firstPkt.has<lp::NonDiscoveryField>()) {
462  ++this->nInNetInvalid;
463  NFD_LOG_FACE_WARN("received NonDiscovery with Data: DROP");
464  return;
465  }
466 
467  if (firstPkt.has<lp::PrefixAnnouncementField>()) {
468  if (m_options.allowSelfLearning) {
469  data->setTag(make_shared<lp::PrefixAnnouncementTag>(firstPkt.get<lp::PrefixAnnouncementField>()));
470  }
471  else {
472  NFD_LOG_FACE_WARN("received PrefixAnnouncement, but self-learning disabled: IGNORE");
473  }
474  }
475 
476  this->receiveData(*data, endpointId);
477 }
478 
479 void
480 GenericLinkService::decodeNack(const Block& netPkt, const lp::Packet& firstPkt,
481  const EndpointId& endpointId)
482 {
483  BOOST_ASSERT(netPkt.type() == tlv::Interest);
484  BOOST_ASSERT(firstPkt.has<lp::NackField>());
485 
486  lp::Nack nack((Interest(netPkt)));
487  nack.setHeader(firstPkt.get<lp::NackField>());
488 
489  if (firstPkt.has<lp::NextHopFaceIdField>()) {
490  ++this->nInNetInvalid;
491  NFD_LOG_FACE_WARN("received NextHopFaceId with Nack: DROP");
492  return;
493  }
494 
495  if (firstPkt.has<lp::CachePolicyField>()) {
496  ++this->nInNetInvalid;
497  NFD_LOG_FACE_WARN("received CachePolicy with Nack: DROP");
498  return;
499  }
500 
501  if (firstPkt.has<lp::IncomingFaceIdField>()) {
502  NFD_LOG_FACE_WARN("received IncomingFaceId: IGNORE");
503  }
504 
505  if (firstPkt.has<lp::CongestionMarkField>()) {
506  nack.setTag(make_shared<lp::CongestionMarkTag>(firstPkt.get<lp::CongestionMarkField>()));
507  }
508 
509  if (firstPkt.has<lp::NonDiscoveryField>()) {
510  ++this->nInNetInvalid;
511  NFD_LOG_FACE_WARN("received NonDiscovery with Nack: DROP");
512  return;
513  }
514 
515  if (firstPkt.has<lp::PrefixAnnouncementField>()) {
516  ++this->nInNetInvalid;
517  NFD_LOG_FACE_WARN("received PrefixAnnouncement with Nack: DROP");
518  return;
519  }
520 
521  this->receiveNack(nack, endpointId);
522 }
523 
524 } // namespace face
525 } // namespace nfd
ndn::lp::Packet
Definition: packet.hpp:31
ndn::tlv::sizeOfNonNegativeInteger
constexpr size_t sizeOfNonNegativeInteger(uint64_t integer) noexcept
Get the number of bytes necessary to hold the value of integer encoded as nonNegativeInteger.
Definition: tlv.hpp:502
nfd::face::MTU_UNLIMITED
const ssize_t MTU_UNLIMITED
indicates the transport has no limit on payload size
Definition: transport.hpp:91
nonstd::optional_lite::std11::move
T & move(T &t)
Definition: optional.hpp:421
ndn::tlv::Interest
@ Interest
Definition: tlv.hpp:65
nfd::face::GenericLinkService::setOptions
void setOptions(const Options &options)
sets Options used by GenericLinkService
Definition: generic-link-service.cpp:57
nfd::face::LinkService::receiveData
void receiveData(const Data &data, const EndpointId &endpoint)
delivers received Data to forwarding
Definition: link-service.cpp:104
ndn::lp::Packet::add
Packet & add(const typename FIELD::ValueType &value)
add a FIELD with value
Definition: packet.hpp:148
ndn::lp::Packet::has
NDN_CXX_NODISCARD bool has() const
Definition: packet.hpp:74
nfd::face::GenericLinkService::Options::allowCongestionMarking
bool allowCongestionMarking
enables send queue congestion detection and marking
Definition: generic-link-service.hpp:134
nfd::face::LpReliability::processIncomingPacket
void processIncomingPacket(const lp::Packet &pkt)
extract and parse all Acks and add Ack for contained Fragment (if any) to AckQueue
Definition: lp-reliability.cpp:97
ndn::SimpleTag
provides a tag type for simple types
Definition: tag.hpp:59
ndn::time::steady_clock::now
static time_point now() noexcept
Definition: time.cpp:80
nfd::face::GenericLinkService::Options::allowSelfLearning
bool allowSelfLearning
enables self-learning forwarding support
Definition: generic-link-service.hpp:154
nfd::face::LpReliability::handleOutgoing
void handleOutgoing(std::vector< lp::Packet > &frags, lp::Packet &&pkt, bool isInterest)
observe outgoing fragment(s) of a network packet and store for potential retransmission
Definition: lp-reliability.cpp:63
nfd::face::GenericLinkService::Options::allowFragmentation
bool allowFragmentation
enables fragmentation
Definition: generic-link-service.hpp:114
nfd::face::LinkService::notifyDroppedInterest
void notifyDroppedInterest(const Interest &packet)
Definition: link-service.cpp:124
ndn::TagHost::setTag
void setTag(shared_ptr< T > tag) const
set a tag item
Definition: tag-host.hpp:79
nfd::face::GenericLinkServiceCounters::nReassembling
SizeCounter< LpReassembler > nReassembling
count of network-layer packets currently being reassembled
Definition: generic-link-service.hpp:62
ndn::TagHost::getTag
shared_ptr< T > getTag() const
get a tag item
Definition: tag-host.hpp:66
NFD_LOG_FACE_DEBUG
#define NFD_LOG_FACE_DEBUG(msg)
Log a message at DEBUG level.
Definition: face-common.hpp:136
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::LinkService::receiveInterest
void receiveInterest(const Interest &interest, const EndpointId &endpoint)
delivers received Interest to forwarding
Definition: link-service.cpp:94
nfd::face::LpReliability::setOptions
void setOptions(const Options &options)
set options for reliability
Definition: lp-reliability.cpp:45
nfd::face::LpReliability::piggyback
void piggyback(lp::Packet &pkt, ssize_t mtu)
called by GenericLinkService to attach Acks onto an outgoing LpPacket
Definition: lp-reliability.cpp:154
pit-token.hpp
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
ndn::lp::Packet::set
Packet & set(const typename FIELD::ValueType &value)
remove all occurrences of FIELD, and add a FIELD with value
Definition: packet.hpp:136
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
ndn::lp::Nack::setHeader
Nack & setHeader(const NackHeader &header)
Definition: nack.hpp:75
ndn::time
Definition: time-custom-clock.hpp:28
nfd::face::GenericLinkService::Options::allowLocalFields
bool allowLocalFields
enables encoding of IncomingFaceId, and decoding of NextHopFaceId and CachePolicy
Definition: generic-link-service.hpp:110
NFD_LOG_FACE_TRACE
#define NFD_LOG_FACE_TRACE(msg)
Log a message at TRACE level.
Definition: face-common.hpp:133
ndn::lp::FieldDecl
Declare a field.
Definition: field-decl.hpp:180
nfd::face::GenericLinkServiceCounters::nInNetInvalid
PacketCounter nInNetInvalid
count of invalid reassembled network-layer packets dropped
Definition: generic-link-service.hpp:70
ndn::tlv::sizeOfVarNumber
constexpr size_t sizeOfVarNumber(uint64_t number) noexcept
Get the number of bytes necessary to hold the value of number encoded as VAR-NUMBER.
Definition: tlv.hpp:450
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::nInLpInvalid
PacketCounter nInLpInvalid
count of invalid LpPackets dropped before reassembly
Definition: generic-link-service.hpp:58
nfd::face::LinkService::getTransport
const Transport * getTransport() const
Definition: link-service.hpp:223
nfd::face::LpReassembler::setOptions
void setOptions(const Options &options)
set options for reassembler
Definition: lp-reassembler.hpp:132
ndn::lp::PitToken
represent a PIT token field
Definition: pit-token.hpp:35
ndn::tlv::Data
@ Data
Definition: tlv.hpp:66
nfd::face::GenericLinkService
GenericLinkService is a LinkService that implements the NDNLPv2 protocol.
Definition: generic-link-service.hpp:96
ndn::lp::Nack::getHeader
const NackHeader & getHeader() const
Definition: nack.hpp:63
nfd::face::LpReliability::RESERVED_HEADER_SPACE
static constexpr size_t RESERVED_HEADER_SPACE
TxSequence TLV-TYPE (3 octets) + TLV-LENGTH (1 octet) + lp::Sequence (8 octets)
Definition: lp-reliability.hpp:198
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::face::LpFragmenter::setOptions
void setOptions(const Options &options)
set options for fragmenter
Definition: lp-fragmenter.cpp:67
nfd::face::LpFragmenter::fragmentPacket
std::tuple< bool, std::vector< lp::Packet > > fragmentPacket(const lp::Packet &packet, size_t mtu)
fragments a network-layer packet into link-layer packets
Definition: lp-fragmenter.cpp:79
nfd::face::GenericLinkServiceCounters::nOutOverMtu
PacketCounter nOutOverMtu
count of outgoing LpPackets dropped due to exceeding MTU limit
Definition: generic-link-service.hpp:54
ndn::lp::Nack
represents a Network Nack
Definition: nack.hpp:39
nfd::face::LpReliability::Options::isEnabled
bool isEnabled
enables link-layer reliability
Definition: lp-reliability.hpp:52
nfd::face::LpReassembler::receiveFragment
std::tuple< bool, Block, lp::Packet > receiveFragment(EndpointId remoteEndpoint, const lp::Packet &packet)
adds received fragment to the buffer
Definition: lp-reassembler.cpp:44
nfd::face::CONGESTION_MARK_SIZE
constexpr size_t CONGESTION_MARK_SIZE
Definition: generic-link-service.cpp:38
nfd::face::GenericLinkServiceCounters::nCongestionMarked
PacketCounter nCongestionMarked
count of outgoing LpPackets that were marked with congestion marks
Definition: generic-link-service.hpp:88
tags.hpp
nfd::face::LinkService::sendPacket
void sendPacket(const Block &packet, const EndpointId &endpoint)
send a lower-layer packet via Transport to endpoint
Definition: link-service.hpp:247
ndn::PacketBase
base class to allow simple management of packet tags
Definition: packet-base.hpp:32
ndn::Interest::wireEncode
size_t wireEncode(EncodingImpl< TAG > &encoder) const
Prepend wire encoding to encoder according to NDN Packet Format v0.3.
Definition: interest.cpp:87
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
nfd::face::LinkService::receiveNack
void receiveNack(const lp::Nack &nack, const EndpointId &endpoint)
delivers received Nack to forwarding
Definition: link-service.cpp:114
NFD_LOG_FACE_WARN
#define NFD_LOG_FACE_WARN(msg)
Log a message at WARN level.
Definition: face-common.hpp:142
ndn::lp::Nack::getInterest
const Interest & getInterest() const
Definition: nack.hpp:51
ndn::lp::Packet::get
FIELD::ValueType get(size_t index=0) const
Definition: packet.hpp:96
NFD_LOG_INIT
#define NFD_LOG_INIT(name)
Definition: logger.hpp:31
nfd::face::LpReliability::onDroppedInterest
signal::Signal< LpReliability, Interest > onDroppedInterest
signals on Interest dropped by reliability system for exceeding allowed number of retx
Definition: lp-reliability.hpp:72
nfd::face::Transport::getSendQueueLength
virtual ssize_t getSendQueueLength()
Definition: transport.hpp:257
nfd::face::LpReassembler::beforeTimeout
signal::Signal< LpReassembler, EndpointId, size_t > beforeTimeout
signals before a partial packet is dropped due to timeout
Definition: lp-reassembler.hpp:96
nfd::face::Transport::getMtu
ssize_t getMtu() const
Definition: transport.hpp:442
ndn::lp::tlv::CongestionMark
@ CongestionMark
Definition: tlv.hpp:48