This week's book giveaway is in the Artificial Intelligence forum.
We're giving away four copies of Pragmatic AI and have Noah Gift on-line!
See this thread for details.
Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working on this syn flooding detection...Have been testing this piece of code my friend compiled...but i have a error message anybody know??? what might be the problem...

package SynFloodDetector;

/**
*
* @author
*/

import java.util.Date;
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.Vector;

import org.jnetpcap.Pcap;
import org.jnetpcap.PcapBpfProgram;
import org.jnetpcap.packet.PcapPacket;
import org.jnetpcap.packet.PcapPacketHandler;
import org.jnetpcap.protocol.network.Ip4;
import org.jnetpcap.protocol.tcpip.Tcp;

/**
* This example is similar to the classic libpcap example shown in nearly every
* tutorial on libpcap. The main difference is that a file is opened instead of
* a live network interface. Using a packet handler it goes into a loop to read
* a few packets, say 10. Prints some simple info about the packets, and then
* closes the pcap handle and exits.
*
* Here is the output generated by this example :
*
* Opening file for reading: tests/test-l2tp.pcap
* Received at Tue Jan 27 16:17:17 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:17 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:18 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:18 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:19 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:19 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:20 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:20 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:21 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:21 EST 2004 caplen=114 len=114 jNetPcap rocks!
*
* @author Mark Bednarczyk
* @author Sly Technologies, Inc.
*/
public class pCapture {

/**
* Main startup method
*
* @param args
* ignored
*/
public static void main(String[] args) {
/***************************************************************************
* First we setup error buffer and name for our file
**************************************************************************/
final StringBuilder errbuf = new StringBuilder(); // For any error msgs
final String file = "outside.tcpdump";

System.out.printf("Opening file for reading: %s%n", file);

/***************************************************************************
* Second we open up the selected file using openOffline call
**************************************************************************/
Pcap pcap = Pcap.openOffline(file, errbuf);

if (pcap == null) {
System.err.printf("Error while opening device for capture: "
+ errbuf.toString());
return;
}

/*PcapBpfProgram filter = new PcapBpfProgram();
String expression = "ip dst 172.16.112.50";
int optimize=0;
int netmask=0xFFFFFF00;

if(pcap.compile(filter, expression, optimize, netmask) != Pcap.OK){
System.err.println(pcap.getErr());
return;
}

if(pcap.setFilter(filter) != Pcap.OK){
System.err.println(pcap.getErr());
return;
}*/
/***************************************************************************
* Third we create a packet handler which will receive packets from the
* libpcap loop.
**************************************************************************/
PcapPacketHandler<String> jpacketHandler = new PcapPacketHandler<String>() {
private int window_size = 1000;
private long time_end = 898171330 + window_size;
private int syn_x_count=0;
private int syn_y_count=0;
private int ack_count=0;
private int count=0;
private int time_window_counter=0;
private Vector<Long> seq_number_storage = new Vector<Long>();
private int threshold = 0;

private final int pascal_ip_to_int = -1408208846;

public void set_window_size(int t){
window_size=t;
}


public void set_threshold(int T){
threshold = T;
}


@Override
public void nextPacket(PcapPacket packet, String user) {

Ip4 ip = new Ip4();
Tcp tcp = new Tcp();
if(packet.hasHeader(ip) && packet.hasHeader(tcp)){
while(packet.getCaptureHeader().seconds() >= time_end){
int difference = syn_x_count - ack_count;
System.out.println("Time-window t=" + ++time_window_counter
+", from " +((time_window_counter -1) * window_size)
+"s to "+(time_window_counter * window_size)
+"s, arrivals= " +syn_x_count
+" departures =" +ack_count
+", difference=" +difference
+((difference>threshold)?",Attack":",Not Attack"));
seq_number_storage.clear();
syn_x_count = 0;
syn_y_count = 0;
count = 0;
time_end += window_size;
}

if(ip.destinationToInt() == pascal_ip_to_int
&& tcp.flags_SYN() && !tcp.flags_ACK()){
syn_x_count++;
}
else if (ip.sourceToInt()==pascal_ip_to_int
&& tcp.flags_SYN() && tcp.flags_ACK())
{
seq_number_storage.add(tcp.seq());
syn_y_count++;
}else if(ip.destinationToInt() == pascal_ip_to_int
&& tcp.flags_ACK()
&& seq_number_storage.contains(tcp.ack()-1)){
ack_count++;
}count ++;
}
}


public void final_print(){
int difference = syn_x_count - ack_count;
System.out.println("Time-window t=" + ++time_window_counter
+", from " +((time_window_counter -1) * window_size)
+"s to "+(time_window_counter * window_size)
+"s, arrivals= " +syn_x_count
+" departures =" +ack_count
+", difference=" +difference
+((difference>threshold)?",Attack":",Not Attack"));
}
};


/*System.out.printf("Received at %s caplen=%-4d len=%-4d %s %s %s \n",
new Date(packet.getCaptureHeader().timestampInMillis()),
packet.getCaptureHeader().caplen(), // Length actually captured
packet.getCaptureHeader().wirelen(), // Original length
ip.toString(),
tcp.toString(),
user // User supplied object
);
}
}
};*/

/***************************************************************************
* Fourth we enter the loop and tell it to capture 10 packets. The loop
* method does a mapping of pcap.datalink() DLT value to JProtocol ID, which
* is needed by JScanner. The scanner scans the packet buffer and decodes
* the headers. The mapping is done automatically, although a variation on
* the loop method exists that allows the programmer to sepecify exactly
* which protocol ID to use as the data link type for this pcap interface.
**************************************************************************/
try {
System.out.println("Set time-window size in seconds(An example would be 1000):");
Scanner keyboard = new Scanner(System.in);
jpacketHandler.set_window_size(keyboard.nextInt());
System.out.println("Set Threshold(An example would be 0):");
jpacketHandler.set_threshold(keyboard.nextInt());
pcap.loop(-1, jpacketHandler, "");
jpacketHandler.final_print();
}catch(InputMismatchException e){
System.err.println("Invalid window-size!");
} finally {
/***************************************************************************
* Last thing to do is close the pcap handle
**************************************************************************/
pcap.close();
}
}
}
 
