Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Eric Newberry | 41aba10 | 2017-11-01 16:42:13 -0700 | [diff] [blame] | 2 | /* |
Davide Pesavento | 91c15c8 | 2024-01-15 17:14:23 -0500 | [diff] [blame] | 3 | * Copyright (c) 2014-2024, Regents of the University of California, |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 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 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 29 | #include "link-service.hpp" |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 30 | #include "lp-fragmenter.hpp" |
| 31 | #include "lp-reassembler.hpp" |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 32 | #include "lp-reliability.hpp" |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 33 | |
Davide Pesavento | 2c9d2ca | 2024-01-27 16:36:51 -0500 | [diff] [blame] | 34 | #include <limits> |
| 35 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 36 | namespace nfd::face { |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 37 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 38 | /** |
| 39 | * \brief Counters provided by GenericLinkService. |
| 40 | * \note The type name GenericLinkServiceCounters is an implementation detail. |
| 41 | * Use GenericLinkService::Counters in public API. |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 42 | */ |
| 43 | class GenericLinkServiceCounters : public virtual LinkService::Counters |
| 44 | { |
| 45 | public: |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 46 | /// Count of failed fragmentations. |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 47 | PacketCounter nFragmentationErrors; |
| 48 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 49 | /** |
| 50 | * \brief Count of outgoing LpPackets dropped due to exceeding MTU limit. |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 51 | * |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 52 | * If this counter is non-zero, the operator should enable fragmentation. |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 53 | */ |
| 54 | PacketCounter nOutOverMtu; |
| 55 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 56 | /// Count of invalid LpPackets dropped before reassembly. |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 57 | PacketCounter nInLpInvalid; |
| 58 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 59 | /// Count of network-layer packets currently being reassembled. |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 60 | SizeCounter<LpReassembler> nReassembling; |
| 61 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 62 | /// Count of dropped partial network-layer packets due to reassembly timeout. |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 63 | PacketCounter nReassemblyTimeouts; |
| 64 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 65 | /// Count of invalid reassembled network-layer packets dropped. |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 66 | PacketCounter nInNetInvalid; |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 67 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 68 | /// Count of network-layer packets that did not require retransmission of a fragment. |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 69 | PacketCounter nAcknowledged; |
| 70 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 71 | /** |
| 72 | * \brief Count of network-layer packets that had at least one fragment retransmitted, |
| 73 | * but were eventually received in full. |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 74 | */ |
| 75 | PacketCounter nRetransmitted; |
| 76 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 77 | /** |
| 78 | * \brief Count of network-layer packets dropped because a fragment reached the maximum |
| 79 | * number of retransmissions. |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 80 | */ |
| 81 | PacketCounter nRetxExhausted; |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 82 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 83 | /// Count of LpPackets dropped due to duplicate Sequence numbers. |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 84 | PacketCounter nDuplicateSequence; |
| 85 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 86 | /// Count of outgoing LpPackets that were marked with congestion marks. |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 87 | PacketCounter nCongestionMarked; |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 88 | }; |
| 89 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 90 | /** |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 91 | * \brief Options that control the behavior of GenericLinkService. |
| 92 | * \note The type name GenericLinkServiceOptions is an implementation detail. |
| 93 | * Use GenericLinkService::Options in public API. |
| 94 | */ |
| 95 | struct GenericLinkServiceOptions |
| 96 | { |
| 97 | /** \brief Enables encoding of IncomingFaceId, and decoding of NextHopFaceId and CachePolicy. |
| 98 | */ |
| 99 | bool allowLocalFields = false; |
| 100 | |
| 101 | /** \brief Enables fragmentation. |
| 102 | */ |
| 103 | bool allowFragmentation = false; |
| 104 | |
| 105 | /** \brief Options for fragmentation. |
| 106 | */ |
| 107 | LpFragmenter::Options fragmenterOptions; |
| 108 | |
| 109 | /** \brief Enables reassembly. |
| 110 | */ |
| 111 | bool allowReassembly = false; |
| 112 | |
| 113 | /** \brief Options for reassembly. |
| 114 | */ |
| 115 | LpReassembler::Options reassemblerOptions; |
| 116 | |
| 117 | /** \brief Options for reliability. |
| 118 | */ |
| 119 | LpReliability::Options reliabilityOptions; |
| 120 | |
| 121 | /** \brief Enables send queue congestion detection and marking. |
| 122 | */ |
| 123 | bool allowCongestionMarking = false; |
| 124 | |
| 125 | /** \brief Starting value for congestion marking interval. |
| 126 | * |
| 127 | * Packets are marked if the queue size stays above THRESHOLD for at least one INTERVAL. |
| 128 | * |
| 129 | * The default value (100 ms) is taken from RFC 8289 (CoDel). |
| 130 | */ |
| 131 | time::nanoseconds baseCongestionMarkingInterval = 100_ms; |
| 132 | |
| 133 | /** \brief Default congestion threshold in bytes. |
| 134 | * |
| 135 | * Packets are marked if the queue size stays above THRESHOLD for at least one INTERVAL. |
| 136 | * |
| 137 | * The default value (64 KiB) works well for a queue capacity of 200 KiB. |
| 138 | */ |
| 139 | size_t defaultCongestionThreshold = 65536; |
| 140 | |
| 141 | /** \brief Enables self-learning forwarding support. |
| 142 | */ |
| 143 | bool allowSelfLearning = true; |
| 144 | |
| 145 | /** \brief Overrides the MTU provided by Transport. |
| 146 | * |
| 147 | * This MTU value will be used instead of the MTU provided by the transport if it is less than |
| 148 | * the transport MTU. However, it will not be utilized when the transport MTU is unlimited. |
| 149 | * |
| 150 | * Acceptable values for this option are values >= #MIN_MTU, which can be validated before |
| 151 | * being set with canOverrideMtuTo(). |
| 152 | */ |
| 153 | ssize_t overrideMtu = std::numeric_limits<ssize_t>::max(); |
| 154 | }; |
| 155 | |
| 156 | /** |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 157 | * \brief GenericLinkService is a LinkService that implements the NDNLPv2 protocol. |
| 158 | * \sa https://redmine.named-data.net/projects/nfd/wiki/NDNLPv2 |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 159 | */ |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 160 | class GenericLinkService NFD_FINAL_UNLESS_WITH_TESTS : public LinkService |
| 161 | , protected virtual GenericLinkServiceCounters |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 162 | { |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 163 | public: |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 164 | /** |
| 165 | * \brief %Counters provided by GenericLinkService. |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 166 | */ |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 167 | using Counters = GenericLinkServiceCounters; |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 168 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 169 | /** |
| 170 | * \brief %Options for GenericLinkService. |
| 171 | */ |
| 172 | using Options = GenericLinkServiceOptions; |
| 173 | |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 174 | explicit |
Davide Pesavento | e4b2238 | 2018-06-10 14:37:24 -0400 | [diff] [blame] | 175 | GenericLinkService(const Options& options = {}); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 176 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 177 | /** |
| 178 | * \brief Get the options used by GenericLinkService. |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 179 | */ |
| 180 | const Options& |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 181 | getOptions() const |
| 182 | { |
| 183 | return m_options; |
| 184 | } |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 185 | |
Davide Pesavento | e0b67df | 2024-02-17 19:14:24 -0500 | [diff] [blame^] | 186 | /** |
| 187 | * \brief Sets the options used by GenericLinkService. |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 188 | */ |
| 189 | void |
| 190 | setOptions(const Options& options); |
| 191 | |
Junxiao Shi | fab9e0d | 2017-02-02 06:04:59 +0000 | [diff] [blame] | 192 | const Counters& |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 193 | getCounters() const NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL |
| 194 | { |
| 195 | return *this; |
| 196 | } |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 197 | |
Eric Newberry | cb6551e | 2020-03-02 14:12:16 -0800 | [diff] [blame] | 198 | ssize_t |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 199 | getEffectiveMtu() const NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL; |
Eric Newberry | cb6551e | 2020-03-02 14:12:16 -0800 | [diff] [blame] | 200 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 201 | /** \brief Whether MTU can be overridden to the specified value. |
Eric Newberry | cb6551e | 2020-03-02 14:12:16 -0800 | [diff] [blame] | 202 | * |
| 203 | * If the transport MTU is unlimited, then this will always return false. |
| 204 | */ |
| 205 | bool |
| 206 | canOverrideMtuTo(ssize_t mtu) const; |
| 207 | |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 208 | NFD_PROTECTED_WITH_TESTS_ELSE_PRIVATE: // send path |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 209 | /** \brief Request an IDLE packet to transmit pending service fields. |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 210 | */ |
| 211 | void |
Teng Liang | f3bc3ae | 2020-06-08 10:19:25 -0700 | [diff] [blame] | 212 | requestIdlePacket(); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 213 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 214 | /** \brief Send an LpPacket. |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 215 | */ |
| 216 | void |
Teng Liang | f3bc3ae | 2020-06-08 10:19:25 -0700 | [diff] [blame] | 217 | sendLpPacket(lp::Packet&& pkt); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 218 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 219 | void |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 220 | doSendInterest(const Interest& interest) NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL; |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 221 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 222 | void |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 223 | doSendData(const Data& data) NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL; |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 224 | |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 225 | void |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 226 | doSendNack(const ndn::lp::Nack& nack) NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL; |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 227 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 228 | /** \brief Assign consecutive sequence numbers to LpPackets. |
Eric Newberry | 32f7eac | 2020-02-07 14:40:17 -0800 | [diff] [blame] | 229 | */ |
| 230 | void |
| 231 | assignSequences(std::vector<lp::Packet>& pkts); |
| 232 | |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 233 | private: // send path |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 234 | /** \brief Encode link protocol fields from tags onto an outgoing LpPacket. |
Eric Newberry | ee400b5 | 2016-11-24 14:12:48 +0000 | [diff] [blame] | 235 | * \param netPkt network-layer packet to extract tags from |
| 236 | * \param lpPacket LpPacket to add link protocol fields to |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 237 | */ |
Eric Newberry | ee400b5 | 2016-11-24 14:12:48 +0000 | [diff] [blame] | 238 | void |
Eric Newberry | 41aba10 | 2017-11-01 16:42:13 -0700 | [diff] [blame] | 239 | encodeLpFields(const ndn::PacketBase& netPkt, lp::Packet& lpPacket); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 240 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 241 | /** \brief Send a complete network layer packet. |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 242 | * \param pkt LpPacket containing a complete network layer packet |
Eric Newberry | 41aba10 | 2017-11-01 16:42:13 -0700 | [diff] [blame] | 243 | * \param isInterest whether the network layer packet is an Interest |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 244 | */ |
| 245 | void |
Teng Liang | f3bc3ae | 2020-06-08 10:19:25 -0700 | [diff] [blame] | 246 | sendNetPacket(lp::Packet&& pkt, bool isInterest); |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 247 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 248 | /** \brief If the send queue is found to be congested, add a congestion mark to the packet |
| 249 | * according to CoDel. |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 250 | * \sa https://tools.ietf.org/html/rfc8289 |
| 251 | */ |
| 252 | void |
| 253 | checkCongestionLevel(lp::Packet& pkt); |
| 254 | |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 255 | private: // receive path |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 256 | void |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 257 | doReceivePacket(const Block& packet, const EndpointId& endpoint) NFD_OVERRIDE_WITH_TESTS_ELSE_FINAL; |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 258 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 259 | /** \brief Decode incoming network-layer packet. |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 260 | * \param netPkt reassembled network-layer packet |
| 261 | * \param firstPkt LpPacket of first fragment |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 262 | * \param endpointId endpoint of peer who sent the packet |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 263 | * |
| 264 | * If decoding is successful, a receive signal is emitted; |
| 265 | * otherwise, a warning is logged. |
| 266 | */ |
| 267 | void |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 268 | decodeNetPacket(const Block& netPkt, const lp::Packet& firstPkt, const EndpointId& endpointId); |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 269 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 270 | /** \brief Decode incoming Interest. |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 271 | * \param netPkt reassembled network-layer packet; TLV-TYPE must be Interest |
| 272 | * \param firstPkt LpPacket of first fragment; must not have Nack field |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 273 | * \param endpointId endpoint of peer who sent the Interest |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 274 | * |
| 275 | * If decoding is successful, receiveInterest signal is emitted; |
| 276 | * otherwise, a warning is logged. |
| 277 | * |
| 278 | * \throw tlv::Error parse error in an LpHeader field |
| 279 | */ |
| 280 | void |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 281 | decodeInterest(const Block& netPkt, const lp::Packet& firstPkt, const EndpointId& endpointId); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 282 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 283 | /** \brief Decode incoming Interest. |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 284 | * \param netPkt reassembled network-layer packet; TLV-TYPE must be Data |
| 285 | * \param firstPkt LpPacket of first fragment |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 286 | * \param endpointId endpoint of peer who sent the Data |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 287 | * |
| 288 | * If decoding is successful, receiveData signal is emitted; |
| 289 | * otherwise, a warning is logged. |
| 290 | * |
| 291 | * \throw tlv::Error parse error in an LpHeader field |
| 292 | */ |
| 293 | void |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 294 | decodeData(const Block& netPkt, const lp::Packet& firstPkt, const EndpointId& endpointId); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 295 | |
Davide Pesavento | aa9e3b2 | 2022-10-21 17:00:07 -0400 | [diff] [blame] | 296 | /** \brief Decode incoming Interest. |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 297 | * \param netPkt reassembled network-layer packet; TLV-TYPE must be Interest |
| 298 | * \param firstPkt LpPacket of first fragment; must have Nack field |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 299 | * \param endpointId endpoint of peer who sent the Nack |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 300 | * |
| 301 | * If decoding is successful, receiveNack signal is emitted; |
| 302 | * otherwise, a warning is logged. |
| 303 | * |
| 304 | * \throw tlv::Error parse error in an LpHeader field |
| 305 | */ |
| 306 | void |
ashiqopu | 075bb7d | 2019-03-10 01:38:21 +0000 | [diff] [blame] | 307 | decodeNack(const Block& netPkt, const lp::Packet& firstPkt, const EndpointId& endpointId); |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 308 | |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 309 | NFD_PROTECTED_WITH_TESTS_ELSE_PRIVATE: |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 310 | Options m_options; |
Eric Newberry | 4c3e6b8 | 2015-11-10 16:48:42 -0700 | [diff] [blame] | 311 | LpFragmenter m_fragmenter; |
| 312 | LpReassembler m_reassembler; |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 313 | LpReliability m_reliability; |
Davide Pesavento | 91c15c8 | 2024-01-15 17:14:23 -0500 | [diff] [blame] | 314 | lp::Sequence m_lastSeqNo = static_cast<lp::Sequence>(-2); |
Eric Newberry | 185ab29 | 2017-03-28 06:45:39 +0000 | [diff] [blame] | 315 | |
Davide Pesavento | 264af77 | 2021-02-09 21:48:24 -0500 | [diff] [blame] | 316 | NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE: |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 317 | /// Time to mark next packet due to send queue congestion |
Davide Pesavento | 91c15c8 | 2024-01-15 17:14:23 -0500 | [diff] [blame] | 318 | time::steady_clock::time_point m_nextMarkTime = time::steady_clock::time_point::max(); |
| 319 | /// Number of marked packets in the current incident of congestion |
| 320 | size_t m_nMarkedSinceInMarkingState = 0; |
Eric Newberry | b49313d | 2017-12-24 20:22:27 -0700 | [diff] [blame] | 321 | |
Davide Pesavento | a3a7a4e | 2022-05-29 16:06:22 -0400 | [diff] [blame] | 322 | friend LpReliability; |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 323 | }; |
| 324 | |
Davide Pesavento | e422f9e | 2022-06-03 01:30:23 -0400 | [diff] [blame] | 325 | } // namespace nfd::face |
Eric Newberry | a98bf93 | 2015-09-21 00:58:47 -0700 | [diff] [blame] | 326 | |
Eric Newberry | 86d3187 | 2015-09-23 16:24:59 -0700 | [diff] [blame] | 327 | #endif // NFD_DAEMON_FACE_GENERIC_LINK_SERVICE_HPP |