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();