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>
39 class GenericLinkService;
50 tlv::sizeOfVarNumber(
sizeof(lp::Sequence)) +
97 handleOutgoing(std::vector<lp::Packet>& frags, lp::Packet&& pkt,
bool isInterest);
116 using UnackedFrags = std::map<lp::Sequence, UnackedFrag>;
124 assignTxSequence(lp::Packet& frag);
140 std::vector<lp::Sequence>
141 findLostLpPackets(UnackedFrags::iterator ackIt);
146 std::vector<lp::Sequence>
147 onLpPacketLost(lp::Sequence txSeq,
bool isTimeout);
157 onLpPacketAcknowledged(UnackedFrags::iterator fragIt);
167 deleteUnackedFrag(UnackedFrags::iterator fragIt);
177 UnackedFrag(lp::Packet pkt);
181 scheduler::ScopedEventId rtoTimer;
182 time::steady_clock::time_point sendTime;
184 size_t nGreaterSeqAcks;
185 shared_ptr<NetPkt> netPkt;
194 NetPkt(lp::Packet&& pkt,
bool isInterest);
197 std::vector<UnackedFrags::iterator> unackedFrags;
204 GenericLinkService* m_linkService;
205 UnackedFrags m_unackedFrags;
210 UnackedFrags::iterator m_firstUnackedFrag;
211 std::queue<lp::Sequence> m_ackQueue;
212 std::map<lp::Sequence, time::steady_clock::time_point> m_recentRecvSeqs;
213 std::queue<lp::Sequence> m_recentRecvSeqsQueue;
214 lp::Sequence m_lastTxSeqNo;
215 scheduler::ScopedEventId m_idleAckTimer;
216 ndn::util::RttEstimator m_rttEst;
220 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
Signals on Interest dropped by reliability system for exceeding allowed number of retx.
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)
const GenericLinkService * getLinkService() const
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.
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...