aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/src/hicn/transport/protocols/rtc.cc
diff options
context:
space:
mode:
authormichele papalini <micpapal@cisco.com>2019-04-03 17:30:31 +0200
committermichele papalini <micpapal@cisco.com>2019-04-03 17:30:31 +0200
commite7ba0ea5e123460683a0b71ee9283d7ffc8392d9 (patch)
tree922f04db2ff61cb67bd9177b7154909671c589d1 /libtransport/src/hicn/transport/protocols/rtc.cc
parentfc938965a323d0865faf1fc93e375cdfbb66aa7b (diff)
[HICN-167] fixes on timeouts and nacks
Change-Id: I4b232bbe7edc4b09d9ebd750724761e7e6c75bf8 Signed-off-by: michele papalini <micpapal@cisco.com>
Diffstat (limited to 'libtransport/src/hicn/transport/protocols/rtc.cc')
-rw-r--r--libtransport/src/hicn/transport/protocols/rtc.cc59
1 files changed, 37 insertions, 22 deletions
diff --git a/libtransport/src/hicn/transport/protocols/rtc.cc b/libtransport/src/hicn/transport/protocols/rtc.cc
index 98abbe35b..e3dcbbdbd 100644
--- a/libtransport/src/hicn/transport/protocols/rtc.cc
+++ b/libtransport/src/hicn/transport/protocols/rtc.cc
@@ -105,6 +105,7 @@ void RTCTransportProtocol::reset() {
actualSegment_ = 0;
inflightInterestsCount_ = 0;
while (interestRetransmissions_.size() != 0) interestRetransmissions_.pop();
+ lastSegNacked_ = 0;
nackedByProducer_.clear();
nackedByProducerMaxSize_ = 512;
@@ -433,8 +434,8 @@ void RTCTransportProtocol::scheduleAppNackRtx(std::vector<uint32_t> &nacks) {
continue;
}
// packetLost_++;
- // XXX here I need to avoid the retrasmission for packet that were nacked by
- // the network
+ // XXX here I need to avoid the retrasmission for packet that were
+ // nacked by the network
interestRetransmissions_.push(nacks[i]);
}
@@ -450,7 +451,8 @@ void RTCTransportProtocol::onTimeout(Interest::Ptr &&interest) {
inflightInterestsCount_--;
}
- if (inflightInterests_[pkt].retransmissions < HICN_MAX_RTX) {
+ if (inflightInterests_[pkt].retransmissions < HICN_MAX_RTX &&
+ lastSegNacked_ <= segmentNumber) {
interestRetransmissions_.push(segmentNumber);
}
@@ -466,7 +468,9 @@ bool RTCTransportProtocol::checkIfProducerIsActive(
if (productionRate == 0) {
// the producer socket is not active
// in this case we consider only the first nack
- if (nack_timer_used_) return false;
+ if (nack_timer_used_) {
+ return false;
+ }
nack_timer_used_ = true;
// actualSegment_ should be the one in the nack, which will the next in
@@ -482,7 +486,6 @@ bool RTCTransportProtocol::checkIfProducerIsActive(
});
return false;
}
-
return true;
}
@@ -492,6 +495,7 @@ void RTCTransportProtocol::onNack(const ContentObject &content_object) {
uint32_t productionRate = *(++payload);
uint32_t nackSegment = content_object.getName().getSuffix();
+
gotNack_ = true;
// we synch the estimated production rate with the actual one
estimatedBw_ = (double)productionRate;
@@ -506,25 +510,18 @@ void RTCTransportProtocol::onNack(const ContentObject &content_object) {
computeMaxWindow(productionRate, 0);
increaseWindow();
+ while (interestRetransmissions_.size() != 0) interestRetransmissions_.pop();
+ lastSegNacked_ = productionSeg;
+
if (nackedByProducer_.size() >= nackedByProducerMaxSize_)
nackedByProducer_.erase(nackedByProducer_.begin());
nackedByProducer_.insert(nackSegment);
} else if (productionSeg < nackSegment) {
- gotFutureNack_++;
// we are asking stuff in the future
- // example
- // 10 12 13 14 15 16 17
- // ^ ^ ^
- // in prod nack actual
- // in this example we sent up to segment 17 and we get a nack for segment 15
- // this means that we will get nack also for 16 17
- // and valid data for 13 14
- // so the next segment to ask is 15, because 13 and 14 will can back anyway
- // we go back only in the case that the actual segment is really bigger than
- // nack segment, other we do nothing
-
- actualSegment_ = min(actualSegment_, nackSegment);
+ gotFutureNack_++;
+
+ actualSegment_ = productionSeg + 1;
computeMaxWindow(productionRate, 0);
decreaseWindow();
@@ -535,6 +532,24 @@ void RTCTransportProtocol::onNack(const ContentObject &content_object) {
} // equal should not happen
}
+void RTCTransportProtocol::onNackForRtx(const ContentObject &content_object) {
+ uint32_t *payload = (uint32_t *)content_object.getPayload()->data();
+ uint32_t productionSeg = *payload;
+ uint32_t nackSegment = content_object.getName().getSuffix();
+
+ if (productionSeg > nackSegment) {
+ // we are asking for stuff produced in the past
+ actualSegment_ = max(productionSeg + 1, actualSegment_);
+
+ while (interestRetransmissions_.size() != 0) interestRetransmissions_.pop();
+ lastSegNacked_ = productionSeg;
+
+ } else if (productionSeg < nackSegment) {
+
+ actualSegment_ = productionSeg + 1;
+ } // equal should not happen
+}
+
void RTCTransportProtocol::onContentObject(
Interest::Ptr &&interest, ContentObject::Ptr &&content_object) {
auto payload = content_object->getPayload();
@@ -546,16 +561,16 @@ void RTCTransportProtocol::onContentObject(
if (payload_size == HICN_NACK_HEADER_SIZE) {
// Nacks always come form the producer, so we set the producerPathLabel_;
producerPathLabel_ = content_object->getPathLabel();
+ schedule_next_interest = checkIfProducerIsActive(*content_object);
if (inflightInterests_[pkt].retransmissions == 0) {
// discard nacks for rtx packets
inflightInterestsCount_--;
- schedule_next_interest = checkIfProducerIsActive(*content_object);
- // if checkIfProducerIsActive returns true, we did all we need to do
+ // if checkIfProducerIsActive returns false, we did all we need to do
// inside that function, no need to call onNack
- if (!schedule_next_interest) onNack(*content_object);
+ if (schedule_next_interest) onNack(*content_object);
updateDelayStats(*content_object);
} else {
- schedule_next_interest = checkIfProducerIsActive(*content_object);
+ if (schedule_next_interest) onNackForRtx(*content_object);
}
} else {