: Finer-grained resolution of sending rates
PATCH 4/7 : Finer-grained resolution of sending rates
[CCID 3]: Finer-grained resolution of sending rates
This patch
* resolves a bug where packets smaller than 32/64 bytes resulted in sending rates of 0
* supports all sending rates from 1/64 bytes/second up to 4Gbyte/second
* simplifies the present overflow problems in calculations
Current sending rate X and the cached value X_recv of the receiver-estimated sending rate are both scaled by 64 (2^6) in order to
* cope with low sending rates (minimally 1 byte/second)
* allow upgrading to use a packets-per-second implementation of CCID 3
* avoid calculation errors due to integer arithmetic cut-off
The patch implements a revised strategy from
http://www.mail-archive.com/[email protected]/msg01040.html
The only difference with regard to that strategy is that t_ipi is already used in the calculation of the nofeedback timeout, which saves one division.
--- include/linux/tfrc.h | 8 +++-- net/dccp/ccids/ccid3.c | 74 +++++++++++++++++++++++++++++-------------------- net/dccp/ccids/ccid3.h | 33 +++++++++++++++++---- 3 files changed, 77 insertions(+), 38 deletions(-)
include/linux/tfrc.h +6 -2
@@ -37,10 +37,14 @@ struct tfrc_rx_info {* @tfrctx_p: current loss event rate (5.4) * @tfrctx_rto: estimate of RTO, equals 4*RTT (4.3) * @tfrctx_ipi: inter-packet interval (4.6) +* +* Note: X and X_recv are both maintained in units of 64 * bytes/second. This +* enables a finer resolution of sending rates and avoids problems with +* integer arithmetic; u32 is not sufficient as scaling consumes 6 bits. */ struct tfrc_tx_info { -__u32 tfrctx_x; -__u32 tfrctx_x_recv; +__u64 tfrctx_x; +__u64 tfrctx_x_recv;__u32 tfrctx_x_calc;__u32 tfrctx_rtt;__u32 tfrctx_p;
net/dccp/ccids/ccid3.h +26 -7
@@ -75,14 +75,14 @@ enum ccid3_hc_tx_states {/** struct ccid3_hc_tx_sock - CCID3 sender half-connection socket * -* @ccid3hctx_x - Current sending rate -* @ccid3hctx_x_recv - Receive rate -* @ccid3hctx_x_calc - Calculated send rate (RFC 3448, 3.1) +* @ccid3hctx_x - Current sending rate in 64 * bytes per second +* @ccid3hctx_x_recv - Receive rate in 64 * bytes per second +* @ccid3hctx_x_calc - Calculated rate in bytes per second * @ccid3hctx_rtt - Estimate of current round trip time in usecs * @ccid3hctx_p - Current loss event rate (0-1) scaled by 1000000 -* @ccid3hctx_s - Packet size -* @ccid3hctx_t_rto - Retransmission Timeout (RFC 3448, 3.1) -* @ccid3hctx_t_ipi - Interpacket (send) interval (RFC 3448, 4.6) +* @ccid3hctx_s - Packet size in bytes +* @ccid3hctx_t_rto - Nofeedback Timer setting in usecs +* @ccid3hctx_t_ipi - Interpacket (send) interval (RFC 3448, 4.6) in usecs * @ccid3hctx_state - Sender state, one of %ccid3_hc_tx_states * @ccid3hctx_last_win_count - Last window counter sent * @ccid3hctx_t_last_win_count - Timestamp of earliest packet
@@ -91,7 +91,7 @@ enum ccid3_hc_tx_states {* @ccid3hctx_idle - Flag indicating that sender is idling * @ccid3hctx_t_ld - Time last doubled during slow start * @ccid3hctx_t_nom - Nominal send time of next packet -* @ccid3hctx_delta - Send timer delta +* @ccid3hctx_delta - Send timer delta (RFC 3448, 4.6) in usecs * @ccid3hctx_hist - Packet history * @ccid3hctx_options_received - Parsed set of retrieved options */
@@ -171,4 +171,23 @@ static inline struct ccid3_hc_rx_sock *c return ccid_priv(dccp_sk(sk)->dccps_hc_rx_ccid); } +static inline u64 scaled_div (u64 a,u32 b) +{ +BUG_ON (b=0 ); + a *=1000000 ; +do_div (a, b); +return a; +} + +static inline u32 scaled_div32 (u64 a,u32 b) +{ +u64 result =scaled_div (a, b); + +if (result >UINT_MAX ) { +DCCP_CRIT ("Overflow: a(%llu)/b(%u) > ~0U" , + (unsigned long long )a, b); +return UINT_MAX ; + } +return result; +}#endif /* _DCCP_CCID3_H_ */
net/dccp/ccids/ccid3.c +44 -28
159 lines not on this page · raw message
Quoted 2 lines · Gerrit Renker
[CCID 3]: Finer-grained resolution of sending rates
Signature · 3 lines
Web: http://wand.net.nz/~iam4 Blog: http://imcdnzl.blogspot.com WAND Network Research Group