Package jpcap.packet

Examples of jpcap.packet.ICMPPacket


      gwmac=((EthernetPacket)ping.datalink).dst_mac;
      break;
    }
   
    //create ICMP packet
    ICMPPacket icmp=new ICMPPacket();
    icmp.type=ICMPPacket.ICMP_ECHO;
    icmp.seq=100;
    icmp.id=0;
    icmp.setIPv4Parameter(0,false,false,false,0,false,false,false,0,0,0,IPPacket.IPPROTO_ICMP,
        thisIP,InetAddress.getByName(args[1]));
    icmp.data="data".getBytes();
   
    EthernetPacket ether=new EthernetPacket();
    ether.frametype=EthernetPacket.ETHERTYPE_IP;
    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();
View Full Code Here


      System.exit(0);
    }
    int index=Integer.parseInt(args[0]);
    JpcapSender sender=JpcapSender.openDevice(devices[index]);

    ICMPPacket p=new ICMPPacket();
    p.type=ICMPPacket.ICMP_TSTAMP;
    p.seq=1000;
    p.id=999;
    p.orig_timestamp=123;
    p.trans_timestamp=456;
    p.recv_timestamp=789;
    p.setIPv4Parameter(0,false,false,false,0,false,false,false,0,1010101,100,IPPacket.IPPROTO_ICMP,
      InetAddress.getByName("www.yahoo.com"),InetAddress.getByName("www.amazon.com"));
    p.data="data".getBytes();

    EthernetPacket ether=new EthernetPacket();
    ether.frametype=EthernetPacket.ETHERTYPE_IP;
View Full Code Here

TOP

Related Classes of jpcap.packet.ICMPPacket

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.