Flow 1.0.0
Flow project: Full implementation reference.
socket_stats.cpp
Go to the documentation of this file.
1/* Flow
2 * Copyright 2023 Akamai Technologies, Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the
5 * "License"); you may not use this file except in
6 * compliance with the License. You may obtain a copy
7 * of the License at
8 *
9 * https://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in
12 * writing, software distributed under the License is
13 * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
14 * CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing
16 * permissions and limitations under the License. */
17
18/// @file
20#include <cassert>
21
22namespace flow::net_flow
23{
24
25// Peer_socket_receive_stats implementations.
26
28{
30 m_total_data_size += data;
31}
32
34{
36 m_good_data_size += data;
37}
38
40{
43}
44
46{
49}
50
52{
55}
56
58{
61}
62
64{
67}
68
70{
72 m_error_data_size += data;
73}
74
76{
79}
80
82{
84}
85
87{
90}
91
93{
96}
97
99{
102}
103
105{
106 if (count == 0)
107 {
109 }
110 else
111 {
112 assert(count >= m_current_pending_acks_count); // Explicit pre-condition.
113
114 /* If there were N pending individual acks at the end of the last handler (i.e., non-blocking
115 * time period), and now there are N + M such pending individual acks (at the end of this
116 * handler), then that means M more individual acks are being withheld from sending (a/k/a
117 * delayed). The N previous ones have already been counted in a preceding invocation. */
118
121 }
122}
123
125{
127}
128
130{
132 if (rcv_wnd_update_only)
133 {
135 }
136}
137
139{
141}
142
144{
146}
147
149{
150 (m_max_buf_data_size >= size) || (m_max_buf_data_size = size);
151}
152
153void Peer_socket_receive_stats_accumulator::low_lvl_packet(const std::type_info& type, size_t size)
154{
155 using std::type_index;
156
157 ++m_low_lvl_packet_count_by_type[type_index(type)];
158 m_low_lvl_packet_size_by_type[type_index(type)] += size;
159}
160
162{
163 // Give them read-only access to the data portion of ourselves.
164 return static_cast<const Peer_socket_receive_stats&>(*this);
165}
166
167// Peer_socket_send_stats_accumulator implementations.
168
169void Peer_socket_send_stats_accumulator::data_sent(size_t data, bool rexmission)
170{
172 m_sent_data_size += data;
173 if (rexmission)
174 {
177 }
178}
179
181{
182 m_dropped_data_count += count;
183 m_dropped_data_size += data;
184}
185
187{
189 if (rcv_wnd_update_only)
190 {
192 }
193}
194
196{
198}
199
201{
202 if (wnd_exhausted == m_rcv_wnd_exhausted)
203 {
204 return;
205 }
206 // else
207
208 m_rcv_wnd_exhausted = wnd_exhausted;
210}
211
213{
215 m_good_ack_data_size += data;
216}
217
219{
221}
222
224{
226}
227
229{
231}
232
234{
236}
237
239{
241}
242
244{
245 (m_max_buf_data_size >= size) || (m_max_buf_data_size = size);
246}
247
249{
250 using std::type_index;
251
253}
254
255void Peer_socket_send_stats_accumulator::low_lvl_packet_xfer_called(const std::type_info& type, bool delayed_by_pacing,
256 size_t size)
257{
258 using std::type_index;
259
260 const auto type_idx = type_index(type);
261 const size_t idx = delayed_by_pacing ? 1 : 0;
264}
265
267 size_t size_expected, size_t size_xferred)
268{
269 using std::numeric_limits;
270 using std::type_index;
271
272 const auto type_idx = type_index(type);
273 const Xfer_op_result op_result
274 = (size_expected == numeric_limits<size_t>::max())
276 : ((size_expected == size_xferred)
280 m_low_lvl_packet_xfer_completed_size_by_type_and_result[type_idx][op_result] += size_expected;
281}
282
284{
285 // Give them read-only access to the data portion of ourselves.
286 return static_cast<const Peer_socket_send_stats&>(*this);
287}
288
289} // namespace flow::net_flow
void sent_low_lvl_ack_packet(bool rcv_wnd_update_only)
Indicates than one low-level ACK packet will be sent as soon as possible.
void good_data_accepted_packet(size_t data)
Indicates good_data_packet(), and these data are not dropped (so either delivered into Receive buffer...
void current_pending_to_ack_packets(size_t count)
Indicates that all incoming data in the current boost.asio handler have been scanned and any ACKs tha...
void good_data_dropped_reassembly_q_overflow_packet(size_t data)
Indicates good_data_packet(), but these data are dropped due to insufficient Receive reassembly queue...
void presumed_dropped_data(size_t data)
Indicates that one or more unreceived data packets have been considered Dropped due to the number of ...
void low_lvl_packet(const std::type_info &type, size_t size)
Indicates a Low_lvl_packet& p was received with typeid(p) == type, deserialized from a buffer of leng...
void good_data_delivered_packet(size_t data)
Indicates good_data_accepted_packet(), and these data are delivered into Receive buffer (either immed...
void late_or_dupe_to_send_ack_packet(size_t data)
Indicates that late_or_dupe_data_packet() and therefore an individual acknowledgment for this packet ...
void total_to_send_ack_packet(size_t data)
Indicates that an individual acknowledgment for one packet will be sent.
void total_data_packet(size_t data)
Indicates one DATA packet has been received on socket.
void rcv_wnd_recovery_event_finish(bool success)
Indicates that the recovery indicated by last rcv_wnd_recovery_event_start() call has finished (we ar...
void good_to_send_ack_packet(size_t data)
Indicates that good_data_delivered_packet() and therefore an individual acknowledgment for this packe...
void good_data_packet(size_t data)
Indicates total_data_packet(), and these data are new and acceptable into Receive buffer assuming the...
void sent_individual_ack()
Indicates than one individual acknowledgment of a data packet has been packaged into an ACK packet th...
void error_data_packet(size_t data)
Indicates total_data_packet(), but there is some error about the sequence numbers so that they are no...
const Peer_socket_receive_stats & stats() const
Returns reference to non-modifiable current set of accumulated stats.
void buffer_fed(size_t size)
Indicates the Receive buffer was enqueued with data from network (so its data_size() increased).
void good_data_first_qd_packet(size_t data)
Indicates good_data_accepted_packet(), and these data are, upon receipt, queued for reassembly (not i...
void good_data_dropped_buf_overflow_packet(size_t data)
Indicates good_data_packet(), but these data are dropped due to insufficient Receive buffer space.
void rcv_wnd_recovery_event_start()
Indicates we seem to have detected that our rcv_wnd went from exhaustion to largely free,...
void late_or_dupe_data_packet(size_t data)
Indicates total_data_packet(), but the arrived data have either already been received before or (more...
void received_low_lvl_ack_packet(bool rcv_wnd_update_only)
Indicates an ACK packet on this socket was received.
void idle_timeout()
Indicates an idle timeout (in the send direction) has been detected and indicated to congestion contr...
void drop_timeout()
Indicates a Drop Timer fired once.
void low_lvl_packet_xfer_completed(const std::type_info &type, size_t size_expected=std::numeric_limits< size_t >::max(), size_t size_xferred=0)
Indicates low_lvl_packet_xfer_called(), and that send operation has now reported its outcome by calli...
void error_ack()
Indicates received_ack(), but there is some error about the sequence number so that it is not accepta...
void buffer_fed(size_t size)
Indicates the Send buffer was enqueued with data from a user send*() call (so its data_size() increas...
void updated_rcv_wnd(bool wnd_exhausted)
Indicates an ACK packet has advertised a rcv_wnd and whether this rcv_wnd would allow one to send one...
void received_ack()
Indicates one individual acknowledgment (of a DATA packet) inside an ACK has been received.
void low_lvl_packet_xfer_called(const std::type_info &type, bool delayed_by_pacing, size_t size)
Indicates low_lvl_packet_xfer_requested(), and that packet has now been given to OS UDP stack to actu...
void loss_event()
Indicates a new loss event (not counting Drop Timeouts) has been reported to congestion control (Cong...
void dropped_data(size_t data, size_t count)
Indicates that 1 or more packets have been converted from In-flight to Dropped.
void low_lvl_packet_xfer_requested(const std::type_info &type)
Indicates a packet was given to the sending module to send, possibly subject to pacing.
const Peer_socket_send_stats & stats() const
Returns reference to non-modifiable current set of accumulated stats.
void late_or_dupe_ack()
Indicates received_ack(), but the arrived acknowledgment is for a packet that has either already been...
void data_sent(size_t data, bool rexmission)
Indicates a DATA packet was sent.
void good_ack(size_t data)
Indicates received_ack(), and the arrived acknowledgment properly acknowledged a DATA packet,...
A data store that keeps stats about the outgoing direction of a Peer_socket connection to another Flo...
Definition: info.hpp:286
uint64_t m_sent_rexmitted_data_count
Of m_sent_data_count, the data that were retransmitted (as opposed to original) data.
Definition: info.hpp:323
uint64_t m_remote_rcv_wnd_recovery_events
Number of times m_rcv_wnd_exhausted changed from true (not counting it being initially set to false).
Definition: info.hpp:344
uint64_t m_sent_rexmitted_data_size
Of m_sent_data_size, the data that were retransmitted (as opposed to original) data.
Definition: info.hpp:321
uint64_t m_received_ack_count
Individual acknowledgments inside low-level ACK packets that have been received (not necessarily all ...
Definition: info.hpp:335
size_t m_max_buf_data_size
Maximum number of bytes in the Send buffer so far.
Definition: info.hpp:397
uint64_t m_late_or_dupe_ack_count
Of m_received_ack_count, those packets that had either already been convered from In-flight to Acknow...
Definition: info.hpp:361
uint64_t m_drop_timeouts
Number of times Drop Timer has fired so far.
Definition: info.hpp:394
std::map< std::type_index, boost::array< uint64_t, 2 > > m_low_lvl_packet_xfer_called_size_by_type
Total size in serialized form of low-level packets that were given to OS in a send call,...
Definition: info.hpp:409
uint64_t m_idle_timeouts
Number of idle timeouts (in the send direction) so far that have been detected and indicated to conge...
Definition: info.hpp:391
uint64_t m_loss_events
Number of loss events so far (not counting Drop Timeouts) that have been reported to congestion contr...
Definition: info.hpp:385
uint64_t m_sent_data_size
Total bytes sent in DATA packets.
Definition: info.hpp:316
uint64_t m_sent_data_count
Number of packets sent in DATA packets.
Definition: info.hpp:318
std::map< std::type_index, std::map< Xfer_op_result, uint64_t > > m_low_lvl_packet_xfer_completed_count_by_type_and_result
Of m_low_lvl_packet_xfer_called_count_by_type, the data for which the send completion handler execute...
Definition: info.hpp:428
uint64_t m_good_ack_count
Of m_received_ack_count, those packets that were properly acknowledged and converted from In-flight t...
Definition: info.hpp:355
bool m_rcv_wnd_exhausted
Whether the last rcv_wnd update from other side indicated window size < max-block-size bytes....
Definition: info.hpp:338
uint64_t m_dropped_data_size
Total bytes in sent DATA packets that are considered permanently dropped (i.e., whose status has chan...
Definition: info.hpp:373
uint64_t m_error_acks_data_count
Of m_received_ack_count, those acknowledgments that contained some error about the sequence numbers s...
Definition: info.hpp:367
std::map< std::type_index, uint64_t > m_low_lvl_packet_xfer_requested_count_by_type
Total count of low-level packets that were given to the sending module to be sent,...
Definition: info.hpp:403
uint64_t m_dropped_data_count
Number of sent DATA packets that are considered permanently dropped (i.e., whose status has changed f...
Definition: info.hpp:378
uint64_t m_received_low_lvl_rcv_wnd_only_ack_count
Of m_received_low_lvl_ack_count, the packets that contained no individual acknowledgments but sent on...
Definition: info.hpp:332
uint64_t m_good_ack_data_size
Of the individual acknowledgments covered by m_received_ack_count, the total bytes in the DATA packet...
Definition: info.hpp:350
uint64_t m_received_low_lvl_ack_count
Number of low-level ACK packets received.
Definition: info.hpp:326
std::map< std::type_index, boost::array< uint64_t, 2 > > m_low_lvl_packet_xfer_called_count_by_type
Count of low-level packets that were given to OS in a send call, from this socket,...
Definition: info.hpp:415
std::map< std::type_index, std::map< Xfer_op_result, uint64_t > > m_low_lvl_packet_xfer_completed_size_by_type_and_result
Of m_low_lvl_packet_xfer_called_size_by_type, the data for which the send completion handler executed...
Definition: info.hpp:421
uint64_t m_remote_rcv_wnd_exhaustion_events
Number of times m_rcv_wnd_exhausted changed from false.
Definition: info.hpp:341
Flow module containing the API and implementation of the Flow network protocol, a TCP-inspired stream...
Definition: node.cpp:25
Xfer_op_result
Result of a send or receive operation, used at least in stat reporting.
@ S_FULLY_XFERRED
Bytes transferred equals bytes expected.
@ S_PARTIALLY_XFERRED
Bytes transferred less than bytes expected.
@ S_ERROR
Error occurred – probably no bytes transferred.
A data store that keeps stats about the incoming direction of a Peer_socket connection to another Flo...
Definition: info.hpp:54
uint64_t m_good_data_delivered_size
Of m_good_data_accepted_size, the data that were delivered into Receive buffer (either immediately up...
Definition: info.hpp:102
uint64_t m_rcv_wnd_recovery_success_count
Of m_rcv_wnd_recovery_count, the number of times the recovery was successful: i.e....
Definition: info.hpp:243
uint64_t m_total_data_size
Bytes in DATA packets received on socket.
Definition: info.hpp:78
uint64_t m_good_to_send_acks_data_size
Of m_total_to_send_acks_data_size, the data that also satisfy the criteria in m_good_data_delivered_s...
Definition: info.hpp:186
uint64_t m_good_data_accepted_size
Of m_good_data_size, the data that were not dropped (so either delivered into Receive buffer or queue...
Definition: info.hpp:91
uint64_t m_late_or_dupe_data_size
Of m_total_data_size, the data that had either already been received before or (more likely) had been...
Definition: info.hpp:156
uint64_t m_rcv_wnd_recovery_timeout_count
Of m_rcv_wnd_recovery_count, the number of times the recovery failed: i.e., resulted in a certain len...
Definition: info.hpp:251
uint64_t m_delayed_acks_count
The total number of individual packet acknowledgments whose sending was delayed (via delayed ACK mech...
Definition: info.hpp:215
uint64_t m_good_to_send_acks_count
Of m_total_to_send_acks_count, the data that also satisfy the criteria in m_good_data_delivered_count...
Definition: info.hpp:191
uint64_t m_total_to_send_acks_count
Number of DATA packets acknowledged thus far or that have been received and are pending to be acknowl...
Definition: info.hpp:179
uint64_t m_total_to_send_acks_data_size
Bytes in received DATA packets acknowledged thus far or that have been received and are pending to be...
Definition: info.hpp:174
uint64_t m_good_data_size
Of m_total_data_size, the data that were new and acceptable into Receive buffer assuming there was sp...
Definition: info.hpp:83
uint64_t m_late_or_dupe_data_count
Of m_total_data_count, the data that had either already been received before or (more likely) had bee...
Definition: info.hpp:161
uint64_t m_sent_individual_acks_count
Number of DATA packets such that for a given packet an individual acknowledgment has been packaged in...
Definition: info.hpp:221
size_t m_max_buf_data_size
Maximum number of bytes in the Receive buffer so far.
Definition: info.hpp:260
uint64_t m_sent_low_lvl_acks_count
Number of low-level ACK packets that have been sent or will be sent as soon as possible.
Definition: info.hpp:224
uint64_t m_good_data_delivered_count
Of m_good_data_accepted_count, the data that were delivered into Receive buffer (either immediately u...
Definition: info.hpp:107
std::map< std::type_index, uint64_t > m_low_lvl_packet_count_by_type
Count of low-level packets received targeted at this socket, split up by packet type similarly to m_l...
Definition: info.hpp:273
uint64_t m_late_or_dupe_to_send_acks_data_size
Of m_total_to_send_acks_data_size, the data that also satisfy the criteria in m_late_or_dupe_data_siz...
Definition: info.hpp:198
uint64_t m_total_data_count
Number of DATA packets received on socket.
Definition: info.hpp:80
uint64_t m_good_data_count
Of m_total_data_count, the data that were new and acceptable into Receive buffer assuming there was s...
Definition: info.hpp:85
size_t m_current_pending_acks_count
Of m_total_to_send_acks_count, the packets that have not yet been sent to the sender (pending acknowl...
Definition: info.hpp:209
uint64_t m_sent_low_lvl_rcv_wnd_only_acks_count
Of m_sent_low_lvl_acks_count, the packets that contained no individual acknowledgments but are to be ...
Definition: info.hpp:257
uint64_t m_good_data_first_qd_size
Of m_good_data_accepted_size, the data that were, upon receipt, queued for reassembly (not immediatel...
Definition: info.hpp:113
uint64_t m_error_data_size
Of m_total_data_size, the data that contained some error about the sequence numbers so that they were...
Definition: info.hpp:145
uint64_t m_good_data_dropped_buf_overflow_size
Of m_good_data_size, the data that were dropped due to insufficient Receive buffer space.
Definition: info.hpp:124
uint64_t m_presumed_dropped_data_size
Total number of bytes in hypothetical data packets that have been considered Dropped due to the numbe...
Definition: info.hpp:168
uint64_t m_late_or_dupe_to_send_acks_count
Of m_total_to_send_acks_count, the data that also satisfy the criteria in m_late_or_dupe_data_count.
Definition: info.hpp:203
uint64_t m_good_data_accepted_count
Of m_good_data_count, the data that were not dropped (so either delivered into Receive buffer or queu...
Definition: info.hpp:96
uint64_t m_good_data_dropped_reassembly_q_overflow_size
Of m_good_data_size, the data that were dropped due to insufficient Receive reassembly queue space (o...
Definition: info.hpp:134
uint64_t m_error_data_count
Of m_total_data_count, the data that contained some error about the sequence numbers so that they wer...
Definition: info.hpp:150
uint64_t m_rcv_wnd_recovery_count
Number of times we detected (heuristically but fairly reliably) that the following event occurred: ou...
Definition: info.hpp:237
uint64_t m_good_data_dropped_reassembly_q_overflow_count
Of m_good_data_count, the data that were dropped due to insufficient Receive reassembly queue space (...
Definition: info.hpp:139
uint64_t m_good_data_first_qd_count
Of m_good_data_accepted_count, the data that were, upon receipt, queued for reassembly (not immediate...
Definition: info.hpp:118
uint64_t m_good_data_dropped_buf_overflow_count
Of m_good_data_count, the data that were dropped due to insufficient Receive buffer space.
Definition: info.hpp:128
std::map< std::type_index, uint64_t > m_low_lvl_packet_size_by_type
Total size in serialized form of low-level packets received targeted at this socket,...
Definition: info.hpp:267