September 2009

Obtaining link speed of the NIC

Hello,
I have a question about functionality which (probably) is not yet in jnetpcap. I mean obtaining a current link speed of the network interface, i.e. 10Mbps, 100Mbps. I tried to find out how to do this in java but haven't managed to. Probably it should be possible using native invocations but I had other obstacles and gave up. Do you plan to include such functionality in some future release? Or maybe it already is included but I missed it?
Best regards,
Leszek

Can't use the PcapStat

Hi All,

I just downloaded the SVN trunk compilted it (the java part) and tested several examples. all testing worked like a charme. Very impressive project!

When I trying to add:
PcapStat stats = new PcapStat();
to one of the tests I'm getting:

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.jnetpcap.PcapStat.initIDs()V
at org.jnetpcap.PcapStat.initIDs(Native Method)
at org.jnetpcap.PcapStat.(PcapStat.java:29)

and the test fails to run.

Any idea? (keep in mind that all other tested are working so it is not a matter of library path issue)

The first thing that come to mind is that the C code is not aligned with the java code. Can it be the case?

Thanks.

64-bit archs

64-bit infrastructure is in place. We should see 64-bit releases for the currently supported platforms within next few weeks.

jNetPcap project roadmap

Here is a roadmap of future releases and features planned for jNetPcap.

+-> 2.X - next generation API branch (TBD) (Browse)
|   +-> new memory managment (in progress)
|   +-> standalone jnetpcap module - libpcap wrapper only functionality
|   +-> standalone jnetproto module - CORE protocols, decoding and analysis
|   +-> standalone jnetsoft module - common code
|
+-> 1.4 - (download)( browse)
|   +-> add support for additional x32 and x64 platforms. 
|   +-> JPacketBuffer handler, Lazy packet decoding
|   +-> Additional protocols added
|   +-> New libpcap 1.0.0 API functions
| 
+-> 1.3  - stable code base
    +-> 1.3 alpha (Sept. 2009) (Download)(Browse)
    +-> 1.3 beta(April 2010) (Download)(Browse)
    +-> 1.3 final (July 11, 2010) - in progress

Wishlist

  1. swing components
  2. Fully functional graphical analyzer (comparable to wireshark)
  3. Eclipse development module for jnetpcap
  4. Support for nearly all public protocols

2.0 - native dissectors and analyzers

Src distributions

I will be adding a source package during releases. (currently source is not distributed and must be extracted from SVN repository.) This will allow users to download both javadocs and source and provide proper locations for these when setting up build environments under IDEs (i.e. http://jnetpcap.com/eclipse). The package name will be "jnetpcap-src" and "jnetpcap-javadoc" is already distributed.

I will also be deploying only 2 jnetpcap-*.tar packages. There will be one for windows and one for linux. The rpm and deb packages will continue to be provided for official releases and not development builds. This adds big overhead to more frequent development builds. The rpm and deb packages can still be provided upon special request and prior arrangements.

In summary:
1) Adding new package type: jnetpcap-src
2) Releasing 2 tar/zip packages: .zip and .tar for windows and linux
3) Stop releasing .rpm and .deb for development builds. Only official releases.

I am working on 1.3.alpha1 release that will have its features and development frozen. Only bug fixes and minor adjustments will be allowed. This release will be cultivated to production/stable quality status.

1.6 - Using in Eclipse projects

jNetPcap is a java project that comes with a required native shared library. The requirement of a native library typically adds confusion and presents difficulty for many as to how properly setup a project in eclipse to reference jNetPcap library correctly.

There are several ways that jNetPcap can be added to your existing java project in Eclipse IDE. Let me briefly outline them here and then lets go through the detailed steps of actually creating a proper build path so your project will compile with jNetPcap.

about setting filter

about setting filter
like this http://jnetpcap.svn.sourceforge.net/viewvc/jnetpcap/jnetpcap/trunk/examp...
from the example the filter is set with this expression "source 192.168.100.1"
can i filter with other thing such as version of IPv4, Protocol ,...
and how do i know what string expression i need to type to set something different ??

Thank you
Champ

Memory Managment update

A little update on my progress with memory management. I have pretty much finished the native API for memory managment. There continued to be small tweaks here and there when I started implementing the new API in various native methods. In my view the API is very clean and easy to use, while enormously enhancing capabilities.

I've upgraded nio_jmemory.cpp file to utilize new API and the java JMemory.class counter part. The main changes in java were that all of the JMemory class properties are now stored natively and not in java. This should speed up all native java calls, especially JBuffer getter/setter methods since they won't have to make multiple JNI calls in order to to check boundaries and other properties. Everything is now stored in native memory where it can be quickly accessed.

Here is what the native memory managment API looks like now:

/*
 * Memory node API.
 * 
 * All functions that take a JNIEnv* argument, automatically throw a java
 * exception upon an error. No exceptions are thrown if return status or 
 * jmem_error() == JMEM_OK.
 */
jmemory_t  *jmem_get          (JNIEnv *env, jobject obj);
char       *jmem_allocate     (JNIEnv *env, jobject obj, size_t size);
int         jmem_connect      (JNIEnv *env, jobject obj, jmemory_t *jmem);
int         jmem_is_connected (JNIEnv *env, jobject obj);
int         jmem_disconnect   (JNIEnv *env, jobject obj);
int         jmem_free         (JNIEnv *env, jmemory_t *jmem);
int         jmem_reset        (JNIEnv *env, jmemory_t *jmem);
int         jmem_active       (JNIEnv *env, jmemory_t *jmem);
int         jmem_set_mode     (jmemory_t *jmem, int mode);
char       *jmem_data_mode    (jmemory_t *jmem, int mode);
char       *jmem_data         (jmemory_t *jmem);
char       *jmem_data_ro      (jmemory_t *jmem);
char       *jmem_data_wo      (jmemory_t *jmem);
size_t      jmem_size         (jmemory_t *jmem);
int         jmem_is_active    (jmemory_t *jmem);

can i print raw data packet like this ?

From my program i can capture packet and print (with toHexDump) and the output is

0000:*ff ff ff ff ff ff 00 50 56 c0 00 08 08 00*45 00 .......PV.....E.
0010: 00 4e 27 b2 00 00 80 11 b4 9b c0 a8 6e 01 c0 a8 .N'.........n...
0020: 6e ff*00 89 00 89 00 3a b1 21*a7 81 01 10 00 01 n......:.!......
0030: 00 00 00 00 00 00 20 45 4a 46 44 45 42 46 45 45 ...... EJFDEBFEE
0040: 42 46 41 43 41 43 41 43 41 43 41 43 41 43 41 43 BFACACACACACACAC
0050: 41 43 41 43 41 41 41 00 00 20 00 01* ACACAAA.. ..

...from the output can i print them stick together ?? like this
*ffffffffffff005056c000080800*4500004e27b200008011b49bc0a86e01c0a8........00200001*

how to..?

Thank you
Champ

Create Complete TCP Packet Example?

team,

does anyone have an example of creating a complete tcp packet from scratch, and sending it?
if so could you post it?

thanks in advance,

mike