22 NS_LOG_COMPONENT_DEFINE(
"ndn.ConsumerPcon");
29 constexpr
double ConsumerPcon::CUBIC_C;
30 constexpr uint32_t ConsumerPcon::BIC_MAX_INCREMENT;
31 constexpr uint32_t ConsumerPcon::BIC_LOW_WINDOW;
37 TypeId(
"ns3::ndn::ConsumerPcon")
40 .AddConstructor<ConsumerPcon>()
42 .AddAttribute(
"CcAlgorithm",
43 "Specify which window adaptation algorithm to use (AIMD, BIC, or CUBIC)",
45 MakeEnumAccessor(&ConsumerPcon::m_ccAlgorithm),
50 "TCP Multiplicative Decrease factor",
52 MakeDoubleAccessor(&ConsumerPcon::m_beta),
53 MakeDoubleChecker<double>())
55 .AddAttribute(
"CubicBeta",
56 "TCP CUBIC Multiplicative Decrease factor",
58 MakeDoubleAccessor(&ConsumerPcon::m_cubicBeta),
59 MakeDoubleChecker<double>())
61 .AddAttribute(
"AddRttSuppress",
62 "Minimum number of RTTs (1 + this factor) between window decreases",
64 MakeDoubleAccessor(&ConsumerPcon::m_addRttSuppress),
65 MakeDoubleChecker<double>())
67 .AddAttribute(
"ReactToCongestionMarks",
68 "If true, process received congestion marks",
70 MakeBooleanAccessor(&ConsumerPcon::m_reactToCongestionMarks),
73 .AddAttribute(
"UseCwa",
74 "If true, use Conservative Window Adaptation",
76 MakeBooleanAccessor(&ConsumerPcon::m_useCwa),
79 .AddAttribute(
"UseCubicFastConvergence",
80 "If true, use TCP CUBIC Fast Convergence",
82 MakeBooleanAccessor(&ConsumerPcon::m_useCubicFastConv),
83 MakeBooleanChecker());
89 : m_ssthresh(
std::numeric_limits<double>::max())
94 , m_cubicLastDecrease(
time::steady_clock::now())
96 , m_bicMaxWin(
std::numeric_limits<double>::max())
109 uint64_t sequenceNum = data->getName().get(-1).toSequenceNumber();
112 if (m_highData < sequenceNum) {
113 m_highData = sequenceNum;
116 if (data->getCongestionMark() > 0) {
117 if (m_reactToCongestionMarks) {
118 NS_LOG_DEBUG(
"Received congestion mark: " << data->getCongestionMark());
122 NS_LOG_DEBUG(
"Ignored received congestion mark: " << data->getCongestionMark());
153 ConsumerPcon::WindowIncrease()
170 BOOST_ASSERT_MSG(
false,
"Unknown CC Algorithm");
172 NS_LOG_DEBUG(
"Window size increased to " <<
m_window);
176 ConsumerPcon::WindowDecrease()
178 if (!m_useCwa || m_highData > m_recPoint) {
179 const double diff =
m_seq - m_highData;
180 BOOST_ASSERT(diff > 0);
182 m_recPoint =
m_seq + (m_addRttSuppress * diff);
196 BOOST_ASSERT_MSG(
false,
"Unknown CC Algorithm");
204 NS_LOG_DEBUG(
"Window size decreased to " <<
m_window);
207 NS_LOG_DEBUG(
"Window decrease suppressed, HighData: " << m_highData <<
", RecPoint: " << m_recPoint);
213 ConsumerPcon::BicIncrease()
224 else if (!m_isBicSs) {
226 if (m_bicTargetWin -
m_window < BIC_MAX_INCREMENT) {
233 if (
m_window + 0.00001 < m_bicMaxWin) {
235 m_bicTargetWin = (m_bicMaxWin + m_bicMinWin) / 2;
241 m_bicMaxWin = std::numeric_limits<double>::max();
248 m_bicSsCwnd = 2 * m_bicSsCwnd;
249 m_bicSsTarget =
m_window + m_bicSsCwnd;
251 if (m_bicSsCwnd >= BIC_MAX_INCREMENT) {
258 ConsumerPcon::BicDecrease()
262 auto prev_max = m_bicMaxWin;
266 if (prev_max > m_bicMaxWin) {
268 m_bicMaxWin = (m_bicMaxWin + m_bicMinWin) / 2;
270 m_bicTargetWin = (m_bicMaxWin + m_bicMinWin) / 2;
274 m_ssthresh =
m_window * m_cubicBeta;
281 ConsumerPcon::CubicIncrease()
289 const double k = std::cbrt(m_cubicWmax * (1 - m_cubicBeta) / CUBIC_C);
292 const double w_cubic = CUBIC_C * std::pow(t - k, 3) + m_cubicWmax;
297 constexpr
double w_est = 0.0;
304 BOOST_ASSERT(m_cubicWmax > 0);
306 double cubic_increment = std::max(w_cubic, w_est) -
m_window;
309 if (cubic_increment < 0) {
310 cubic_increment = 0.0;
318 ConsumerPcon::CubicDecrease()
322 const double FAST_CONV_DIFF = 1.0;
328 if (m_useCubicFastConv &&
m_window < m_cubicLastWmax * (1 - FAST_CONV_DIFF / 100)) {
330 m_cubicWmax =
m_window * (1.0 + m_cubicBeta) / 2.0;
338 m_ssthresh =
m_window * m_cubicBeta;
virtual void OnData(shared_ptr< const Data > data) override
Method that will be called every time new Data arrives.
virtual void OnTimeout(uint32_t sequenceNum) override
Timeout event.
virtual void OnTimeout(uint32_t sequenceNumber)
Timeout event.
Copyright (c) 2011-2015 Regents of the University of California.
Ndn application for sending out Interest packets (window-based)
static time_point now() noexcept
uint32_t m_seq
currently requested sequence number
TracedValue< double > m_window
boost::chrono::microseconds microseconds
NS_OBJECT_ENSURE_REGISTERED(GlobalRouter)
virtual void ScheduleNextPacket()
Constructs the Interest packet and sends it using a callback to the underlying NDN protocol...
static TypeId GetTypeId()
virtual void OnData(shared_ptr< const Data > contentObject)
Method that will be called every time new Data arrives.
Copyright (c) 2011-2015 Regents of the University of California.
TracedValue< uint32_t > m_inFlight