Ignore:
Timestamp:
Nov 6, 2008, 2:56:51 AM (14 years ago)
Author:
charles
Message:

update NEWS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-io.c

    r7042 r7055  
    3030#include "net.h"
    3131#include "peer-io.h"
    32 #include "ratecontrol.h"
    3332#include "trevent.h"
    3433#include "utils.h"
    3534
    3635#define IO_TIMEOUT_SECS 8
     36
     37static size_t
     38addPacketOverhead( size_t d )
     39{
     40    /**
     41     * http://sd.wareonearth.com/~phil/net/overhead/
     42     *
     43     * TCP over Ethernet:
     44     * Assuming no header compression (e.g. not PPP)
     45     * Add 20 IPv4 header or 40 IPv6 header (no options)
     46     * Add 20 TCP header
     47     * Add 12 bytes optional TCP timestamps
     48     * Max TCP Payload data rates over ethernet are thus:
     49     *  (1500-40)/(38+1500) = 94.9285 %  IPv4, minimal headers
     50     *  (1500-52)/(38+1500) = 94.1482 %  IPv4, TCP timestamps
     51     *  (1500-52)/(42+1500) = 93.9040 %  802.1q, IPv4, TCP timestamps
     52     *  (1500-60)/(38+1500) = 93.6281 %  IPv6, minimal headers
     53     *  (1500-72)/(38+1500) = 92.8479 %  IPv6, TCP timestamps
     54     *  (1500-72)/(42+1500) = 92.6070 %  802.1q, IPv6, ICP timestamps
     55     */
     56    static const double assumed_payload_data_rate = 94.0;
     57
     58    return (size_t)( d * ( 100.0 / assumed_payload_data_rate ) );
     59}
    3760
    3861/**
     
    83106
    84107    struct tr_bandwidth    bandwidth[2];
    85     tr_ratecontrol *       speedometer[2];
    86108
    87109    tr_crypto *            crypto;
     
    177199    if( len < io->bufferSize[TR_UP] )
    178200    {
    179         const size_t          n = io->bufferSize[TR_UP] - len;
     201        const size_t payload = io->bufferSize[TR_UP] - len;
     202        const size_t n = addPacketOverhead( payload );
    180203        struct tr_bandwidth * b = &io->bandwidth[TR_UP];
    181204        b->bytesLeft -= MIN( b->bytesLeft, (size_t)n );
    182205        b->bytesUsed += n;
    183         tr_rcTransferred( io->speedometer[TR_UP], n );
    184206        dbgmsg( io,
    185207                "wrote %zu bytes to peer... upload bytesLeft is now %zu",
     
    209231    if( len > io->bufferSize[TR_DOWN] )
    210232    {
    211         const size_t          n = len - io->bufferSize[TR_DOWN];
     233        const size_t payload = len - io->bufferSize[TR_DOWN];
     234        const size_t n = addPacketOverhead( payload );
    212235        struct tr_bandwidth * b = io->bandwidth + TR_DOWN;
    213236        b->bytesLeft -= MIN( b->bytesLeft, (size_t)n );
    214237        b->bytesUsed += n;
    215         tr_rcTransferred( io->speedometer[TR_DOWN], n );
    216238        dbgmsg( io,
    217239                "%zu new input bytes. bytesUsed is %zu, bytesLeft is %zu",
     
    314336    io->bandwidth[TR_UP].isUnlimited = 1;
    315337    io->bandwidth[TR_DOWN].isUnlimited = 1;
    316     io->speedometer[TR_UP] = tr_rcInit( );
    317     io->speedometer[TR_DOWN] = tr_rcInit( );
    318338    bufevNew( io );
    319339    return io;
     
    360380    tr_peerIo * io = vio;
    361381
    362     tr_rcClose( io->speedometer[TR_DOWN] );
    363     tr_rcClose( io->speedometer[TR_UP] );
    364382    evbuffer_free( io->output );
    365383    bufferevent_free( io->bufev );
     
    646664    adjustInputBuffer( io );
    647665    adjustOutputBuffer( io );
    648 }
    649 
    650 double
    651 tr_peerIoGetRateToClient( const tr_peerIo * io )
    652 {
    653     return tr_rcRate( io->speedometer[TR_DOWN] );
    654 }
    655 
    656 double
    657 tr_peerIoGetRateToPeer( const tr_peerIo * io )
    658 {
    659     return tr_rcRate( io->speedometer[TR_UP] );
    660666}
    661667
Note: See TracChangeset for help on using the changeset viewer.