Book navigation

Navigation

LiveCaptureFactory missing

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 testjnetstream

and 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 :)

 
 #

After a lot of experiments I have came to a decision that working from the jar is better.
Earvin James - san diego real estate

 
 #

I am use this codes biodegradable file.your work on this file is very biodegradable plastic hard and great.Thanks for working. biodegradable plastics petersam451

 
 #

thanks for useful codes
jeux poker

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Who's online

There are currently 1 user and 10 guests online.

Online users

  • sukabla

Who's new

  • sukabla
  • donaldjeo
  • madhav
  • andrewkent52
  • petersam021