最近更换了服务器的消息队列,客户端反馈说服务器有时候会多发消息下去,十分纳闷,只改了服务器的消息队列,但是服务器像客户端发消息的代码一行没改,日志也只是发一条消息下去,但是因为改了消息队列,最后使用linux抓包看看,以证清白。
tcpdump输出demo如下(这不是调试时的数据,只是demo)。这里我指定查看8060端口。
1 2 3 4 5
| root@mdev-2:/home/banfushen/webclient tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes 17:41:07.061086 IP 10.xxx.xxx.xxx.51321 > 11.xxx.xxx.xxx.8060: Flags [.], seq 2312385062:2312385063, ack 2244282406, win 1021, length 1 17:41:07.061177 IP 11.xxx.xxx.xxx.8060 > 10.xxx.xxx.xxx.51321: Flags [.], ack 1, win 101, options [nop,nop,sack 1 {0:1}], length 0
|
抓包之后,发现的确只发下去一条,然后去抓客户端,在客户端打断点调试,最后发现是客户端自己的确收到一条,但是别的逻辑导致事件重复触发。最后证明清白。
tcpdump还有一些别的命令做一下记录:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| tcpdump -i en0
tcpdump host 192.xxx.xxx.xx
tcpdump src host 192.xxx.xxx.xx
tcpdump dst host 192.xxx.xxx.xx
tcpdump port 3000
|
tcpdump非常强大,还有一些更多的功能用到的时候再查询。