22 #ifndef NDN_CXX_UTIL_SEGMENT_FETCHER_HPP
23 #define NDN_CXX_UTIL_SEGMENT_FETCHER_HPP
148 static shared_ptr<SegmentFetcher>
163 class PendingSegment;
168 shouldStop(
const weak_ptr<SegmentFetcher>& weakSelf);
171 fetchFirstSegment(
const Interest& baseInterest,
bool isRetransmission);
174 fetchSegmentsInWindow(
const Interest& origInterest);
177 sendInterest(uint64_t segNum,
const Interest& interest,
bool isRetransmission);
180 afterSegmentReceivedCb(
const Interest& origInterest,
const Data& data,
181 const weak_ptr<SegmentFetcher>& weakSelf);
184 afterValidationSuccess(
const Data& data,
const Interest& origInterest,
185 std::map<uint64_t, PendingSegment>::iterator pendingSegmentIt,
186 const weak_ptr<SegmentFetcher>& weakSelf);
189 afterValidationFailure(
const Data& data,
191 const weak_ptr<SegmentFetcher>& weakSelf);
195 const weak_ptr<SegmentFetcher>& weakSelf);
198 afterTimeoutCb(
const Interest& origInterest,
199 const weak_ptr<SegmentFetcher>& weakSelf);
202 afterNackOrTimeout(
const Interest& origInterest);
214 signalError(uint32_t code,
const std::string& msg);
217 updateRetransmittedSegment(uint64_t segmentNum,
222 cancelExcessInFlightSegments();
225 checkAllSegmentsReceived();
277 enum class SegmentState {
293 static constexpr
double MIN_SSTHRESH = 2.0;
295 shared_ptr<SegmentFetcher> m_this;
301 RttEstimator m_rttEstimator;
304 std::queue<uint64_t> m_retxQueue;
305 Name m_versionedDataName;
306 uint64_t m_nextSegmentNum = 0;
309 int64_t m_nSegmentsInFlight = 0;
310 int64_t m_nSegments = 0;
311 uint64_t m_highInterest = 0;
312 uint64_t m_highData = 0;
313 uint64_t m_recPoint = 0;
314 int64_t m_nReceived = 0;
315 int64_t m_nBytesReceived = 0;
316 uint64_t m_nextSegmentInOrder = 0;
318 std::map<uint64_t, Buffer> m_segmentBuffer;
319 std::map<uint64_t, PendingSegment> m_pendingSegments;
320 std::set<uint64_t> m_receivedSegments;
Represents a Data packet.
Provide a communication channel with local or remote NDN forwarder.
Represents an Interest packet.
Represents an absolute name.
Handle for a pending Interest.
Represents a Network Nack.
A handle for a scheduled event.
Generic time-based scheduler.
Validation error code and optional detailed error message.
Interface for validating data and interest packets.
bool useConstantInterestTimeout
if true, Interest timeout is kept at maxTimeout
double mdCoef
multiplicative decrease coefficient
double initSsthresh
initial slow start threshold
RttEstimator::Options rttOptions
options for RTT estimator
double aiStep
additive increase step (in segments)
double initCwnd
initial congestion window size
bool disableCwa
disable Conservative Window Adaptation
bool resetCwndToInit
reduce cwnd to initCwnd when loss event occurs
time::milliseconds interestLifetime
lifetime of sent Interests - independent of Interest timeout
bool useConstantCwnd
if true, window size is kept at initCwnd
bool inOrder
true for 'in order' mode, false for 'block' mode
size_t flowControlWindow
maximum number of segments stored in the reorder buffer
bool ignoreCongMarks
disable window decrease after congestion mark received
time::milliseconds maxTimeout
maximum allowed time between successful receipt of segments
Utility class to fetch the latest version of a segmented object.
Signal< SegmentFetcher > onInOrderComplete
Emitted on successful retrieval of all segments in 'in order' mode.
static shared_ptr< SegmentFetcher > start(Face &face, const Interest &baseInterest, security::Validator &validator, const Options &options=Options())
Initiates segment fetching.
Signal< SegmentFetcher, ConstBufferPtr > onComplete
Emitted upon successful retrieval of the complete object (all segments).
Signal< SegmentFetcher, ConstBufferPtr > onInOrderData
Emitted after each data segment in segment order has been validated.
Signal< SegmentFetcher, Data > afterSegmentValidated
Emitted whenever a received data segment has been successfully validated.
ErrorCode
Error codes passed to onError.
@ INTEREST_TIMEOUT
Retrieval timed out because the maximum timeout between the successful receipt of segments was exceed...
@ DATA_HAS_NO_SEGMENT
One of the retrieved Data packets lacked a segment number in the last Name component (excl....
@ FINALBLOCKID_NOT_SEGMENT
A received FinalBlockId did not contain a segment component.
@ SEGMENT_VALIDATION_FAIL
One of the retrieved segments failed user-provided validation.
@ NACK_ERROR
An unrecoverable Nack was received during retrieval.
Signal< SegmentFetcher > afterSegmentNacked
Emitted whenever an Interest for a data segment is nacked.
void stop()
Stops fetching.
Signal< SegmentFetcher, uint32_t, std::string > onError
Emitted when the retrieval could not be completed due to an error.
Signal< SegmentFetcher, Data > afterSegmentReceived
Emitted whenever a data segment received.
Signal< SegmentFetcher > afterSegmentTimedOut
Emitted whenever an Interest for a data segment times out.
Provides a lightweight signal / event system.
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
boost::chrono::milliseconds milliseconds