Results 1 to 5 of 5
  1. #1
    ming8907 is offline Member
    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0

    Post keep ip address event

    I want to keep track ip address where have 135 destination port then in next packet with same ip address have 4445 destination port. I try the code at below, but can't run it. how to solve it? please help.Thanks.



    packet = jpcap.getPacket();
    if(packet instanceof IPPacket){
    IPPacket ipp = (IPPacket)packet;
    InetAddress destAdd = ipp.dst_ip;
    InetAddress srcAdd = ipp.src_ip;
    if(ipp instanceof TCPPacket){
    TCPPacket tcp = (TCPPacket)ipp;
    int destPort = tcp.dst_port;
    int srcPort = tcp.src_port;
    if(destPort == 135 || destPort == 445)
    {

    System.out.println(srcAdd + " " + destAdd + " " +srcPort + " " + destPort);
    Packet packet2 = jpcap.getPacket();
    if(packet2 instanceof IPPacket){
    IPPacket ipp2 = (IPPacket)packet2;
    InetAddress destAdd2 = ipp2.dst_ip;
    InetAddress srcAdd2 = ipp2.src_ip;
    if(destAdd2 == destAdd && srcAdd2 == srcAdd ){
    if(ipp2 instanceof TCPPacket){
    TCPPacket tcp2 =(TCPPacket)ipp2;
    int destPort2 = tcp2.dst_port;
    int srcPort2 = tcp2.src_port;
    if(destPort2 == 4444 || destPort2 == 9996){

    System.out.println(srcAdd2 + " " + destAdd2 + " " +srcPort2 + " " + destPort2);
    }

    }
    }
    }
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default Re: keep ip address event

    What does "but can't run it" mean?
    Errors?
    Exceptions?
    Stack traces?

    Also, when posting code please use [code] tags [/code].
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    ming8907 is offline Member
    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0

    Default Re: keep ip address event

    it run till line System.out.println(srcAdd + " " + destAdd + " " +srcPort + " " + destPort);
    then stuck.


    i new at here.sorry about the code tags.
    Last edited by ming8907; 07-26-2012 at 05:38 PM.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default Re: keep ip address event

    Then I'd suggest adding in some more debugging statements to find out exactly where it is getting stuck.
    I can't follow the flow of that code as it stands with no formatting.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: keep ip address event

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Getting IP address
    By GaneshB in forum Networking
    Replies: 11
    Last Post: 01-26-2012, 10:26 AM
  2. set IP address
    By yolimau in forum Networking
    Replies: 10
    Last Post: 05-30-2010, 02:37 AM
  3. Ip address finding
    By anilkumar_vist in forum New To Java
    Replies: 6
    Last Post: 04-10-2010, 03:06 AM
  4. checking for an event during an event
    By infinity in forum AWT / Swing
    Replies: 22
    Last Post: 04-09-2009, 01:08 AM
  5. JSP getting IP address
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-29-2008, 09:05 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •