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))),
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.
TracedValue< double > m_window
bool m_setInitialWindowOnTimeout
NS_OBJECT_ENSURE_REGISTERED(GlobalRouter)
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.
span_constexpr std::size_t size(span< T, Extent > const &spn)
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) ...