diff options
author | Olivier Roques <olvrqs@gmail.com> | 2019-11-21 15:47:00 +0000 |
---|---|---|
committer | Olivier Roques <olvrqs@gmail.com> | 2019-11-22 12:33:01 +0000 |
commit | d41e15b580287a26f6b58241eaec7957ee336050 (patch) | |
tree | 9fa19199fcc340eec582353986cc354660bac130 /libtransport/src/hicn/transport/utils/suffix_strategy.h | |
parent | 4d593c09d9cc1496788f7953de25832193064103 (diff) |
[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 <olvrqs@gmail.com>
Change-Id: I71a5a0031cd783277d0aa59fd68d5d7bf64fe6ae
Diffstat (limited to 'libtransport/src/hicn/transport/utils/suffix_strategy.h')
-rw-r--r-- | libtransport/src/hicn/transport/utils/suffix_strategy.h | 47 |
1 files changed, 18 insertions, 29 deletions
diff --git a/libtransport/src/hicn/transport/utils/suffix_strategy.h b/libtransport/src/hicn/transport/utils/suffix_strategy.h index 4358d12f0..3014855f6 100644 --- a/libtransport/src/hicn/transport/utils/suffix_strategy.h +++ b/libtransport/src/hicn/transport/utils/suffix_strategy.h @@ -38,8 +38,6 @@ class SuffixStrategy { std::uint32_t getSuffix() { return suffix_; } - virtual std::uint32_t getNextSuffix() = 0; - void updateSuffix(std::uint32_t new_suffix) { suffix_ = new_suffix; } std::size_t getNbSegments() { return nb_segments_; } @@ -57,6 +55,7 @@ class SuffixStrategy { transport::core::NextSegmentCalculationStrategy suffix_stragegy_; std::uint32_t suffix_; std::size_t nb_segments_; + virtual std::uint32_t getNextSuffix() = 0; }; class SuffixManifest : public SuffixStrategy { @@ -66,27 +65,22 @@ class SuffixManifest : public SuffixStrategy { std::uint32_t start_offset) : SuffixStrategy(suffix_stragegy, start_offset) {} - std::uint32_t getNextSuffix(); - SuffixManifest operator++() { - uint32_t next_suffix = getNextSuffix(); - updateSuffix(next_suffix); - return SuffixManifest(suffix_stragegy_, next_suffix); + updateSuffix(getNextSuffix()); + SuffixManifest temp_suffix(suffix_stragegy_, suffix_); + temp_suffix.setNbSegments(getNbSegments()); + return temp_suffix; } SuffixManifest operator++(int) { SuffixManifest temp_suffix(suffix_stragegy_, suffix_); - uint32_t next_suffix = getNextSuffix(); - updateSuffix(next_suffix); + temp_suffix.setNbSegments(getNbSegments()); + updateSuffix(getNextSuffix()); return temp_suffix; } - SuffixManifest operator+(uint32_t shift) { - for (uint32_t i = 0; i < shift; i++) { - updateSuffix(getNextSuffix()); - } - return SuffixManifest(suffix_stragegy_, getSuffix()); - } + protected: + std::uint32_t getNextSuffix(); }; class SuffixContent : public SuffixStrategy { @@ -101,28 +95,22 @@ class SuffixContent : public SuffixStrategy { std::uint32_t start_offset) : SuffixContent(suffix_stragegy, start_offset, false) {} - std::uint32_t getNextSuffix(); - SuffixContent operator++() { - uint32_t next_suffix = getNextSuffix(); - updateSuffix(next_suffix); - return SuffixContent(suffix_stragegy_, next_suffix, making_manifest_); + updateSuffix(getNextSuffix()); + SuffixContent temp_suffix(suffix_stragegy_, suffix_, making_manifest_); + temp_suffix.setNbSegments(getNbSegments()); + temp_suffix.content_counter_ = content_counter_; + return temp_suffix; } SuffixContent operator++(int) { SuffixContent temp_suffix(suffix_stragegy_, suffix_, making_manifest_); - uint32_t next_suffix = getNextSuffix(); - updateSuffix(next_suffix); + temp_suffix.setNbSegments(getNbSegments()); + temp_suffix.content_counter_ = content_counter_; + updateSuffix(getNextSuffix()); return temp_suffix; } - SuffixContent operator+(uint32_t shift) { - for (uint32_t i = 0; i < shift; i++) { - updateSuffix(getNextSuffix()); - } - return SuffixContent(suffix_stragegy_, getSuffix(), making_manifest_); - } - void setUsingManifest(bool value) { making_manifest_ = value; } void reset(std::uint32_t reset_suffix) { @@ -135,5 +123,6 @@ class SuffixContent : public SuffixStrategy { /* content_counter_ keeps track of the number of segments */ /* between two manifests */ uint32_t content_counter_; + std::uint32_t getNextSuffix(); }; } // namespace utils |