为什么两个测试主机之间的往返时间不同?

时间:2013-11-20 06:10:58

标签: tcp roundtrip

我编写了一个http put客户端(使用libcurl libarary)将文件放入apache webdav服务器,并使用tcpdump在服务器端捕获数据包,然后使用tcptrace(www.tcptrace.org)分析转储文件,以下是结果: 主机a是客户端,主机b是服务器端:

 a->b:                              b->a:
     total packets:        152120           total packets:        151974      
     ack pkts sent:        152120           ack pkts sent:        151974      
     pure acks sent:          120           pure acks sent:       151854      
     sack pkts sent:            0           sack pkts sent:            0      
     dsack pkts sent:           0           dsack pkts sent:           0      
     max sack blks/ack:         0           max sack blks/ack:         0      
     unique bytes sent: 3532149672           unique bytes sent:     30420      
     actual data pkts:     152000           actual data pkts:        120      
     actual data bytes: 3532149672           actual data bytes:     30420      
     rexmt data pkts:           0           rexmt data pkts:           0      
     rexmt data bytes:          0           rexmt data bytes:          0      
     zwnd probe pkts:           0           zwnd probe pkts:           0      
     zwnd probe bytes:          0           zwnd probe bytes:          0      
     outoforder pkts:           0           outoforder pkts:           0      
     pushed data pkts:       3341           pushed data pkts:        120      
     SYN/FIN pkts sent:       0/0           SYN/FIN pkts sent:       0/0      
     req 1323 ws/ts:          N/Y           req 1323 ws/ts:          N/Y      
     urgent data pkts:          0 pkts      urgent data pkts:          0 pkts 
     urgent data bytes:         0 bytes     urgent data bytes:         0 bytes
     mss requested:             0 bytes     mss requested:             0 bytes
     max segm size:         31856 bytes     max segm size:           482 bytes
     min segm size:           216 bytes     min segm size:            25 bytes
     avg segm size:         23237 bytes     avg segm size:           253 bytes
     max win adv:             125 bytes     max win adv:            5402 bytes
     min win adv:             125 bytes     min win adv:            5402 bytes
     zero win adv:              0 times     zero win adv:              0 times
     avg win adv:             125 bytes     avg win adv:            5402 bytes
     initial window:        15928 bytes     initial window:            0 bytes
     initial window:            1 pkts      initial window:            0 pkts 
     ttl stream length:        NA           ttl stream length:        NA      
     missed data:              NA           missed data:              NA      
     truncated data:            0 bytes     truncated data:            0 bytes
     truncated packets:         0 pkts      truncated packets:         0 pkts 
     data xmit time:      151.297 secs      data xmit time:      150.696 secs 
     idletime max:        44571.3 ms        idletime max:        44571.3 ms   
     throughput:         23345867 Bps       throughput:              201 Bps  

     RTT samples:          151915           RTT samples:             120      
     RTT min:                 0.0 ms        RTT min:                 0.1 ms   
     RTT max:                 0.3 ms        RTT max:                40.1 ms   
     RTT avg:                 0.0 ms        RTT avg:                19.9 ms   
     RTT stdev:               0.0 ms        RTT stdev:              19.8 ms

     RTT from 3WHS:           0.0 ms        RTT from 3WHS:           0.0 ms   

     RTT full_sz smpls:     74427           RTT full_sz smpls:        60      
     RTT full_sz min:         0.0 ms        RTT full_sz min:        39.1 ms   
     RTT full_sz max:         0.3 ms        RTT full_sz max:        40.1 ms   
     RTT full_sz avg:         0.0 ms        RTT full_sz avg:        39.6 ms   
     RTT full_sz stdev:       0.0 ms        RTT full_sz stdev:       0.3 ms   

     post-loss acks:            0           post-loss acks:            0      
     segs cum acked:           89           segs cum acked:            0      
     duplicate acks:            0           duplicate acks:            0      
     triple dupacks:            0           triple dupacks:            0      
     max # retrans:             0           max # retrans:             0      
     min retr time:           0.0 ms        min retr time:           0.0 ms   
     max retr time:           0.0 ms        max retr time:           0.0 ms   
     avg retr time:           0.0 ms        avg retr time:           0.0 ms   
     sdv retr time:           0.0 ms        sdv retr time:           0.0 ms  

根据上述结果,客户端到服务器的RTT很小,但服务器端到客户端的数量很大。任何人都可以帮我解释一下吗?

2 个答案:

答案 0 :(得分:1)

因为这个

 unique bytes sent: 3532149672           unique bytes sent:     30420      
 actual data pkts:     152000           actual data pkts:        120      
 actual data bytes: 3532149672           actual data bytes:     30420 

a-> b正在发送稳定的数据流,这可以确保缓冲区被填满并且事情会被推送。

b-> a只发送一些acks等,几乎没有做任何事情,因此事情会在缓冲区中留下一段时间(几毫秒)。

除此之外,RTT是往返时间。这是应用程序将数据包排队等待发送以及收到相应响应的时间。由于a上的主机正在忙于推送数据,并且可能正在填充自己的缓冲区,因此从b获得确认的内容将会产生少量的额外开销。

答案 1 :(得分:0)

首先host b发送的数据非常少(样本量非常小)。其次,我怀疑host a具有不对称的互联网连接(例如10MB / 1MB)。