23 #include "ns3/simulator.h"
24 #include "ns3/packet.h"
25 #include "ns3/callback.h"
26 #include "ns3/string.h"
27 #include "ns3/uinteger.h"
28 #include "ns3/double.h"
31 NS_LOG_COMPONENT_DEFINE(
"ndn.ConsumerWindow");
42 TypeId(
"ns3::ndn::ConsumerWindow")
45 .AddConstructor<ConsumerWindow>()
47 .AddAttribute(
"Window",
"Initial size of the window", StringValue(
"1"),
48 MakeUintegerAccessor(&ConsumerWindow::GetWindow, &ConsumerWindow::SetWindow),
49 MakeUintegerChecker<uint32_t>())
51 .AddAttribute(
"PayloadSize",
52 "Average size of content object size (to calculate interest generation rate)",
53 UintegerValue(1040), MakeUintegerAccessor(&ConsumerWindow::GetPayloadSize,
54 &ConsumerWindow::SetPayloadSize),
55 MakeUintegerChecker<uint32_t>())
57 .AddAttribute(
"Size",
"Amount of data in megabytes to request, relying on PayloadSize "
58 "parameter (alternative to MaxSeq attribute)",
60 MakeDoubleAccessor(&ConsumerWindow::GetMaxSize, &ConsumerWindow::SetMaxSize),
61 MakeDoubleChecker<double>())
63 .AddAttribute(
"MaxSeq",
"Maximum sequence number to request (alternative to Size attribute, "
64 "would activate only if Size is -1). "
65 "The parameter is activated only if Size negative (not set)",
66 IntegerValue(std::numeric_limits<uint32_t>::max()),
67 MakeUintegerAccessor(&ConsumerWindow::GetSeqMax, &ConsumerWindow::SetSeqMax),
68 MakeUintegerChecker<uint32_t>())
70 .AddAttribute(
"InitialWindowOnTimeout",
"Set window to initial value when timeout occurs",
75 .AddTraceSource(
"WindowTrace",
76 "Window that controls how many outstanding interests are allowed",
78 "ns3::ndn::ConsumerWindow::WindowTraceCallback")
79 .AddTraceSource(
"InFlight",
"Current number of outstanding interests",
81 "ns3::ndn::ConsumerWindow::WindowTraceCallback");
93 ConsumerWindow::SetWindow(uint32_t window)
100 ConsumerWindow::GetWindow()
const
106 ConsumerWindow::GetPayloadSize()
const
112 ConsumerWindow::SetPayloadSize(uint32_t payload)
118 ConsumerWindow::GetMaxSize()
const
127 ConsumerWindow::SetMaxSize(
double size)
131 m_seqMax = std::numeric_limits<uint32_t>::max();
136 NS_LOG_DEBUG(
"MaxSeqNo: " <<
m_seqMax);
141 ConsumerWindow::GetSeqMax()
const
147 ConsumerWindow::SetSeqMax(uint32_t seqMax)
158 if (
m_window ==
static_cast<uint32_t
>(0)) {
162 "Next event in " << (std::min<double>(0.5,
m_rtt->RetransmitTimeout().ToDouble(Time::S)))
165 Simulator::Schedule(Seconds(
166 std::min<double>(0.5,
m_rtt->RetransmitTimeout().ToDouble(Time::S))),