分析`pcap`文件中每个tcp包的tcp有效负载

时间:2013-04-24 17:07:27

标签: networking pcap libpcap tcpdump

我有很多pcap个文件 在每个pcap文件中都有一些tcp包 我想要以下步骤:

1过滤pcap文件以获得预期的tcp数据包(如果使用tshark,则过滤器类似于tcp.srcport==80 and tcp.dstport==20000)。每个tcp包中的tcp数据都是几十个字节,

  1) the first 2 bytes are sequence number
  2) the second 2 bytes indicate a length: **n**
  3) the following **n** bytes are random (if **n** is 2, then there are 2 random bytes)
  4) immediately after the **n** bytes is an IP address
每个tcp数据包

2,我想得到4)

中提到的源IP和IP地址字符串

最重要的是,我只想从每个tcp数据包中获取一对IP,很容易从tshark获取源IP,但是tcp数据中的IP地址需要一些努力

是否有任何好的源代码片段或可用于我的目标的好方法? 谢谢!

0 个答案:

没有答案