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" 30 NS_LOG_COMPONENT_DEFINE(
"ndn.ConsumerWindow");
41 TypeId(
"ns3::ndn::ConsumerWindow")
44 .AddConstructor<ConsumerWindow>()
46 .AddAttribute(
"Window",
"Initial size of the window", StringValue(
"1"),
47 MakeUintegerAccessor(&ConsumerWindow::GetWindow, &ConsumerWindow::SetWindow),
48 MakeUintegerChecker<uint32_t>())
50 .AddAttribute(
"PayloadSize",
51 "Average size of content object size (to calculate interest generation rate)",
52 UintegerValue(1040), MakeUintegerAccessor(&ConsumerWindow::GetPayloadSize,
53 &ConsumerWindow::SetPayloadSize),
54 MakeUintegerChecker<uint32_t>())
56 .AddAttribute(
"Size",
"Amount of data in megabytes to request, relying on PayloadSize " 57 "parameter (alternative to MaxSeq attribute)",
59 MakeDoubleAccessor(&ConsumerWindow::GetMaxSize, &ConsumerWindow::SetMaxSize),
60 MakeDoubleChecker<double>())
62 .AddAttribute(
"MaxSeq",
"Maximum sequence number to request (alternative to Size attribute, " 63 "would activate only if Size is -1). " 64 "The parameter is activated only if Size negative (not set)",
65 IntegerValue(std::numeric_limits<uint32_t>::max()),
66 MakeUintegerAccessor(&ConsumerWindow::GetSeqMax, &ConsumerWindow::SetSeqMax),
67 MakeUintegerChecker<uint32_t>())
69 .AddAttribute(
"InitialWindowOnTimeout",
"Set window to initial value when timeout occurs",
71 MakeBooleanAccessor(&ConsumerWindow::m_setInitialWindowOnTimeout),
74 .AddTraceSource(
"WindowTrace",
75 "Window that controls how many outstanding interests are allowed",
76 MakeTraceSourceAccessor(&ConsumerWindow::m_window),
77 "ns3::ndn::ConsumerWindow::WindowTraceCallback")
78 .AddTraceSource(
"InFlight",
"Current number of outstanding interests",
79 MakeTraceSourceAccessor(&ConsumerWindow::m_inFlight),
80 "ns3::ndn::ConsumerWindow::WindowTraceCallback");
92 ConsumerWindow::SetWindow(uint32_t window)
94 m_initialWindow = window;
95 m_window = m_initialWindow;
99 ConsumerWindow::GetWindow()
const 101 return m_initialWindow;
105 ConsumerWindow::GetPayloadSize()
const 107 return m_payloadSize;
111 ConsumerWindow::SetPayloadSize(uint32_t payload)
113 m_payloadSize = payload;
117 ConsumerWindow::GetMaxSize()
const 126 ConsumerWindow::SetMaxSize(
double size)
134 m_seqMax = floor(1.0 + m_maxSize * 1024.0 * 1024.0 / m_payloadSize);
135 NS_LOG_DEBUG(
"MaxSeqNo: " <<
m_seqMax);
140 ConsumerWindow::GetSeqMax()
const 146 ConsumerWindow::SetSeqMax(uint32_t seqMax)
157 if (m_window == static_cast<uint32_t>(0)) {
161 "Next event in " << (std::min<double>(0.5,
m_rtt->RetransmitTimeout().ToDouble(Time::S)))
164 Simulator::Schedule(Seconds(
165 std::min<double>(0.5,
m_rtt->RetransmitTimeout().ToDouble(Time::S))),
168 else if (m_inFlight >= m_window) {
189 m_window = m_window + 1;
191 if (m_inFlight > static_cast<uint32_t>(0))
193 NS_LOG_DEBUG(
"Window: " << m_window <<
", InFlight: " << m_inFlight);
201 if (m_inFlight > static_cast<uint32_t>(0))
204 if (m_setInitialWindowOnTimeout) {
206 m_window = m_initialWindow;
209 NS_LOG_DEBUG(
"Window: " << m_window <<
", InFlight: " << m_inFlight);
virtual void OnTimeout(uint32_t sequenceNumber)
Timeout event.
uint32_t m_seqMax
maximum number of sequence number
Copyright (c) 2011-2015 Regents of the University of California.
NS_OBJECT_ENSURE_REGISTERED(ContentStore)
Ptr< RttEstimator > m_rtt
RTT estimator.
static TypeId GetTypeId()
virtual void OnTimeout(uint32_t sequenceNumber)
Timeout event.
virtual void ScheduleNextPacket()
Constructs the Interest packet and sends it using a callback to the underlying NDN protocol...
NDN application for sending out Interest packets.
virtual void OnData(shared_ptr< const Data > contentObject)
Method that will be called every time new Data arrives.
void SendPacket()
Actually send packet.
ConsumerWindow()
Default constructor.
Copyright (c) 2011-2015 Regents of the University of California.
ndn ConsumerWindow
Copyright (c) 2011-2015 Regents of the University of California.
virtual void OnData(shared_ptr< const Data > contentObject)
Method that will be called every time new Data arrives.
EventId m_sendEvent
EventId of pending "send packet" event.
virtual void WillSendOutInterest(uint32_t sequenceNumber)
An event that is fired just before an Interest packet is actually send out (send is inevitable) ...
virtual void WillSendOutInterest(uint32_t sequenceNumber)
An event that is fired just before an Interest packet is actually send out (send is inevitable) ...