I have to write TCP Reassembly code in c++. Can somebody please suggest me what is the most suitable library I can use with enough documentation. I tried [pcapplusplus][1] but in this library, I can't find documentation how to implement TCP reassembly, only the api reference.
https://github.com/seladb/PcapPlusPlus
So I am curious to know whelther you can give me an example tutorial on how to use pcapplusplus TCP Reassembly or there are are other such library available?
Use TCP reassembly in PcapPlusPlus:
PcapPlusPlus contains a TCP reassembly example that shows how to use the API (you can also find this example in the documentation):
https://github.com/seladb/PcapPlusPlus/tree/master/Examples/TcpReassembly
Write your own implementation of TCP reassembly:
You can use the PcapPlusPlus TCP reassembly implementation as a reference:
https://github.com/seladb/PcapPlusPlus/blob/master/Packet%2B%2B/header/TcpReassembly.h
https://github.com/seladb/PcapPlusPlus/blob/master/Packet%2B%2B/src/TcpReassembly.cpp
Related
I've got a proprietary BMS language that is sending it's info over a specific UDP port on the network. The existing interface is not very well made or maintained, and functions poorly.
I have access to the stack for the code, and don't mind creating some interpretation functionality
My question is what is the best way that I should be receiving these raw packets in my program to be interpreted? I'm not finding any good documentation on how to do this, and I wanted to try and do it in a reasonably appropriate way.
Do I basically need to make my program constantly sniff a specific port? and will this be cumbersome to the network or program to be doing this?
You tagged this BACnet. Why don't you try Wireshark, with a capture filter "udp port 47808" and see if wireshark exposes the packets in a way that makes sense to you. (or have you done this). If it is bacnet, then normal UDP sockets, bound to port 47808 is the way to go. Note, that 47808-47823 are the most common BACnet "default" ports. Use cports or something to see exactly what port(s) your application is bound to.
You could use a packet-capture library - but that has security connotations, so instead you can probably (for most part) get away with using a .NET 'UdpClient'.
But! The real challenge is the breaking-down & interpretation of the BACnet packets, which is the hard part.
There is (now!/finally) a NuGet package for BACnet - not that I've used it, but that might be one of the best choices for your case.
But I also suggest you experiment with the (advanced & free) VTS (Visual Test Tool) too.
You could also try using the BACnet stack that YABE uses too.
I'm currently working on a networking library, but I don't know which way I should create it. The library should be designed to be used with games. Both reliable and unreliable packets are needed. Should I use "TCP and UDP", "UDP and SCTP", "UDP and create an RUDP protocol" or "RAW and build everything from ground up"? This is a long question that kept me struggling to much! I think creating a "robust" RUDP protocol is the best solution, but can I make a robust one?(extra work isn't a problem)
Thanks for your time.
Each one of those is made for a reason. TCP for kinda slow reliable connections, UDP for fast unreliable connections, STCP is not commonly used so it's not certainly stable(not preferred), RUDP best used when both reliable and unreliable messages are needed and RAW is mostly used by organizations trying to build their own networking system.
I've used netty with udp and tcp protocols.
To my surprise it can be used with serial port as well.
Transport used is rxtx, there are a very few positive recommendations for rxtx.
Can netty be used with jssc instead of rxtx?
Should an application developer really care about the underlying implementation (rxtx or jssc)?
Should there be a problem developing in x86 then swapping to ARM?
There is currently no support for jssc, but you could write your own transport implementation using it.
As Norman said you could write your own jssc channel implementation to make it work with netty. However you may find ready libraries here below:
Original lib:
https://github.com/jkschneider/netty-jssc
My fork with some fixes:
https://github.com/tttomat19/netty-jssc
Regarding ARM/x86 question I believe jssc supports ARM, but I did not try it.
Regarding rxtx and jssc comparison I had unpleasant experience with rxtx performance and maven build.
Netty is really well documented when it comes to TCP, but I wanted to try a simple UDP server-client example and didn't find any good code out there. (mostly mailing lists and users with allegedly buggy code)
Anyone care to provide some simple example? Thanks!
Maybe this will help you
https://github.com/normanmaurer/javamagazin-netty-ws/tree/master/src/main/java/me/normanmaurer/javamagazin/netty/examples/ws
It also bootstrap a simple udp server
In testing certain network device driver receive features, I need to send special packets on the wire. I know I need to open a raw socket and push the bytes out. Is there some well-known example (C, perl, whatever) code already available for playing at this level?
(added later) I would prefer non-platform-specific answers, they'll be the most useful for everyone.
Look at the documentation for packet. Basically, you create a socket with SOCK_RAW or SOCK_DGRAM, then write to the socket using normal socket i/o. However, the data you send will be put directly on the line, rather than automatically getting the headers that are necessary for most network interop.
http://www.codeproject.com/KB/IP/sendrawpacket.aspx
There's already an existing project that may be able to help you with this.
Check out http://tcpreplay.synfin.net/wiki/tcprewrite#RewritingLayer2
and http://tcpreplay.synfin.net/
Seems to me you are looking for a tool to generate your own packets, Scapy is such a tool often used in the security industry (such as pentesters).
Demo is available: http://www.secdev.org/projects/scapy/demo.html
I can't think of any examples. But you should just be able to open up a UDP socket to any IP address you like and start writing data to it. Make sure its UDP or this will not work.
I found that there's a good C example here at Security-Freak, which only needed a little modification for flexibility. I'm hoping there are more answers in other languages.