• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to read contents of TCP packets in Internet

 
hari prasad
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to get the IP address of a packet from the remote host in Internet and read what each fields mean for designing a firewall
with address and service filters and acting as a applicaiton gateway?
so i want to read headers and other fields of the incoming packets
and authenicate it
which package and class can we be used for this in Java?
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hari,
Welcome to JavaRanch, the absolute best site on the www for Java information. We don't have many rules around here, but we do have one. Please change your display name to a first and last name to comply with the JavaRanch Naming Policy. You can change it here. Thank you for your cooperation.

Java is not well suited for creating low level packet analyzers since the core API does not support raw sockets. If you just want the IP address you can call getInetAddress() on the Socket object. You can also call getPort() for the remote port and getLocalPort() for the local port on the Socket. Past that, you need a third party API or you can create your own JNI routines.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!