[HICN-331] schedule rtx at the right time 64/22764/1
authormichele papalini <micpapal@cisco.com>
Wed, 16 Oct 2019 08:21:18 +0000 (10:21 +0200)
committermichele papalini <micpapal@cisco.com>
Wed, 16 Oct 2019 08:21:18 +0000 (10:21 +0200)
Signed-off-by: michele papalini <micpapal@cisco.com>
Change-Id: Iae4e0bbc5a1e534fd3727d02804aba370378af00

libtransport/src/hicn/transport/protocols/rtc.cc
libtransport/src/hicn/transport/protocols/rtc.h

index 3e2fe91..92ef4ff 100644 (file)
@@ -528,7 +528,7 @@ void RTCTransportProtocol::addRetransmissions(uint32_t start, uint32_t stop) {
     checkRtx();
 }
 
-void RTCTransportProtocol::retransmit() {
+uint64_t RTCTransportProtocol::retransmit() {
   auto it = interestRetransmissions_.begin();
 
   // cut len to max HICN_MAX_RTX_SIZE
@@ -539,6 +539,7 @@ void RTCTransportProtocol::retransmit() {
   }
 
   it = interestRetransmissions_.begin();
+  uint64_t smallest_timeout = ULONG_MAX;
 
   while (it != interestRetransmissions_.end()) {
     uint32_t pkt = it->first & modMask_;
@@ -596,10 +597,13 @@ void RTCTransportProtocol::retransmit() {
                                  &interest_name);
       interest_name->setSuffix(it->first);
       sendInterest(interest_name, true);
+    }else if(rtx_time < smallest_timeout){
+      smallest_timeout = rtx_time;
     }
 
     ++it;
   }
+  return smallest_timeout;
 }
 
 void RTCTransportProtocol::checkRtx() {
@@ -608,20 +612,15 @@ void RTCTransportProtocol::checkRtx() {
     return;
   }
 
-  //we use the packet intearriva time on the fastest path
-  //even if this stats should be the same on both
-  auto pathStats = pathTable_.find(producerPathLabels_[0]);
+  rtx_timer_used_ = true;
+  uint64_t next_timeout = retransmit();
   uint64_t wait = 1;
-  if(pathStats != pathTable_.end()){
-    uint32_t GAP = floor(pathStats->second->getInterArrivalGap() / 2.0);
-    uint32_t RTT = floor(pathStats->second->getMinRtt() / 2.0);
-    wait =  min(RTT,GAP);
-    if(wait < 1)
-      wait = 1;
+  uint64_t now = std::chrono::duration_cast<std::chrono::milliseconds>(
+                         std::chrono::steady_clock::now().time_since_epoch())
+                         .count();
+  if(next_timeout != ULONG_MAX && now < next_timeout){
+        wait =  next_timeout - now;
   }
-
-  rtx_timer_used_ = true;
-  retransmit();
   rtx_timer_->expires_from_now(std::chrono::milliseconds(wait));
   rtx_timer_->async_wait([this](std::error_code ec) {
     if (ec) return;
index 509f113..cac885b 100644 (file)
@@ -124,7 +124,7 @@ class RTCTransportProtocol : public TransportProtocol, public Reassembly {
   void scheduleNextInterests() override;
   void addRetransmissions(uint32_t val);
   void addRetransmissions(uint32_t start, uint32_t stop);
-  void retransmit();
+  uint64_t retransmit();
   void checkRtx();
   void probeRtt();
   void onTimeout(Interest::Ptr &&interest) override;