我對我的客戶端程序無法建立到遠程Web服務器的TCP連接的問題感到困惑。爲什麼客戶端在TCP握手期間發送RST數據包?
[現場]
客戶端程序基於Ubuntu服務器12.04 LTS上。
192.168.1.118(客戶程序)< ------- TCP ---------> sync.oncecode.com(web服務器)
[現象]
客戶端發送SYN,Web服務器回覆SYN/ACK,客戶端立即發送RST。在TCP/IP頭文件中看不到任何內容。有人能給我一些線索可能發生在這裏嗎?我已經跑出去的想法......
[tcpdump的日誌]
21:31:31.622576 IP 192.168.1.118.51441 > sync.oncecode.com.http: Flags [S], seq 3468888759, win 5360, options [mss 536,sackOK,TS val 40855676 ecr 0,nop,wscale 7], length 0
0x0000: 4500 003c 537d 4000 4006 ee75 c0a8 0176 E..<S}@[email protected]
0x0010: 2a79 0c32 c8f1 0050 cec3 0ab7 0000 0000 *y.2...P........
0x0020: a002 14f0 f8f7 0000 0204 0218 0402 080a ................
0x0030: 026f 687c 0000 0000 0103 0307 .oh|........
21:31:31.690808 IP sync.oncecode.com.http > 192.168.1.118.51441: Flags [S.], seq 1535159088, ack 3468888760, win 5792, options [mss 1440,sackOK,TS val 971694021 ecr 40830368,nop,wscale 6], length 0
0x0000: 4500 003c 0000 4000 3606 4bf3 2a79 0c32 E..<[email protected]*y.2
0x0010: c0a8 0176 0050 c8f1 5b80 ab30 cec3 0ab8 ...v.P..[..0....
0x0020: a012 16a0 6d6e 0000 0204 05a0 0402 080a ....mn..........
0x0030: 39ea dfc5 026f 05a0 0103 0306 9....o......
21:31:31.690826 IP 192.168.1.118.51441 > sync.oncecode.com.http: Flags [R], seq 3468888760, win 0, length 0
0x0000: 4500 0028 0000 4000 4006 4207 c0a8 0176 E..([email protected]@.B....v
0x0010: 2a79 0c32 c8f1 0050 cec3 0ab8 0000 0000 *y.2...P........
0x0020: 5004 0000 145a 0000
[追加] 防火牆似乎是關機,我檢查
[email protected]:~$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
完成了,謝謝你的建議。 – tihuBird
「SYN + ACK」中的「TSecr」與「SYN」中的「TSval」不同。所以至少看起來'SYN + ACK'不是對我們在這個數據包捕獲中看到的'SYN'的回覆。有沒有重發?也許這種不匹配是由NAT引起的,從未在這種情況下徘徊過。 – MattH
MattH,你是對的,客戶端發起發送很多重傳同步包,因爲服務器沒有響應。一段時間後,服務器響應sync/ack,然後客戶端發送RST。我懷疑家庭路由器有問題,所以重新啓動路由器,問題仍然存在。但是,在客戶端重新啓動ubuntu服務器後,TCP握手成功非常神祕。 – tihuBird