Package jpcap

Examples of jpcap.JpcapSender


    ether.src_mac=device.mac_address;
    ether.dst_mac=gwmac;
    icmp.datalink=ether;
   
    captor.setFilter("icmp and dst host "+thisIP.getHostAddress(),true);
    JpcapSender sender=captor.getJpcapSenderInstance();
    //JpcapSender sender=JpcapSender.openDevice(device);
    sender.sendPacket(icmp);
    while(true){
      ICMPPacket p=(ICMPPacket) captor.getPacket();
      //System.out.println("received "+p);
      if(p==null){
        System.out.println("Timeout");
      }else if(p.type==ICMPPacket.ICMP_TIMXCEED){
        p.src_ip.getHostName();
        System.out.println(icmp.hop_limit+": "+p.src_ip);
        icmp.hop_limit++;
      }else if(p.type==ICMPPacket.ICMP_UNREACH){
        p.src_ip.getHostName();
        System.out.println(icmp.hop_limit+": "+p.src_ip);
        System.exit(0);
      }else if(p.type==ICMPPacket.ICMP_ECHOREPLY){
        p.src_ip.getHostName();
        System.out.println(icmp.hop_limit+": "+p.src_ip);
        System.exit(0);
      }else continue;
      sender.sendPacket(icmp);
    }
  }
View Full Code Here

TOP

Related Classes of jpcap.JpcapSender

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.