28 #ifndef NDN_UTIL_SEGMENT_FETCHER_HPP 29 #define NDN_UTIL_SEGMENT_FETCHER_HPP 31 #include "../common.hpp" 32 #include "../face.hpp" 33 #include "../security/v2/validator.hpp" 107 typedef function<void (uint32_t code, const std::string& msg)>
ErrorCallback;
172 static shared_ptr<SegmentFetcher>
201 [[deprecated(
"use SegmentFetcher::start instead")]]
202 static shared_ptr<SegmentFetcher>
206 const CompleteCallback& completeCallback,
207 const ErrorCallback& errorCallback);
231 [[deprecated(
"use SegmentFetcher::start instead")]]
232 static shared_ptr<SegmentFetcher>
235 shared_ptr<security::v2::Validator> validator,
236 const CompleteCallback& completeCallback,
237 const ErrorCallback& errorCallback);
240 class PendingSegment;
245 fetchFirstSegment(
const Interest& baseInterest,
246 bool isRetransmission,
247 shared_ptr<SegmentFetcher>
self);
250 fetchSegmentsInWindow(
const Interest& origInterest, shared_ptr<SegmentFetcher>
self);
253 afterSegmentReceivedCb(
const Interest& origInterest,
255 shared_ptr<SegmentFetcher>
self);
257 afterValidationSuccess(
const Data& data,
259 std::map<uint64_t, PendingSegment>::iterator pendingSegmentIt,
260 shared_ptr<SegmentFetcher>
self);
263 afterValidationFailure(
const Data& data,
265 shared_ptr<SegmentFetcher>
self);
268 afterNackReceivedCb(
const Interest& origInterest,
270 shared_ptr<SegmentFetcher>
self);
273 afterTimeoutCb(
const Interest& origInterest,
274 shared_ptr<SegmentFetcher>
self);
277 afterNackOrTimeout(
const Interest& origInterest,
278 shared_ptr<SegmentFetcher>
self);
281 finalizeFetch(shared_ptr<SegmentFetcher>
self);
290 signalError(uint32_t code,
const std::string& msg);
293 updateRetransmittedSegment(uint64_t segmentNum,
294 const PendingInterestId* pendingInterest,
298 cancelExcessInFlightSegments();
301 checkAllSegmentsReceived();
317 Signal<SegmentFetcher, uint32_t, std::string>
onError;
340 enum class SegmentState {
351 const PendingInterestId* id;
356 static constexpr
double MIN_SSTHRESH = 2.0;
360 Scheduler m_scheduler;
363 time::milliseconds m_timeout;
366 std::queue<uint64_t> m_retxQueue;
367 Name m_versionedDataName;
368 uint64_t m_nextSegmentNum;
371 int64_t m_nSegmentsInFlight;
373 uint64_t m_highInterest;
377 int64_t m_nBytesReceived;
379 std::map<uint64_t, Buffer> m_receivedSegments;
380 std::map<uint64_t, PendingSegment> m_pendingSegments;
386 #endif // NDN_UTIL_SEGMENT_FETCHER_HPP
Copyright (c) 2013-2017 Regents of the University of California.
time::milliseconds interestLifetime
lifetime of sent Interests - independent of Interest timeout
function< void(uint32_t code, const std::string &msg)> ErrorCallback
an unrecoverable Nack was received during retrieval
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
static shared_ptr< SegmentFetcher > fetch(Face &face, const Interest &baseInterest, security::v2::Validator &validator, const CompleteCallback &completeCallback, const ErrorCallback &errorCallback)
Initiates segment fetching.
double mdCoef
multiplicative decrease coefficient
Signal< SegmentFetcher, ConstBufferPtr > onComplete
Emits upon successful retrieval of the complete data.
time::milliseconds maxTimeout
maximum allowed time between successful receipt of segments
bool useConstantInterestTimeout
if true, Interest timeout is kept at maxTimeout
Utility class to fetch the latest version of a segmented object.
Represents an Interest packet.
represents a Network Nack
double aiStep
additive increase step (in segments)
bool disableCwa
disable Conservative Window Adaptation
one of the retrieved segments failed user-provided validation
ErrorCode
Error codes passed to onError
static shared_ptr< SegmentFetcher > start(Face &face, const Interest &baseInterest, security::v2::Validator &validator, const Options &options=Options())
Initiates segment fetching.
Signal< SegmentFetcher > afterSegmentNacked
Emits whenever an Interest for a data segment is nacked.
Provide a communication channel with local or remote NDN forwarder.
Signal< SegmentFetcher, Data > afterSegmentValidated
Emits whenever a received data segment has been successfully validated.
retrieval timed out because the maximum timeout between the successful receipt of segments was exceed...
function< void(ConstBufferPtr data)> CompleteCallback
one of the retrieved Data packets lacked a segment number in the last Name component (excl...
Represents an absolute name.
double initSsthresh
initial slow start threshold
double initCwnd
initial congestion window size
bool ignoreCongMarks
disable window decrease after congestion mark received
bool resetCwndToInit
reduce cwnd to initCwnd when loss event occurs
Signal< SegmentFetcher, Data > afterSegmentReceived
Emits whenever a data segment received.
Signal< SegmentFetcher > afterSegmentTimedOut
Emits whenever an Interest for a data segment times out.
RttEstimator::Options rttOptions
options for RTT estimator
Validation error code and optional detailed error message.
Signal< SegmentFetcher, uint32_t, std::string > onError
Emits when the retrieval could not be completed due to an error.
Identifies a scheduled event.
Represents a Data packet.
a received FinalBlockId did not contain a segment component
bool useConstantCwnd
if true, window size is kept at initCwnd
Interface for validating data and interest packets.