linux tcp重传超时时间,tcp 重传超时次数

tcp 重传超时次数

数据被重发以后若还是收不到应答, 则进行再次发送. 此时等待确认应答时间会以 2 倍, 4 倍的指数函数延长.

此外, 数据也不会被无限, 反复的重发. 达到一定的重发次数之后, 如果仍然没有任何确认应答返回, 就会判断为网络或者对端主机发生了异常, 强制关闭连接.

Linux 的设置

最小重传时间是 200ms

最大重传时间是 120s

重传次数为 15TCP retransmits an unacknowledged packet up to tcp_retries2 sysctl setting times(defaults to15)usingan exponential backoff timeoutforwhich each retransmission timeoutisbetween TCP_RTO_MIN(200ms)andTCP_RTO_MAX(120seconds).Oncethe15thretryexpires(bydefault),the TCP stack will notify the layers above(IE.App)ofa broken connection.

ThevalueofTCP_RTO_MINandTCP_RTO_MAXishardcodedintheLinuxkernelanddefinedbythe following constants:

#defineTCP_RTO_MAX((unsigned)(120*HZ))

#defineTCP_RTO_MIN((unsigned)(HZ/5))

Linux 2.6+ uses HZ of 1000ms, so TCP_RTO_MIN is ~200 ms and TCP_RTO_MAX is ~120 seconds. Given a default value of tcp_retries set to 15, it means that it takes 924.6 seconds before a broken network link is notified to the upper layer (IE. application), since the connection is detected as broken when the last (15th) retry expires.

ab7653affab982b574eb7acc55df2e04.gifimage.PNGFromtheLinuxkernel doc

tcp_retries2-INTEGER

Thisvalueinfluences the timeoutofan alive TCP connection,

when RTO retransmissions remain unacknowledged.GivenavalueofN,a hypothetical TCP connection following

exponential backoffwithan initial RTOofTCP_RTO_MIN would

retransmit N times before killing the connection at the(N+1)th RTO.

Thedefaultvalueof15yields a hypothetical timeoutof924.6

secondsandisa lower boundforthe effective timeout.

TCP will effectively timeoutat the first RTO which exceeds the

hypothetical timeout.

RFC1122recommends at least100secondsforthe timeout,

which corresponds to avalueofat least8.

参考地址

https://pracucci.com/linux-tcp-rto-min-max-and-tcp-retries2.html

来源: http://www.jianshu.com/p/51d7f7fb3e4b

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值