How can you access batch information in a JpCap package

How can I get the relevant batch information from a JpCap package? I am trying to find the source / destination IP address and port. So far I have tried a string parsing the Packet toString () method, but that seems rude.

+3
source share
2 answers

You need to overlay the Packet object on the correct type of package that I think.

So something like:

TCPPacket p = (TCPPacket)packet;

// Get the tcp src and dest ports
int destPort = p.dst_port;
int srcPort = p.src_port;

// Get the src and dest IP addresses from the IP layer
InetAddress destIp = p.dst_ip;
InetAddress srcIp = p.src_ip;
+4
source

Here is a good example on accessing package information using Jpcap

+1
source

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


All Articles