apps: Add more configurability to ndn::ConsumerWindow
By default, it will zero out the window upon timeout
diff --git a/apps/ndn-consumer-window.cc b/apps/ndn-consumer-window.cc
index 165326b..bc42f67 100644
--- a/apps/ndn-consumer-window.cc
+++ b/apps/ndn-consumer-window.cc
@@ -57,6 +57,11 @@
MakeDoubleAccessor (&ConsumerWindow::GetMaxSize, &ConsumerWindow::SetMaxSize),
MakeDoubleChecker<double> ())
+ .AddAttribute ("InitialWindowOnTimeout", "Set window to initial value when timeout occurs",
+ BooleanValue (true),
+ MakeBooleanAccessor (&ConsumerWindow::m_setInitialWindowOnTimeout),
+ MakeBooleanChecker ())
+
.AddTraceSource ("WindowTrace",
"Window that controls how many outstanding interests are allowed",
MakeTraceSourceAccessor (&ConsumerWindow::m_window))
@@ -77,13 +82,14 @@
void
ConsumerWindow::SetWindow (uint32_t window)
{
- m_window = window;
+ m_initialWindow = window;
+ m_window = m_initialWindow;
}
uint32_t
ConsumerWindow::GetWindow () const
{
- return m_window;
+ return m_initialWindow;
}
uint32_t
@@ -130,9 +136,9 @@
{
if (!m_sendEvent.IsRunning ())
{
- m_sendEvent = Simulator::Schedule (Seconds (m_rtt->RetransmitTimeout ().ToDouble (Time::S)),
+ m_sendEvent = Simulator::Schedule (Seconds (m_rtt->RetransmitTimeout ().ToDouble (Time::S) * 0.1),
&Consumer::SendPacket, this);
- m_rtt->IncreaseMultiplier ();
+ // m_rtt->IncreaseMultiplier ();
}
}
else if (m_inFlight >= m_window)
@@ -189,10 +195,13 @@
void
ConsumerWindow::OnTimeout (uint32_t sequenceNumber)
{
- // NS_FATAL_ERROR ("No timeouts should happen: " << sequenceNumber);
if (m_inFlight > static_cast<uint32_t> (0)) m_inFlight--;
- // m_window = std::max<uint32_t> (0, m_window - 1);
- m_window = 0;
+
+ if (m_setInitialWindowOnTimeout)
+ {
+ // m_window = std::max<uint32_t> (0, m_window - 1);
+ m_window = m_initialWindow;
+ }
Consumer::OnTimeout (sequenceNumber);
}
diff --git a/apps/ndn-consumer-window.h b/apps/ndn-consumer-window.h
index 5713c70..32ad8aa 100644
--- a/apps/ndn-consumer-window.h
+++ b/apps/ndn-consumer-window.h
@@ -37,11 +37,11 @@
*/
class ConsumerWindow: public Consumer
{
-public:
+public:
static TypeId GetTypeId ();
-
+
/**
- * \brief Default constructor
+ * \brief Default constructor
*/
ConsumerWindow ();
@@ -58,14 +58,14 @@
virtual void
OnTimeout (uint32_t sequenceNumber);
-
+
protected:
/**
* \brief Constructs the Interest packet and sends it using a callback to the underlying NDN protocol
*/
virtual void
ScheduleNextPacket ();
-
+
private:
virtual void
SetWindow (uint32_t window);
@@ -84,11 +84,14 @@
void
SetMaxSize (double size);
-
+
private:
uint32_t m_payloadSize; // expected payload size
double m_maxSize; // max size to request
+ uint32_t m_initialWindow;
+ bool m_setInitialWindowOnTimeout;
+
TracedValue<uint32_t> m_window;
TracedValue<uint32_t> m_inFlight;
};