22 #ifndef NDN_CXX_UTIL_SEGMENT_FETCHER_HPP
23 #define NDN_CXX_UTIL_SEGMENT_FETCHER_HPP
171 static shared_ptr<SegmentFetcher>
184 class PendingSegment;
189 shouldStop(
const weak_ptr<SegmentFetcher>& weakSelf);
192 fetchFirstSegment(
const Interest& baseInterest,
bool isRetransmission);
195 fetchSegmentsInWindow(
const Interest& origInterest);
198 sendInterest(uint64_t segNum,
const Interest& interest,
bool isRetransmission);
201 afterSegmentReceivedCb(
const Interest& origInterest,
const Data& data,
202 const weak_ptr<SegmentFetcher>& weakSelf);
205 afterValidationSuccess(
const Data& data,
const Interest& origInterest,
206 std::map<uint64_t, PendingSegment>::iterator pendingSegmentIt,
207 const weak_ptr<SegmentFetcher>& weakSelf);
210 afterValidationFailure(
const Data& data,
212 const weak_ptr<SegmentFetcher>& weakSelf);
216 const weak_ptr<SegmentFetcher>& weakSelf);
219 afterTimeoutCb(
const Interest& origInterest,
220 const weak_ptr<SegmentFetcher>& weakSelf);
223 afterNackOrTimeout(
const Interest& origInterest);
235 signalError(uint32_t code,
const std::string& msg);
238 updateRetransmittedSegment(uint64_t segmentNum,
243 cancelExcessInFlightSegments();
246 checkAllSegmentsReceived();
298 enum class SegmentState {
314 static constexpr
double MIN_SSTHRESH = 2.0;
316 shared_ptr<SegmentFetcher> m_this;
320 Scheduler m_scheduler;
321 security::Validator& m_validator;
322 util::RttEstimator m_rttEstimator;
325 std::queue<uint64_t> m_retxQueue;
326 Name m_versionedDataName;
327 uint64_t m_nextSegmentNum = 0;
330 int64_t m_nSegmentsInFlight = 0;
331 int64_t m_nSegments = 0;
332 uint64_t m_highInterest = 0;
333 uint64_t m_highData = 0;
334 uint64_t m_recPoint = 0;
335 int64_t m_nReceived = 0;
336 int64_t m_nBytesReceived = 0;
337 uint64_t m_nextSegmentInOrder = 0;
339 std::map<uint64_t, Buffer> m_segmentBuffer;
340 std::map<uint64_t, PendingSegment> m_pendingSegments;
341 std::set<uint64_t> m_receivedSegments;
Represents a Data packet.
Provide a communication channel with local or remote NDN forwarder.
Represents an Interest packet.
Handle for a pending Interest.
Utility class to fetch a versioned and segmented object.
signal::Signal< SegmentFetcher, Data > afterSegmentValidated
Emitted whenever a received data segment has been successfully validated.
signal::Signal< SegmentFetcher > afterSegmentNacked
Emitted whenever an Interest for a data segment is nacked.
static shared_ptr< SegmentFetcher > start(Face &face, const Interest &baseInterest, security::Validator &validator, const Options &options={})
Initiates segment fetching.
void stop()
Stops fetching.
signal::Signal< SegmentFetcher, ConstBufferPtr > onInOrderData
Emitted after each data segment in segment order has been validated.
signal::Signal< SegmentFetcher, ConstBufferPtr > onComplete
Emitted upon successful retrieval of the complete object (all segments).
signal::Signal< SegmentFetcher > onInOrderComplete
Emitted on successful retrieval of all segments in 'in order' mode.
signal::Signal< SegmentFetcher, Data > afterSegmentReceived
Emitted whenever a data segment received.
ErrorCode
Error codes passed to onError.
@ INTEREST_TIMEOUT
Retrieval timed out because the maximum timeout between the successful receipt of segments was exceed...
@ FINALBLOCKID_NOT_SEGMENT
A received FinalBlockId did not contain a segment component.
@ NACK_ERROR
An unrecoverable Nack was received during retrieval.
@ SEGMENT_VALIDATION_FAIL
One of the retrieved segments failed user-provided validation.
@ DATA_HAS_NO_SEGMENT
One of the retrieved Data packets lacked a segment number in the last Name component (excl....
signal::Signal< SegmentFetcher, uint32_t, std::string > onError
Emitted when the retrieval could not be completed due to an error.
signal::Signal< SegmentFetcher > afterSegmentTimedOut
Emitted whenever an Interest for a data segment times out.
SegmentFetcherOptions Options
Represents a Network Nack.
A handle for a scheduled event.
Validation error code and optional detailed error message.
Interface for validating data and interest packets.
Provides a lightweight signal / event system.
::boost::chrono::time_point< steady_clock > time_point
#define NDN_CXX_PUBLIC_WITH_TESTS_ELSE_PRIVATE
::boost::chrono::milliseconds milliseconds
Options for SegmentFetcher.
size_t flowControlWindow
Maximum number of segments stored in the reorder buffer.
double initCwnd
Initial congestion window size.
bool resetCwndToInit
Reduce cwnd to initCwnd when a loss event occurs.
bool probeLatestVersion
Use the first Interest to probe the latest version of the object.
double mdCoef
Multiplicative decrease coefficient.
time::milliseconds maxTimeout
Maximum allowed time between successful receipt of segments.
bool disableCwa
Disable Conservative Window Adaptation.
bool inOrder
Set to true for 'in order' mode, false for 'block' mode.
bool useConstantInterestTimeout
If true, Interest timeout is kept fixed at maxTimeout.
double initSsthresh
Initial slow start threshold.
time::milliseconds interestLifetime
Lifetime of sent Interests (independent of Interest timeout)
double aiStep
Additive increase step (in segments)
bool useConstantCwnd
If true, window size is kept fixed at initCwnd.
util::RttEstimator::Options rttOptions
Options for the RTT estimator.
bool ignoreCongMarks
Disable window decrease after a congestion mark is received.