How to read and write raw ip packets from java on mac?

What would be the easiest way to send and receive raw network packets. Should I write my own JNI packaging for some c API, in which case, which API am I looking for?

EDIT: I want to be able to do what wirehark does, i.e. write all incoming packets on the interface and, in addition, send my own created packets. And I want to do it on a Mac.

+3
source share
5 answers

If you start with the idea that you need something like a packet sniffer, you might want to look at http://netresearch.ics.uci.edu/kfujii/jpcap/doc/ .

+1
source

Raw Socket Java - JDK . . . , . - PING, , . :)

+1

BPF api JNI

+1

TINI - Java- Ethernet, Ethernet TCP. -, . , , .

0

Java, Java .

Also note that access to raw sockets is usually available only for the “root” processes, since otherwise any user could: a) sniff all the traffic and b) generate fake packets.

Instead of writing your entire program so that it runs as root, you might think that packet capture and generation is done in a separate program using some sort of IPC (RMI, named pipe, TCP socket, etc. ) to exchange data with your Java application.

0
source

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


All Articles