简体   繁体   English

如何使用jpcap捕获数据包?

[英]how to catch packet using jpcap?

i have installed jpcap and add it in library but i have error in this line: 我已经安装了jpcap并将其添加到库中,但是在这一行中有错误:

String[] devices = JpcapCaptor.getDeviceList(); String []设备= JpcapCaptor.getDeviceList();

i think I added it wrong because it said: Javadoc not found. 我想我加错了,因为它说:找不到Javadoc。 Either Javadoc documentation for this item does not exist or you have not added specified Javadoc in the Java Platform Manager or the Library Manager. 此项的Javadoc文档不存在,或者您没有在Java Platform Manager或Library Manager中添加指定的Javadoc。

public static void main(String[] args) throws UnknownHostException {
    // TODO code application logic here
  String[] devices = JpcapCaptor.getDeviceList();
    if(args.length<1){
        System.out.println("Usage: java SentUDP <device index (e.g., 0, 1..)>");
        for(int i=0;i<devices.length;i++)
            System.out.println(i+":"+devices[i].name+"("+devices[i].description+")");
        System.exit(0);
    }

Here is a link to the javadoc for the deviceList() method: http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/javadoc/jpcap/JpcapCaptor.html#getDeviceList () 这是deviceList()方法的javadoc链接: http : //netresearch.ics.uci.edu/kfujii/Jpcap/doc/javadoc/jpcap/JpcapCaptor.html#getDeviceList ()

As you can see, it returns an array of NetworkInterface objects, not an array of strings. 如您所见,它返回一个NetworkInterface对象数组,而不是一个字符串数组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM