29 = std::numeric_limits<size_t>::max();
38 m_cong_wnd_bytes(sock->max_block_size() *
39 ((sock->opt(sock->m_opts.m_st_cong_ctl_init_cong_wnd_blocks) == 0)
40 ? ((sock->max_block_size() > 2190)
42 : ((sock->max_block_size() > 1095)
45 : sock->opt(sock->m_opts.m_st_cong_ctl_init_cong_wnd_blocks))),
46 m_init_cong_wnd_bytes(m_cong_wnd_bytes),
48 m_slow_start_thresh_bytes(std::numeric_limits<size_t>::max()),
49 m_acked_bytes_since_window_update(0)
96 FLOW_LOG_TRACE(
"cong_ctl [" << sock <<
"] update: cong_wnd already at limit.");
139 const size_t increment_bytes = min(bytes, limit);
141 FLOW_LOG_TRACE(
"cong_ctl [" << sock <<
"] update: [slow_start] cong_wnd incrementing "
142 "by [" << sock->bytes_blocks_str(increment_bytes) <<
"]; "
143 "acked [" << sock->bytes_blocks_str(bytes) <<
"]; "
144 "max increment [" << sock->bytes_blocks_str(limit) <<
"].");
178 bool cwnd_changed =
false;
192 FLOW_LOG_INFO(
"cong_ctl [" << sock <<
"] info: [cong_avoid] acknowledgment group brings tally to more "
193 "than one congestion window -- thought to be rare or impossible.");
198 unsigned int increment_blocks = sock->opt(sock->m_opts.m_st_cong_ctl_cong_avoidance_increment_blocks);
199 if (increment_blocks == 0)
201 increment_blocks = 1;
203 const size_t increment_bytes = increment_blocks * sock->max_block_size();
205 FLOW_LOG_TRACE(
"cong_ctl [" << sock <<
"] update: [cong_avoid] cong_wnd incrementing "
206 "by [" << sock->bytes_blocks_str(increment_bytes) <<
"]; "
207 "acked [" << sock->bytes_blocks_str(bytes) <<
"].");
220 FLOW_LOG_TRACE(
"cong_ctl [" << sock <<
"] update: [cong_avoid] cong_wnd not yet incrementing; "
221 "acked [" << sock->bytes_blocks_str(bytes) <<
"].");
229 size_t new_cong_wnd_bytes)
305 const size_t new_cong_wnd_bytes
306 = sock->opt(sock->m_opts.m_st_cong_ctl_cong_wnd_on_drop_timeout_blocks) * sock->max_block_size();
331 FLOW_LOG_TRACE(
"cong_ctl [" << sock <<
"] update: Idle Timeout event; "
338 FLOW_LOG_TRACE(
"cong_ctl [" <<
socket() <<
"] update: Idle Timeout event; set cong_wnd to initial cong_wnd.");
349 >= sock->opt(sock->m_opts.m_st_cong_ctl_max_cong_wnd_blocks) * sock->max_block_size();
355 const size_t limit = sock->opt(sock->m_opts.m_st_cong_ctl_max_cong_wnd_blocks) * sock->max_block_size();
360 "to [" << sock->bytes_blocks_str(limit) <<
"].");
372 return cong_wnd_bytes < slow_start_thresh_bytes;
377 using std::numeric_limits;
381 '|' << (
in_slow_start() ?
"slow_start" :
"cong_avoid") <<
"]: "
Interface that the user should implement, passing the implementing Logger into logging classes (Flow'...
void log_state(const std::string &context) const
Logs, in a TRACE message, all internal state values.
size_t slow_start_threshold_bytes() const
Return current stored SSTHRESH value in bytes.
size_t m_acked_bytes_since_window_update
While in congestion avoidance mode (!in_slow_start()), the # of acked bytes reported to on_acks() tha...
size_t m_slow_start_thresh_bytes
Current value of SSTRESH.
size_t m_cong_wnd_bytes
Current value of CWND.
Congestion_control_classic_data(log::Logger *logger_ptr, Peer_socket::Const_ptr sock)
Constructs object by setting up logging and saving a pointer to the containing Peer_socket,...
void on_drop_timeout(size_t new_slow_start_thresh_bytes)
Adjust state, including CWND and SSTHRESH, assuming a Drop Timeout just occurred.
void on_congestion_event(size_t new_slow_start_thresh_bytes, size_t new_cong_wnd_bytes)
Sets internally stored SSHTRESH and CWND to the given values; appropriately resets internal state so ...
void clamp_congestion_window()
If congestion_window_at_limit(), sets CWND to the limit value.
const size_t m_init_cong_wnd_bytes
Initial value of CWND in constructor.
Peer_socket::Const_ptr socket() const
Analogous to Congestion_control_strategy::socket().
bool congestion_window_at_limit() const
Returns true if and only if the stored CWND is >= a certain constant maximum value.
void on_acks(size_t bytes)
Adjusts state, including potentially CWND, based on either "congestion avoidance" or "slow start" alg...
size_t init_congestion_window_bytes() const
The value to which the constructor set the stored CWND value (also known as Initial Window or IW).
static const size_t S_MAX_SLOW_START_CWND_INCREMENT_BLOCKS
The constant that limits how much CWND can grow in slow start for a single ack group.
size_t congestion_window_bytes() const
Return current stored CWND value in bytes.
boost::weak_ptr< Peer_socket::Const_ptr::element_type > m_sock
Same meaning as in Congestion_control_strategy.
bool in_slow_start() const
Return true if and only if CWND < SSTHRESH.
void on_idle_timeout()
Adjust state, namely CWND, assuming an Idle Timeout just occurred.
Const_target_ptr Const_ptr
Short-hand for ref-counted pointer to immutable values of type Target_type::element_type (a-la T cons...
#define FLOW_LOG_INFO(ARG_stream_fragment)
Logs an INFO message into flow::log::Logger *get_logger() with flow::log::Component get_log_component...
#define FLOW_LOG_TRACE(ARG_stream_fragment)
Logs a TRACE message into flow::log::Logger *get_logger() with flow::log::Component get_log_component...
Flow module containing the API and implementation of the Flow network protocol, a TCP-inspired stream...
Flow_log_component
The flow::log::Component payload enumeration comprising various log components used by Flow's own int...