| |

VerySource

 Forgot password?
 Register
Search
View: 867|Reply: 5

Problems in IP packet monitor

[Copy link]

2

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-1-25 16:00:01
| Show all posts |Read mode
PacketCapture: loading native library jpcap .. ok
Exception in thread "main" java.lang.UnsatisfiedLinkError: findDevice
at net.sourceforge.jpcap.capture.PacketCapture.findDevice (Native Method)
at subjectprogram.CapturePacketTest.main (CapturePacketTest.java:57)


Please give pointers, thank you.
Reply

Use magic Report

2

Threads

5

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-2-14 13:30:01
| Show all posts
The source program is as follows:

package subjectprogram;

import net.sourceforge.jpcap.capture. *;
import net.sourceforge.jpcap.net. *;
import java.util. *;
import java.io. *;

public class CapturePacketTest implements RawPacketListener, PacketListener {

// public Vector <String> CaptureVec = new Vector <String> ();
public static FileOutputStream fos = null;

public void rawPacketArrived (RawPacket rawPacket) {
// System.out.println ("rawPacket =" + rawPacket);
}

public void packetArrived (Packet packet) {
try {
if (packet instanceof TCPPacket) {
TCPPacket tcppacket = ((TCPPacket) packet);
// System.out.println ("Packet =" + packet);
// System.out.println ("window size =" +
// tcppacket.getWindowSize ());
// System.out.println ("Packet =" +
// ((TCPPacket) packet) .toColoredVerboseString (true));
// if (tcppacket.getDestinationPort () == 110 ||
// tcppacket.getSourcePort () == 110) // pop3
if (tcppacket.getDestinationPort () == 80
|| tcppacket.getSourcePort () == 80) {// http
String captureStr = new String (tcppacket.getTCPData ());
System.out.println (">>" + captureStr);
fos.write (tcppacket.getTCPData ());
fos
.write (new String (
"************************************************* *********\n ")
.getBytes ());
// fos.close ();
// CaptureVec.addElement (captureStr);
}
}
} catch (Exception ioe) {
System.out.println ("Exception occurred:" + ioe);
}
}

public static void main (String [] args) throws Exception {
// Print copyright info
System.out.println ();
System.out
.println ("Capture Ethernet packet Ver 0.01, author yanqlv (maomao).");
System.out
.println ("Copyright (c) 2005 yanqlv of Luoyang Normal College, all Rights Reserved.");
System.out.println ();

// Determin which capture device to use
PacketCapture pcap = new PacketCapture ();
String defaultDevice = pcap.findDevice ();
StringTokenizer st1 = new StringTokenizer (defaultDevice, "\n");
String defaultDeviceStr = st1.nextToken ();
int default_num = 1;

String [] capDevices = pcap.lookupDevices ();
int capdevice_num = capDevices.length;
System.out.println ("There" + (capdevice_num> 1? "Are": "is") + ""
+ capdevice_num + "device" + (capdevice_num> 1? "s": "")
+ "found!");
System.out
.println ("********************************************** ******************************* ");
for (int i = 0; i <capdevice_num; i ++) {
// System.out.println ("***** capture device [" + i
// + "] =" + capDevices [i]);
StringTokenizer st = new StringTokenizer (capDevices [i], "\n");
String capStr = st.nextToken ();
String capDesc ​​= st.nextToken ();
if (defaultDeviceStr.equals (capStr))
default_num = i + 1;
System.out.println ("[" + (i + 1) + "]" + capStr + "\n (" + capDesc
+ ")");
}
System.out
.println ("********************************************** ******************************* ");

System.out.println ("(default to use" + default_num + ")");

int selectn = 1;
if (capdevice_num> 1) {
System.out.print ("Please select [");
for (int i = 0; i <capdevice_num; i ++) {
System.out.print (i + 1);
if (i! = capdevice_num-1)
System.out.print ("or");
}
System.out.print ("]:");
String readstr = new DataInputStream (System.in) .readLine ();
selectn = Integer.parseInt (new String (readstr));
}
// System.out.println ("selectn =" + selectn);

// Want to save capture result to file
fos = new FileOutputStream ("D: /TDdownload/capture.txt");

// Begin capture
pcap.open ((new StringTokenizer (capDevices [selectn-1], "\n"))
.nextToken (), true);
CapturePacketTest t1 = new CapturePacketTest ();
pcap.addRawPacketListener (t1);
pcap.addPacketListener (t1);
pcap.capture (-1);
}

}
Reply

Use magic Report

0

Threads

18

Posts

15.00

Credits

Newbie

Rank: 1

Credits
15.00

 China

Post time: 2020-2-17 13:00:01
| Show all posts
What package are you using? Where is the error?
At least mark it out, so what do you think?
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-4-4 08:00:01
| Show all posts
pcap.findDevice (); Error not finding device
What bag do you use
Mine is jpcap + winpcap
NetworkInterface [] devices = jpcap.JpcapCaptor.getDeviceList ();
JpcapCaptor cap = jpcap.JpcapCaptor.openDevice (devices [1], 1028, true, 100000);
cap.processPacket (-1, object);
Reply

Use magic Report

0

Threads

18

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-4-11 09:30:01
| Show all posts
a bit difficult
Under the UP
Reply

Use magic Report

0

Threads

21

Posts

19.00

Credits

Newbie

Rank: 1

Credits
19.00

 China

Post time: 2020-5-2 11:15:01
| Show all posts
lz It is estimated that winpcap is not installed
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list