Linux TCP:服务器在收到客户端的 [SYN] 后立即发送 [RST, ACK]

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5272026/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 00:29:38  来源:igfitidea点击:

TCP: Server sends [RST, ACK] immediately after receiving [SYN] from Client

linuxtcpnioredhat

提问by Riyaz

Host_A tries to send some data to Host_B over TCP. Host_B is listening on port 8181. Both Host_A & Host_B are Linux boxes (Red Hat Enterprise). The TCP layer is implemented using Java NIO API.

Host_A 尝试通过 TCP 向 Host_B 发送一些数据。Host_B 正在侦听端口 8181。Host_A 和 Host_B 都是 Linux 机器(Red Hat Enterprise)。TCP 层是使用 Java NIO API 实现的。

Whatever Host_A sends, Host_B is unable to receive. Sniffing the data on wire using WireShark resulted in the following log:

无论 Host_A 发送什么,Host_B 都无法接收。使用 WireShark 嗅探电线上的数据导致以下日志:

1) Host_A (33253) > Host_B (8181): [SYN] Seq=0 Win=5840 Len=0 MSS=1460 TSV=513413781 TSER=0 WS=7
2) Host_B (8181) > Host_A (33253): [RST, ACK] Seq=1 Ack=1 Win=0 Len=0

1) Host_A (33253) > Host_B (8181): [SYN] Seq=0 Win=5840 Len=0 MSS=1460 TSV=513413781 TSER=0 WS=7
2) Host_B (8181) > Host_A (33253): [RST , ACK] Seq=1 Ack=1 Win=0 Len=0

The logs show that Host_A sends a [SYN] flag to Host_B in order to establish connection. But instead of [SYN, ACK] Host_B responds with an [RST, ACK] which resets/closes the connection. This behavior is observed always.

日志显示 Host_A 向 Host_B 发送 [SYN] 标志以建立连接。但是,而不是 [SYN, ACK] Host_B 以 [RST, ACK] 响应,该 [RST, ACK] 重置/关闭连接。这种行为总是被观察到。

I am wondering under what circumstance does a TCP listener sends [RST,ACK] in response to a [SYN]?

我想知道在什么情况下 TCP 侦听器会发送 [RST,ACK] 以响应 [SYN]?

采纳答案by Erik

RST, ACKmeans the port is closed. You sure Host_B is listening on the right IP/interface?

RST, ACK表示端口已关闭。您确定 Host_B 正在侦听正确的 IP/接口吗?

Also check your firewall for a -j REJECT --reject-with tcp-reset

还要检查您的防火墙是否有 -j REJECT --reject-with tcp-reset

回答by zbz.lvlv

It happened to me because I did not set sockaddr_in.sin_familyto AF_INET, in the server c++ program.

它发生在我身上,因为我没有在服务器 C++ 程序中设置sockaddr_in.sin_familyAF_INET, 。