你如何在gopacket中使用tcp assembly包?

huangapple go评论93阅读模式
英文:

How do you use the tcp assembly package in gopacket?

问题

我一直在使用pcap包和gopacket来解析网络流量,并取得了相当不错的成功。这些库使得处理网络捕获数据变得更加容易,确实节省了我大量的时间。

我想进一步使用tcp assembly包来重新组装TCP流,但是从文档中提供的示例中,我不太确定如何操作。

链接在这里:

http://godoc.org/code.google.com/p/gopacket/tcpassembly/tcpreader

我想要的是一个简单的示例,演示如何设置这个功能,使得数据包从一端进入,而另一端输出一个有序的字节流。

提前感谢!

英文:

I've been using the pcap package along with gopacket to parse network traffic with pretty good success. These libraries have made it much easier to work with network captures and they've definitely saved me a ton of time.

I'd like to take it a step further and use the tcp assembly package to start reassembling TCP streams, but I'm not really sure from the examples provided in the docs how to go about it.

The link is here:

http://godoc.org/code.google.com/p/gopacket/tcpassembly/tcpreader

What I'm looking for is a simple example that demonstrates how to set this up so that you have packets going in one end and a nice byte ordered data stream coming out the other end.

Thanks in advance!

答案1

得分: 4

原来在主要的代码库中已经提供了一个完整的示例:

https://github.com/google/gopacket/blob/master/examples/httpassembly/main.go

效果很好 你如何在gopacket中使用tcp assembly包?

英文:

Turns out there is already a full example provided in the main repo:

https://github.com/google/gopacket/blob/master/examples/httpassembly/main.go

Worked great 你如何在gopacket中使用tcp assembly包?

答案2

得分: 3

我已经在https://code.google.com/p/gopacket/source/browse/examples/statsassembly/main.go上添加了第二个示例,它使用了一些稍微不同的模式,从而得到一个可以更轻松处理高吞吐量嗅探的二进制文件。

英文:

I've added a second example at https://code.google.com/p/gopacket/source/browse/examples/statsassembly/main.go as well, which uses some slightly different patterns, resulting in a binary that can handle higher-throughput sniffing a little easier.

huangapple
  • 本文由 发表于 2014年1月16日 02:48:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/21145781.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定