Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   How to get IP address using jpcap? (http://www.velocityreviews.com/forums/t485850-how-to-get-ip-address-using-jpcap.html)

yikaikai 03-21-2007 02:00 AM

How to get IP address using jpcap?
 
I got the code from
http://netresearch.ics.uci.edu/kfuji...doc/index.html

but how can I get IP address from packet?

public void receivePacket(Packet packet) {
System.out.println(packet);



Gordon Beaton 03-21-2007 07:48 AM

Re: How to get IP address using jpcap?
 
On Wed, 21 Mar 2007 10:00:38 +0800, yikaikai wrote:
> I got the code from
> http://netresearch.ics.uci.edu/kfuji...doc/index.html
>
> but how can I get IP address from packet?
>
> public void receivePacket(Packet packet) {
> System.out.println(packet);


After skimming the javadocs, I'd say you need to do something like
this:

if (packet instanceOf IPPacket) {
IPPacket ipp = (IPPacket)packet;
InetAddress dest = ipp.dest_ip;
InetAddress src = ipp.src_ip;
}

/gordon

--
[ don't email me support questions or followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e

yikaikai 03-21-2007 08:33 AM

Re: How to get IP address using jpcap?
 
Thank you, I got it.
"Gordon Beaton" <n.o.t@for.email> 写入消息新闻:4600e366$0$24617$8404b019@news.wineas y.se...
> On Wed, 21 Mar 2007 10:00:38 +0800, yikaikai wrote:
>> I got the code from
>> http://netresearch.ics.uci.edu/kfuji...doc/index.html
>>
>> but how can I get IP address from packet?
>>
>> public void receivePacket(Packet packet) {
>> System.out.println(packet);

>
> After skimming the javadocs, I'd say you need to do something like
> this:
>
> if (packet instanceOf IPPacket) {
> IPPacket ipp = (IPPacket)packet;
> InetAddress dest = ipp.dest_ip;
> InetAddress src = ipp.src_ip;
> }
>
> /gordon
>
> --
> [ don't email me support questions or followups ]
> g o r d o n + n e w s @ b a l d e r 1 3 . s e
>





All times are GMT. The time now is 03:32 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.