aamirh khan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the build error i get:

init:
deps-clean:
Updating property file: C:\Users\Aamir Khan\Documents\NetBeansProjects\SynFloodDetector\build\built-clean.properties
Deleting directory C:\Users\Aamir Khan\Documents\NetBeansProjects\SynFloodDetector\build
clean:
init:
deps-jar:
Created dir: C:\Users\Aamir Khan\Documents\NetBeansProjects\SynFloodDetector\build
Updating property file: C:\Users\Aamir Khan\Documents\NetBeansProjects\SynFloodDetector\build\built-jar.properties
Created dir: C:\Users\Aamir Khan\Documents\NetBeansProjects\SynFloodDetector\build\classes
Created dir: C:\Users\Aamir Khan\Documents\NetBeansProjects\SynFloodDetector\build\empty
Created dir: C:\Users\Aamir Khan\Documents\NetBeansProjects\SynFloodDetector\build\generated-sources\ap-source-output
Compiling 1 source file to C:\Users\Aamir Khan\Documents\NetBeansProjects\SynFloodDetector\build\classes
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\Users\Aamir Khan\Documents\NetBeansProjects\SynFloodDetector\src\SynFloodDetector\pCapture.java:194: error: cannot find symbol
jpacketHandler.setWindowSize(keyboard.nextInt());
symbol: method setWindowSize(int)
location: variable jpacketHandler of type PcapPacketHandler<String>
C:\Users\Aamir Khan\Documents\NetBeansProjects\SynFloodDetector\src\SynFloodDetector\pCapture.java:196: error: cannot find symbol
jpacketHandler.setThreshold(keyboard.nextInt());
symbol: method setThreshold(int)
location: variable jpacketHandler of type PcapPacketHandler<String>
C:\Users\Aamir Khan\Documents\NetBeansProjects\SynFloodDetector\src\SynFloodDetector\pCapture.java:198: error: cannot find symbol
jpacketHandler.finalPrint();
symbol: method finalPrint()
location: variable jpacketHandler of type PcapPacketHandler<String>
3 errors
1 warning
C:\Users\Aamir Khan\Documents\NetBeansProjects\SynFloodDetector\nbproject\build-impl.xml:603: The following error occurred while executing this line:
C:\Users\Aamir Khan\Documents\NetBeansProjects\SynFloodDetector\nbproject\build-impl.xml:245: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)
 
author and iconoclast
Sheriff
Posts: 24220
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I came to this thread because the subject line sounded like this was some sort of exotic error; but it's just a run-of-the-mill undefined symbol problem. This source assumes that the class PcapPacketHandler has methods setThreshold(), finalPrint(), and setWindowSize(), but apparently it does not. Your anonymous subclass has methods with similar names -- final_print(), for example -- but of course, those are totally unrelated. And since the variable is of type PcapPacketHandler, only methods of that type are available; any new methods you add won't be found by the compiler. So

1) Fix the names! and
2) Turn your anonymous class into a real named class, and use its name as the variable type.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!