Submitted by thatzall on Fri, 08/28/2009 - 09:58
I'm trying to get a proto together but whenever I try to open a pcap file, I get the following:
Unable to load factory class [com.slytechs.jnetstream.livecapture.DefaultLiveCaptureFactory]
when stepping into Captures.openFile(File f):
try {
for (FilePacket packet: Captures.openFile(testFile)) {
for (Header header: packet.getAllHeaders()) {
System.out.print(header.getName());
System.out.print(" has ");
System.out.println(header.getAllFields().length + " fields");
}
}
Captures.close();
} catch (FileFormatException e) {
errorMsg= "Invalid file format for file \"" + testFile + "\".";
result = false;
} catch (IOException e) {
errorMsg= "Invalid file format for file \"" + testFile + "\".";
result = false;
}
Assert.assertTrue(errorMsg, result);
Live capture is supplied by a separate module. You must download or compile the live-capture module. I'm sorry I can't help with this right now until next week. I'm not sure why its missing form the distribution package. It was working before.
Try jar -tvf on the jnetstream jar file and make sure that it has DefaultLIveCaptureFactory class in it. There are also several other jar files in the installation directory. The jNetStreamStandalone.jar should contain everything you need.
thatzall,
I just tried:
import org.jnetstream.capture.Captures; import org.jnetstream.capture.FilePacket; import org.jnetstream.packet.Header; public class testjnetstream { public static void main(String[] args) { String testFile = "test.pcap"; try { for (FilePacket packet: Captures.openFile(testFile)) { for (Header header: packet.getAllHeaders()) { System.out.print(header.getName()); System.out.print(" has "); System.out.println(header.getAllFields().length + " fields"); } } Captures.close(); } catch (Exception e) { System.out.print("Got exception [" + e + "]"); } } // end main() } // end CLASS testjnetstreamand got:
C:\jnetstream-newtest>javac -classpath jnetstream-3.0a1.jar testjnetstream.java
C:\jnetstream-newtest>java -classpath jnetstream-3.0a1.jar;.\;commons-logging.jar testjnetstream
Ethernet2 has 0 fields
Ip4 has 0 fields
Udp has 0 fields
Ethernet2 has 0 fields
Ip4 has 0 fields
Udp has 0 fields
Ethernet2 has 0 fields
Ip4 has 0 fields
Udp has 0 fields
Ethernet2 has 0 fields
Ip4 has 0 fields
Udp has 0 fields
Ethernet2 has 0 fields
Ip4 has 0 fields
Udp has 0 fields
Ethernet2 has 0 fields
Ip4 has 0 fields
Udp has 0 fields
Ethernet2 has 0 fields
Ip4 has 0 fields
Udp has 0 fields
Ethernet2 has 0 fields
Ip4 has 0 fields
Udp has 0 fields
Ethernet2 has 0 fields
Ip4 has 0 fields
Udp has 0 fields
Jim
You are seeing 0 fields, because packet decoder is not working. In jNS its based on NPL scripts, which have been since abandoned for pure java with annotations approach.
But as you can see that packets are being properly extracted from the file. It would not be hard to build a jNS PcapPacket out of these packets and buffers to get the decoding functionality.
Hi Mark,
Actually.... I just posted the code, compile and run lines, and output, above, to let thatzall know that I don't get that error with "DefaultLiveCaptureFactory" :)...
Jim
I updated the code and all is set. I was building from the SVN earlier and must have missed some code. Working from the jar and everything is better.
Glad to hear it :)
Very interesting to read.I would like to thank you for the efforts you had made for writing this awesome article.
java ftp
ftp server
ftp hosting
Hi this is a but late, but for the sake of others and documentation… It sounds like it’s just the bow, I would touch it up with thickend epoxy and then sand it smooth.
cigar roller
wholesale cigar
corporate entertainment
mens gift ideas
Thank you for Lida
Wow
I read your Post, it is really a good thing. You should improve it.
Voluntary Insurance
Long Term Care Insurance
Life Settlement