apps: Fixing bug with setting Size/MaxSeq in ndn::ConsumerWindow
Before this fix, recently introduced alternative MaxSeq, made parameter
Size essentially useless.
diff --git a/apps/ndn-consumer-window.cc b/apps/ndn-consumer-window.cc
index f7bbec2..474c4fc 100644
--- a/apps/ndn-consumer-window.cc
+++ b/apps/ndn-consumer-window.cc
@@ -53,16 +53,18 @@
MakeUintegerAccessor (&ConsumerWindow::GetPayloadSize, &ConsumerWindow::SetPayloadSize),
MakeUintegerChecker<uint32_t>())
- .AddAttribute ("Size", "Amount of data in megabytes to request, relying on PayloadSize parameter (alternative to MaxSeq attribute)",
+ .AddAttribute ("Size",
+ "Amount of data in megabytes to request, relying on PayloadSize parameter (alternative to MaxSeq attribute)",
DoubleValue (-1), // don't impose limit by default
MakeDoubleAccessor (&ConsumerWindow::GetMaxSize, &ConsumerWindow::SetMaxSize),
MakeDoubleChecker<double> ())
.AddAttribute ("MaxSeq",
- "Maximum sequence number to request (alternative to Size attribute)",
+ "Maximum sequence number to request (alternative to Size attribute, would activate only if Size is -1). "
+ "The parameter is activated only if Size negative (not set)",
IntegerValue (std::numeric_limits<uint32_t>::max ()),
- MakeIntegerAccessor (&ConsumerWindow::m_seqMax),
- MakeIntegerChecker<uint32_t> ())
+ MakeUintegerAccessor (&ConsumerWindow::GetSeqMax, &ConsumerWindow::SetSeqMax),
+ MakeUintegerChecker<uint32_t> ())
.AddAttribute ("InitialWindowOnTimeout", "Set window to initial value when timeout occurs",
BooleanValue (true),
@@ -135,6 +137,21 @@
// std::cout << "MaxSeqNo: " << m_seqMax << "\n";
}
+uint32_t
+ConsumerWindow::GetSeqMax () const
+{
+ return m_seqMax;
+}
+
+void
+ConsumerWindow::SetSeqMax (uint32_t seqMax)
+{
+ if (m_maxSize < 0)
+ m_seqMax = seqMax;
+
+ // ignore otherwise
+}
+
void
ConsumerWindow::ScheduleNextPacket ()
diff --git a/apps/ndn-consumer-window.h b/apps/ndn-consumer-window.h
index 2057123..e89d0a7 100644
--- a/apps/ndn-consumer-window.h
+++ b/apps/ndn-consumer-window.h
@@ -88,6 +88,12 @@
void
SetMaxSize (double size);
+ uint32_t
+ GetSeqMax () const;
+
+ void
+ SetSeqMax (uint32_t seqMax);
+
private:
uint32_t m_payloadSize; // expected payload size
double m_maxSize; // max size to request