aspose file tools
The moose likes Sockets and Internet Protocols and the fly likes Can I get source ip address and destination ip address of udp packet? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "Can I get source ip address and destination ip address of udp packet?" Watch "Can I get source ip address and destination ip address of udp packet?" New topic
Author

Can I get source ip address and destination ip address of udp packet?

vikas byn
Ranch Hand

Joined: Mar 18, 2011
Posts: 64
Can I get source ip address and destination ip address of udp packet?
Jaikiran Pai
Saloon Keeper

Joined: Jul 20, 2005
Posts: 6720

See http://download.oracle.com/javase/6/docs/api/java/net/DatagramPacket.html#getSocketAddress%28%29

[My Blog] [JavaRanch Journal]
vikas byn
Ranch Hand

Joined: Mar 18, 2011
Posts: 64


It will give information of Source address only.

actually I have one udp server in java at localhost and have some virtual interfaces on it.

now I send udp packet on this server at one virtual interface(say eth0:1). I received that packet but when extract information of source address only.

while i see tcpdump it will give information of source and destination.

that's why i am asking here if tcpdump get information of source and destination then java should have some api to get these information.

Rob Spoor
Saloon Keeper

Joined: Oct 27, 2005
Posts: 18367

If you click on that link you are sure to see a few other methods that return other addresses. Try those first.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
vikas byn
Ranch Hand

Joined: Mar 18, 2011
Posts: 64
Rob Spoor wrote:If you click on that link you are sure to see a few other methods that return other addresses. Try those first.


i tried it there are two methods for getting ip information - public SocketAddress getSocketAddress() and public InetAddress getAddress() - they give same address information.

actually i need three things - payload, source address and destination address (which is virtual interface in my case).

please forgive me for my bad english.
 
IntelliJ Java IDE
 
subject: Can I get source ip address and destination ip address of udp packet?
 
Threads others viewed
server socket and accept call
VPN
response time
TCP, UDP,IP
data packet or control packet?
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture