免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
楼主: flw
打印 上一主题 下一主题

Linux Kernel 2.6,listen(5),永不 accept,到底能建立成功多少个连接? [复制链接]

论坛徽章:
1
双子座
日期:2015-01-04 14:25:06
1 [报告]
发表于 2008-09-02 18:07 |显示全部楼层
原帖由 chenzhanyiczy 于 2008-9-2 17:31 发表
只有5个吧,listen是建立连接,只是没有accpet

不会只有5个的

Figure 4.10. Actual number of queued connections for values of backlog.

123.JPG (21.84 KB, 下载次数: 76)

123.JPG

论坛徽章:
1
双子座
日期:2015-01-04 14:25:06
2 [报告]
发表于 2008-09-02 21:34 |显示全部楼层
To understand the backlog argument, we must realize that for a given listening socket, the kernel maintains two queues :

1.An incomplete connection queue, which contains an entry for each SYN that has arrived from a client for which the server is awaiting completion of the TCP three-way handshake. These sockets are in the SYN_RCVD state .

2.A completed connection queue, which contains an entry for each client with whom the TCP three-way handshake has completed. These sockets are in the ESTABLISHED state .

The backlog argument to the listen function has historically specified the maximum value for the sum of both queues.

Berkeley-derived implementations add a fudge factor to the backlog: It is multiplied by 1.5

When a SYN arrives from a client, TCP creates a new entry on the incomplete queue and then responds with the second segment of the three-way handshake: the server's SYN with an ACK of the client's SYN (Section 2.6). This entry will remain on the incomplete queue until the third segment of the three-way handshake arrives (the client's ACK of the server's SYN), or until the entry times out. (Berkeley-derived implementations have a timeout of 75 seconds for these incomplete entries.)

If the queues are full when a client SYN arrives, TCP ignores the arriving SYN (pp. 930–931 of TCPv2); it does not send an RST. This is because the condition is considered temporary, and the client TCP will retransmit its SYN, hopefully finding room on the queue in the near future. If the server TCP immediately responded with an RST, the client's connect would return an error, forcing the application to handle this condition instead of letting TCP's normal retransmission take over. Also, the client could not differentiate between an RST in response to a SYN meaning "there is no server at this port" versus "there is a server at this port but its queues are full."


Some implementations do send an RST when the queue is full. This behavior is incorrect for the reasons stated above, and unless your client specifically needs to interact with such a server, it's best to ignore this possibility. Coding to handle this case reduces the robustness of the client and puts more load on the network in the normal RST case, where the port really has no server listening on it.

[ 本帖最后由 yecheng_110 于 2008-9-2 22:05 编辑 ]

论坛徽章:
1
双子座
日期:2015-01-04 14:25:06
3 [报告]
发表于 2008-09-02 21:41 |显示全部楼层
Linux ubuntu 2.6.22-14-generic #1 SMP Tue Feb 12 02:46:46 UTC 2008 x86_64 GNU/Linux

netstat -nat | grep EST | grep 9999 | awk '$4=="127.0.0.1:9999"' |wc -l
一直是6
completed connection queue的长度应该是6
netstat -nat | grep SYN_RECV | grep 9999 | awk '$4=="127.0.0.1:9999"' |wc -l
这个最大是16
incomplete connection queue的长度可能是16
而且隔一段时间会变少然后再增加到16
这个时间应该就是a timeout of 75 seconds

netstat -nat | grep 9999 | awk '$5=="127.0.0.1:9999"'|wc -l
这个和第二段的代码保持一致的增加 比第二段代码的输出多1
就是多SYN_SENT这行

上一贴是unp上摘抄的内容
这是对照着的实验 应该和理论是吻合的

[ 本帖最后由 yecheng_110 于 2008-9-2 22:25 编辑 ]

论坛徽章:
1
双子座
日期:2015-01-04 14:25:06
4 [报告]
发表于 2008-09-04 09:49 |显示全部楼层
原帖由 chenzhanyiczy 于 2008-9-3 23:42 发表
问一下: 什么是REST 连接?

就是发reset包

论坛徽章:
1
双子座
日期:2015-01-04 14:25:06
5 [报告]
发表于 2008-09-04 11:30 |显示全部楼层
原帖由 chenzhanyiczy 于 2008-9-4 11:18 发表


我的意思是reset指的是什么意思?指:重新连接?

表示没有提供这个服务
断开连接

论坛徽章:
1
双子座
日期:2015-01-04 14:25:06
6 [报告]
发表于 2008-09-04 11:50 |显示全部楼层
原帖由 chenzhanyiczy 于 2008-9-4 11:47 发表
reset在tcp head的表现是rst=1??

是的
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP