Show
Ignore:
Timestamp:
06/25/09 11:05:57 (9 months ago)
Author:
arvid
Message:

added handshake diagram

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • dotorg/trunk/html/beps/bep_0029.rst

    r11161 r11163  
    4444The main drawbacks with this solution are: 
    4545 
    46 1. The user needs to configure his/her BitTorrent client, it won't 
     46#. The user needs to configure his/her BitTorrent client, it won't 
    4747   work out-of-the-box. 
    48 2. The user needs to know his/her internet connection's upload 
     48#. The user needs to know his/her internet connection's upload 
    4949   capacity. This capacity may change, especially on laptops that 
    5050   may connect to a large number of different networks. 
    51 3. The headroom of 20% is arbitrary and wastes bandwidth. Whenever 
     51#. The headroom of 20% is arbitrary and wastes bandwidth. Whenever 
    5252   there is no interactive traffic competing with BitTorrent, the 
    5353   extra 20% are wasted. Whenever there is competing interactive 
     
    253253 
    254254ST_STATE = 2 
    255         State packet. Used to transmit an ACK with no data. 
     255        State packet. Used to transmit an ACK with no data. Packets that don't 
     256        include any payload do not increase the ``seq_nr``. 
    256257 
    257258ST_RESET = 3 
     
    290291---------------- 
    291292 
    292 *describe the initial connection setup sequence* 
     293Here is a diagram illustrating the exchanges and states to initiate 
     294a connection. The c.* refers to a state in the socket itself, pkt.* 
     295refers to a field in the packet header. 
     296 
     297:: 
     298 
     299   initiating endpoint                           accepting endpoint      
     300 
     301             | c.state = CS_SYN_SENT                         | 
     302             | c.seq_nr = 1                                  | 
     303             | c.conn_id_recv = rand()                       | 
     304             | c.conn_id_send = c.conn_id_recv + 1           | 
     305             |                                               | 
     306             |                                               | 
     307             | ST_SYN                                        | 
     308             |   seq_nr=c.seq_nr++                           | 
     309             |   ack_nr=*                                    | 
     310             |   conn_id=c.rcv_conn_id                       | 
     311             | >-------------------------------------------> |  
     312             |             c.receive_conn_id = pkt.conn_id+1 |  
     313             |             c.send_conn_id = pkt.conn_id      |  
     314             |             c.seq_nr = rand()                 |  
     315             |             c.ack_nr = pkt.seq_nr             | 
     316             |             c.state = CS_CONNECTED            | 
     317             |                                               | 
     318             |                                               | 
     319             |                                               | 
     320             |                                               | 
     321             |                     ST_STATE                  | 
     322             |                       seq_nr=c.seq_nr++       | 
     323             |                       ack_nr=c.ack_nr         | 
     324             |                       conn_id=c.send_conn_id  | 
     325             | <------------------------------------------<  | 
     326             | c.state = CS_CONNECTED                        | 
     327             | c.ack_nr = pkt.seq_nr                         | 
     328             |                                               | 
     329             |                                               | connection established 
     330        .. ..|.. .. .. .. .. .. .. .. .. .. .. .. .. .. .. ..|.. .. 
     331             |                                               | 
     332             |                                               | 
     333             | ST_DATA                                       | 
     334             |   seq_nr=c.seq_nr++                           | 
     335             |   ack_nr=c.ack_nr                             | 
     336             |   conn_id=c.conn_id_send                      | 
     337             | >-------------------------------------------> |  
     338             |                         c.ack_nr = pkt.seq_nr | 
     339             |                                               | 
     340             |                                               | 
     341             |                                               | 
     342             |                     ST_DATA                   | 
     343             |                       seq_nr=c.seq_nr++       | 
     344             |                       ack_nr=c.ack_nr         | 
     345             |                       conn_id=c.send_conn_id  | 
     346             | <------------------------------------------<  | 
     347             | c.ack_nr = pkt.seq_nr                         | 
     348             |                                               | 
     349             |                                               | 
     350             V                                               V 
     351 
    293352 
    294353packet loss