写在前面
本文看下如何使用抓包的方式来验证TCP的三次握手的过程,关于tcp三次握手详细参考这篇文章。
1:tcpdump抓包验证
[root@localhost test]# tcpdump -i lo -c 3 -S
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on lo, link-type EN10MB (Ethernet), snapshot length 262144 bytes
00:47:33.995757 IP localhost.56498 > localhost.http: Flags [S], seq 1585108291, win 43690, options [mss 65495,sackOK,TS val 342326312 ecr 0,nop,ws
00:47:33.995771 IP localhost.http > localhost.56498: Flags [S.], seq 1018668475, ack 1585108292, win 43690, options [mss 65495,sackOK,TS val 34232
00:47:33.995785 IP localhost.56498 > localhost.http: Flags [.], ack 1018668476, win 342, options [nop,nop,TS val 342326312 ecr 342326312], length
3 packets captured
24 packets received by filter
0 packets dropped by kernel
和tcp头对应关系如下:
第一次握手:
第二次握手:
第三次握手:
2:wireshark抓包验证
我们来抓百度的包:
抓到的包:
第一次握手sync:
第二次握手sync,ack:
第三次握手ack: