26 #ifndef NFD_DAEMON_FACE_LP_RELIABILITY_HPP
27 #define NFD_DAEMON_FACE_LP_RELIABILITY_HPP
31 #include <ndn-cxx/lp/packet.hpp>
32 #include <ndn-cxx/lp/sequence.hpp>
33 #include <ndn-cxx/util/rtt-estimator.hpp>
34 #include <ndn-cxx/util/scheduler.hpp>
41 class GenericLinkService;
52 tlv::sizeOfVarNumber(
sizeof(lp::Sequence)) +
105 handleOutgoing(std::vector<lp::Packet>& frags, lp::Packet&& pkt,
bool isInterest);
124 using UnackedFrags = std::map<lp::Sequence, UnackedFrag>;
132 assignTxSequence(lp::Packet& frag);
148 std::vector<lp::Sequence>
149 findLostLpPackets(UnackedFrags::iterator ackIt);
154 std::vector<lp::Sequence>
155 onLpPacketLost(lp::Sequence txSeq,
bool isTimeout);
165 onLpPacketAcknowledged(UnackedFrags::iterator fragIt);
175 deleteUnackedFrag(UnackedFrags::iterator fragIt);
185 UnackedFrag(lp::Packet p)
192 ndn::scheduler::ScopedEventId rtoTimer;
193 time::steady_clock::time_point sendTime = time::steady_clock::now();
194 size_t retxCount = 0;
195 size_t nGreaterSeqAcks = 0;
196 shared_ptr<NetPkt> netPkt;
205 NetPkt(lp::Packet&& p,
bool isInterest)
207 , isInterest(isInterest)
212 std::vector<UnackedFrags::iterator> unackedFrags;
215 bool didRetx =
false;
219 GenericLinkService* m_linkService =
nullptr;
220 UnackedFrags m_unackedFrags;
225 UnackedFrags::iterator m_firstUnackedFrag;
226 std::queue<lp::Sequence> m_ackQueue;
227 std::map<lp::Sequence, time::steady_clock::time_point> m_recentRecvSeqs;
228 std::queue<lp::Sequence> m_recentRecvSeqsQueue;
229 lp::Sequence m_lastTxSeqNo;
230 ndn::scheduler::ScopedEventId m_idleAckTimer;
231 ndn::util::RttEstimator m_rttEst;
235 operator<<(std::ostream& os,
const FaceLogHelper<LpReliability>& flh);
GenericLinkService is a LinkService that implements the NDNLPv2 protocol.
Provides for reliable sending and receiving of link-layer packets.
signal::Signal< LpReliability, Interest > onDroppedInterest
Called when an Interest is dropped for exceeding the allowed number of retransmissions.
LpReliability(const Options &options, GenericLinkService *linkService)
void piggyback(lp::Packet &pkt, ssize_t mtu)
Called by GenericLinkService to attach Acks onto an outgoing LpPacket.
static constexpr size_t RESERVED_HEADER_SPACE
TxSequence TLV-TYPE (3 octets) + TLV-LENGTH (1 octet) + lp::Sequence (8 octets)
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.
bool processIncomingPacket(const lp::Packet &pkt)
Extract and parse all Acks and add Ack for contained Fragment (if any) to AckQueue.
const GenericLinkService * getLinkService() const noexcept
Returns the GenericLinkService that owns this instance.
void setOptions(const Options &options)
Set options for reliability.
#define NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE
std::ostream & operator<<(std::ostream &os, const FaceLogHelper< Face > &flh)
time::nanoseconds idleAckTimerPeriod
Period between sending pending Acks in an IDLE packet.
bool isEnabled
Enables link-layer reliability.
size_t maxRetx
Maximum number of retransmissions for an LpPacket.
size_t seqNumLossThreshold
A fragment is considered lost if this number of fragments with greater sequence numbers are acknowled...