tcp超时重传(RTO)之karn算法及其简要实验

        我们都知道, tcp是面向连接的可靠传输, 其中的超时重传是可靠性保证之一。 好了, 不扯那么多理论了, 本来来玩一个简要的实验。

        前面说过了, telnet ip port命令是在向ip, port发起tcp连接, 假如这个ip, port不存在, 那么客户端自然连接不上, 那么客户端不会因为一次失败而气馁。

        试想一下, 你电话给你女朋友, 但你女朋友没有接, 你当然可以1分钟后再打啦, 如果还不接, 那就再等2分钟后打, 如果还不接, 那就再等4分钟后打, 如果还不接, 再等8分钟后打, 如果还不接, 继续,  租后估计你耐心也没有了, 超出你的心理预期了, 超时了。


         废话少说, 来看看:

xxxxxx$ telnet 1.1.1.1 80
Trying 1.1.1.1...
telnet: connect to address 1.1.1.1: Connection timed out
xxxxxx$ 
         抓包结果为:

xxxxxx$ sudo tcpdump -iany host 1.1.1.1 -Xnlps0
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 65535 bytes
10:20:32.582494 IP 10.100.70.139.37049 > 1.1.1.1.http: Flags [S], seq 1996420739, win 14280, options [mss 1428,sackOK,TS val 1096292390 ecr 0,nop,wscale 8], length 0
        0x0000:  4510 003c eea5 4000 4006 f915 0a64 468b  E..<..@[email protected].
        0x0010:  0101 0101 90b9 0050 76fe f683 0000 0000  .......Pv.......
        0x0020:  a002 37c8 531f 0000 0204 0594 0402 080a  ..7.S...........
        0x0030:  4158 1826 0000 0000 0103 0308 0000 0000  AX.&............
        0x0040:  0000 0000 0000 0000 0000 0000            ............
10:20:33.580560 IP 10.100.70.139.37049 > 1.1.1.1.http: Flags [S], seq 1996420739, win 14280, options [mss 1428,sackOK,TS val 1096292640 ecr 0,nop,wscale 8], length 0
        0x0000:  4510 003c eea6 4000 4006 f914 0a64 468b  E..<..@[email protected].
        0x0010:  0101 0101 90b9 0050 76fe f683 0000 0000  .......Pv.......
        0x0020:  a002 37c8 531f 0000 0204 0594 0402 080a  ..7.S...........
        0x0030:  4158 1920 0000 0000 0103 0308 0000 0000  AX..............
        0x0040:  0000 0000 0000 0000 0000 0000            ............
10:20:35.584564 IP 10.100.70.139.37049 > 1.1.1.1.http: Flags [S], seq 1996420739, win 14280, options [mss 1428,sackOK,TS val 1096293141 ecr 0,nop,wscale 8], length 0
        0x0000:  4510 003c eea7 4000 4006 f913 0a64 468b  E..<..@[email protected].
        0x0010:  0101 0101 90b9 0050 76fe f683 0000 0000  .......Pv.......
        0x0020:  a002 37c8 531f 0000 0204 0594 0402 080a  ..7.S...........
        0x0030:  4158 1b15 0000 0000 0103 0308 0000 0000  AX..............
        0x0040:  0000 0000 0000 0000 0000 0000            ............
10:20:39.596562 IP 10.100.70.139.37049 > 1.1.1.1.http: Flags [S], seq 1996420739, win 14280, options [mss 1428,sackOK,TS val 1096294144 ecr 0,nop,wscale 8], length 0
        0x0000:  4510 003c eea8 4000 4006 f912 0a64 468b  E..<..@[email protected].
        0x0010:  0101 0101 90b9 0050 76fe f683 0000 0000  .......Pv.......
        0x0020:  a002 37c8 531f 0000 0204 0594 0402 080a  ..7.S...........
        0x0030:  4158 1f00 0000 0000 0103 0308 0000 0000  AX..............
        0x0040:  0000 0000 0000 0000 0000 0000            ............

       上面的重传过程一目了然, RTO分别是1s, 2s, 4s 

       这就是tcp重传之karn算法。


         




你可能感兴趣的:(s2:,软件进阶,s2:,Linux杂项,s4:,操作系统,s4:,计算机网络)