用tcpdump来抓包和分析IP/TCP的结构

来源:互联网 发布:内蒙广电网络登录入口 编辑:程序博客网 时间:2024/05/16 01:37

         抓包:

xxxxxx$ sudo tcpdump -iany port 5432 -Xnlps0tcpdump: verbose output suppressed, use -v or -vv for full protocol decodelistening on any, link-type LINUX_SLL (Linux cooked), capture size 65535 bytes22:11:14.191365 IP 10.100.70.139.30052 > 1.2.3.4.postgres: Flags [S], seq 3929399830, win 14280, options [mss 1428,sackOK,TS val 1171752792 ecr 0,nop,wscale 8], length 0        0x0000:  4510 003c 654e 4000 4006 8069 0a64 468b  E..<eN@.@..i.dF.        0x0010:  0102 0304 7564 1538 ea35 e216 0000 0000  ....ud.8.5......        0x0020:  a002 37c8 5523 0000 0204 0594 0402 080a  ..7.U#..........        0x0030:  45d7 8758 0000 0000 0103 0308 0000 0000  E..X............        0x0040:  0000 0000 0000 0000 0000 0000            ............
         之前我们说过, tcpdump抓的是网络层数据, 一起来看看。 IP数据头结构, 想必大家已经很熟悉了, 我就不单独画图。

         4表示ipv4,  5表示IP头有5*4字节, 也就是说, IP头侧长度为20字节, 这是个典型的值。 也就是说, 如下部分都是IP头:

4510 003c 654e 4000 4006 8069 0a64 468b
0102 0304

         我们来看上面的IP数据:

         003c的十进制是60, 表明整个IP头+IP身体, 总共有60字节。 IP头的其他信息也类似分析, 不太赘述。


         至于tcp的部分, 对着TCP头结构看吧, 看着看着, 挺有意思的。


         

原创粉丝点击