How to get IP address using jpcap?

Discussion in 'Java' started by yikaikai, Mar 21, 2007.

  1. yikaikai

    yikaikai Guest

    yikaikai, Mar 21, 2007
    #1
    1. Advertising

  2. On Wed, 21 Mar 2007 10:00:38 +0800, yikaikai wrote:
    > I got the code from
    > http://netresearch.ics.uci.edu/kfujii/jpcap/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
     
    Gordon Beaton, Mar 21, 2007
    #2
    1. Advertising

  3. yikaikai

    yikaikai Guest

    Thank you, I got it.
    "Gordon Beaton" <> дÈëÏûÏ¢ÐÂÎÅ:4600e366$0$24617$...
    > On Wed, 21 Mar 2007 10:00:38 +0800, yikaikai wrote:
    >> I got the code from
    >> http://netresearch.ics.uci.edu/kfujii/jpcap/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, Mar 21, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. avnrao
    Replies:
    1
    Views:
    7,343
    avnrao
    May 4, 2004
  2. Patrice
    Replies:
    0
    Views:
    926
    Patrice
    May 4, 2004
  3. Unexplored Dimension

    Using Jpcap

    Unexplored Dimension, Mar 27, 2006, in forum: Java
    Replies:
    1
    Views:
    4,831
    IchBin
    Mar 27, 2006
  4. Eelco

    jpcap unsatisfiedlinkerror

    Eelco, Nov 13, 2006, in forum: Java
    Replies:
    4
    Views:
    2,795
    Eelco
    Nov 14, 2006
  5. Bentow
    Replies:
    2
    Views:
    1,224
    John B. Matthews
    Sep 22, 2009
Loading...

Share This Page