From 5b5e59e8c6209c518bbd5aa1185305b57cf73777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Rodr=C3=ADguez=20P=C3=A9rez?= Date: Wed, 23 Sep 2020 10:20:45 +0200 Subject: [PATCH] Use a single source of truth for InFlight calculation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ndn-consumer-window and ndn-consumer-pcon use a simple count for updating the number of InFlight packets. This works fines as long as no packet arrives after its timeout has fired. In this case `m_inFlight` is decreased twice. Ultimately the counter (wrongly) reaches 0 and prevents proper working of the window algorithm. This fix does away with the manual calculation of the counter and replaces it with the size of the `m_seqTimeouts` set. Signed-off-by: Miguel Rodríguez Pérez --- apps/ndn-consumer-pcon.cpp | 8 ++------ apps/ndn-consumer-window.cpp | 5 ++--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/apps/ndn-consumer-pcon.cpp b/apps/ndn-consumer-pcon.cpp index 22427407c..3dfece56b 100644 --- a/apps/ndn-consumer-pcon.cpp +++ b/apps/ndn-consumer-pcon.cpp @@ -126,9 +126,7 @@ ConsumerPcon::OnData(shared_ptr data) WindowIncrease(); } - if (m_inFlight > static_cast(0)) { - m_inFlight--; - } + m_inFlight = m_seqTimeouts.size(); NS_LOG_DEBUG("Window: " << m_window << ", InFlight: " << m_inFlight); @@ -140,9 +138,7 @@ ConsumerPcon::OnTimeout(uint32_t sequenceNum) { WindowDecrease(); - if (m_inFlight > static_cast(0)) { - m_inFlight--; - } + m_inFlight = m_seqTimeouts.size(); NS_LOG_DEBUG("Window: " << m_window << ", InFlight: " << m_inFlight); diff --git a/apps/ndn-consumer-window.cpp b/apps/ndn-consumer-window.cpp index 79c31e2a5..072991341 100644 --- a/apps/ndn-consumer-window.cpp +++ b/apps/ndn-consumer-window.cpp @@ -199,8 +199,7 @@ ConsumerWindow::OnData(shared_ptr contentObject) void ConsumerWindow::OnTimeout(uint32_t sequenceNumber) { - if (m_inFlight > static_cast(0)) - m_inFlight--; + m_inFlight = m_seqTimeouts.size(); if (m_setInitialWindowOnTimeout) { // m_window = std::max (0, m_window - 1); @@ -214,8 +213,8 @@ ConsumerWindow::OnTimeout(uint32_t sequenceNumber) void ConsumerWindow::WillSendOutInterest(uint32_t sequenceNumber) { - m_inFlight++; Consumer::WillSendOutInterest(sequenceNumber); + m_inFlight = m_seqTimeouts.size(); } } // namespace ndn