How to listen to network traffic on an interface / device using Java?

I am looking to implement a reverse QoS system (because I do not have the resources to saturate my network in order to actually perform QoS). Everything I saw about capturing network traffic using Java seems to point to Jpcap - a 3+ year old library or other similar projects. Also, reading the java.net documentation did not help, although the ServerSocket class seems to be on the right track.

What I'm looking for is the source code of the library or a newer / supported infrastructure for this. I want to capture all packets coming over the network and throw them into buffers, and then free them from the buffers after a certain time, depending on the protocol that the packet carries.

I know how to create socket applications, but I donโ€™t know how to go up (down technically) to interfaces. Help will be greatly appreciated!

+4
source share
1 answer

What you are looking for is simply beyond the scope of the universal Java application.

If you plan on considering a specific OS, such as Windows or Linux (my following examples), then there are a few things you can do.

For Windows, any given application cannot do this without driver privileges. WinPCap is probably the most widely used tool in this case, and that uses jpcap. This is a โ€œdriverโ€ that is basically just โ€œMan-in-the-middleโ€ of your traffic.

Linux https://security.stackexchange.com/questions/13267/monitoring-outgoing-network-traffic

, , Java-, , Java .

+2

Source: https://habr.com/ru/post/1539216/


All Articles