首页 > 其他分享 >TCP的FIN_WAIT1状态

TCP的FIN_WAIT1状态

时间:2022-12-10 13:02:24浏览次数:77  
标签:retries WAIT1 RTO tcp TCP value FIN backlog

  今天打流测试出现大量的FIN_WAIT1状态,可知主动关闭没有收到ack,

有个问题是?这个状态会维持多长时间??

参考这几篇博客:

​​修改重传次数&& 超时重传最大时间​​

​​TCP的定时器​​  查看tcp_write_timeout 中部分的代码有检测sock_dead状态下的超时时间

if (sock_flag(sk, SOCK_DEAD)) {
const int alive = (icsk->icsk_rto < TCP_RTO_MAX);

retry_until = tcp_orphan_retries(sk, alive);
do_reset = alive ||
!retransmits_timed_out(sk, retry_until, 0, 0);

if (tcp_out_of_resources(sk, do_reset))
return 1;
}
/* Calculate maximal number or retries on an orphaned socket. */
static int tcp_orphan_retries(struct sock *sk, int alive)
{
int retries = sysctl_tcp_orphan_retries; /* May be zero. */

/* We know from an ICMP that something is wrong. */
if (sk->sk_err_soft && !alive)
retries = 0;

/* However, if socket sent something recently, select some safe
* number of retries. 8 corresponds to >100 seconds with minimal
* RTO of 200msec. */
if (retries == 0 && alive)
retries = 8;
return retries;
}

 

可知:

如果系统负载较重,有很多 FIN_WAIT1,那么可以考虑通过降低 tcp_orphan_retries 来解决问题

linux 内核文档有:

tcp_orphan_retries - INTEGER
This value influences the timeout of a locally closed TCP connection, when RTO retransmissions remain unacknowledged.
See tcp_retries2 for more details.
The default value is 8.
If your machine is a loaded WEB server,
you should think about lowering this value, such sockets
may consume significant resources. Cf. tcp_max_orphans.

 

tcp_retries2 - INTEGER
This value influences the timeout of an alive TCP connection,
when RTO retransmissions remain unacknowledged.
Given a value of N, a hypothetical TCP connection following
exponential backoff with an initial RTO of TCP_RTO_MIN would
retransmit N times before killing the connection at the (N+1)th RTO.
The default value of 15 yields a hypothetical timeout of 924.6
seconds and is a lower bound for the effective timeout.
TCP will effectively time out at the first RTO which exceeds the hypothetical timeout.
RFC 1122 recommends at least 100 seconds for the timeout,
which corresponds to a value of at least 8.

 

同时对比分析

net.ipv4.tcp_max_syn_backlog=102400
net.core.somaxconn=102400

sysctl is an API. So you can just read the Linux kernel ​​documentation for appropriate version​​:

tcp_max_syn_backlog - INTEGER
Maximal number of remembered connection requests, which have not
received an acknowledgment from connecting client.
The minimal value is 128 for low memory machines, and it will
increase in proportion to the memory of machine.
If server suffers from overload, try increasing this number.

somaxconn - INTEGER
Limit of socket listen() backlog, known in userspace as SOMAXCONN.
Defaults to 128. See also tcp_max_syn_backlog for additional tuning
for TCP sockets.

Let's consider a ​​TCP-handshake​​​.. ​​tcp_max_syn_backlog​​​ represents the maximal number of connections in ​​SYN_RECV​​​ queue. I.e. when your server received SYN, sent SYN-ACK and haven't received ACK yet. This is a separate queue of so-called "request sockets" - ​​reqsk​​​ in code (i.e. not fully-fledged sockets, "request sockets" occupy less memory. In this state we can save some memory and not yet allocate a full socket because the full connection may not be at all in the future if ACK will not arrive). The value of this queue is affected (see ​​this post​​​) by ​​listen()​​​'s ​​backlog​​​ argument and limited by ​​tcp_max_syn_backlog​​ in kernel.

​somaxconn​​​ represents the maximal size of ​​ESTABLISHED​​​ queue. This is another queue.
Recall the previously mentioned ​​​SYN_RECV​​​ queue - your server is waiting for ACK from client. When the ACK arrives the kernel roughly speaking makes the big full-fledged socket from "request socket" and moves it to ESTABLISHED queue. Then you can do ​​accept()​​​ on this socket. This queue is also affected by ​​listen()​​​'s ​​backlog​​​ argument and limited by ​​somaxconn​​ in kernel.

 

http代理服务器(3-4-7层代理)-网络事件库公共组件、内核kernel驱动 摄像头驱动 tcpip网络协议栈、netfilter、bridge 好像看过!!!! 但行好事 莫问前程 --身高体重180的胖子



标签:retries,WAIT1,RTO,tcp,TCP,value,FIN,backlog
From: https://blog.51cto.com/u_15404950/5927491

相关文章

  • 27. Object.defineProperty
    vue2数据驱动,双向绑定原理,Object.definePropertyObject.defineproperty是ES5的一个函数,为对象添加属性语法:Object.defineProperty(目标对象,属性名,{属性修饰符})......
  • 45th ICPC World Finals Challenge powered by Huawei
    虽然好几天前就结束了,但现在才有时间写。打的是\(\text{P1}\)。题有兴趣的可以自己看:分榜只展示前面一部分(奖嘿嘿耳机。码又臭又长(附了一些注释。//If,......
  • find命令find -name 文件名
    find命令详解find命令作用find命令用来在指定目录下查找文件。find命令选项基本格式find目录-选项动作[-print-exec-ok...]常用选项:-a:and必须满足两......
  • 工具5:FinalShell
    FinalShell是一体化的的服务器,网络管理软件,不仅是ssh客户端,还是功能强大的开发,运维工具,充分满足开发,运维需求.设置好要连接的主机输入linux指令,操作电脑命令,比如广播......
  • trylock的finally 除了解锁最好啥都别做
    一个大兄弟的生产大概代码//从数据库拿点特定状态的数据List<X>bosPaymentBills=pageQueryBosPaymentBill(beginTime,endTime,PushStatusEnum.NO_PUSH.getCode(),st......
  • You may have an infinite update loop in a component render function.报错解决办法
    报错本例在computed中进行修改data里的数据时发生的错误Youmayhaveaninfiniteupdateloopinacomponentrenderfunction.原因data中的数据一直处于监听状态,因......
  • Objective-C #define 用法
    在C语言中,预处理代码(Preprocessor)是非常强大的工具,能让你的代码变得更加易读和易改。利用预处理代码,你可以重新定义代码的一部分,使得你的代码更适合你的风格。预处理......
  • Maven - oracle ojdbc jar包报错:Could not find artifact com.oracle:ojdbc8
    oracleojdbcjar包报错:Couldnotfindartifactcom.oracle:ojdbc8 在IDEA中引入一个新项目时,由于项目中引入了如下依赖:<dependency><groupId>c......
  • 【FAQ】pip更新遇到ValueError: Unable to find resource t64.exe in package pip._ve
    【问题】pip更新报错ERROR:Exception:Traceback(mostrecentcalllast):File"C:\Users\dlut_\AppData\Roaming\Python\Python39\site-packages\pip\_internal\cl......
  • 合并报表软件FineReport中如何设置工具栏控制
    不同用户角色登录系统时查看同一张模板所看到工具栏按钮不同,比如说技术支持部长角色登录系统时,查看一张模板,看不到工具栏上的导出和打印按钮,技术支持总调度角色却可以,下面......