provides for reliable sending and receiving of link-layer packets More...
#include <lp-reliability.hpp>
Classes | |
class | NetPkt |
contains a network-layer packet with unacknowledged fragments More... | |
struct | Options |
Public Types | |
using | UnackedFrags = std::map< lp::Sequence, UnackedFrag > |
Public Member Functions | |
LpReliability (const Options &options, GenericLinkService *linkService) | |
void | setOptions (const Options &options) |
set options for reliability More... | |
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 More... | |
bool | processIncomingPacket (const lp::Packet &pkt) |
extract and parse all Acks and add Ack for contained Fragment (if any) to AckQueue More... | |
void | piggyback (lp::Packet &pkt, ssize_t mtu) |
called by GenericLinkService to attach Acks onto an outgoing LpPacket More... | |
void | startIdleAckTimer () |
start the idle Ack timer More... | |
std::vector< lp::Sequence > | findLostLpPackets (UnackedFrags::iterator ackIt) |
find and mark as lost fragments where a configurable number of Acks (m_options.seqNumLossThreshold ) have been received for greater TxSequence numbers More... | |
std::vector< lp::Sequence > | onLpPacketLost (lp::Sequence txSeq, bool isTimeout) |
resend (or give up on) a lost fragment More... | |
void | onLpPacketAcknowledged (UnackedFrags::iterator fragIt) |
remove the fragment with the given sequence number from the map of unacknowledged fragments, as well as its associated network packet (if any) More... | |
void | deleteUnackedFrag (UnackedFrags::iterator fragIt) |
delete a fragment from UnackedFrags and advance acknowledge window if necessary More... | |
Static Public Attributes | |
static constexpr size_t | RESERVED_HEADER_SPACE |
TxSequence TLV-TYPE (3 octets) + TLV-LENGTH (1 octet) + lp::Sequence (8 octets) More... | |
provides for reliable sending and receiving of link-layer packets
Definition at line 45 of file lp-reliability.hpp.
using nfd::face::LpReliability::UnackedFrags = std::map<lp::Sequence, UnackedFrag> |
Definition at line 111 of file lp-reliability.hpp.
nfd::face::LpReliability::LpReliability | ( | const Options & | options, |
GenericLinkService * | linkService | ||
) |
Definition at line 36 of file lp-reliability.cpp.
References m_linkService.
void nfd::face::LpReliability::setOptions | ( | const Options & | options | ) |
set options for reliability
Definition at line 47 of file lp-reliability.cpp.
References ndn::detail::ScopedCancelHandle< HandleT >::cancel(), nfd::face::GenericLinkService, nfd::face::LpReliability::Options::idleAckTimerPeriod, nfd::face::LpReliability::Options::isEnabled, and m_idleAckTimer.
const GenericLinkService * nfd::face::LpReliability::getLinkService | ( | ) | const |
This is only used for logging, and may be nullptr.
Definition at line 59 of file lp-reliability.cpp.
References m_linkService.
void nfd::face::LpReliability::handleOutgoing | ( | std::vector< lp::Packet > & | frags, |
lp::Packet && | pkt, | ||
bool | isInterest | ||
) |
observe outgoing fragment(s) of a network packet and store for potential retransmission
frags | fragments of network packet |
pkt | encapsulated network packet |
isInterest | whether the network packet is an Interest |
Definition at line 65 of file lp-reliability.cpp.
References ndn::util::RttEstimator::getEstimatedRto(), nfd::getScheduler(), m_firstUnackedFrag, m_rttEst, m_unackedFrags, nonstd::optional_lite::std11::move(), netPkt, NFD_LOG_FACE_TRACE, ndn::time::steady_clock::now(), onLpPacketLost(), pkt, and sendTime.
bool nfd::face::LpReliability::processIncomingPacket | ( | const lp::Packet & | pkt | ) |
extract and parse all Acks and add Ack for contained Fragment (if any) to AckQueue
pkt | incoming LpPacket |
Definition at line 107 of file lp-reliability.cpp.
References ndn::util::RttEstimator::addMeasurement(), findLostLpPackets(), ndn::lp::Packet::get(), ndn::util::RttEstimator::getEstimatedRto(), ndn::lp::Packet::has(), ndn::lp::Packet::list(), m_ackQueue, m_recentRecvSeqs, m_recentRecvSeqsQueue, m_rttEst, m_unackedFrags, NFD_LOG_FACE_DEBUG, NFD_LOG_FACE_TRACE, ndn::time::steady_clock::now(), onLpPacketAcknowledged(), onLpPacketLost(), and startIdleAckTimer().
void nfd::face::LpReliability::piggyback | ( | lp::Packet & | pkt, |
ssize_t | mtu | ||
) |
called by GenericLinkService to attach Acks onto an outgoing LpPacket
pkt | outgoing LpPacket to attach Acks to |
mtu | MTU of the Transport |
Definition at line 193 of file lp-reliability.cpp.
References ndn::lp::tlv::Ack, ndn::lp::Packet::add(), ndn::lp::tlv::LpPacket, m_ackQueue, m_firstUnackedFrag, m_lastTxSeqNo, m_unackedFrags, ndn::MAX_NDN_PACKET_SIZE, nfd::face::MTU_UNLIMITED, NDN_THROW, NFD_LOG_FACE_TRACE, ndn::lp::Packet::set(), ndn::Block::size(), ndn::tlv::sizeOfVarNumber(), ndn::Block::type(), and ndn::lp::Packet::wireEncode().
void nfd::face::LpReliability::startIdleAckTimer | ( | ) |
start the idle Ack timer
This timer requests an IDLE packet to acknowledge pending fragments not already piggybacked. It is called regularly on a period configured in Options::idleAckTimerPeriod. This allows Acks to be returned to the sender, even if the link goes idle.
Definition at line 236 of file lp-reliability.cpp.
References nfd::getScheduler(), and m_idleAckTimer.
Referenced by processIncomingPacket().
std::vector< lp::Sequence > nfd::face::LpReliability::findLostLpPackets | ( | UnackedFrags::iterator | ackIt | ) |
find and mark as lost fragments where a configurable number of Acks (m_options.seqNumLossThreshold
) have been received for greater TxSequence numbers
ackIt | iterator pointing to acknowledged fragment |
Definition at line 251 of file lp-reliability.cpp.
References m_firstUnackedFrag, m_unackedFrags, and NFD_LOG_FACE_TRACE.
Referenced by processIncomingPacket().
std::vector< lp::Sequence > nfd::face::LpReliability::onLpPacketLost | ( | lp::Sequence | txSeq, |
bool | isTimeout | ||
) |
resend (or give up on) a lost fragment
Definition at line 278 of file lp-reliability.cpp.
References deleteUnackedFrag(), ndn::util::RttEstimator::getEstimatedRto(), nfd::getScheduler(), ndn::tlv::Interest, m_firstUnackedFrag, m_linkService, m_rttEst, m_unackedFrags, netPkt, NFD_LOG_FACE_DEBUG, NFD_LOG_FACE_TRACE, and onDroppedInterest.
Referenced by handleOutgoing(), and processIncomingPacket().
void nfd::face::LpReliability::onLpPacketAcknowledged | ( | UnackedFrags::iterator | fragIt | ) |
remove the fragment with the given sequence number from the map of unacknowledged fragments, as well as its associated network packet (if any)
fragIt | iterator to acknowledged fragment |
If the given TxSequence marks the beginning of the send window, the window will be incremented. If the associated network packet has been fully transmitted, it will be removed.
Definition at line 364 of file lp-reliability.cpp.
References deleteUnackedFrag(), m_linkService, and netPkt.
Referenced by processIncomingPacket().
void nfd::face::LpReliability::deleteUnackedFrag | ( | UnackedFrags::iterator | fragIt | ) |
delete a fragment from UnackedFrags and advance acknowledge window if necessary
fragIt | iterator to an UnackedFrag, must be dereferencable |
Definition at line 388 of file lp-reliability.cpp.
References m_firstUnackedFrag, m_unackedFrags, nonstd::optional_lite::std11::move(), nGreaterSeqAcks, ndn::time::steady_clock::now(), pkt, retxCount, and sendTime.
Referenced by onLpPacketAcknowledged(), and onLpPacketLost().
signal::Signal<LpReliability, Interest> nfd::face::LpReliability::onDroppedInterest |
signals on Interest dropped by reliability system for exceeding allowed number of retx
Definition at line 72 of file lp-reliability.hpp.
Referenced by onLpPacketLost().
NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE nfd::face::LpReliability::__pad0__ |
Definition at line 109 of file lp-reliability.hpp.
NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE nfd::face::LpReliability::__pad1__ |
Definition at line 120 of file lp-reliability.hpp.
NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE nfd::face::LpReliability::__pad2__ |
Definition at line 172 of file lp-reliability.hpp.
lp::Packet nfd::face::LpReliability::pkt |
Definition at line 175 of file lp-reliability.hpp.
Referenced by deleteUnackedFrag(), and handleOutgoing().
scheduler::ScopedEventId nfd::face::LpReliability::rtoTimer |
Definition at line 176 of file lp-reliability.hpp.
time::steady_clock::TimePoint nfd::face::LpReliability::sendTime |
Definition at line 177 of file lp-reliability.hpp.
Referenced by deleteUnackedFrag(), and handleOutgoing().
size_t nfd::face::LpReliability::retxCount |
Definition at line 178 of file lp-reliability.hpp.
Referenced by deleteUnackedFrag().
size_t nfd::face::LpReliability::nGreaterSeqAcks |
number of Acks received for sequences greater than this fragment
Definition at line 179 of file lp-reliability.hpp.
Referenced by deleteUnackedFrag().
shared_ptr<NetPkt> nfd::face::LpReliability::netPkt |
Definition at line 180 of file lp-reliability.hpp.
Referenced by handleOutgoing(), onLpPacketAcknowledged(), and onLpPacketLost().
|
static |
TxSequence TLV-TYPE (3 octets) + TLV-LENGTH (1 octet) + lp::Sequence (8 octets)
Definition at line 199 of file lp-reliability.hpp.
NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE nfd::face::LpReliability::__pad3__ |
Definition at line 204 of file lp-reliability.hpp.
GenericLinkService* nfd::face::LpReliability::m_linkService |
Definition at line 205 of file lp-reliability.hpp.
Referenced by getLinkService(), LpReliability(), onLpPacketAcknowledged(), and onLpPacketLost().
UnackedFrags nfd::face::LpReliability::m_unackedFrags |
Definition at line 206 of file lp-reliability.hpp.
Referenced by deleteUnackedFrag(), findLostLpPackets(), handleOutgoing(), onLpPacketLost(), piggyback(), and processIncomingPacket().
UnackedFrags::iterator nfd::face::LpReliability::m_firstUnackedFrag |
An iterator that points to the first unacknowledged fragment in the current window.
The window can wrap around so that the beginning of the window is at a TxSequence greater than other fragments in the window. When the window is moved past the last item in the iterator, the first fragment in the map will become the start of the window.
Definition at line 212 of file lp-reliability.hpp.
Referenced by deleteUnackedFrag(), findLostLpPackets(), handleOutgoing(), onLpPacketLost(), and piggyback().
std::queue<lp::Sequence> nfd::face::LpReliability::m_ackQueue |
Definition at line 213 of file lp-reliability.hpp.
Referenced by piggyback(), and processIncomingPacket().
std::map<lp::Sequence, time::steady_clock::TimePoint> nfd::face::LpReliability::m_recentRecvSeqs |
Definition at line 214 of file lp-reliability.hpp.
Referenced by processIncomingPacket().
std::queue<lp::Sequence> nfd::face::LpReliability::m_recentRecvSeqsQueue |
Definition at line 215 of file lp-reliability.hpp.
Referenced by processIncomingPacket().
lp::Sequence nfd::face::LpReliability::m_lastTxSeqNo |
Definition at line 216 of file lp-reliability.hpp.
Referenced by piggyback().
scheduler::ScopedEventId nfd::face::LpReliability::m_idleAckTimer |
Definition at line 217 of file lp-reliability.hpp.
Referenced by setOptions(), and startIdleAckTimer().
ndn::util::RttEstimator nfd::face::LpReliability::m_rttEst |
Definition at line 218 of file lp-reliability.hpp.
Referenced by handleOutgoing(), onLpPacketLost(), and processIncomingPacket().