How do you use the tcp assembly package in gopacket?

余生长醉 提交于 2020-07-06 17:43:01

问题


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:


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 :)




回答2:


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.



来源:https://stackoverflow.com/questions/21145781/how-do-you-use-the-tcp-assembly-package-in-gopacket

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!