Error in Jpcap
I want to capture netwotk packet for that i have this code
import java.net.InetAddress;
import jpcap.net.*;
import jpcap.*;
import jpcap.net.EthernetPacket;
import jpcap.net.IPPacket;
import jpcap.net.TCPPacket;
import java.util.Scanner;
class Capture
public static void main(String[] args) throws java.io.IOException{
//Get the Device information - Start
//Obtain the list of network interfaces
NetworkInterface[] devices = JpcapCaptor.getDeviceList();
//for each network interface
for (int i = 0; i < devices.length; i++) {
//print out its name and description
System.out.println(i+": "+devices.name + "(" + devices[i].description+")");
//print out its datalink name and description
System.out.println(" datalink: "+devices[i].datalink_name + "(" + devices[i].datalink_description+")");
//print out its MAC address
System.out.print(" MAC address:");
for (byte b : devices[i].mac_address)
System.out.print(Integer.toHexString(b&0xff) + ":");
System.out.println();
//print out its IP address, subnet mask and broadcast address
for (NetworkInterfaceAddress a : devices[i].addresses)
System.out.println(" address:"+a.address + " " + a.subnet + " "+ a.broadcast);
//Get the Device information - End
//Capture the packets
System.out.println("\n \n ");
System.out.println("Please Enter the Device Name to Capture the Packet");
Scanner in = new Scanner(System.in);
int a = in.nextInt();
if(a <= devices.length)
int index=a; // set index of the interface that you want to open.
//Open an interface with openDevice(NetworkInterface intrface, int snaplen, boolean promics, int to_ms)
JpcapCaptor captor=JpcapCaptor.openDevice(devices[index], 65535, false, 20);
captor.setFilter("icmp",true);
for(int i=0;i<50;i++){
//capture a single packet and print it out
System.out.println(captor.getPacket());
JpcapWriter writer=JpcapWriter.openDumpFile(captor,"s.txt");
else
System.out.println("Please Enter the correct value");
but when i compile this code i get a error saying
Capture.java:4: error: cannot access EthernetPacket
import jpcap.net.EthernetPacket;
*^*
bad class file: .\jpcap\net\EthernetPacket.class
class file contains wrong class: net.sourceforge.jpcap.net.EthernetPacket
Please remove or make sure it appears in the correct subdirectory of the classpath.
PLEASE HELP ME
It looks like you've messed around with the JAR file. Are you trying to use two Jpcaps at the same time?
Similar Messages
-
How to use jmf convert the rtp packet (captured by jpcap) in to wav file?
I use the jpcap capture the rtp packets(payload: ITU-T G.711 PCMU ,from voip)
and now I want to use JMF read those data and convert in to wav file
How to do this? please help mepedrorp wrote:
Hi Captfoss!
I fixed it but now I have another problem. My application send me this message:
Cannot initialize audio renderer with format: LINEAR, Unknown Sample Rate, 16-bit, Mono, LittleEndian, Signed
Unable to handle format: ALAW/rtp, Unknown Sample Rate, 8-bit, Mono, FrameSize=8 bits
Failed to prefetch: com.sun.media.PlaybackEngine@1b45ddc
Error: Unable to prefetch com.sun.media.PlaybackEngine@1b45ddc
This time the fail is prefetching. I have no idea why this problem is. Could you help me?The system cant play an audio file / stream if it doesn't know the sample rate...somewhere along the way, in your code, the sample rate got lost. Sample rates are highly important, because they tell the system how fast to play the file.
You need to go look through your code and find where the sample rate information is getting lost... -
Jpcap does not work in threads
Hello there!
The problem is next:
I'm using jpcap lib for packet sniffer. As ordinary user has more than one device, I'm trying to use it as threads. But it doesn't work at all :(
Single process runs well, but this stops at the very beginning with no error at all. Just stops.
public DeviceSniffer(int device) {
System.out.println("Start of initialization device number "+device);
this.requestCount = 0;
this.responseCount = 0;
this.deviceNumber = device;
this.requestMessages = new ArrayList<RequestMessage>(REQUEST_LIMIT);
this.incompleteRequestMessages = new ArrayList<RequestMessage>(
REQUEST_LIMIT);
this.responseMessages = new ArrayList<ResponseMessage>(REQUEST_LIMIT);
public void run() {
System.out.println("Sniffer started!");
snifferStart();
public void snifferStart() {
try {
NetworkInterface[] devices = JpcapCaptor.getDeviceList();
System.out.println("Device: " + devices[deviceNumber].description);
jpcap = JpcapCaptor.openDevice(devices[deviceNumber], 2000, false, 20);
jpcap.setFilter("tcp", true);
jpcap.loopPacket(-1, new DeviceSniffer(deviceNumber));
catch (IOException e) {
System.out.println("[E] ---");
}and calling is like ordinary thread:
NetworkInterface[] devices = JpcapCaptor.getDeviceList();
for ( int i = 0; i < devices.length; i++ ){
Thread t = new DeviceSniffer(i);
t.start();
}Does anybody have any solution? Or I should use any other lib/framework?
KirillOk, if I re-write a bit thread calling:
NetworkInterface[] devices = JpcapCaptor.getDeviceList();
for ( int i = 0; i < devices.length; i++ ){
Thread t = new DeviceSniffer(devices);
t.start();
}and DeviceSniffer: private NetworkInterface device;
public DeviceSniffer(NetworkInterface device){
this.device = device;
this.requestCount = 0;
this.responseCount = 0;
this.requestMessages = new ArrayList<RequestMessage>(REQUEST_LIMIT);
this.incompleteRequestMessages = new ArrayList<RequestMessage>(
REQUEST_LIMIT);
this.responseMessages = new ArrayList<ResponseMessage>(REQUEST_LIMIT);
private void startSniffer() throws Throwable {
System.out.println("Device: " + device.description);
jpcap = JpcapCaptor.openDevice(device, 2000, false, 20);
jpcap.setFilter("tcp", true);
jpcap.loopPacket(-1, new DeviceSniffer(device));
public void run() {
System.out.println("Sniffer started!");
try {
startSniffer();
catch (Throwable e) {
e.printStackTrace();
}it even starts caputiring, but...Sniffer started!
Device: Adapter for generic dialup and VPN capture
Sniffer started!
Device: TAP-Win32 Adapter V8 (Microsoft's Packet Scheduler)
Sniffer started!
Device: VMware Virtual Ethernet Adapter
Sniffer started!
Device: Intel(R) Wireless WiFi Link 4965AGN (Microsoft's Packet Scheduler)
Sniffer started!
Device: Broadcom NetXtreme Gigabit Ethernet Driver (Microsoft's Packet Scheduler)
Sniffer started!
Device: VMware Virtual Ethernet Adapter
# An unexpected error has been detected by HotSpot Virtual Machine:
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0b163b87, pid=5992, tid=5788
# Java VM: Java HotSpot(TM) Client VM (1.5.0_06-b05 mixed mode)
# Problematic frame:
# C [wpcap.dll+0x13b87]
.....some lines are missing...
[error occurred during error reporting, step 120, id 0xc0000005]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j jpcap.JpcapCaptor.setFilter(Ljava/lang/String;Z)V+0
j DeviceSniffer.startSniffer()V+52
j DeviceSniffer.run()V+9
v ~StubRoutines::call_stubDoes this mean that I can't access wpcap.dll in threads or, in other words, is it impossible to capture all devices at one time anisochronously?
Edited by: kirillica on Jan 30, 2008 4:27 AM
more info added -
folks.. i have taken the sample program of a simple sniffer.. but its not working.... it is giving syntax error saying
" for each statements are only available if source level is 5.0"
import jpcap.*;
import jpcap.packet.Packet;
class Tcpdump implements PacketReceiver {
public void receivePacket(Packet packet) {
System.out.println(packet);
public static void main(String[] args) throws Exception {
NetworkInterface[] devices = JpcapCaptor.getDeviceList();
System.out.println("usage: java Tcpdump <select a number from the following>");
for (int i = 0; i < devices.length; i++) {
System.out.println(i+" :"+devices.name + "(" + devices[i].description+")");
System.out.println(" data link:"+devices[i].datalink_name + "("
+ devices[i].datalink_description+")");
System.out.print(" MAC address:");
// Giving Error in the following for Loop
for (byte b : devices[i].mac_address)
System.out.print(Integer.toHexString(b&0xff) + ":");
System.out.println();
// Giving Error in the following for Loop
for (NetworkInterfaceAddress a : devices[i].addresses)
System.out.println(" address:"+a.address + " " + a.subnet + " "
+ a.broadcast);it is giving error in the follwing lines of code
for (byte b : devices.mac_address)----------------------> here is error
System.out.print(Integer.toHexString(b&0xff) + ":");
System.out.println();
for (NetworkInterfaceAddress a : devices[i].addresses)-------->here
System.out.println(" address:"+a.address + " " + a.subnet + " "
+ a.broadcast); -
JPCAP: Network Device Information Display
hi i am using JPCAP to display network device information.. but, problem i am getting with following code is that it works only on first JComboBox value change and then, Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException occurs..
import java.awt.*;
import java.awt.TrayIcon.MessageType;
import java.awt.event.*;
import javax.swing.*;
import jpcap.*;
public class jpcap_example {
* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
JFrame frame1 = new JFrame("Network Device(s) Information");
String device_names[];
JComboBox device_select;
JPanel panel1 = new JPanel(new BorderLayout());
JPanel panel2 = new JPanel(new GridLayout(5, 1));
final JLabel IPAddress = new JLabel("IP Address", JLabel.LEFT);
final JLabel SubnetMask = new JLabel("Subnet Mask", JLabel.LEFT);
final JLabel Broadcast = new JLabel("Broadcast Address", JLabel.LEFT);
final JLabel MACAddress = new JLabel("MAC Address", JLabel.LEFT);
final JLabel Localloop = new JLabel("IsLocal", JLabel.LEFT);
final NetworkInterface devices[] = JpcapCaptor.getDeviceList();
device_names = new String[devices.length];
for (int i = 0; i < devices.length; i++)
device_names[i] = devices.name;
if (devices.length == 0)
JOptionPane.showMessageDialog(frame1, "Should run this app as root to see all hidden devices..", "Fatal Error", JOptionPane.ERROR_MESSAGE);
device_select = new JComboBox(device_names);
device_select.setForeground(Color.BLUE);
device_select.setMaximumRowCount(3);
panel1.add(device_select, BorderLayout.NORTH);
panel2.add(IPAddress);
panel2.add(SubnetMask);
panel2.add(Broadcast);
panel2.add(MACAddress);
panel2.add(Localloop);
panel1.add(panel2, BorderLayout.WEST);
frame1.add(panel1);
frame1.setSize(new Dimension(640, 480));
frame1.setVisible(true);
frame1.addWindowListener(new WindowAdapter()
@Override
public void windowClosing(WindowEvent e) {
// TODO Auto-generated method stub
super.windowClosing(e);
System.exit(0);
device_select.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
JComboBox temp = (JComboBox)e.getSource();
IPAddress.setText("IPAddress");
SubnetMask.setText("SubnetMask");
Broadcast.setText("BroadcastAddress");
MACAddress.setText("MAC Address");
Localloop.setText("IsLocal?");
for (int i = 0; i < devices[temp.getSelectedIndex()].addresses.length; i++)
IPAddress.setText(IPAddress.getText() + devices[temp.getSelectedIndex()].addresses[i].address.toString());
SubnetMask.setText(SubnetMask.getText() + devices[temp.getSelectedIndex()].addresses[i].subnet.toString());
Broadcast.setText(Broadcast.getText() + devices[temp.getSelectedIndex()].addresses[i].broadcast.toString());
MACAddress.setText(MACAddress.getText() + devices[temp.getSelectedIndex()].mac_address.toString());
Localloop.setText(Localloop.getText() + devices[temp.getSelectedIndex()].loopback);
can somebody please tell me where i am making mistake??sorry, for late reply..
i changed code for displaying mac address correctly (thought it should correct the problem but, still same error).. here's the change..
for (int i = 0; i < devices[temp.getSelectedIndex()].mac_address.length; i++)
int j = (int)devices[temp.getSelectedIndex()].mac_address;
j &= 0xff;
MACAddress.setText(MACAddress.getText() + " : "+ Integer.toHexString(j));
Localloop.setText(Localloop.getText() + devices[temp.getSelectedIndex()].loopback);
anyhow, it is showing exception in this line..Broadcast.setText(Broadcast.getText() + devices[temp.getSelectedIndex()].addresses[i].broadcast.toString());
i wonder what could be problem in that line .. ??
{for last value of i, it showed like fe80:0:0:.... in IP Address field; and ffff:ffff:ffff:ffff:0:0:0:0 in subnet mask .. before exception occured..
i suppose i know what it is but, still not sure.. what is it??} -
Jpcap locating and code compilation problem for packet sniffing
To my previous thread "How to capture and Read Packets", I've got reply to use jpcap. Yes I have tried to use this but the when I tried to compile the code it gives a lot of error, surely because javac cant find the jpcap library. I have download the library which is in installation form and when I installed library the jpcap, instead of installing in lib of JRE or JDK it installed in system32 of window file system and hence the compiler unable to locate this file kindly tell me how can I tackle this problem. i.e. how can and where should I place jpcap.dll file
Regards,
Danish KamranHi
Thanks for the response.
I would like to know if it is possible to capture all the data that is returned from a running port in a server. For eg. if oracle Apps Instance is running on port 1615, will I be able to capture all the data (before sending it to the DB server, through JpCap or any other java program) that, that form is sending to the Oracke DB Server?
What I need to to develop is an intermediate (middleware) Database Simulator using java for an oracle application. I need to capture the data that oracle application is sending into this Simulator and then send it to the Oracle DB server, after performing some operations in the simulator. Is this possible through java socket programming?
Thanks in advance.
Revathi -
Hi Gents:
I am writing an application for a contract i got.
I am using JPcap to capture inital packets so i can route the data trhough a secure means. Anyhow, the project is beyond the scope of this question.
We were getting HotSpot VM error. After replacing the dll such as WinPCap we found that there were not more exceptions but the program would run.
However the software does not detect and print the network cards found.
This same software work in a laptop dell 6000 but it does not work in another laptop despite the fact that both have the same network card and same JRE version. The code also work in a window 2000 server.
Please, i would apprieciate some help. I have tried many thing and search a lot . here is the code:
public PacketCaptureThread(String aDevice) {
device=aDevice;
terminated=false;
packetCapture= new PacketCapture();
public void run(){
try{
packetCapture.open(device,snaplen,promiscuous,timeout);
System.out.println("opening :"+device + "in thread: "+ this.getName() );
packetCapture.addPacketListener(new PacketHandler());
packetCapture.capture(PACKET_COUNT);
catch(CaptureDeviceOpenException ex){
ex.printStackTrace();
catch(CapturePacketException ex){
ex.printStackTrace();
class PacketHandler implements PacketListener
public void packetArrived(Packet packet){
try {
// only handle TCP packets
if(packet instanceof TCPPacket) {
TCPPacket tcpPacket = (TCPPacket)packet;
String srcHost = tcpPacket.getSourceAddress();
String dstHost = tcpPacket.getDestinationAddress();
int port=tcpPacket.getDestinationPort();
if(port!=80){
System.out.println("TCP packet :"+"source-> " + srcHost +
" destination -> "+dstHost + " port: " + port);
if(packet instanceof IPPacket){
IPPacket ipPacket=(IPPacket)packet;
String srcHost= ipPacket.getSourceAddress();
String dtsHost=ipPacket.getDestinationAddress();
ipPacket.getTypeOfService();
System.out.println("IP packet :"+"source-> " + srcHost +
" destination -> "+dtsHost);
if(packet instanceof EthernetPacket){
EthernetPacket ethernetPacket=(EthernetPacket)packet;
String srcHost=ethernetPacket.getSourceHwAddress();
String dstHost=ethernetPacket.getDestinationHwAddress();
// System.out.println("ethernet packet :"+" source-> " + srcHost +
// " destination -> "+dstHost);
if(packet instanceof ICMPPacket){
ICMPPacket icmpPacket=(ICMPPacket)packet;
String srcHost=icmpPacket.getSourceAddress();
String dstHost=icmpPacket.getDestinationAddress();
System.out.println("ICMPPacket packet :"+"source-> " + srcHost +
" destination -> "+dstHost);
if(packet instanceof ARPPacket){
ARPPacket arpPacket=(ARPPacket)packet;
String srcHost=arpPacket.getSourceHwAddress();
String dstHost=arpPacket.getDestinationProtoAddress();
System.out.println("ARP packet :"+"source-> " + srcHost +
" destination -> "+dstHost);
} catch( Exception e ) {
e.printStackTrace();
I also have a simple version, no threads, but that version still does not detect the network cards.
Thank you
MarlonHi,
Download and install the following.
HP OSD Utility.
Proximity Sensor Driver.
When done, restart the notebook.
Regards,
DP-K
****Click the White thumb to say thanks****
****Please mark Accept As Solution if it solves your problem****
****I don't work for HP****
Microsoft MVP - Windows Experience -
[SOLVED] compiling jpcap on 64bit system
hello
can i compile jpcap on arch x86_64?
because when i try it i get this error:
/usr/bin/ld: /tmp/ccWFe5Db.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/tmp/ccWFe5Db.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [libjpcap.so] Error 1
i tried to serach web but i just found out that this is architecture issue but no solution..
edit:
if i use 32bit enviroment (http://wiki.archlinux.org/index.php/Arc … bit_system) to compile it will it wrok on my 64 bit?
Last edited by _dunmer (2009-02-28 13:15:28)this is whole makefile
JAVA_DIR = $(JAVA_HOME)
JNI_INCLUDE = $(JAVA_DIR)/include
# try to detect your OS using 'uname'
PLATFORM = $(shell "uname")
ifeq ($(PLATFORM), Linux)
JNI_INCLUDE2 = $(JAVA_DIR)/include/linux
COMPILE_OPTION = -shared -L.
SUFFIX = .so
else
ifeq ($(PLATFORM), FreeBSD)
JNI_INCLUDE2 = $(JAVA_DIR)/include/freebsd
COMPILE_OPTION = -shared -L.
SUFFIX = .so
else
ifeq ($(PLATFORM), SunOS)
JNI_INCLUDE2 = $(JAVA_DIR)/include/solaris
COMPILE_OPTION = -G
SUFFIX = .so
else
ifeq ($(PLATFORM), Darwin)
JNI_INCLUDE2 = /System/Library/Frameworks/JavaVM.framework/Headers
COMPILE_OPTION = -bundle -framework JavaVM
SUFFIX = .jnilib
endif
endif
endif
endif
# Specify where pcap.h is
PCAP_INCLUDE = /usr/include
#PCAP_INCLUDE = /usr/include/pcap
#CC = cl
CC = gcc
all: libjpcap.so
libjpcap.so: JpcapCaptor.c JpcapSender.c JpcapWriter.c\
packet_arp.c packet_datalink.c packet_icmp.c packet_ip.c\
packet_ipv6.c packet_tcp.c packet_udp.c
$(CC) $(COMPILE_OPTION) -I$(JNI_INCLUDE) -I$(JNI_INCLUDE2)\
-I$(PCAP_INCLUDE)\
JpcapCaptor.c JpcapSender.c JpcapWriter.c\
packet_arp.c packet_datalink.c packet_icmp.c packet_ip.c\
packet_ipv6.c packet_tcp.c packet_udp.c\
-o libjpcap$(SUFFIX) -lpcap
clean:
-rm libjpcap$(SUFFIX)
witt thie make file i get this error:
[dunmer@joybox c]$ make
gcc -shared -L. -I/opt/java/include -I/opt/java/include/linux\
-I/usr/include\
JpcapCaptor.c JpcapSender.c JpcapWriter.c\
packet_arp.c packet_datalink.c packet_icmp.c packet_ip.c\
packet_ipv6.c packet_tcp.c packet_udp.c\
-o libjpcap.so -lpcap
JpcapCaptor.c: In function 'Java_jpcap_JpcapCaptor_processPacket':
JpcapCaptor.c:467: warning: cast to pointer from integer of different size
JpcapCaptor.c: In function 'Java_jpcap_JpcapCaptor_loopPacket':
JpcapCaptor.c:486: warning: cast to pointer from integer of different size
JpcapCaptor.c: In function 'dispatcher_handler':
JpcapCaptor.c:700: warning: cast from pointer to integer of different size
JpcapWriter.c: In function 'Java_jpcap_JpcapWriter_close':
JpcapWriter.c:47: warning: incompatible implicit declaration of built-in function 'free'
packet_icmp.c: In function 'analyze_icmp':
packet_icmp.c:79: warning: cast to pointer from integer of different size
packet_icmp.c:81: warning: cast from pointer to integer of different size
/usr/bin/ld: /tmp/cceBND7o.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/tmp/cceBND7o.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [libjpcap.so] Error 1
when i add -fPIC to CFLAGS it doesn't do anything and i get the same output
somebody tell me to chanege Linux part of make file like this:
ifeq ($(PLATFORM), Linux)
JNI_INCLUDE2 = $(JAVA_DIR)/include/linux
-- COMPILE_OPTION = -shared -L.
++ COMPILE_OPTION = -shared -fPIC -L.
whit this a i get another error:
[dunmer@joybox c]$ make
gcc -I/opt/java/include -I/opt/java/include/linux\
-I/usr/include\
JpcapCaptor.c JpcapSender.c JpcapWriter.c\
packet_arp.c packet_datalink.c packet_icmp.c packet_ip.c\
packet_ipv6.c packet_tcp.c packet_udp.c\
-o libjpcap.so -lpcap
JpcapCaptor.c: In function 'Java_jpcap_JpcapCaptor_processPacket':
JpcapCaptor.c:467: warning: cast to pointer from integer of different size
JpcapCaptor.c: In function 'Java_jpcap_JpcapCaptor_loopPacket':
JpcapCaptor.c:486: warning: cast to pointer from integer of different size
JpcapCaptor.c: In function 'dispatcher_handler':
JpcapCaptor.c:700: warning: cast from pointer to integer of different size
JpcapWriter.c: In function 'Java_jpcap_JpcapWriter_close':
JpcapWriter.c:47: warning: incompatible implicit declaration of built-in function 'free'
packet_icmp.c: In function 'analyze_icmp':
packet_icmp.c:79: warning: cast to pointer from integer of different size
packet_icmp.c:81: warning: cast from pointer to integer of different size
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.3/../../../../lib/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [libjpcap.so] Error 1
nothing i could find about -fPIC helped me.. -
when i use jpcap
in the JpcapCaptor.java class
in this method NetworkInterface[] getDeviceList();
my project stop and that is an error that wpcap.dll not found
please help mehttp://sourceforge.net/forum/forum.php?forum_id=85830
-
Is there anybody that have jpcap ( rawsocket ) examples Thanks
I'am an Italian programmers, sorry i speak a little English.
I downloaded from http://www.goto.info.waseda.ac.jp/~fujii/jpcap/index.html , jpcap pakage.
By it i can read and send packet/rawsocket.
When i capturing packet it's all ok.
When i want send packet i have an exception: java.io.IOException: sendto error
probably i have not setting any field.
Is there anybody that can help-me.
Is there anybody that have some examples that explain how to send packet ( ICMP,TCP,UDP )
In the pakage documentation i dont find nothing.
In the pakage documentation there is only a tcpdump examples.
Thanks you ulisse640
p.s. Below there is the code that give the error.
package progetto10;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import jpcap.*;
public class Frame1 extends JFrame {
JPanel contentPane;
JButton jButton1 = new JButton();
String device = "\\Device\\Packet_{6B0E8DE3-8F46-41E3-B3BD-673C59BB0028}";
BorderLayout borderLayout1 = new BorderLayout();
/**Construct the frame*/
public Frame1() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try
jbInit();
catch(Exception e)
e.printStackTrace();
/**Component initialization*/
private void jbInit() throws Exception {
//setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]")));
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("Frame Title");
jButton1.setText("Bottone");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
jButton1_actionPerformed(e);
contentPane.add(jButton1, BorderLayout.CENTER);
/**Overridden so we can exit when window is closed*/
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
void jButton1_actionPerformed(ActionEvent e) {
try
Jpcap jpcap = null;
IPAddress.setAddressConvert(true);
String[] devices = Jpcap.getDeviceList();
for( int i=0; i<devices.length; i++ )
System.out.println( devices[i] );
jpcap = new Jpcap(device,1500,true ,200);
UDPPacket pack = createUDP(); //TCPPacket pack = createTCP();
System.out.println("");
System.out.println("openRawSocket");
jpcap.openRawSocket();
jpcap.sendPacket( pack );
jpcap.close();
catch(Exception ex)
ex.printStackTrace();
public EthernetPacket createEthernetPacket() throws Exception {
EthernetPacket ep = new EthernetPacket();
ep.frametype = 2048;
String strdst = new String("00:50:ba:49:6c:9b");
ep.dst_mac = strdst.getBytes();
String strsrc = new String("00:00:e2:44:b8:dd");
ep.src_mac = strsrc.getBytes();
return ep;
public UDPPacket createUDP() throws Exception {
UDPPacket up = new UDPPacket( 80,333 );
//up.setIPv4Parameter(0,false,false,false,false,false,false,0,1,255,17,new IPAddress("100.100.100.1"),new IPAddress("100.100.100.2"));
up.src_ip = new IPAddress("100.100.100.1");
up.dst_ip = new IPAddress("100.100.100.2");
up.dont_frag = true;
up.protocol = 17;
up.ident = 1;
up.offset = 0;
up.version = 4;
up.data = "".getBytes();
up.hop_limit = 128;
up.length = 48;
displayUDP( up );
return up;
public TCPPacket createTCP() throws Exception {
TCPPacket tp = new TCPPacket(80,333,5215133,0,false,false,false,false,true,false,8192,0);
//tp.setIPv4Parameter(0,false,false,false,false,false,false,0,1,255, 6,new IPAddress("100.100.100.1"),new IPAddress("100.100.100.2"));
tp.src_ip = new IPAddress("100.100.100.1");
tp.dst_ip = new IPAddress("100.100.100.2");
tp.dont_frag = true;
tp.protocol = 6;
tp.ident = 1;
tp.offset = 0;
tp.version = 4;
tp.data = "".getBytes();
tp.hop_limit = 128;
tp.length = 48;
displayTCP( tp );
return tp;
public void displayUDP(UDPPacket packet) {
System.out.println( "UDP Packet");
System.out.println("-----------------");
System.out.println("caplen:" +packet.caplen );
System.out.println("sec:" +packet.sec );
System.out.println("usec:" +packet.usec );
System.out.println("datalink:" +packet.datalink );
System.out.println("data:" +packet.data.length );
System.out.println("-----------------");
System.out.println("priority:" +packet.priority );
System.out.println("d_flag:" +packet.d_flag );
System.out.println("t_flag:" +packet.t_flag );
System.out.println("r_flag:" +packet.r_flag );
System.out.println("rsv_frag:" +packet.rsv_frag );
System.out.println("dont_frag:"+packet.dont_frag );
System.out.println("more_frag:"+packet.more_frag );
System.out.println("offset:" +packet.offset );
System.out.println("ident:" +packet.ident );
System.out.println("ttl: ** not found **" );
System.out.println("protocol:" +packet.protocol );
System.out.println("src_ip:" +packet.src_ip );
System.out.println("dst_ip:" +packet.dst_ip );
System.out.println("length:" +packet.length );
System.out.println("version:" +packet.version );
System.out.println("hop_limit:"+packet.hop_limit );
System.out.println("-----------------");
System.out.println("src_port:" +packet.src_port );
System.out.println("dst_port:" +packet.dst_port );
public void displayTCP(TCPPacket packet) {
System.out.println( "TCP Packet");
System.out.println("-----------------");
System.out.println("caplen:" +packet.caplen );
System.out.println("sec:" +packet.sec );
System.out.println("usec:" +packet.usec );
System.out.println("datalink:" +packet.datalink );
System.out.println("data:" +packet.data.length );
System.out.println("-----------------");
System.out.println("priority:" +packet.priority );
System.out.println("d_flag:" +packet.d_flag );
System.out.println("t_flag:" +packet.t_flag );
System.out.println("r_flag:" +packet.r_flag );
System.out.println("rsv_frag:" +packet.rsv_frag );
System.out.println("dont_frag:"+packet.dont_frag );
System.out.println("more_frag:"+packet.more_frag );
System.out.println("offset:" +packet.offset );
System.out.println("ident:" +packet.ident );
System.out.println("ttl: ** not found **" );
System.out.println("protocol:" +packet.protocol );
System.out.println("src_ip:" +packet.src_ip );
System.out.println("dst_ip:" +packet.dst_ip );
System.out.println("length:" +packet.length );
System.out.println("version:" +packet.version );
System.out.println("hop_limit:"+packet.hop_limit );
System.out.println("-----------------");
System.out.println("src_port:" +packet.src_port );
System.out.println("dst_port:" +packet.dst_port );
System.out.println("sequence:" +packet.sequence );
System.out.println("ack_num:" +packet.ack_num );
System.out.println("urg:" +packet.urg );
System.out.println("ack:" +packet.ack );
System.out.println("psh:" +packet.psh );
System.out.println("rst:" +packet.rst );
System.out.println("syn:" +packet.syn );
System.out.println("fin:" +packet.fin );
System.out.println("window:" +packet.window );
System.out.println("urgent:" +packet.urgent_pointer);
}I have done quite a bit of work with the jpcap software. The tcp dump functionality works fine but as you stated there are problems with the send. I hope you are fimilar with C programming because there are bugs in the native implementation that you will unfortunutely need to work out.
I have the source code that I worked on at work or I would send it to you now. If you would like a copy of my updated version of the C code then send me an email. It's not perfect but its a start. BTW -- what operating system are you attempting to run this on? I only have patched the code for windows.
[email protected] -
I am trying to get this code to work, but for some reason, i cant. Can anyone help me?
This is my code, but for some reason the i can not get the data method to work... please help me out.
import jpcap.*;
import jpcap.packet.*;
class PacketFun
public static void main(String[] args) throws Exception
NetworkInterface[] devices = JpcapCaptor.getDeviceList();
JpcapCaptor jpcap = JpcapCaptor.openDevice(devices[3], 2000, false, 20);
for (int i =0; i <= 10; i++)
Packet packet = jpcap.getPacket();
if (packet == null)
else
System.out.println("-----|" + "NEW" + "|-----");
System.out.println(packet.data());
}Error:
C:\Users\redcrusher\Desktop\Packet_Fun - Copy\PacketFun.java:23: cannot find symbol
symbol : method data()
location: class jpcap.packet.Packet
System.out.println(packet.data());
^
1 error
Tool completed with exit code 1--redcrusherhttp://netresearch.ics.uci.edu/kfujii/jpcap/doc/javadoc/index.html
It says it is there.....No it doesn't. Look again. There is no method by that name anywhere in JPcap. -
Hi everybody,
I have to send and receive IPv6 packets. So I tried to use jpcap, and I encountered a problem : I can send ipv4 packets but when I try to send an ipv6 packet I get an error :
java.io.IOException: only IPv4 packet is supported
at jpcap.JpcapSender.sendPacket(Native Method)
I send an IPPacket which can be filled with ipv4 and ipv6. Is this impossible or do I make a mistake ?
Bests regards,
Tychopealse can you post the code allowing sending the packages IP v4
because me I have probleme with these packet -
dear all
i cannot send packets using jpcap
it doesnot give any error
just run but no packets transmitied (although it captures correctly)
i used the ping example came with it but not work
if anyone worked with him
please help me even with source
thanxHow do you know it isn't sending them?
-
A problem with jpcap 0.4
Hi everybody,
I have to send and receive IPv6 packets. So I tried to use jpcap, and I encountered a problem : I can send ipv4 packets but when I try to send an ipv6 packet I get an error :
java.io.IOException: only IPv4 packet is supported
at jpcap.JpcapSender.sendPacket(Native Method)
I send an IPPacket which can be filled with ipv4 and ipv6. Is this impossible or do I make a mistake ?
Bests regards,
TychoSorry, I called Apple Support and they asked me to do a hard reboot and it just booted. The hard reboot is to press and hold the home button and and on/off button at the top.
This rebooted the ipad and also had the updated ios 7.0.4.
The support person said sometimes the wifi connectivity could cause a problem with reboot after an OS update.
Thanks
Gopinath -
Error in starting Adobe Bridge in Photoshop CS2
I've just installed Photoshop CS2, however upon opening Adobe Bridge this error message appears " The application has failed to start because libagluc28.dll was not found. Reinstalling to application may fix the problem"
I have reinstalled and click repair but to no avail
I followed Adobe Support Knowledgebase solution and run CMD and this appears:
c:Documents and Settings/Jesus M Ferraris>
then i entered the command
cacls c:\windows\installer /T /E /C /G administrators:F
but an error message appears - 'cacls' is not recognized as an internal or external command, operable program or bathc file
I also entered the next command
cacls "c:\documents and setting\all users" /Y /E /C /G administrators:F
still the same error as above appears, Please help, have I miss something or was my procedure correct...
P4, 512ram, WXP 80gHDVery useful.
Good Luck.
My
Si
tes
Maybe you are looking for
-
I have a Mac Pro using OSX 10.7.4. When using apple mail I click on the address icon to obtain email address and nothing happens. I've restarted both the application and the Mac but still won't open address book. Any ideas please.
-
I am using Oracel 8i Version: 8.1.7.0.0. it was crash so I use following command to revover database but error occure alter database recover Sun May 28 13:10:54 2006 Media Recovery Start Media Recovery Log Recovery of Online Redo Log: Thread 1 Group
-
Backup to TM - reformat/install - TM files to new install?
I just bought the Time Capsule and am in the process of backing up my files via Time Machine. I want to then reformat my hd and do a clean install of leopard and applications. My question is, once I format/reinstall, can I pull specific files and set
-
OHS - Webserver SSL Termination for EPM
Gurus, Could you please help me with the instructions to setting up the EPM environment as SSL (web server termiantion at OHS.) I am done wih the installing an configuring all of the EPM products and now I need to enable the SSL at OHS. I have review
-
Ie code fix for image viewer?
I'm wondering if anyone knows how to deal with ie's treatment of image viewer parameters set in dw. When I configure image viewer to display slides so that they are perfectly displayed in safari and mozilla, they display off center, and sometimes the