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",
74 .AddTraceSource(
"WindowTrace",
75 "Window that controls how many outstanding interests are allowed",
77 "ns3::ndn::ConsumerWindow::WindowTraceCallback")
78 .AddTraceSource(
"InFlight",
"Current number of outstanding interests",
80 "ns3::ndn::ConsumerWindow::WindowTraceCallback");
92 ConsumerWindow::SetWindow(uint32_t window)
99 ConsumerWindow::GetWindow()
const 105 ConsumerWindow::GetPayloadSize()
const 111 ConsumerWindow::SetPayloadSize(uint32_t payload)
117 ConsumerWindow::GetMaxSize()
const 126 ConsumerWindow::SetMaxSize(
double size)
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))),
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)
TracedValue< double > m_window
bool m_setInitialWindowOnTimeout
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.
TracedValue< uint32_t > m_inFlight
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)