1

我正在开发服务器,客户端消息通过手机发送。服务器和手机通过Wifi连接。

客户端向服务器发送 HTTP Post 消息,服务器应该回复 200 ok。它适用于大多数系统,但在某些系统中,服务器收到 POST 消息后,它会回复 TCP RST。

服务器 IP 为:192.168.1.2,客户端 IP 为:192.168.1.9。这是不工作时的流程。

|Time     | 192.168.1.9                           |
|         |                   | 192.168.1.2       |                   
|103.313276|         49988 > 5901 [SYN]            |TCP: 49988 > 5901 [SYN] Seq=0 Win=14600 Len=0 MSS=1460 SACK_PERM=1 TSval=306973 TSecr=0 WS=64
|         |(49988)  ------------------>  (5901)   |
|103.313469|         5901 > 49988 [SYN,            |TCP: 5901 > 49988 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460 WS=8 TSval=0 TSecr=0 SACK_PERM=1
|         |(49988)  <------------------  (5901)   |
|106.281619|         5901 > 49988 [SYN,            |TCP: 5901 > 49988 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460 WS=8 TSval=0 TSecr=0 SACK_PERM=1
|         |(49988)  <------------------  (5901)   |
|112.316765|         5901 > 49988 [SYN,            |TCP: 5901 > 49988 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460 WS=8 TSval=0 TSecr=0 SACK_PERM=1
|         |(49988)  <------------------  (5901)   |
|124.381196|         POST 192.168.1.2:59           |HTTP: POST 192.168.1.2:5901/ftcontentserver.rcs.mnc.mcc.pub.3gppnetwork.org HTTP/1.1 
|         |(49988)  ------------------>  (5901)   |
|124.381300|         5901 > 49988 [RST]            |TCP: 5901 > 49988 [RST] Seq=1 Win=0 Len=0
|         |(49988)  <------------------  (5901)   |

这是它起作用的情况:

|Time     | 192.168.1.3                           | 192.168.1.2                           |
|         |                   | 192.168.1.2       |                   
|117.828732|         42956 > 5901 [SYN]            |                   |TCP: 42956 > 5901 [SYN] Seq=0 Win=14600 Len=0 MSS=1460 SACK_PERM=1 TSval=2994458 TSecr=0 WS=64
|         |(42956)  ------------------>  (5901)   |                   |
|117.828828|         5901 > 42956 [SYN,            |                   |TCP: 5901 > 42956 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460 WS=8 TSval=0 TSecr=0 SACK_PERM=1
|         |(42956)  <------------------  (5901)   |                   |
|117.930471|         42956 > 5901 [ACK]            |                   |TCP: 42956 > 5901 [ACK] Seq=1 Ack=1 Win=14656 Len=0 TSval=2994490 TSecr=0
|         |(42956)  ------------------>  (5901)   |                   |
|117.930932|         [TCP Window Update]           |                   |TCP: [TCP Window Update] 5901 > 42956 [ACK] Seq=1 Ack=1 Win=262800 Len=0 TSval=75822 TSecr=2994490
|         |(42956)  <------------------  (5901)   |                   |
|117.941444|         POST 192.168.1.2:59           |                   |HTTP: POST 192.168.1.2:5901/ftcontentserver.rcs.mnc.mcc.pub.3gppnetwork.org HTTP/1.1 
|         |(42956)  ------------------>  (5901)   |                   |
|117.964006|         HTTP/1.1 204 No Con           |                   |HTTP: HTTP/1.1 204 No Content 
|         |(42956)  <------------------  (5901)   |                   |

这是我在第一种情况下得到的错误:专家信息(警告/协议):确认号:TCP 损坏。确认字段为非零,而 ACK 标志未设置

有人可以建议可能出了什么问题吗?

这是wireshark转储

No.     Time        Source                Destination           Protocol Length Info
      1 0.000000    192.168.1.9           192.168.1.2           TCP      74     49988 > 5901 [SYN] Seq=0 Win=14600 Len=0 MSS=1460 SACK_PERM=1 TSval=306973 TSecr=0 WS=64

Frame 1: 74 bytes on wire (592 bits), 74 bytes captured (592 bits)
Ethernet II, Src: Lge_4c:96:28 (5c:17:d3:4c:96:28), Dst: IntelCor_d4:8d:40 (00:23:14:d4:8d:40)
Internet Protocol Version 4, Src: 192.168.1.9 (192.168.1.9), Dst: 192.168.1.2 (192.168.1.2)
Transmission Control Protocol, Src Port: 49988 (49988), Dst Port: 5901 (5901), Seq: 0, Len: 0

No.     Time        Source                Destination           Protocol Length Info
      2 0.000193    192.168.1.2           192.168.1.9           TCP      78     5901 > 49988 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460 WS=8 TSval=0 TSecr=0 SACK_PERM=1

Frame 2: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)
Ethernet II, Src: IntelCor_d4:8d:40 (00:23:14:d4:8d:40), Dst: Lge_4c:96:28 (5c:17:d3:4c:96:28)
Internet Protocol Version 4, Src: 192.168.1.2 (192.168.1.2), Dst: 192.168.1.9 (192.168.1.9)
Transmission Control Protocol, Src Port: 5901 (5901), Dst Port: 49988 (49988), Seq: 0, Ack: 1, Len: 0

No.     Time        Source                Destination           Protocol Length Info
      3 2.968343    192.168.1.2           192.168.1.9           TCP      78     5901 > 49988 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460 WS=8 TSval=0 TSecr=0 SACK_PERM=1

Frame 3: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)
Ethernet II, Src: IntelCor_d4:8d:40 (00:23:14:d4:8d:40), Dst: Lge_4c:96:28 (5c:17:d3:4c:96:28)
Internet Protocol Version 4, Src: 192.168.1.2 (192.168.1.2), Dst: 192.168.1.9 (192.168.1.9)
Transmission Control Protocol, Src Port: 5901 (5901), Dst Port: 49988 (49988), Seq: 0, Ack: 1, Len: 0

No.     Time        Source                Destination           Protocol Length Info
      4 9.003489    192.168.1.2           192.168.1.9           TCP      78     5901 > 49988 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460 WS=8 TSval=0 TSecr=0 SACK_PERM=1

Frame 4: 78 bytes on wire (624 bits), 78 bytes captured (624 bits)
Ethernet II, Src: IntelCor_d4:8d:40 (00:23:14:d4:8d:40), Dst: Lge_4c:96:28 (5c:17:d3:4c:96:28)
Internet Protocol Version 4, Src: 192.168.1.2 (192.168.1.2), Dst: 192.168.1.9 (192.168.1.9)
Transmission Control Protocol, Src Port: 5901 (5901), Dst Port: 49988 (49988), Seq: 0, Ack: 1, Len: 0

No.     Time        Source                Destination           Protocol Length Info
      5 21.067920   192.168.1.9           192.168.1.2           HTTP     148    POST 192.168.1.2:5901/ftcontentserver.rcs.mnc.mcc.pub.3gppnetwork.org HTTP/1.1 

Frame 5: 148 bytes on wire (1184 bits), 148 bytes captured (1184 bits)
Ethernet II, Src: Lge_4c:96:28 (5c:17:d3:4c:96:28), Dst: IntelCor_d4:8d:40 (00:23:14:d4:8d:40)
Internet Protocol Version 4, Src: 192.168.1.9 (192.168.1.9), Dst: 192.168.1.2 (192.168.1.2)
Transmission Control Protocol, Src Port: 49988 (49988), Dst Port: 5901 (5901), Seq: 1, Ack: 1, Len: 82
Hypertext Transfer Protocol

No.     Time        Source                Destination           Protocol Length Info
      6 21.068024   192.168.1.2           192.168.1.9           TCP      54     5901 > 49988 [RST] Seq=1 Win=0 Len=0

Frame 6: 54 bytes on wire (432 bits), 54 bytes captured (432 bits)
Ethernet II, Src: IntelCor_d4:8d:40 (00:23:14:d4:8d:40), Dst: Lge_4c:96:28 (5c:17:d3:4c:96:28)
Internet Protocol Version 4, Src: 192.168.1.2 (192.168.1.2), Dst: 192.168.1.9 (192.168.1.9)
Transmission Control Protocol, Src Port: 5901 (5901), Dst Port: 49988 (49988), Seq: 1, Len: 0
4

1 回答 1

1

对于不工作的情况,TCP 握手没有完成。原因是本地端没有向接收到的 SYN/ACK 发送 ACK。为了提高可读性,我提供了 3 次握手的简短/编辑变体:

49988 > 5901 [SYN]  |TCP: 49988 > 5901 [SYN] Seq=0 Win=14600 Len=0 MSS=1460
5901 > 49988 [SYN,  |TCP: 5901 > 49988 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460
5901 > 49988 [SYN,  |TCP: 5901 > 49988 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460
5901 > 49988 [SYN,  |TCP: 5901 > 49988 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460

对于失败的情况,3 次握手完成:

42956 > 5901 [SYN]  ||TCP: 42956 > 5901 [SYN] Seq=0 Win=14600 Len=0 MSS=1460
5901 > 42956 [SYN,  ||TCP: 5901 > 42956 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460
42956 > 5901 [ACK]  ||TCP: 42956 > 5901 [ACK] Seq=1 Ack=1 Win=14656 Len=0

现在,为什么部分..一旦发出 connect(),底层 TCP 将发送 SYN 并响应 SYN-ACK,所以我在这里看到任何不好的事情,除了本地堆栈需要更多时间响应 SYN-ACK。此外,客户端在发送请求之前是否等待足够的 connect() 成功。如果 connect() 没有通过或被延迟,那么它不应该在该连接上发送任何数据。

于 2013-09-30T18:11:13.273 回答