From af6553e2bea9dc7210fa11c7b7b0473e0c59de3d Mon Sep 17 00:00:00 2001 From: michele papalini Date: Wed, 30 Oct 2019 11:30:31 +0100 Subject: [HICN-318] schedule rounds using timers in rtc conusmer Signed-off-by: michele papalini Change-Id: I2e52d002533706abdd82fbca5ebb80e81374de86 --- libtransport/src/hicn/transport/protocols/rtc.cc | 24 +++++++++++------------- libtransport/src/hicn/transport/protocols/rtc.h | 4 ++-- 2 files changed, 13 insertions(+), 15 deletions(-) (limited to 'libtransport') diff --git a/libtransport/src/hicn/transport/protocols/rtc.cc b/libtransport/src/hicn/transport/protocols/rtc.cc index f52494aba..3edd90725 100644 --- a/libtransport/src/hicn/transport/protocols/rtc.cc +++ b/libtransport/src/hicn/transport/protocols/rtc.cc @@ -34,6 +34,7 @@ RTCTransportProtocol::RTCTransportProtocol( rtx_timer_ = std::make_unique(portal_->getIoService()); probe_timer_ = std::make_unique(portal_->getIoService()); sentinel_timer_ = std::make_unique(portal_->getIoService()); + round_timer_ = std::make_unique(portal_->getIoService()); reset(); } @@ -45,6 +46,7 @@ RTCTransportProtocol::~RTCTransportProtocol() { int RTCTransportProtocol::start() { probeRtt(); + newRound(); return TransportProtocol::start(); } @@ -60,10 +62,10 @@ void RTCTransportProtocol::resume() { is_running_ = true; - lastRoundBegin_ = std::chrono::steady_clock::now(); inflightInterestsCount_ = 0; probeRtt(); + newRound(); scheduleNextInterests(); portal_->runEventsLoop(); @@ -75,7 +77,6 @@ void RTCTransportProtocol::resume() { void RTCTransportProtocol::reset() { portal_->setConsumerCallback(this); // controller var - lastRoundBegin_ = std::chrono::steady_clock::now(); currentState_ = HICN_RTC_SYNC_STATE; // cwin var @@ -143,15 +144,14 @@ uint32_t min(uint32_t a, uint32_t b) { return b; } -void RTCTransportProtocol::checkRound() { - uint32_t duration = - (uint32_t)std::chrono::duration_cast( - std::chrono::steady_clock::now() - lastRoundBegin_) - .count(); - if (duration >= HICN_ROUND_LEN) { - lastRoundBegin_ = std::chrono::steady_clock::now(); - updateStats(duration); // update stats and window - } +void RTCTransportProtocol::newRound() { + round_timer_->expires_from_now(std::chrono::milliseconds( + HICN_ROUND_LEN)); + round_timer_->async_wait([this](std::error_code ec) { + if (ec) return; + updateStats(HICN_ROUND_LEN); + newRound(); + }); } void RTCTransportProtocol::updateDelayStats( @@ -449,7 +449,6 @@ void RTCTransportProtocol::sendInterest(Name *interest_name, bool rtx) { } void RTCTransportProtocol::scheduleNextInterests() { - checkRound(); if (!is_running_ && !is_first_) return; while (inflightInterestsCount_ < currentCWin_) { @@ -505,7 +504,6 @@ void RTCTransportProtocol::scheduleNextInterests() { actualSegment_ = (actualSegment_ + 1) % HICN_MIN_PROBE_SEQ; sendInterest(interest_name, false); - checkRound(); } } diff --git a/libtransport/src/hicn/transport/protocols/rtc.h b/libtransport/src/hicn/transport/protocols/rtc.h index 908be017a..46063d041 100644 --- a/libtransport/src/hicn/transport/protocols/rtc.h +++ b/libtransport/src/hicn/transport/protocols/rtc.h @@ -108,7 +108,6 @@ class RTCTransportProtocol : public TransportProtocol, public Reassembly { private: // algo functions void reset() override; - void checkRound(); // CC functions void updateDelayStats(const ContentObject &content_object); @@ -129,6 +128,7 @@ class RTCTransportProtocol : public TransportProtocol, public Reassembly { uint64_t retransmit(); void checkRtx(); void probeRtt(); + void newRound(); void onTimeout(Interest::Ptr &&interest) override; bool onNack(const ContentObject &content_object, bool rtx); void onContentObject(Interest::Ptr &&interest, @@ -141,7 +141,7 @@ class RTCTransportProtocol : public TransportProtocol, public Reassembly { } // controller var - std::chrono::steady_clock::time_point lastRoundBegin_; + std::unique_ptr round_timer_; unsigned currentState_; // cwin var -- cgit 1.2.3-korg