Valve Game company Open source Gamenetworkingsockets[1], both support reliable data transmission, but also support unreliable data transmission, its data transmission is based on UDP, the implementation of TCP-friendly congestion control mechanism to ensure the fairness of bandwidth occupancy. [2] Its rate-control formula is based on a famous paper. Now, record its bandwidth calculation program here for a rainy time:
Const Int64 k_nmillion = 1000000;
int tfrccalcx (int s, Int64 RTT, float p)
{
//TFRC throughput equation
//// s
// x_bps =-- --------------------------------------------------------
// r*sqrt (2*B*P/3) + (T_rto * (3*sqrt (3*B*P/8) *p* (1+32*p^2)))
//b is TCP acknowlege packet rate, assumed to be 1 for this implementation
float R = (double) Rtt/k_nmillio n;
float T_rto = MAX (4 * R, 1.0f);
return static_cast< int > (static_cast<float> (s)/
(R * sqrt (2 * p/3) + (T_rto * (3 * sqrt (3 * P/8) * p * (1 + * (p * p)))));
}
[1]gamenetworkingsockets
[2]padhye J, Firoiu V, Towsley D, et al. Modeling TCP throughput:a simple model and its Empirical Validation[j]. ACM Sigcomm Computer Communication Review, 1998, 4:303-314