html tool

显示标签为“tcpdump”的博文。显示所有博文
显示标签为“tcpdump”的博文。显示所有博文

2020年10月20日星期二

tcpdump抓的tcp包超过了mtu问题

 

本来是处理tcpreplay mtu重新分割问题,最后发现可以tcpdump抓包处理mtu- tcpdump抓的tcp包超过了mtu问题


1.关闭gso

参考:

https://www.cnblogs.com/jiangz/archive/2012/12/25/2831862.html [这里讲了要关闭gso但没有说原因]

http://wsfdl.com/%E8%B8%A9%E5%9D%91%E6%9D%82%E8%AE%B0/2016/07/12/tcp_package_large_then_MTU.html [这里说了原因,但没有说如何关闭,但推荐了https://stackoverflow.com/questions/2350985/length-of-captured-packets-more-than-mtu/2351026#2351026 的地址]

原文:

为了降低 CPU 的负载,提高网络的出口带宽,TSO 提供一些较大的缓冲区来缓存 TCP 发送的包,然后由网卡负责把缓存的大包拆分成多个小于 MTU 的包。tcpdump 或者 wireshare 抓取的是网卡上层的包,所以我们可能会观察到大小超过 MTU 的包:

[popexizhi: tcpdump是 从网卡上层抓的包]




2. 从generic segmentation offload 关闭,测试发现还是有1500 以上的mtu,查看详细的原文如下:分析如果是有网卡层的缓存,是不是看看协议是否也有类似的缓存设置

参考: https://stackoverflow.com/questions/2350985/length-of-captured-packets-more-than-mtu/2351026#2351026

打开

https://lists.openwall.net/netdev/2008/11/14/20

这里看到如下:



On 13-11-2008 15:29, Sami Farin wrote:

...

> Oh, I had old ethtool..

> These with v 6:

> # ethtool -k eth0

> Offload parameters for eth0:

> rx-checksumming: off

> tx-checksumming: off

> scatter-gather: off

> tcp segmentation offload: off

> udp fragmentation offload: off

> generic segmentation offload: on    #这个就是要关闭的gso

> Wow.  I turned gso off and now it works just like before.

> No packets over size of mtu anymore, either.


3. 测试了segmentation 果然有,tcp-segmentation-offload, 测试了一下 tso off

再次查看如下,重新测试抓包ok了

[root@localhost post_http]# ethtool -k eth0|grep segmentation

tcp-segmentation-offload: off

        tx-tcp-segmentation: off

        tx-tcp-ecn-segmentation: off

        tx-tcp6-segmentation: off

        tx-tcp-mangleid-segmentation: off

generic-segmentation-offload: off

tx-fcoe-segmentation: off [fixed]

tx-gre-segmentation: off [fixed]

tx-ipip-segmentation: off [fixed]

tx-sit-segmentation: off [fixed]

tx-udp_tnl-segmentation: off [fixed]

tx-gre-csum-segmentation: off [fixed]

tx-udp_tnl-csum-segmentation: off [fixed]

tx-sctp-segmentation: off [fixed]


2020年10月19日星期一

tcpdump !

参考: https://blog.csdn.net/shenwansangz/article/details/44834935

过滤不包含 ip的 tcp pcap 

tcpdump -i e1 host ! 10.10.10.1 and tcp

2018年9月28日星期五

解决tcpdump -w 的写缓存不实时写文件的问题解决


问题:
解决tcpdump -w 的写缓存不实时写文件的问题解决

解决方式: --待测试
tcpdump -w file直接写文件,而不适用操作系统写缓存方式

 --packet-buffered
              If the -w option is not specified, make the printed packet  out‐
              put  ``packet-buffered'';  i.e.,  as the description of the con‐
              tents of each packet is printed, it will be written to the stan‐
              dard  output, rather than, when not writing to a terminal, being
              written only when the output buffer fills.

              If the -w option is specified, make the saved raw packet  output
              ``packet-buffered'';  i.e.,  as each packet is saved, it will be
              written to the output file, rather than being written only  when
              the output buffer fills.

              The  -U  flag will not be supported if tcpdump was built with an
              older version of libpcap that lacks the pcap_dump_flush()  func‐
              tion.

2018年4月26日星期四

tcpdump分割大的pcap包




https://blog.csdn.net/wwrzzu/article/details/78881148


使用tcpdump的r和c参数拆分。
eg:tcpdump -r chicago.pcap -c 1000 -w output.pcap

2018年2月24日星期六

tcpdump read pcap

参考:
https://serverfault.com/questions/38626/how-can-i-read-pcap-files-in-a-friendly-format
sudo tcpdump -ttttnnr tcp_dump.pcap

https://www.jianshu.com/p/13db2d1a2f07

-r从指定的文件中读取包(这些包一般通过-w选项产生)。

[popexizhi:看来tcpdump 的命令要详细阅读了,之前一直以为看不了呢:)]

2017年12月14日星期四

tcpdump -ttt


http://www.jianshu.com/p/13db2d1a2f07

:)

tcpdump -ni eth0 -ttt



参数的含义如下:
-n不把网络地址转换成名字
-i指定监听的网络接口。
-t不在每一行中输出时间戳。
-tt在每一行中输出非格式化的时间戳
-ttt输出本行和前面一行之间的时间差。
-tttt在每一行中输出由date处理的默认格式的时间戳。
[popexizhi: 这个太有意思了,当我首次看到 -t, -tt, -ttt, -tttt以为是个排版错误呢:)]

(3) TCP包的输出信息

用tcpdump捕获的TCP包的一般输出信息是:
src > dst: flags data-seqno ack window urgent options
src > dst:表明从源地址到目的地址, flags是TCP报文中的标志信息,具体描述如下:
标识 字符缩写 描述
S SYN 同步标识
F FIN 终止标识
R RST 复位标识
P PSH 推送标识
. 以上四个标识bit全部为0
data-seqno是报文中的数据的顺序号, ack是下次期望的顺序号, window是接收缓存的窗口大小, urgent表明 报文中是否有紧急指针。 Options是选项。
作者:Yihulee 链接:http://www.jianshu.com/p/13db2d1a2f07 來源:简书 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。