sir in java-ee how could i get detail of packet header( source_IP,destination_IP,Source_Port,Destination_Port only ) which are transmitting and receiving at our system through socket....
whenever we open browser and open any site such as www.stackoverflow.com
then our java-ee program's output comes as fallow
if 222 packet transfer takes place then detail of all the 222
source_IP Destination_ip source_port destination_port
192.168.5.10 64.34.119.12 2121 2929
64.34.119.12 192.168.5.10 . .
. . . .
. . . .
and so on...

- 1
- 1
-
Explain your question in more datail.. http://stackoverflow.com/faq#howtoask – Sachin Mhetre May 02 '12 at 06:08
-
This may help you http://stackoverflow.com/questions/2642487/how-can-you-access-the-packet-information-in-a-jpcap-packet – Viral Thakkar May 02 '12 at 07:18
4 Answers
Not in plain Java but with the help of some libraries like http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/

- 24,152
- 13
- 73
- 111
Yes you can capture all the packets that are travelling through a specific interface on any machine, there are many tools like wireshark etc. which help you do so, and since these are open source you can see the source and pick what you need out of them :)

- 2,411
- 20
- 32
socket is an end point communication between two machines. By using server socket u can get the destination ip and port. In case client view also you can get the source ip not port.using port only u are connecting to your server.

- 440
- 2
- 11
As far as i know, you can't do this with plain java. In Java you can only do point to point connections via Sockets. For capturing all packets, the network card must also be in promiscuous mode. Switching to this mode can't also be done in plain java. You could use RMI to call native code, but then you are platform dependend.

- 1,183
- 1
- 11
- 24