Changeset 7055


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

update NEWS

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEWS

    r7054 r7055  
    77   + More accurate bandwidth management
    88   + Bandwidth displays now include BitTorrent protocol overhead
    9    + Files are preallocated as soon as any data is received
     9   + Files are preallocated as soon as any data is received for that file
    1010   + Stability, security, and performance improvements to the RPC/Web UI server
    1111   + Support compression when serving Web UI and RPC responses
  • 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
  • trunk/libtransmission/peer-io.h

    r6991 r7055  
    208208                                                  tr_direction direction );
    209209
    210 double            tr_peerIoGetRateToClient( const tr_peerIo * io );
    211 
    212 double            tr_peerIoGetRateToPeer( const tr_peerIo * io );
    213 
    214210
    215211#endif
  • trunk/libtransmission/peer-mgr-private.h

    r6795 r7055  
    2727struct tr_peerIo;
    2828struct tr_peermsgs;
     29struct tr_ratecontrol;
    2930
    3031enum
     
    3738typedef struct tr_peer
    3839{
    39     unsigned int    peerIsChoked       : 1;
    40     unsigned int    peerIsInterested   : 1;
    41     unsigned int    clientIsChoked     : 1;
    42     unsigned int    clientIsInterested : 1;
    43     unsigned int    doPurge            : 1;
     40    unsigned int             peerIsChoked       : 1;
     41    unsigned int             peerIsInterested   : 1;
     42    unsigned int             clientIsChoked     : 1;
     43    unsigned int             clientIsInterested : 1;
     44    unsigned int             doPurge            : 1;
    4445
    4546    /* number of bad pieces they've contributed to */
    46     uint8_t     strikes;
     47    uint8_t                  strikes;
    4748
    48     uint8_t     encryption_preference;
    49     uint16_t    port;
    50     struct in_addr in_addr;
    51     struct tr_peerIo * io;
     49    uint8_t                  encryption_preference;
     50    uint16_t                 port;
     51    struct in_addr           in_addr;
     52    struct tr_peerIo       * io;
    5253
    53     struct tr_bitfield * blame;
    54     struct tr_bitfield * have;
    55     float    progress;
     54    struct tr_bitfield     * blame;
     55    struct tr_bitfield     * have;
     56
     57    /** how complete the peer's copy of the torrent is. [0.0...1.0] */
     58    float                    progress;
    5659
    5760    /* the client name from the `v' string in LTEP's handshake dictionary */
    58     char *    client;
     61    char                   * client;
    5962
    60     time_t    peerSentPieceDataAt;
    61     time_t    chokeChangedAt;
    62     time_t    pieceDataActivityDate;
     63    time_t                   peerSentPieceDataAt;
     64    time_t                   chokeChangedAt;
     65    time_t                   pieceDataActivityDate;
    6366
    64     struct tr_peermsgs * msgs;
    65     tr_publisher_tag    msgsTag;
     67    struct tr_peermsgs     * msgs;
     68    tr_publisher_tag         msgsTag;
     69
     70    /* the rate at which pieces are being transferred between client and peer.
     71     * protocol overhead is NOT included; this is only the piece data */
     72    struct tr_ratecontrol  * pieceSpeed[2];
    6673}
    6774tr_peer;
    6875
     76double tr_peerGetPieceSpeed( const tr_peer    * peer,
     77                             tr_direction       direction );
     78
    6979#endif
  • trunk/libtransmission/peer-mgr.c

    r7042 r7055  
    3232#include "peer-msgs.h"
    3333#include "ptrarray.h"
     34#include "ratecontrol.h"
    3435#include "stats.h" /* tr_statsAddUploaded, tr_statsAddDownloaded */
    3536#include "torrent.h"
     
    128129    tr_ptrArray *  incomingHandshakes; /* tr_handshake */
    129130    tr_timer *     bandwidthTimer;
    130     double         rateHistory[2][BANDWIDTH_PULSE_HISTORY];
    131131    double         globalPoolHistory[2][BANDWIDTH_PULSE_HISTORY];
    132132};
     
    327327    p = tr_new0( tr_peer, 1 );
    328328    memcpy( &p->in_addr, in_addr, sizeof( struct in_addr ) );
     329    p->pieceSpeed[TR_CLIENT_TO_PEER] = tr_rcInit( );
     330    p->pieceSpeed[TR_PEER_TO_CLIENT] = tr_rcInit( );
    329331    return p;
    330332}
     
    363365    tr_bitfieldFree( peer->blame );
    364366    tr_free( peer->client );
     367
     368    tr_rcClose( peer->pieceSpeed[TR_CLIENT_TO_PEER] );
     369    tr_rcClose( peer->pieceSpeed[TR_PEER_TO_CLIENT] );
    365370    tr_free( peer );
    366371}
     
    10091014            tor->activityDate = now;
    10101015            tor->uploadedCur += e->length;
     1016            tr_rcTransferred ( peer->pieceSpeed[TR_CLIENT_TO_PEER], e->length );
     1017            tr_rcTransferred ( tor->pieceSpeed[TR_CLIENT_TO_PEER], e->length );
     1018            tr_rcTransferred ( tor->session->pieceSpeed[TR_CLIENT_TO_PEER], e->length );
    10111019            tr_statsAddUploaded( tor->session, e->length );
    10121020            if( peer )
     
    10231031            tr_torrent * tor = t->tor;
    10241032            tor->activityDate = now;
     1033            tr_statsAddDownloaded( tor->session, e->length );
     1034            tr_rcTransferred ( peer->pieceSpeed[TR_PEER_TO_CLIENT], e->length );
     1035            tr_rcTransferred ( tor->pieceSpeed[TR_PEER_TO_CLIENT], e->length );
     1036            tr_rcTransferred ( tor->session->pieceSpeed[TR_PEER_TO_CLIENT], e->length );
    10251037            /* only add this to downloadedCur if we got it from a peer --
    10261038             * webseeds shouldn't count against our ratio.  As one tracker
     
    10311043            if( peer )
    10321044                tor->downloadedCur += e->length;
    1033             tr_statsAddDownloaded( tor->session, e->length );
    10341045            if( peer ) {
    10351046                struct peer_atom * a = getExistingAtom( t, &peer->in_addr );
     
    17161727}
    17171728
    1718 double
    1719 tr_peerMgrGetRate( const tr_peerMgr * manager,
    1720                    tr_direction       direction )
    1721 {
    1722     int    i;
    1723     double bytes = 0;
    1724 
    1725     assert( manager != NULL );
    1726     assert( direction == TR_UP || direction == TR_DOWN );
    1727 
    1728     for( i = 0; i < BANDWIDTH_PULSE_HISTORY; ++i )
    1729         bytes += manager->rateHistory[direction][i];
    1730 
    1731     return ( BANDWIDTH_PULSES_PER_SECOND * bytes )
    1732            / ( BANDWIDTH_PULSE_HISTORY * 1024 );
    1733 }
    1734 
    17351729float*
    17361730tr_peerMgrWebSpeeds( const tr_peerMgr * manager,
     
    17591753    return ret;
    17601754}
     1755
     1756double
     1757tr_peerGetPieceSpeed( const tr_peer    * peer,
     1758                      tr_direction       direction )
     1759{
     1760    assert( peer );
     1761    assert( direction==TR_CLIENT_TO_PEER || direction==TR_PEER_TO_CLIENT );
     1762
     1763    return tr_rcRate( peer->pieceSpeed[direction] );
     1764}
     1765
    17611766
    17621767struct tr_peer_stat *
     
    17911796        stat->progress           = peer->progress;
    17921797        stat->isEncrypted        = tr_peerIoIsEncrypted( peer->io ) ? 1 : 0;
    1793         stat->rateToPeer         = tr_peerIoGetRateToPeer( peer->io );
    1794         stat->rateToClient       = tr_peerIoGetRateToClient( peer->io );
     1798        stat->rateToPeer         = tr_peerGetPieceSpeed( peer, TR_CLIENT_TO_PEER );
     1799        stat->rateToClient       = tr_peerGetPieceSpeed( peer, TR_PEER_TO_CLIENT );
    17951800        stat->peerIsChoked       = peer->peerIsChoked;
    17961801        stat->peerIsInterested   = peer->peerIsInterested;
     
    18961901        else
    18971902        {
    1898             struct ChokeData * node = &choke[size++];
    1899             node->peer = peer;
    1900             node->isInterested = peer->peerIsInterested;
    1901             node->rateToClient = tr_peerIoGetRateToClient( peer->io );
    1902             node->rateToPeer = tr_peerIoGetRateToPeer( peer->io );
     1903            struct ChokeData * n = &choke[size++];
     1904            n->peer        = peer;
     1905            n->isInterested = peer->peerIsInterested;
     1906            n->rateToPeer   = tr_peerGetPieceSpeed( peer, TR_CLIENT_TO_PEER );
     1907            n->rateToClient = tr_peerGetPieceSpeed( peer, TR_PEER_TO_CLIENT );
    19031908        }
    19041909    }
     
    23232328    const double baseline = desiredAvgKB * 1024.0 /
    23242329                            BANDWIDTH_PULSES_PER_SECOND;
    2325     const double min = baseline * 0.66;
    2326     const double max = baseline * 1.33;
     2330    const double min = baseline * 0.90;
     2331    const double max = baseline * 1.10;
    23272332    int          i;
    23282333    double       usedBytes;
     
    25712576    /* allocate the upload and download bandwidth */
    25722577    for( i = 0; i < 2; ++i )
    2573         mgr->rateHistory[i][mgr->bandwidthPulseNumber] =
    2574             allocateBandwidth( mgr, i );
     2578        allocateBandwidth( mgr, i );
    25752579
    25762580    managerUnlock( mgr );
  • trunk/libtransmission/peer-mgr.h

    r6949 r7055  
    113113                             int * setmePeersFrom ); /* TR_PEER_FROM__MAX */
    114114
    115 double tr_peerMgrGetRate( const tr_peerMgr  * manager,
    116                           tr_direction        direction );
    117 
    118115struct tr_peer_stat* tr_peerMgrPeerStats( const tr_peerMgr  * manager,
    119116                                          const uint8_t     * torrentHash,
  • trunk/libtransmission/peer-msgs.c

    r6964 r7055  
    16811681{
    16821682    tr_peermsgs * peer = vpeer;
    1683     const double  rateToClient = tr_peerIoGetRateToClient( peer->io );
    1684     const int     estimatedBlocksInNext30Seconds =
    1685         ( rateToClient * 30 * 1024 ) / peer->torrent->blockSize;
     1683    const double rateToClient = tr_peerGetPieceSpeed( peer->info,
     1684                                                      TR_PEER_TO_CLIENT );
     1685    const int estimatedBlocksInNext30Seconds =
     1686                  ( rateToClient * 30 * 1024 ) / peer->torrent->blockSize;
    16861687
    16871688    peer->minActiveRequests = 4;
  • trunk/libtransmission/ratecontrol.h

    r6857 r7055  
    2828typedef struct tr_ratecontrol tr_ratecontrol;
    2929
    30 tr_ratecontrol * tr_rcInit( void );
    3130
    32 void             tr_rcTransferred(               tr_ratecontrol *,
    33                                           size_t byteCount );
     31tr_ratecontrol * tr_rcInit        ( void );
    3432
    35 float            tr_rcRate( const tr_ratecontrol * );
     33void             tr_rcClose       ( tr_ratecontrol         * ratecontrol );
    3634
    37 void             tr_rcClose( tr_ratecontrol * );
     35void             tr_rcTransferred ( tr_ratecontrol         * ratecontrol,
     36                                    size_t                   byteCount );
     37
     38float            tr_rcRate        ( const tr_ratecontrol   * ratecontrol );
     39
    3840
    3941#endif
  • trunk/libtransmission/session.c

    r6961 r7055  
    3030#include "platform.h" /* tr_lock */
    3131#include "port-forwarding.h"
     32#include "ratecontrol.h"
    3233#include "rpc-server.h"
    3334#include "stats.h"
     
    254255    h->proxyUsername = tr_strdup( proxyUsername );
    255256    h->proxyPassword = tr_strdup( proxyPassword );
     257    h->pieceSpeed[TR_PEER_TO_CLIENT] = tr_rcInit( );
     258    h->pieceSpeed[TR_CLIENT_TO_PEER] = tr_rcInit( );
    256259
    257260    if( configDir == NULL )
     
    504507{
    505508    if( session && toClient )
    506         *toClient = tr_peerMgrGetRate( session->peerMgr, TR_DOWN );
     509        *toClient = tr_rcRate( session->pieceSpeed[TR_PEER_TO_CLIENT] );
    507510
    508511    if( session && toPeer )
    509         *toPeer = tr_peerMgrGetRate( session->peerMgr, TR_UP );
     512        *toPeer = tr_rcRate( session->pieceSpeed[TR_CLIENT_TO_PEER] );
    510513}
    511514
     
    621624
    622625    /* free the session memory */
     626    tr_rcClose( session->pieceSpeed[TR_PEER_TO_CLIENT] );
     627    tr_rcClose( session->pieceSpeed[TR_CLIENT_TO_PEER] );
    623628    tr_lockFree( session->lock );
    624629    for( i = 0; i < session->metainfoLookupCount; ++i )
  • trunk/libtransmission/session.h

    r7031 r7055  
    5858};
    5959
     60struct tr_ratecontrol;
     61
    6062struct tr_handle
    6163{
     
    112114    struct tr_metainfo_lookup *  metainfoLookup;
    113115    int                          metainfoLookupCount;
     116
     117    /* the rate at which pieces are being transferred between client and peer.
     118     * protocol overhead is NOT included; this is only the piece data */
     119    struct tr_ratecontrol     *  pieceSpeed[2];
    114120};
    115121
  • trunk/libtransmission/torrent.c

    r7051 r7055  
    468468    randomizeTiers( info );
    469469
     470    tor->pieceSpeed[TR_CLIENT_TO_PEER] = tr_rcInit( );
     471    tor->pieceSpeed[TR_PEER_TO_CLIENT] = tr_rcInit( );
     472
    470473    tor->blockSize = getBlockSize( info->pieceSize );
    471474
     
    719722                   tr_direction       direction )
    720723{
    721     int    i;
    722     double bytes = 0;
    723 
    724724    assert( tor != NULL );
    725725    assert( direction == TR_UP || direction == TR_DOWN );
    726726
    727     for( i = 0; i < BANDWIDTH_PULSE_HISTORY; ++i )
    728         bytes += tor->rateHistory[direction][i];
    729 
    730     return ( BANDWIDTH_PULSES_PER_SECOND * bytes )
    731            / ( BANDWIDTH_PULSE_HISTORY * 1024 );
     727    return tr_rcRate( tor->pieceSpeed[direction] );
    732728}
    733729
     
    10831079    h->torrentCount--;
    10841080
     1081    tr_rcClose( t->pieceSpeed[TR_PEER_TO_CLIENT] );
     1082    tr_rcClose( t->pieceSpeed[TR_CLIENT_TO_PEER] );
     1083
    10851084    tr_metainfoFree( inf );
    10861085    tr_free( tor );
     
    17911790            if( !stat( path, &sb )
    17921791                    && S_ISREG( sb.st_mode )
    1793                     && ( sb.st_size <= it->length ) )
     1792                    && ( (uint64_t)sb.st_size <= it->length ) )
    17941793                bytesLeft -= sb.st_size;
    17951794
  • trunk/libtransmission/torrent.h

    r6961 r7055  
    2626#define TR_TORRENT_H 1
    2727
     28struct tr_ratecontrol;
     29
    2830/**
    2931***  Package-visible ctor API
     
    225227    int                        uniqueId;
    226228
     229    /* this is the count of raw bytes transferred between the
     230     * client and its peers over the past HISTORY time slices.
     231     * this count is used for bandwidth allocation, and includes
     232     * piece data, protocol overhead, and estimated tcp header overhead. */
    227233    double                     rateHistory[2][BANDWIDTH_PULSE_HISTORY];
     234
     235    /* the rate at which pieces are being transferred between client and
     236     * its peers.  protocol overhead is NOT included; only the piece data */
     237    struct tr_ratecontrol    * pieceSpeed[2];
    228238};
    229239
Note: See TracChangeset for help on using the changeset viewer.