TCP吞吐量的计算公式

 Valve游戏公司开源GameNetworkingSockets[1],既支持可靠的数据传输,也支持不可靠的数据传输,它的数据传输是基于UDP的,实现了对TCP友好的拥塞控制机制,保证带宽占用的公平性。它的速率控制公式就是基于一篇大名鼎鼎的论文[2]。现在,把它的带宽计算程序录在这里,以备不时之需:

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_nMillion;
    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 + 32 * ( 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, 28(4): 303-314

猜你喜欢

转载自blog.csdn.net/u010643777/article/details/80036402
今日推荐