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!
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 :)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With