Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can you access the packet information in a JpCap Packet

How can I pull relevant packet information from a JpCap packet? I am trying to find the source/destination ip and port. So far I have tried string parsing the Packet's toString() method, but that seems brutish.

like image 902
Mantas Vidutis Avatar asked Dec 08 '25 15:12

Mantas Vidutis


1 Answers

You have to cast the Packet object to the correct type of Packet 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;
like image 165
Binary Nerd Avatar answered Dec 10 '25 04:12

Binary Nerd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!