資源簡介
import java.net.Inet4Address;
import java.net.InetAddress;
import java.util.Arrays;
import jpcap.*;
import jpcap.packet.*;
public class ARP {
public static byte[] arp(InetAddress ip) throws java.io.IOException{
//發現本機器的網絡接口
代碼片段和文件信息
import?java.net.Inet4Address;
import?java.net.InetAddress;
import?java.util.Arrays;
import?jpcap.*;
import?jpcap.packet.*;
public?class?ARP?{
public?static?byte[]?arp(InetAddress?ip)?throws?java.io.IOException{
?????//發現本機器的網絡接口
int?i;
NetworkInterface[]?devices=JpcapCaptor.getDeviceList();
NetworkInterface?device=null;
for?(i?=?0;?i?{
?System.out.println(devices[i].description);
}
device?=?devices[0];//我的機器是第三個進行網絡通信
if(device==null)
throw?new?IllegalArgumentException(ip+“?is?not?a?local?address“);
//開啟網絡接口
JpcapCaptor?captor=JpcapCaptor.openDevice(device2000false3000);
captor.setFilter(“arp“true);
JpcapSender?sender=captor.getJpcapSenderInstance();
InetAddress?srcip=null;
//獲得接口地址,這里考慮到一網絡接口可能有多地址
for(i?=?0;?i?
- 上一篇:java 讀取txt數據并保存到數據庫中源代碼
- 下一篇:絲織物密度檢測器
評論
共有 條評論