From d41e15b580287a26f6b58241eaec7957ee336050 Mon Sep 17 00:00:00 2001 From: Olivier Roques Date: Thu, 21 Nov 2019 15:47:00 +0000 Subject: [HICN-411] Change how manifests are requested This patch introduces a new way of requesting manifests such that all the segments they contain fill the current transport window. When a manifest (M) is received, we compute L = last_segment_requested + current_window_size. L is therefore equal or greater than the last segment of the current window. Then we compare L to the suffix of the next manifest that will be (potentially) requested. If L > next_manifest, it means that the last segment of the window is greater than the first segment contained in the next manifest. Therefore we request manifests until L <= next_manifest, ie until the manifests would cover the entire window. If L <= next_manifest, then all the manifests that were requested already cover the window, so there's no need to request more. However if the next manifest immediately follows the current one (M), we still need to request it so that the content suffix queue is correctly updated. Signed-off-by: Olivier Roques Change-Id: I71a5a0031cd783277d0aa59fd68d5d7bf64fe6ae --- .../protocols/manifest_indexing_manager.cc | 111 ++++++++++----------- 1 file changed, 54 insertions(+), 57 deletions(-) (limited to 'libtransport/src/hicn/transport/protocols/manifest_indexing_manager.cc') diff --git a/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.cc b/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.cc index 05cabc60d..0c3fd76cf 100644 --- a/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.cc +++ b/libtransport/src/hicn/transport/protocols/manifest_indexing_manager.cc @@ -29,7 +29,6 @@ ManifestIndexManager::ManifestIndexManager( interface::ConsumerSocket *icn_socket, TransportProtocol *next_interest) : IncrementalIndexManager(icn_socket), PacketManager(1024), - manifests_in_flight_(0), next_reassembly_segment_(suffix_queue_.end()), next_to_retrieve_segment_(suffix_queue_.end()), suffix_manifest_(core::NextSegmentCalculationStrategy::INCREMENTAL, 0), @@ -39,7 +38,6 @@ bool ManifestIndexManager::onManifest( core::ContentObject::Ptr &&content_object) { auto manifest = std::make_unique(std::move(*content_object)); - bool manifest_verified = verification_manager_->onPacketToVerify(*manifest); if (manifest_verified) { @@ -54,14 +52,12 @@ bool ManifestIndexManager::onManifest( case core::ManifestType::INLINE_MANIFEST: { auto _it = manifest->getSuffixList().begin(); auto _end = --manifest->getSuffixList().end(); + final_suffix_ = manifest->getFinalBlockNumber(); // final block number if (TRANSPORT_EXPECT_FALSE(manifest->isFinalManifest())) { _end++; } - // Get final block number - final_suffix_ = manifest->getFinalBlockNumber(); - suffix_hash_map_[_it->first] = std::make_pair(std::vector(_it->second, _it->second + 32), manifest->getHashAlgorithm()); @@ -93,62 +89,13 @@ bool ManifestIndexManager::onManifest( 1); suffix_manifest_.setSuffixStrategy( manifest->getNextSegmentCalculationStrategy()); - } else if (manifests_in_flight_) { - manifests_in_flight_--; } - if (TRANSPORT_EXPECT_FALSE(manifest->isFinalManifest() || - suffix_manifest_.getSuffix() > - final_suffix_)) { - break; + if (TRANSPORT_EXPECT_FALSE(manifest->isFinalManifest()) == 0) { + fillWindow(manifest->getWritableName(), + manifest->getName().getSuffix()); } - // Get current window size - double current_window_size = 0.; - socket_->getSocketOption(GeneralTransportOptions::CURRENT_WINDOW_SIZE, - current_window_size); - - // Get portal - std::shared_ptr portal; - socket_->getSocketOption(GeneralTransportOptions::PORTAL, portal); - - // Number of segments in manifest - std::size_t segment_count = 0; - - // Manifest namespace - Name &name = manifest->getWritableName(); - - if (manifests_in_flight_ >= MAX_MANIFESTS_IN_FLIGHT) { - break; - } - - // Send as many manifest as required for filling window. - do { - segment_count += suffix_manifest_.getNbSegments(); - suffix_manifest_++; - - Interest::Ptr interest = getPacket(); - name.setSuffix(suffix_manifest_.getSuffix()); - interest->setName(name); - - uint32_t interest_lifetime; - socket_->getSocketOption(GeneralTransportOptions::INTEREST_LIFETIME, - interest_lifetime); - interest->setLifetime(interest_lifetime); - - // Send requests for manifest out of the congestion window (no - // in_flight_interests++) - portal->sendInterest( - std::move(interest), - std::bind(&ManifestIndexManager::onManifestReceived, this, - std::placeholders::_1, std::placeholders::_2), - std::bind(&ManifestIndexManager::onManifestTimeout, this, - std::placeholders::_1)); - manifests_in_flight_++; - } while (segment_count < current_window_size && - suffix_manifest_.getSuffix() < final_suffix_ && - manifests_in_flight_ < MAX_MANIFESTS_IN_FLIGHT); - break; } case core::ManifestType::FLIC_MANIFEST: { @@ -193,6 +140,56 @@ void ManifestIndexManager::onManifestTimeout(Interest::Ptr &&i) { std::placeholders::_1)); } +void ManifestIndexManager::fillWindow(Name &name, uint32_t current_manifest) { + /* Send as many manifest as required for filling window. */ + uint32_t interest_lifetime; + double window_size; + std::shared_ptr portal; + Interest::Ptr interest; + uint32_t current_segment = *next_to_retrieve_segment_; + // suffix_manifest_ now points to the next manifest to request + uint32_t last_requested_manifest = (suffix_manifest_++).getSuffix(); + + socket_->getSocketOption(GeneralTransportOptions::PORTAL, portal); + socket_->getSocketOption(GeneralTransportOptions::INTEREST_LIFETIME, + interest_lifetime); + socket_->getSocketOption(GeneralTransportOptions::CURRENT_WINDOW_SIZE, + window_size); + + if (TRANSPORT_EXPECT_FALSE(suffix_manifest_.getSuffix() >= final_suffix_)) { + suffix_manifest_.updateSuffix(last_requested_manifest); + return; + } + + if (current_segment + window_size < suffix_manifest_.getSuffix() && + current_manifest != last_requested_manifest) { + suffix_manifest_.updateSuffix(last_requested_manifest); + return; + } + + do { + interest = getPacket(); + name.setSuffix(suffix_manifest_.getSuffix()); + interest->setName(name); + interest->setLifetime(interest_lifetime); + + // Send interests for manifest out of the congestion window (no + // in_flight_interests++) + portal->sendInterest( + std::move(interest), + std::bind(&ManifestIndexManager::onManifestReceived, this, + std::placeholders::_1, std::placeholders::_2), + std::bind(&ManifestIndexManager::onManifestTimeout, this, + std::placeholders::_1)); + + last_requested_manifest = (suffix_manifest_++).getSuffix(); + } while (current_segment + window_size >= suffix_manifest_.getSuffix() && + suffix_manifest_.getSuffix() < final_suffix_); + + // suffix_manifest_ now points to the last requested manifest + suffix_manifest_.updateSuffix(last_requested_manifest); +} + bool ManifestIndexManager::onContentObject( const core::ContentObject &content_object) { bool verify_signature; -- cgit 1.2.3-korg