Giter Site home page Giter Site logo

kaitoy / pcap4j Goto Github PK

View Code? Open in Web Editor NEW
1.2K 67.0 309.0 14.87 MB

A Java library for capturing, crafting, and sending packets.

Home Page: https://www.pcap4j.org/

License: Other

Java 99.85% Perl 0.05% HTML 0.05% Shell 0.01% Dockerfile 0.05%
capture-packets winpcap libpcap sending-packets java-library pcap-library jna java npcap

pcap4j's Introduction

Japanese

Pcap4J

Logos

Slack Maven Central

Build Status CircleCI Build status Coverage Status Code Quality: Java Total Alerts

Pcap4J

Pcap4J is a Java library for capturing, crafting and sending packets. Pcap4J wraps a native packet capture library (libpcap, WinPcap, or Npcap) via JNA and provides you Java-Oriented APIs.

Contents

Download

Pcap4J is available on the Maven Central Repository.

Why Pcap4J was born

I have been developing an SNMP network simulator (SNeO, available at the link below) by Java, which needed to capture packets and I found the pcap was useful for it. Although there are some implementations of the pcap such as libpcap (for UNIX) and WinPcap (for Windows), because they are both native libraries, a Java wrapper library was necessary in order to use them for SNeO. I researched it and found three Java wrapper libraries for pcap: jpcap, jNetPcap, and Jpcap. But both jpcap and jNetPcap were unsuitable for SNeO because they seemed to be designed for mainly capturing packets and not to be useful for making and sending packets so much. On the other hand, Jpcap looked useful for making and sending packets. But it had a defect in capturing ICMP packets and its development seemed to be stopped long ago. That's why I started developing Pcap4j.

Features

  • Capturing packets via a network interface and converting them into Java objects. You can get/set each field of a packet header via the Java object converted from the packet. You can also craft a packet object from scratch.
  • Sending packet objects to a real network.
  • Supported protocols:
    • Ethernet, Linux SLL, raw IP, PPP (RFC1661, RFC1662), BSD (Mac OS X) loopback encapsulation, and Radiotap
    • IEEE 802.11
      • Probe Request
    • LLC and SNAP
    • IEEE802.1Q
    • ARP
    • IPv4 (RFC791 and RFC1349) and IPv6 (RFC2460)
    • ICMPv4 (RFC792) and ICMPv6 (RFC4443, RFC4861, and RFC6275)
    • TCP (RFC793, RFC2018, and draft-ietf-tcpm-1323bis-21), UDP, and SCTP (only common header)
    • GTPv1 (only GTP-U and GTP-C header)
    • DNS (RFC1035, RFC3596, and RFC6844)
  • All built-in packet classes are serializable and thread-safe (practically immutable).
  • You can add a protocol support without modifying Pcap4J library itself.
  • Dumping and reading pcap-formatted files (e.g. a capture file of Wireshark).

How to use

System requirements

Dependencies

Pcap4j 1.1.0 or older needs Java 5.0+. Pcap4j 1.2.0 or newer needs Java 6.0+. And also a pcap native library (libpcap 1.0.0+, WinPcap 3.0+, or Npcap), jna, slf4j-api, and an implementation of logger for slf4j are required. I'm using the following libraries for the test.

  • libpcap 1.1.1
  • WinPcap 4.1.2
  • jna 5.1.0
  • slf4j-api 1.7.25
  • logback-core 1.0.0
  • logback-classic 1.0.0
Platforms

I tested Pcap4j on the following OSes with x86 or x64 processors.

  • Windows: XP, Vista, 7, 10, 2003 R2, 2008, 2008 R2, and 2012
  • Linux
    • RHEL: 5, 6, and 7
    • CentOS: 5, 6, and 7
    • Ubuntu: 13
  • UNIX
    • Solaris: 10
    • FreeBSD: 10

And tomute tested Pcap4j on Mac OS X. The report is here. Thank you, tomute!

I hope Pcap4j can run on the other OSes supported by both JNA and libpcap.

Others

Pcap4J needs administrator/root privileges. Or, if on Linux, you can run Pcap4J with a non-root user by granting capabilities CAP_NET_RAW and CAP_NET_ADMIN to your java command by the following command: setcap cap_net_raw,cap_net_admin=eip /path/to/java

Documents

The latest JavaDoc is here. Each version's JavaDoc is on the Maven Central Repository.

Refer to here for information about Pcap4J modules.

Because Pcap4J is a wrapper of a pcap native library, the following documents help you to understand how to use Pcap4J.

You can learn how to write Pcap4J programs from samples.

Learn more about Pcap4j from the following documents:

How to run samples

See the following examples:

If you want to run a sample in pcap4j-sample on Eclipse, add pcap4j-packetfactory-static or pcap4j-packetfactory-propertiesbased project to the top of User Entries in Classpath tab of the Run Configuration for the sample.

How to use in Maven project

Add a dependency to the pom.xml as like below:

<project xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
                      http://maven.apache.org/xsd/maven-4.0.0.xsd">
  ...
  <dependencies>
    <dependency>
      <groupId>org.pcap4j</groupId>
      <artifactId>pcap4j-core</artifactId>
      <version>1.8.2</version>
    </dependency>
    <dependency>
      <groupId>org.pcap4j</groupId>
      <artifactId>pcap4j-packetfactory-static</artifactId>
      <version>1.8.2</version>
    </dependency>
       ...
  </dependencies>
  ...
</project>

About native library loading

By default, Pcap4j loads the native libraries on the following conditions:

  • Windows
    • search path: The paths in the PATH environment variable, etc. (See MSDN for the details.)
    • file name: wpcap.dll and Packet.dll
  • Linux/UNIX
    • search path: The search paths of shared libraries configured on the OS. (e.g. The paths in the LD_LIBRARY_PATH environment variable)
    • file name: libpcap.so
  • Mac OS X
    • search path: The search paths of shared libraries configured on the OS. (e.g. The paths in the DYLD_LIBRARY_PATH environment variable)
    • file name: libpcap.dylib

You can use the following Java system properties to change the default behavior.

  • jna.library.path: The search path
  • org.pcap4j.core.pcapLibName: The full path of the pcap library (wpcap.dll, libpcap.so, or libpcap.dylib)
  • (Windows only) org.pcap4j.core.packetLibName: The full path of the packet library (Packet.dll)
WinPcap or Npcap

There are two native pcap libraries for Windows; WinPcap and Npcap.

The development of WinPcap has stopped since version 4.1.3 (libpcap 1.0.0 base) was released on 3/8/2013, while Npcap is still being developed. So, you should pick Npcap if you want to use new features or so.

Pcap4J can load WinPcap without tricks because it's installed in %SystemRoot%\System32\.

On the other hand, because Npcap is installed in %SystemRoot%\System32\Npcap\ by default, you need to do either of the following so that Pcap4J can load it:

  • Add %SystemRoot%\System32\Npcap\ to PATH.
  • Set jna.library.path to %SystemRoot%\System32\Npcap\.
  • Set org.pcap4j.core.pcapLibName to %SystemRoot%\System32\Npcap\wpcap.dll and org.pcap4j.core.packetLibName to %SystemRoot%\System32\Npcap\Packet.dll.
  • Install Npcap with WinPcap Compatible Mode on.

Docker

A Docker image for Pcap4J on CentOS is available at Docker Hub.

Download it by docker pull kaitoy/pcap4j and execute docker run kaitoy/pcap4j:latest to start capturing packets from eth0 on the container.

This image is built everytime a commit is made on the Git repositry.

How to build

  1. Install libpcap, WinPcap, or Npcap:

    Install WinPcap (if Windows) or libpcap (if Linux/UNIX). It's needed for the unit tests which are run during a build.

  2. Install JDK:

    Download and install JDK 9, 10, or 11, and set the environment variable JAVA_HOME properly.

  3. Add the JDK to Maven toolchains:

    Create toolchains.xml describing the JDK installed at the previous step and put it into ~/.m2/. toolchains.xml is like below:

    <?xml version="1.0" encoding="UTF-8"?>
    <toolchains xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 http://maven.apache.org/xsd/toolchains-1.1.0.xsd">
      <toolchain>
        <type>jdk</type>
        <provides>
          <version>11</version>
        </provides>
        <configuration>
          <jdkHome>/path/to/jdk-11</jdkHome>
        </configuration>
      </toolchain>
    </toolchains>
  4. Install Git:

    Download Git and install it. This step is optional.

  5. Clone the Pcap4J repository:

    If you installed Git, execute the following command: git clone [email protected]:kaitoy/pcap4j.git
    Otherwise, download the repository as a zip ball and extract it.

  6. Build:

    Open a command prompt/a terminal, cd to the project root directory, and execute ./mvnw install. Note Administrator/root privileges are needed for the unit tests.

Contributing Code

  1. Fork this repository.

  2. Create a branch from v1 branch.

  3. Write code.

    • Please refer to This PR as an example when adding protocol support.
    • This project follows Google Java Style Guide. Execute the following command to format your code: mvnw com.coveo:fmt-maven-plugin:format
  4. Send a PR from the branch.

License

LICENSE

Contacts

Kaito Yamada ([email protected])

pcap4j's People

Contributors

1sand0s avatar camsteffen avatar cbrowne avatar fooinha avatar ggadon avatar holzerc avatar jeffreymyers avatar jmmk avatar jnbptstm avatar kaitoy avatar leomaateric avatar michaelkoetter avatar misanek avatar oshyshko avatar pjsg avatar racorn avatar xcorail avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pcap4j's Issues

Fatal error while using pcap4j library somewhere in PcapHandle.setFilter

Hello,
I am trying to migrate from libjpcap to pcap4j in the commercial monitoring system, my company is developing for a while. But i am experiencing periodic failures, occurring while setting filter (PcapHandle.setFilter).

For now I have been tested lib on OS X only.

Any help would be really appreciable. Here is error core dump:

A fatal error has been detected by the Java Runtime Environment:

SIGSEGV (0xb) at pc=0x00007fff852c2609, pid=17287, tid=24835

JRE version: Java(TM) SE Runtime Environment (7.0_51-b13) (build 1.7.0_51-b13)

Java VM: Java HotSpot(TM) 64-Bit Server VM (24.51-b03 mixed mode bsd-amd64 compressed oops)

Problematic frame:

C [libpcap.A.dylib+0x3609] gen_proto+0xc9

Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

If you would like to submit a bug report, please visit:

http://bugreport.sun.com/bugreport/crash.jsp

The crash happened outside the Java Virtual Machine in native code.

See problematic frame for where to report the bug.

--------------- T H R E A D ---------------

Current thread (0x00007f8c0b984800): JavaThread "IcmpPingerSpec-akka.actor.default-dispatcher-4" [_thread_in_native, id=24835, stack(0x000000011e4bb000,0x000000011e5bb000)]

siginfo:si_signo=SIGSEGV: si_errno=0, si_code=1 (SEGV_MAPERR), si_addr=0x0000000001fffef0

Registers:
RAX=0x0000000001fffee0, RBX=0x000000011f5bffd8, RCX=0x0000000000000000, RDX=0x00000001205c0000
RSP=0x000000011e5b75b0, RBP=0x000000011e5b75e0, RSI=0x0000000000000000, RDI=0x00000001225c0000
R8 =0x0000000000000000, R9 =0x0000000000000003, R10=0x0000000000000000, R11=0x0000000000000246
R12=0x0000000001fffee0, R13=0x000000011e5b76a0, R14=0x0000000000000006, R15=0x000000011e9bfee0
RIP=0x00007fff852c2609, EFLAGS=0x0000000000010206, ERR=0x0000000000000006
TRAPNO=0x000000000000000e

Top of Stack: (sp=0x000000011e5b75b0)
0x000000011e5b75b0: 000000011ddf9ee0 000000011ddf9ee0
0x000000011e5b75c0: 0000000000000000 000000011e5b76a0
0x000000011e5b75d0: 0000000000000006 0000000000000000
0x000000011e5b75e0: 000000011e5b7600 00007fff852c2408
0x000000011e5b75f0: 0000000000000000 0000000000000006
0x000000011e5b7600: 000000011e5b8af0 00007fff852d156b
0x000000011e5b7610: 0000000100000000 00007f8c00002c80
0x000000011e5b7620: 0000000000000000 0000000000000029
0x000000011e5b7630: 0000000000000001 000000011e5b7670
0x000000011e5b7640: 00000000000000c8 0000000600000000
0x000000011e5b7650: 000000011e5b8934 000000011e5b8930
0x000000011e5b7660: 00007f8c00000000 0000000000000000
0x000000011e5b7670: 0000000000002c80 00007f8c00002c80
0x000000011e5b7680: 0000000000320101 00007f8cffffffff
0x000000011e5b7690: 0000000000000000 0000000000000000
0x000000011e5b76a0: 0000000000000006 0000000000000000
0x000000011e5b76b0: 0000000000000000 0000000000000000
0x000000011e5b76c0: 0000000100000000 00007fff8db69bd9
0x000000011e5b76d0: 00007f8c0a421bf0 0000000000000000
0x000000011e5b76e0: 000000011e5b7930 00007f8c00000000
0x000000011e5b76f0: 0000000100000000 00007fff00000000
0x000000011e5b7700: 00007f8c00000000 00007f8c00000000
0x000000011e5b7710: 9a27019b00000000 0000000100000000
0x000000011e5b7720: 0000000000000000 0000000100000000
0x000000011e5b7730: 000000011e5b7750 0000000100000000
0x000000011e5b7740: 0000000000000000 00000001fbe85430
0x000000011e5b7750: 0000000100000020 000000010caf6bc6
0x000000011e5b7760: 000000011e5b7818 0000000000000000
0x000000011e5b7770: 000000011e5b7790 000000010c798332
0x000000011e5b7780: 00000007b36681c0 00007f8c0a4a49a0
0x000000011e5b7790: 000000011e5b7890 0000000100000000
0x000000011e5b77a0: 000000010b503a00 00007f8c00000000

Instructions: (pc=0x00007fff852c2609)
0x00007fff852c25e9: df 21 ec 83 c7 06 be 10 00 00 00 e8 48 78 00 00
0x00007fff852c25f9: 48 89 c3 bf 20 01 00 00 e8 b3 e3 ff ff 49 89 c4
0x00007fff852c2609: 41 c7 44 24 10 15 00 00 00 4d 89 a4 24 98 00 00
0x00007fff852c2619: 00 49 89 5c 24 08 41 c7 44 24 28 2c 00 00 00 8b

Register to memory mapping:

RAX=0x0000000001fffee0 is an unknown value
RBX=0x000000011f5bffd8 is an unknown value
RCX=0x0000000000000000 is an unknown value
RDX=0x00000001205c0000 is an unknown value
RSP=0x000000011e5b75b0 is pointing into the stack for thread: 0x00007f8c0b984800
RBP=0x000000011e5b75e0 is pointing into the stack for thread: 0x00007f8c0b984800
RSI=0x0000000000000000 is an unknown value
RDI=0x00000001225c0000 is an unknown value
R8 =0x0000000000000000 is an unknown value
R9 =0x0000000000000003 is an unknown value
R10=0x0000000000000000 is an unknown value
R11=0x0000000000000246 is an unknown value
R12=0x0000000001fffee0 is an unknown value
R13=0x000000011e5b76a0 is pointing into the stack for thread: 0x00007f8c0b984800
R14=0x0000000000000006 is an unknown value
R15=0x000000011e9bfee0 is an unknown value

Stack: [0x000000011e4bb000,0x000000011e5bb000], sp=0x000000011e5b75b0, free space=1009k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libpcap.A.dylib+0x3609] gen_proto+0xc9
C [libpcap.A.dylib+0x3408] gen_proto_abbrev+0x31f
C [libpcap.A.dylib+0x1256b] pcap_parse+0x64b
C [libpcap.A.dylib+0x2168] pcap_compile+0x6fd
C [jna8952875308539213822.tmp+0xd94c] ffi_call_unix64+0x4c

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j org.pcap4j.core.NativeMappings.pcap_compile(Lcom/sun/jna/Pointer;Lorg/pcap4j/core/NativeMappings$bpf_program;Ljava/lang/String;II)I+0
j org.pcap4j.core.PcapHandle.setFilter(Ljava/lang/String;Lorg/pcap4j/core/BpfProgram$BpfCompileMode;Ljava/net/Inet4Address;)V+147
j org.pcap4j.core.PcapHandle.setFilter(Ljava/lang/String;Lorg/pcap4j/core/BpfProgram$BpfCompileMode;)V+6
j icmp.pcap.wrapper.PcapCaptorWrapper.setFilter(Ljava/lang/String;Z)V+10
j icmp.pcap.wrapper.PcapWrapper$class.getDefaultGatewayMacAddress(Licmp/pcap/wrapper/PcapWrapper;Lorg/pcap4j/core/PcapNetworkInterface;I)Lorg/pcap4j/util/MacAddress;+67
j icmp.pcap.wrapper.PcapWrapper$.getDefaultGatewayMacAddress(Lorg/pcap4j/core/PcapNetworkInterface;I)Lorg/pcap4j/util/MacAddress;+3
j icmp.worker.IcmpContext.(Licmp/pcap/wrapper/PcapWrapper;)V+59
j icmp.worker.IcmpRequestsProcessor.(Licmp/pcap/wrapper/PcapWrapper;Lscala/Function1;)V+20
j icmp.worker.IcmpWorker.(Licmp/pcap/wrapper/PcapWrapper;)V+26
v ~StubRoutines::call_stub
j sun.reflect.NativeConstructorAccessorImpl.newInstance0(Ljava/lang/reflect/Constructor;[Ljava/lang/Object;)Ljava/lang/Object;+0
j sun.reflect.NativeConstructorAccessorImpl.newInstance([Ljava/lang/Object;)Ljava/lang/Object;+72
j sun.reflect.DelegatingConstructorAccessorImpl.newInstance([Ljava/lang/Object;)Ljava/lang/Object;+5
j java.lang.reflect.Constructor.newInstance([Ljava/lang/Object;)Ljava/lang/Object;+79
j akka.util.Reflect$.instantiate(Ljava/lang/reflect/Constructor;Lscala/collection/immutable/Seq;)Ljava/lang/Object;+21
j akka.actor.ArgsReflectConstructor.produce()Lakka/actor/Actor;+11
j akka.actor.Props.newActor()Lakka/actor/Actor;+4
j akka.actor.ActorCell.newActor()Lakka/actor/Actor;+41
j akka.actor.ActorCell.create(Lscala/Option;)V+13
j akka.actor.ActorCell.invokeAll$1(Lakka/dispatch/sysmsg/SystemMessage;I)V+279
j akka.actor.ActorCell.systemInvoke(Lakka/dispatch/sysmsg/SystemMessage;)V+6
j akka.dispatch.Mailbox.processAllSystemMessages()V+51
j akka.dispatch.Mailbox.run()V+8
j akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec()Z+4
j scala.concurrent.forkjoin.ForkJoinTask.doExec()I+10
j scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(Lscala/concurrent/forkjoin/ForkJoinTask;)V+10
j scala.concurrent.forkjoin.ForkJoinPool.runWorker(Lscala/concurrent/forkjoin/ForkJoinPool$WorkQueue;)V+11
j scala.concurrent.forkjoin.ForkJoinWorkerThread.run()V+14
v ~StubRoutines::call_stub

--------------- P R O C E S S ---------------

Java Threads: ( => current thread )
0x00007f8c0e800800 JavaThread "IcmpPingerSpec-akka.actor.default-dispatcher-5" [_thread_in_Java, id=25347, stack(0x000000011e5be000,0x000000011e6be000)]
=>0x00007f8c0b984800 JavaThread "IcmpPingerSpec-akka.actor.default-dispatcher-4" [_thread_in_native, id=24835, stack(0x000000011e4bb000,0x000000011e5bb000)]
0x00007f8c0e801800 JavaThread "IcmpPingerSpec-akka.actor.default-dispatcher-3" [_thread_blocked, id=24323, stack(0x000000011e3b8000,0x000000011e4b8000)]
0x00007f8c0b983000 JavaThread "IcmpPingerSpec-akka.actor.default-dispatcher-2" [_thread_in_Java, id=23811, stack(0x000000011dc5b000,0x000000011dd5b000)]
0x00007f8c0acf6000 JavaThread "IcmpPingerSpec-scheduler-1" [_thread_blocked, id=23299, stack(0x000000011e038000,0x000000011e138000)]
0x00007f8c0acd6000 JavaThread "ScalaTest-dispatcher" [_thread_blocked, id=22787, stack(0x000000011defb000,0x000000011dffb000)]
0x00007f8c0acb6800 JavaThread "Monitor Ctrl-Break" daemon [_thread_in_native, id=22275, stack(0x000000011d880000,0x000000011d980000)]
0x00007f8c0b001000 JavaThread "Service Thread" daemon [_thread_blocked, id=21251, stack(0x000000011c9ca000,0x000000011caca000)]
0x00007f8c0b804000 JavaThread "C2 CompilerThread1" daemon [_thread_blocked, id=20739, stack(0x000000011c8c7000,0x000000011c9c7000)]
0x00007f8c0c05f000 JavaThread "C2 CompilerThread0" daemon [_thread_blocked, id=20227, stack(0x000000011c7c4000,0x000000011c8c4000)]
0x00007f8c0c059800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=19715, stack(0x000000011c6c1000,0x000000011c7c1000)]
0x00007f8c0c041800 JavaThread "Finalizer" daemon [_thread_blocked, id=14595, stack(0x000000011c470000,0x000000011c570000)]
0x00007f8c0c03f000 JavaThread "Reference Handler" daemon [_thread_blocked, id=14083, stack(0x000000011c36d000,0x000000011c46d000)]
0x00007f8c0d000000 JavaThread "ScalaTest-run-running-IcmpPingerSpec" [_thread_blocked, id=6403, stack(0x000000010d054000,0x000000010d154000)]

Other Threads:
0x00007f8c0c03e000 VMThread [stack: 0x000000011c26a000,0x000000011c36a000] [id=13571]
0x00007f8c0c05a800 WatcherThread [stack: 0x000000011cacd000,0x000000011cbcd000] [id=21763]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
PSYoungGen total 142848K, used 18982K [0x00000007aaa80000, 0x00000007b4080000, 0x0000000800000000)
eden space 132096K, 8% used [0x00000007aaa80000,0x00000007ab5a2318,0x00000007b2b80000)
from space 10752K, 70% used [0x00000007b3600000,0x00000007b3d676f0,0x00000007b4080000)
to space 10752K, 0% used [0x00000007b2b80000,0x00000007b2b80000,0x00000007b3600000)
ParOldGen total 174592K, used 16K [0x0000000700000000, 0x000000070aa80000, 0x00000007aaa80000)
object space 174592K, 0% used [0x0000000700000000,0x0000000700004000,0x000000070aa80000)
PSPermGen total 21504K, used 17387K [0x00000006fae00000, 0x00000006fc300000, 0x0000000700000000)
object space 21504K, 80% used [0x00000006fae00000,0x00000006fbefaf28,0x00000006fc300000)

Card table byte_map: [0x0000000110266000,0x0000000110a90000] byte_map_base: 0x000000010ca8f000

Polling page: 0x000000010d193000

Code Cache [0x000000010d1a6000, 0x000000010d416000, 0x00000001101a6000)
total_blobs=491 nmethods=174 adapters=271 free_code_cache=48274Kb largest_free_block=49410688

Compilation events (10 events):
Event: 1.189 Thread 0x00007f8c0b804000 nmethod 168 0x000000010d27f910 code [0x000000010d27fa40, 0x000000010d27fad8]
Event: 1.193 Thread 0x00007f8c0b804000 170 java.util.ArrayList::ensureExplicitCapacity (26 bytes)
Event: 1.194 Thread 0x00007f8c0c05f000 171 java.util.ArrayList::ensureCapacityInternal (23 bytes)
Event: 1.196 Thread 0x00007f8c0b804000 nmethod 170 0x000000010d277650 code [0x000000010d2777a0, 0x000000010d277a08]
Event: 1.196 Thread 0x00007f8c0b804000 172 java.util.AbstractCollection:: (5 bytes)
Event: 1.196 Thread 0x00007f8c0b804000 nmethod 172 0x000000010d27f0d0 code [0x000000010d27f200, 0x000000010d27f258]
Event: 1.196 Thread 0x00007f8c0b804000 173 java.io.UnixFileSystem::resolve (103 bytes)
Event: 1.198 Thread 0x00007f8c0c05f000 nmethod 171 0x000000010d277050 code [0x000000010d2771a0, 0x000000010d277428]
Event: 1.201 Thread 0x00007f8c0b804000 nmethod 173 0x000000010d285450 code [0x000000010d285600, 0x000000010d285e58]
Event: 1.262 Thread 0x00007f8c0c05f000 174 java.lang.String::equalsIgnoreCase (48 bytes)

GC Heap History (4 events):
Event: 0.761 GC heap before
{Heap before GC invocations=1 (full 0):
PSYoungGen total 76800K, used 66048K [0x00000007aaa80000, 0x00000007b0000000, 0x0000000800000000)
eden space 66048K, 100% used [0x00000007aaa80000,0x00000007aeb00000,0x00000007aeb00000)
from space 10752K, 0% used [0x00000007af580000,0x00000007af580000,0x00000007b0000000)
to space 10752K, 0% used [0x00000007aeb00000,0x00000007aeb00000,0x00000007af580000)
ParOldGen total 174592K, used 0K [0x0000000700000000, 0x000000070aa80000, 0x00000007aaa80000)
object space 174592K, 0% used [0x0000000700000000,0x0000000700000000,0x000000070aa80000)
PSPermGen total 21504K, used 10530K [0x00000006fae00000, 0x00000006fc300000, 0x0000000700000000)
object space 21504K, 48% used [0x00000006fae00000,0x00000006fb848a48,0x00000006fc300000)
Event: 0.769 GC heap after
Heap after GC invocations=1 (full 0):
PSYoungGen total 76800K, used 6945K [0x00000007aaa80000, 0x00000007b4080000, 0x0000000800000000)
eden space 66048K, 0% used [0x00000007aaa80000,0x00000007aaa80000,0x00000007aeb00000)
from space 10752K, 64% used [0x00000007aeb00000,0x00000007af1c86f0,0x00000007af580000)
to space 10752K, 0% used [0x00000007b3600000,0x00000007b3600000,0x00000007b4080000)
ParOldGen total 174592K, used 8K [0x0000000700000000, 0x000000070aa80000, 0x00000007aaa80000)
object space 174592K, 0% used [0x0000000700000000,0x0000000700002000,0x000000070aa80000)
PSPermGen total 21504K, used 10530K [0x00000006fae00000, 0x00000006fc300000, 0x0000000700000000)
object space 21504K, 48% used [0x00000006fae00000,0x00000006fb848a48,0x00000006fc300000)
}
Event: 1.159 GC heap before
{Heap before GC invocations=2 (full 0):
PSYoungGen total 76800K, used 72993K [0x00000007aaa80000, 0x00000007b4080000, 0x0000000800000000)
eden space 66048K, 100% used [0x00000007aaa80000,0x00000007aeb00000,0x00000007aeb00000)
from space 10752K, 64% used [0x00000007aeb00000,0x00000007af1c86f0,0x00000007af580000)
to space 10752K, 0% used [0x00000007b3600000,0x00000007b3600000,0x00000007b4080000)
ParOldGen total 174592K, used 8K [0x0000000700000000, 0x000000070aa80000, 0x00000007aaa80000)
object space 174592K, 0% used [0x0000000700000000,0x0000000700002000,0x000000070aa80000)
PSPermGen total 21504K, used 16518K [0x00000006fae00000, 0x00000006fc300000, 0x0000000700000000)
object space 21504K, 76% used [0x00000006fae00000,0x00000006fbe21a30,0x00000006fc300000)
Event: 1.167 GC heap after
Heap after GC invocations=2 (full 0):
PSYoungGen total 142848K, used 7581K [0x00000007aaa80000, 0x00000007b4080000, 0x0000000800000000)
eden space 132096K, 0% used [0x00000007aaa80000,0x00000007aaa80000,0x00000007b2b80000)
from space 10752K, 70% used [0x00000007b3600000,0x00000007b3d676f0,0x00000007b4080000)
to space 10752K, 0% used [0x00000007b2b80000,0x00000007b2b80000,0x00000007b3600000)
ParOldGen total 174592K, used 16K [0x0000000700000000, 0x000000070aa80000, 0x00000007aaa80000)
object space 174592K, 0% used [0x0000000700000000,0x0000000700004000,0x000000070aa80000)
PSPermGen total 21504K, used 16518K [0x00000006fae00000, 0x00000006fc300000, 0x0000000700000000)
object space 21504K, 76% used [0x00000006fae00000,0x00000006fbe21a30,0x00000006fc300000)
}

Deoptimization events (9 events):
Event: 0.493 Thread 0x00007f8c0d000000 Uncommon trap: reason=unloaded action=reinterpret pc=0x000000010d233228 method=sun.misc.URLClassPath$FileLoader.getResource(Ljava/lang/String;Z)Lsun/misc/Resource; @ 142
Event: 0.517 Thread 0x00007f8c0d000000 Uncommon trap: reason=unreached action=reinterpret pc=0x000000010d22cdd0 method=java.util.HashMap.getEntry(Ljava/lang/Object;)Ljava/util/HashMap$Entry; @ 58
Event: 0.585 Thread 0x00007f8c0d000000 Uncommon trap: reason=unreached action=reinterpret pc=0x000000010d22aeb8 method=java.net.URL.(Ljava/net/URL;Ljava/lang/String;Ljava/net/URLStreamHandler;)V @ 228
Event: 0.598 Thread 0x00007f8c0d000000 Uncommon trap: reason=unreached action=reinterpret pc=0x000000010d21d078 method=java.util.zip.ZipCoder.encoder()Ljava/nio/charset/CharsetEncoder; @ 4
Event: 0.626 Thread 0x00007f8c0d000000 Uncommon trap: reason=unreached action=reinterpret pc=0x000000010d2228dc method=java.util.zip.ZipCoder.encoder()Ljava/nio/charset/CharsetEncoder; @ 4
Event: 0.691 Thread 0x00007f8c0d000000 Uncommon trap: reason=class_check action=maybe_recompile pc=0x000000010d23f20c method=com.typesafe.config.impl.Tokenizer$TokenIterator.nextCharRaw()I @ 14
Event: 0.691 Thread 0x00007f8c0d000000 Uncommon trap: reason=class_check action=maybe_recompile pc=0x000000010d23f20c method=com.typesafe.config.impl.Tokenizer$TokenIterator.nextCharRaw()I @ 14
Event: 0.691 Thread 0x00007f8c0d000000 Uncommon trap: reason=class_check action=maybe_recompile pc=0x000000010d23f20c method=com.typesafe.config.impl.Tokenizer$TokenIterator.nextCharRaw()I @ 14
Event: 0.691 Thread 0x00007f8c0d000000 Uncommon trap: reason=class_check action=maybe_recompile pc=0x000000010d23f20c method=com.typesafe.config.impl.Tokenizer$TokenIterator.nextCharRaw()I @ 14

Internal exceptions (10 events):
Event: 1.265 Thread 0x00007f8c0e801800 Threw 0x00000007ab452d98 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u51/527/hotspot/src/share/vm/prims/jvm.cpp:1244
Event: 1.265 Thread 0x00007f8c0e801800 Threw 0x00000007ab45e2f8 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u51/527/hotspot/src/share/vm/prims/jvm.cpp:1244
Event: 1.265 Thread 0x00007f8c0e801800 Threw 0x00000007ab46a5c8 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u51/527/hotspot/src/share/vm/prims/jvm.cpp:1244
Event: 1.265 Thread 0x00007f8c0e801800 Threw 0x00000007ab476988 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u51/527/hotspot/src/share/vm/prims/jvm.cpp:1244
Event: 1.266 Thread 0x00007f8c0e801800 Threw 0x00000007ab482dd8 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u51/527/hotspot/src/share/vm/prims/jvm.cpp:1244
Event: 1.267 Thread 0x00007f8c0e801800 Threw 0x00000007ab48e850 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u51/527/hotspot/src/share/vm/prims/jvm.cpp:1244
Event: 1.267 Thread 0x00007f8c0e801800 Threw 0x00000007ab49c408 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u51/527/hotspot/src/share/vm/prims/jvm.cpp:1244
Event: 1.268 Thread 0x00007f8c0e801800 Threw 0x00000007ab4a9988 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u51/527/hotspot/src/share/vm/prims/jvm.cpp:1244
Event: 1.268 Thread 0x00007f8c0e801800 Threw 0x00000007ab4b75e0 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u51/527/hotspot/src/share/vm/prims/jvm.cpp:1244
Event: 1.268 Thread 0x00007f8c0b983000 Threw 0x00000007ab22c2c0 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u51/527/hotspot/src/share/vm/prims/jvm.cpp:1244

Events (10 events):
Event: 1.268 loading class 0x00007f8c0c197650
Event: 1.268 loading class 0x00007f8c0c197650 done
Event: 1.268 loading class 0x00007f8c0a49ae20
Event: 1.268 loading class 0x00007f8c0a49ae20 done
Event: 1.268 loading class 0x000000011a36b070
Event: 1.268 loading class 0x000000011a36b070 done
Event: 1.268 loading class 0x00007f8c0a581b80
Event: 1.268 loading class 0x00007f8c0a581b80 done
Event: 1.268 loading class 0x00007f8c0a564790
Event: 1.268 loading class 0x00007f8c0a564790 done

Dynamic libraries:
0x000000000093d000 /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
0x000000000093d000 /System/Library/Frameworks/Security.framework/Versions/A/Security
0x000000000093d000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
0x000000000093d000 /usr/lib/libz.1.dylib
0x000000000093d000 /usr/lib/libSystem.B.dylib
0x000000000093d000 /usr/lib/libobjc.A.dylib
0x000000000093d000 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x000000000093d000 /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
0x000000000093d000 /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
0x000000000093d000 /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
0x000000000093d000 /System/Library/PrivateFrameworks/RemoteViewServices.framework/Versions/A/RemoteViewServices
0x000000000093d000 /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
0x000000000093d000 /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit
0x000000000093d000 /System/Library/PrivateFrameworks/DataDetectorsCore.framework/Versions/A/DataDetectorsCore
0x000000000093d000 /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv
0x000000000093d000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
0x000000000093d000 /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
0x000000000093d000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/Versions/A/SpeechRecognition
0x000000000093d000 /usr/lib/libauto.dylib
0x000000000093d000 /usr/lib/libicucore.A.dylib
0x000000000093d000 /usr/lib/libxml2.2.dylib
0x000000000093d000 /System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI
0x000000000093d000 /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
0x000000000093d000 /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
0x000000000093d000 /usr/lib/liblangid.dylib
0x000000000093d000 /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSupport
0x000000000093d000 /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
0x000000000093d000 /usr/lib/libDiagnosticMessagesClient.dylib
0x000000000093d000 /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
0x000000000093d000 /System/Library/PrivateFrameworks/PerformanceAnalysis.framework/Versions/A/PerformanceAnalysis
0x000000000093d000 /System/Library/PrivateFrameworks/GenerationalStorage.framework/Versions/A/GenerationalStorage
0x000000000093d000 /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
0x000000000093d000 /System/Library/PrivateFrameworks/Sharing.framework/Versions/A/Sharing
0x000000000093d000 /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
0x000000000093d000 /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText
0x000000000093d000 /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
0x000000000093d000 /System/Library/PrivateFrameworks/Backup.framework/Versions/A/Backup
0x000000000093d000 /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
0x000000000093d000 /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
0x000000000093d000 /usr/lib/libCRFSuite.dylib
0x000000000093d000 /usr/lib/libc++.1.dylib
0x000000000093d000 /usr/lib/libc++abi.dylib
0x000000000093d000 /usr/lib/system/libcache.dylib
0x000000000093d000 /usr/lib/system/libcommonCrypto.dylib
0x000000000093d000 /usr/lib/system/libcompiler_rt.dylib
0x000000000093d000 /usr/lib/system/libcopyfile.dylib
0x000000000093d000 /usr/lib/system/libcorecrypto.dylib
0x000000000093d000 /usr/lib/system/libdispatch.dylib
0x000000000093d000 /usr/lib/system/libdyld.dylib
0x000000000093d000 /usr/lib/system/libkeymgr.dylib
0x000000000093d000 /usr/lib/system/liblaunch.dylib
0x000000000093d000 /usr/lib/system/libmacho.dylib
0x000000000093d000 /usr/lib/system/libquarantine.dylib
0x000000000093d000 /usr/lib/system/libremovefile.dylib
0x000000000093d000 /usr/lib/system/libsystem_asl.dylib
0x000000000093d000 /usr/lib/system/libsystem_blocks.dylib
0x000000000093d000 /usr/lib/system/libsystem_c.dylib
0x000000000093d000 /usr/lib/system/libsystem_configuration.dylib
0x000000000093d000 /usr/lib/system/libsystem_dnssd.dylib
0x000000000093d000 /usr/lib/system/libsystem_info.dylib
0x000000000093d000 /usr/lib/system/libsystem_kernel.dylib
0x000000000093d000 /usr/lib/system/libsystem_m.dylib
0x000000000093d000 /usr/lib/system/libsystem_malloc.dylib
0x000000000093d000 /usr/lib/system/libsystem_network.dylib
0x000000000093d000 /usr/lib/system/libsystem_notify.dylib
0x000000000093d000 /usr/lib/system/libsystem_platform.dylib
0x000000000093d000 /usr/lib/system/libsystem_pthread.dylib
0x000000000093d000 /usr/lib/system/libsystem_sandbox.dylib
0x000000000093d000 /usr/lib/system/libsystem_stats.dylib
0x000000000093d000 /usr/lib/system/libunc.dylib
0x000000000093d000 /usr/lib/system/libunwind.dylib
0x000000000093d000 /usr/lib/system/libxpc.dylib
0x000000000093d000 /usr/lib/libbsm.0.dylib
0x000000000093d000 /usr/lib/libsqlite3.dylib
0x000000000093d000 /usr/lib/libxar.1.dylib
0x000000000093d000 /usr/lib/libpam.2.dylib
0x000000000093d000 /usr/lib/libOpenScriptingUtil.dylib
0x000000000093d000 /usr/lib/libbz2.1.0.dylib
0x000000000093d000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
0x000000000093d000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
0x000000000093d000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
0x000000000093d000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
0x000000000093d000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
0x000000000093d000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
0x000000000093d000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
0x000000000093d000 /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS
0x000000000093d000 /usr/lib/system/libkxld.dylib
0x000000000093d000 /System/Library/PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth
0x000000000093d000 /System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC
0x000000000093d000 /System/Library/Frameworks/OpenDirectory.framework/Versions/A/Frameworks/CFOpenDirectory.framework/Versions/A/CFOpenDirectory
0x000000000093d000 /System/Library/Frameworks/ServiceManagement.framework/Versions/A/ServiceManagement
0x000000000093d000 /usr/lib/libxslt.1.dylib
0x000000000093d000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
0x000000000093d000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
0x000000000093d000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync
0x000000000093d000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
0x000000000093d000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
0x000000000093d000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
0x000000000093d000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
0x000000000093d000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
0x000000000093d000 /System/Library/Frameworks/IOSurface.framework/Versions/A/IOSurface
0x000000000093d000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
0x000000000093d000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
0x000000000093d000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
0x000000000093d000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
0x000000000093d000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
0x000000000093d000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
0x000000000093d000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
0x000000000093d000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontParser.dylib
0x000000000093d000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontRegistry.dylib
0x000000000093d000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
0x000000000093d000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
0x000000000093d000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib
0x000000000093d000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib
0x000000000093d000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJP2.dylib
0x000000000093d000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib
0x000000000093d000 /usr/lib/libcups.2.dylib
0x000000000093d000 /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos
0x000000000093d000 /System/Library/Frameworks/GSS.framework/Versions/A/GSS
0x000000000093d000 /usr/lib/libresolv.9.dylib
0x000000000093d000 /usr/lib/libiconv.2.dylib
0x000000000093d000 /System/Library/PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal
0x000000000093d000 /System/Library/PrivateFrameworks/TrustEvaluationAgent.framework/Versions/A/TrustEvaluationAgent
0x000000000093d000 /usr/lib/libheimdal-asn1.dylib
0x000000000093d000 /System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory
0x000000000093d000 /System/Library/PrivateFrameworks/CommonAuth.framework/Versions/A/CommonAuth
0x000000000093d000 /System/Library/Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation
0x000000000093d000 /System/Library/PrivateFrameworks/Bom.framework/Versions/A/Bom
0x000000000093d000 /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
0x000000000093d000 /System/Library/Frameworks/QuartzCore.framework/Versions/A/Frameworks/CoreImage.framework/Versions/A/CoreImage
0x000000000093d000 /System/Library/Frameworks/QuartzCore.framework/Versions/A/Frameworks/ScalableUserInterface.framework/Versions/A/ScalableUserInterface
0x000000000093d000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
0x000000000093d000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGFXShared.dylib
0x000000000093d000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
0x000000000093d000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
0x000000000093d000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCVMSPluginSupport.dylib
0x000000000093d000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreVMClient.dylib
0x000000000093d000 /System/Library/PrivateFrameworks/FaceCore.framework/Versions/A/FaceCore
0x000000000093d000 /System/Library/PrivateFrameworks/CrashReporterSupport.framework/Versions/A/CrashReporterSupport
0x000000000093d000 /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL
0x000000000093d000 /System/Library/PrivateFrameworks/AppleFSCompression.framework/Versions/A/AppleFSCompression
0x000000000093d000 /System/Library/PrivateFrameworks/Ubiquity.framework/Versions/A/Ubiquity
0x000000000093d000 /System/Library/PrivateFrameworks/IconServices.framework/Versions/A/IconServices
0x000000000093d000 /System/Library/PrivateFrameworks/ChunkingLibrary.framework/Versions/A/ChunkingLibrary
0x000000000093d000 /System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/CoreSymbolication
0x000000000093d000 /System/Library/PrivateFrameworks/Symbolication.framework/Versions/A/Symbolication
0x000000000093d000 /System/Library/PrivateFrameworks/DebugSymbols.framework/Versions/A/DebugSymbols
0x0000000051232000 /System/Library/CoreServices/Encodings/libCyrillicConverter.dylib
0x000000010c600000 /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/server/libjvm.dylib
0x000000000093d000 /usr/lib/libstdc++.6.dylib
0x000000010d156000 /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/libverify.dylib
0x000000010d163000 /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/libjava.dylib
0x000000010d19d000 /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/libzip.dylib
0x000000011c572000 /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/JavaRuntimeSupport
0x000000011c58a000 /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework/Versions/A/JavaNativeFoundation
0x000000011c59f000 /System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM
0x000000000093d000 /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
0x000000011c5ac000 /System/Library/PrivateFrameworks/JavaLaunching.framework/Versions/A/JavaLaunching
0x000000000093d000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
0x000000000093d000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
0x000000000093d000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
0x000000000093d000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
0x000000000093d000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
0x000000000093d000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI
0x000000011d87c000 /Applications/IntelliJ IDEA 14.app/Contents/bin/libbreakgen64.jnilib
0x000000011d982000 /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/libnet.dylib
0x000000011d9df000 /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/libnio.dylib
0x000000011dd62000 /private/var/folders/8w/6bnn8v2s29j00pv7wqtlvqzh0000gn/T/jna-2050689243/jna8952875308539213822.tmp
0x000000000093d000 /usr/lib/libpcap.A.dylib

VM Arguments:
jvm_args: -Didea.launcher.port=7532 -Didea.launcher.bin.path=/Applications/IntelliJ IDEA 14.app/Contents/bin -Dfile.encoding=UTF-8
java_command: com.intellij.rt.execution.application.AppMain org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner -s integration.icmp.IcmpPingerSpec -showProgressMessages true -C org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestReporter
Launcher Type: SUN_STANDARD

Environment Variables:
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
PATH=/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/share/maven/bin
SHELL=/bin/bash

Signal Handlers:
SIGSEGV: [libjvm.dylib+0x525425], sa_mask[0]=0xfffefeff, sa_flags=0x00000043
SIGBUS: [libjvm.dylib+0x525425], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGFPE: [libjvm.dylib+0x41892a], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGPIPE: [libjvm.dylib+0x41892a], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGXFSZ: [libjvm.dylib+0x41892a], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGILL: [libjvm.dylib+0x41892a], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGUSR1: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000002
SIGUSR2: [libjvm.dylib+0x41841c], sa_mask[0]=0x00000004, sa_flags=0x00000042
SIGHUP: [libjvm.dylib+0x4166ab], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGINT: [libjvm.dylib+0x4166ab], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGTERM: [libjvm.dylib+0x4166ab], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGQUIT: [libjvm.dylib+0x4166ab], sa_mask[0]=0xfffefeff, sa_flags=0x00000042

--------------- S Y S T E M ---------------

OS:Bsduname:Darwin 13.4.0 Darwin Kernel Version 13.4.0: Sun Aug 17 19:50:11 PDT 2014; root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
rlimit: STACK 8192k, CORE 0k, NPROC 709, NOFILE 10240, AS infinity
load average:2.89 2.49 2.44

CPU:total 8 (4 cores per cpu, 2 threads per core) family 6 model 70 stepping 1, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, aes, erms, ht, tsc, tscinvbit

Memory: 4k page, physical 16777216k(4194304k free)

/proc/meminfo:

vm_info: Java HotSpot(TM) 64-Bit Server VM (24.51-b03) for bsd-amd64 JRE (1.7.0_51-b13), built on Dec 18 2013 18:45:56 by "java_re" with gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

time: Mon Mar 2 12:25:57 2015
elapsed time: 1 seconds

Add original length to packet

First of all, after trying two other Java pcap libraries and trying to write a simple one myself, I very much appreciate your work!

For a research project I need to parse pcap files, split them by package, store them in some custom format and later write them back in pcap format. That works fine with pcap4j, except that apparently it lacks the information of the original packet length (at the moment packets apparently only include the captured length, which might be less).

Implementing it is fairly easy (adding it to NativeMappings pcap_pkthdr), hence I did so in order to solve my problem. However, I would very much appreciate it becoming a feature of the official library, so I would not need to manage a fork. I could provide a pull request if you chose to implement this feature, though I am unsure about how to "correctly" place it within the structure for pcap4j. My solution at the moment is rather hacky.

VLAN ID incorrect

I've discovered that the VLAN ID is getting pulled out of the Dot1q Header incorrectly.

I ran Wireshark on the same computer, same interface I'm capturing with pcap4j. Wireshark and pcap4j were both run at the same time.

Wireshark shows the packet having a VLAN ID of 218, but pcap4j shows 4058. I printed out the packet like so:

if (packet.contains(Dot1qVlanTagPacket.class)) {
    Dot1qVlanTagPacket dot1qp = packet.get(Dot1qVlanTagPacket.class);
    System.out.println("Dot1qVlanTagPacket: " + dot1qp);
    vlanId = dot1qp.getHeader().getVid();
}

And the printout shows

Dot1qVlanTagPacket: [IEEE802.1Q Tag header (4 bytes)]
  Priority: 0
  CFI: 0
  VID: 4058
  Type: 0x0800(IPv4)

But in Wireshark the packet shows

802.1Q Virtual LAN, PRI: 0, CFI: 0, ID: 218
000. .... .... .... = Priority: Best Effort (default) (0)
...0 .... .... .... = CFI: Canonical (0)
.... 0000 1101 1010 = ID: 218
Type: IP (0x0800)

IPv6 packets can be dumped to file incorrectly

An IPv6 packet with a high (>127) traffic class will not be properly written to a pcap file. Since traffic class is a byte, values higher than 127 are actually negative, and corrupt the version nibble (all bits are high) when raw data is created through bitwise or'ing.

The method getRawFields():

rawFields.add(
    ByteArrays.toByteArray(
        version.value() << 28 | trafficClass.value() << 20 | flowLabel.value()
    )
);

Bit masking of trafficClass.value() with 0xFF before the shift should fix the problem.

sample Loop.java fails with "java.lang.UnsupportedOperationException: This code is never included in pcap4j-core.jar."

I'm getting the following error when attempting to run Loop.java with the latest commit (f888f26).

java.lang.UnsupportedOperationException: This code is never included in pcap4j-core.jar.

I've encountered this problem when running on Windows 8 (WinPcap 4.1.3) and Ubuntu (libpcap 1.3.0). "mvn install" completes successfully. Below is a capture of when it happens. I redacted mac addresses.

root@jd3560:/media/jdrews/SSD OS/git/pcap4j# java -cp /media/jdrews/SSD\ OS/git/pcap4j/pcap4j-sample/target/classes:/media/jdrews/SSD\ OS/git/pcap4j/pcap4j-core/target/classes:/root/.m2/repository/net/java/dev/jna/jna/4.1.0/jna-4.1.0.jar:/root/.m2/repository/org/slf4j/slf4j-api/1.6.4/slf4j-api-1.6.4.jar org.pcap4j.sample.Loop
org.pcap4j.sample.Loop.count: 5
org.pcap4j.sample.Loop.readTimeout: 10
org.pcap4j.sample.Loop.snaplen: 65536


SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
NIF[0]: eth0
      : link layer address: xx:xx:xx:xx:xx:xx
NIF[1]: nflog
      : description: Linux netfilter log (NFLOG) interface
NIF[2]: nfqueue
      : description: Linux netfilter queue (NFQUEUE) interface
NIF[3]: eth1
      : link layer address: xx:xx:xx:xx:xx:xx
      : address: /192.168.3.35
      : address: /fe80:0:0:0:c218:85ff:fec4:6dff
NIF[4]: any
      : description: Pseudo-device that captures on all interfaces
NIF[5]: lo
      : link layer address: 00:00:00:00:00:00
      : address: /127.0.0.1
      : address: /0:0:0:0:0:0:0:1

Select a device number to capture packets, or enter 'q' to quit > 3
eth1(null)
JNA: Callback org.pcap4j.core.PcapHandle$GotPacketFuncExecutor@55015495 threw the following exception:
java.lang.UnsupportedOperationException: This code is never included in pcap4j-core.jar.
    at org.pcap4j.packet.factory.PacketFactoryBinder.getPacketFactory(PacketFactoryBinder.java:27)
    at org.pcap4j.packet.factory.PacketFactories.getFactory(PacketFactories.java:56)
    at org.pcap4j.core.PcapHandle$GotPacketFuncExecutor$1.run(PcapHandle.java:815)
    at org.pcap4j.core.PcapHandle$SimpleExecutor.execute(PcapHandle.java:783)
    at org.pcap4j.core.PcapHandle$GotPacketFuncExecutor.got_packet(PcapHandle.java:810)
    at org.pcap4j.core.NativeMappings.pcap_loop(Native Method)
    at org.pcap4j.core.PcapHandle.loop(PcapHandle.java:671)
    at org.pcap4j.core.PcapHandle.loop(PcapHandle.java:634)
    at org.pcap4j.sample.Loop.main(Loop.java:79)
JNA: Callback org.pcap4j.core.PcapHandle$GotPacketFuncExecutor@55015495 threw the following exception:
java.lang.UnsupportedOperationException: This code is never included in pcap4j-core.jar.
    at org.pcap4j.packet.factory.PacketFactoryBinder.getPacketFactory(PacketFactoryBinder.java:27)
    at org.pcap4j.packet.factory.PacketFactories.getFactory(PacketFactories.java:56)
    at org.pcap4j.core.PcapHandle$GotPacketFuncExecutor$1.run(PcapHandle.java:815)
    at org.pcap4j.core.PcapHandle$SimpleExecutor.execute(PcapHandle.java:783)
    at org.pcap4j.core.PcapHandle$GotPacketFuncExecutor.got_packet(PcapHandle.java:810)
    at org.pcap4j.core.NativeMappings.pcap_loop(Native Method)
    at org.pcap4j.core.PcapHandle.loop(PcapHandle.java:671)
    at org.pcap4j.core.PcapHandle.loop(PcapHandle.java:634)
    at org.pcap4j.sample.Loop.main(Loop.java:79)
JNA: Callback org.pcap4j.core.PcapHandle$GotPacketFuncExecutor@55015495 threw the following exception:
java.lang.UnsupportedOperationException: This code is never included in pcap4j-core.jar.
    at org.pcap4j.packet.factory.PacketFactoryBinder.getPacketFactory(PacketFactoryBinder.java:27)
    at org.pcap4j.packet.factory.PacketFactories.getFactory(PacketFactories.java:56)
    at org.pcap4j.core.PcapHandle$GotPacketFuncExecutor$1.run(PcapHandle.java:815)
    at org.pcap4j.core.PcapHandle$SimpleExecutor.execute(PcapHandle.java:783)
    at org.pcap4j.core.PcapHandle$GotPacketFuncExecutor.got_packet(PcapHandle.java:810)
    at org.pcap4j.core.NativeMappings.pcap_loop(Native Method)
    at org.pcap4j.core.PcapHandle.loop(PcapHandle.java:671)
    at org.pcap4j.core.PcapHandle.loop(PcapHandle.java:634)
    at org.pcap4j.sample.Loop.main(Loop.java:79)
JNA: Callback org.pcap4j.core.PcapHandle$GotPacketFuncExecutor@55015495 threw the following exception:
java.lang.UnsupportedOperationException: This code is never included in pcap4j-core.jar.
    at org.pcap4j.packet.factory.PacketFactoryBinder.getPacketFactory(PacketFactoryBinder.java:27)
    at org.pcap4j.packet.factory.PacketFactories.getFactory(PacketFactories.java:56)
    at org.pcap4j.core.PcapHandle$GotPacketFuncExecutor$1.run(PcapHandle.java:815)
    at org.pcap4j.core.PcapHandle$SimpleExecutor.execute(PcapHandle.java:783)
    at org.pcap4j.core.PcapHandle$GotPacketFuncExecutor.got_packet(PcapHandle.java:810)
    at org.pcap4j.core.NativeMappings.pcap_loop(Native Method)
    at org.pcap4j.core.PcapHandle.loop(PcapHandle.java:671)
    at org.pcap4j.core.PcapHandle.loop(PcapHandle.java:634)
    at org.pcap4j.sample.Loop.main(Loop.java:79)
JNA: Callback org.pcap4j.core.PcapHandle$GotPacketFuncExecutor@55015495 threw the following exception:
java.lang.UnsupportedOperationException: This code is never included in pcap4j-core.jar.
    at org.pcap4j.packet.factory.PacketFactoryBinder.getPacketFactory(PacketFactoryBinder.java:27)
    at org.pcap4j.packet.factory.PacketFactories.getFactory(PacketFactories.java:56)
    at org.pcap4j.core.PcapHandle$GotPacketFuncExecutor$1.run(PcapHandle.java:815)
    at org.pcap4j.core.PcapHandle$SimpleExecutor.execute(PcapHandle.java:783)
    at org.pcap4j.core.PcapHandle$GotPacketFuncExecutor.got_packet(PcapHandle.java:810)
    at org.pcap4j.core.NativeMappings.pcap_loop(Native Method)
    at org.pcap4j.core.PcapHandle.loop(PcapHandle.java:671)
    at org.pcap4j.core.PcapHandle.loop(PcapHandle.java:634)
    at org.pcap4j.sample.Loop.main(Loop.java:79)
ps_recv: 6
ps_drop: 0
ps_ifdrop: 0
root@jd3560:/media/jdrews/SSD OS/git/pcap4j#

JVM crash - SIGSEV

Hi,

we are using your pcap4j for network sniffing (btw thanks a lot for your hard work) and we are seeing frequent crashes after we upgraded to 1.6.2 version. Before we were using version 1.3.0 and the crash was not happening. The other change we did with version upgrade is that we kept only static packet factory in gradle script, before we had both properties based factory and static factory included. No other significant changes.

The issue is in: C [jna7435779821996815317.tmp+0xa32b] Java_com_sun_jna_Native_setInt+0x9b

Please see the attached error log below.

Any help will be much appreciated.

Thank you.
Petr

hs_err_pid1927.txt

IndexOutOfBounds in ByteArrays.calcChecksum

I'm trying to port some code from C to java which is building packets. I was having trouble getting the checksum for udp packets to match up, so after building the packet with the packet builder, I zeroed out bytes 26 and 27, then called short ck = ByteArrays.calcChecksum(retval);, which throws an exception. It almost appears that it's expecting a packet to be a length of % 2, which I don't believe is a requirement. I'm using 1.3.0. Any ideas? BTW, thanks for the awesome software. If I make some money with my project, I will look into helping support the project.

java.lang.ArrayIndexOutOfBoundsException: arr.length: 53, offset: 52, len: 2
at org.pcap4j.util.ByteArrays.validateBounds(ByteArrays.java:796) ~[pcap4j-core-1.3.0.jar:?]
at org.pcap4j.util.ByteArrays.getShort(ByteArrays.java:125) ~[pcap4j-core-1.3.0.jar:?]
at org.pcap4j.util.ByteArrays.getShort(ByteArrays.java:114) ~[pcap4j-core-1.3.0.jar:?]
at org.pcap4j.util.ByteArrays.calcChecksum(ByteArrays.java:669) ~[pcap4j-core-1.3.0.jar:?]

JNA error handling callback exception continuing

Hi,

firstly I would like to thank you for a very nice library. We are using it to capture packets in our application and we are experiencing the following issue:

We create a handle with openLive call and start a loop on it with handle.loop(-1, listener); and we randomly start seeing the JNA errors printed in console, concretely JNA error handling callback exception continuing and the capturing stops working completely afterwards. Unfortunately it is not deterministic and happens only sometime and randomly.

Environment we use:
Java: 1.7.0_75
OS: W2k3 SE SP2, 32 bit
WinPcap: 4.1.3

It would really help us if you can provide any help with this issue.

Thank you and kind regards,

Petr

Problem with tun devices on FreeBSD

If a tun device has been opened (by openvpn, for example), using Pcaps.findAllDevs will result in:

Exception in thread "main" java.lang.AssertionError: devName: tun0 pcapAddr.addr.getSaFamily(): 28 saFamily: 28
    at org.pcap4j.core.AbstractPcapAddress.throwAssetion(AbstractPcapAddress.java:80)
    at org.pcap4j.core.AbstractPcapAddress.<init>(AbstractPcapAddress.java:62)
    at org.pcap4j.core.PcapIpV6Address.<init>(PcapIpV6Address.java:22)
    at org.pcap4j.core.PcapIpV6Address.newInstance(PcapIpV6Address.java:26)
    at org.pcap4j.core.PcapNetworkInterface.<init>(PcapNetworkInterface.java:75)
    at org.pcap4j.core.PcapNetworkInterface.newInstance(PcapNetworkInterface.java:130)
    at org.pcap4j.core.Pcaps.findAllDevs(Pcaps.java:74)

The error message seems nonsensical... It's claiming 28 != 28?

java.lang.ClassNotFoundException: org.pcap4j.packet.factory.StaticPacketFactory

When I started with GetNextPacket example, I got the following errors:
java.lang.ClassNotFoundException: org.pcap4j.packet.factory.StaticPacketFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.pcap4j.util.PropertiesLoader.getClass(PropertiesLoader.java:295)
at org.pcap4j.packet.PacketPropertiesLoader.getPacketFactoryClass(PacketPropertiesLoader.java:306)
at org.pcap4j.packet.factory.PacketFactories.getFactory(PacketFactories.java:49)
at org.pcap4j.packet.UdpPacket.(UdpPacket.java:64)
at org.pcap4j.packet.UdpPacket.newPacket(UdpPacket.java:37)
at org.pcap4j.packet.factory.StaticIpNumberPacketFactory.newPacket(StaticIpNumberPacketFactory.java:55)
at org.pcap4j.packet.factory.StaticIpNumberPacketFactory.newPacket(StaticIpNumberPacketFactory.java:1)
at org.pcap4j.packet.IpV4Packet.(IpV4Packet.java:79)
at org.pcap4j.packet.IpV4Packet.newPacket(IpV4Packet.java:47)
at org.pcap4j.packet.factory.StaticEtherTypePacketFactory.newPacket(StaticEtherTypePacketFactory.java:52)
at org.pcap4j.packet.factory.StaticEtherTypePacketFactory.newPacket(StaticEtherTypePacketFactory.java:1)
at org.pcap4j.packet.EthernetPacket.(EthernetPacket.java:66)
at org.pcap4j.packet.EthernetPacket.newPacket(EthernetPacket.java:51)
at org.pcap4j.packet.factory.StaticDataLinkTypePacketFactory.newPacket(StaticDataLinkTypePacketFactory.java:49)
at org.pcap4j.packet.factory.StaticDataLinkTypePacketFactory.newPacket(StaticDataLinkTypePacketFactory.java:1)
at org.pcap4j.core.PcapHandle.getNextPacket(PcapHandle.java:219)
at org.pcap4j.sample.GetNextPacket.main(GetNextPacket.java:62)

No way to specify the pcap buffer size

There is currently no way to change the default pcap buffer size. During high load situations this can lead to dropped packets when the application cannot process the captured packets fast enough.

The pcap api provides the function pcap_set_buffer_size() for this.

From the documentation:
Packets that arrive for a capture are stored in a buffer, so that they do not have to be read by the application as soon as they arrive. On some platforms, the buffer's size can be set; a size that's too small could mean that, if too many packets are being captured and the snapshot length doesn't limit the amount of data that's buffered, packets could be dropped if the buffer fills up before the application can read packets from it, while a size that's too large could use more non-pageable operating system memory than is necessary to prevent packets from being dropped.
The buffer size is set with pcap_set_buffer_size().

GotPacketFuncExecutor#got_packet method not thread save

In the "got_packet" method within the GotPacketFuncExecutor class the captured byte array is copied from the captured Pointer to a new Packet instance in a different thread. Meaning that the pointer could no longer by valid and garbage data is read.

Solution:
move the line "packet.getByteArray(0, header.caplen)" out of the execute method so the data is copied still within the captured thread where the pointer is still valid.

This bug caused me some headache because I was getting garbage packets quite a lot

Wi-Fi packet dissection

Hi,
This is really as much of a question as it is an enhancement. I'd love to use the library and have it actively sniffing "probe requests" using the Bpf: "subtype probereq". Unfortunately it seems Pcap4j is unable to parse these packets as well as the DataLinkType 127 or DLT_IEEE802_11_RADIO information.

I would like to use the DLT to get the RSSI (Signal Strength) of the packet. Is there any documentation on how to manually add a new link type along with information? is this even supported?

I could add an AbstractPacket for dissecting the Probe Request but, unfortunately it wouldn't be worth it without the DLT information.

Thanks.
Tom

http://www.tcpdump.org/linktypes.html

Unable to get MAC address of PcapNetworkInterface on windows

I'd like to be able to find the MAC address of a PcapNetworkInterface on windows, but getLinkLayerAddresses returns an empty array. Is there any way to make this work, maybe by configuring something in the os, or winpcap, or pcap4j?

I am able to find MAC addresses using the java.net.NetworkInterface class, however the list of network interfaces enumerated by that class does not line up with what is given by Pcaps.findAllDevs(), so there's no reliable way I can see to get the right MAC address with the right pcap network interface (both the name and description fields are different in the two classes).

Any thoughts about how to reliably get MAC addresses for pcap devices on windows?

LinuxSllPacket not correctly managed by handle.getNextPacket() on offline pcap

Hello,

I try to parse a saved pcap file of a PPP capture made on Linux, leading to a LinuxSllPacket.
In logs getNextPacket() seems to well identify the packet type :

  • [org/pcap4j/packet/factory/packet-factory.properties] Got org.pcap4j.packet.LinuxSllPacket by org.pcap4j.packet.Packet.classFor.org.pcap4j.packet.namednumber.DataLinkType.113

    I checked in the mapping properties file, it is the right one :
    org.pcap4j.packet.Packet.classFor.org.pcap4j.packet.namednumber.DataLinkType.113 = org.pcap4j.packet.LinuxSllPacket

The handle's DataLayerType retrieved is the right one :
--> 113 (Linux cooked-mode capture)

but the packet type returned is an IllegalPacket :
Packet class org.pcap4j.packet.IllegalPacket

I use the 1.4.0 version of the library.

Here is Wireshark extract for the pcap file :
image

Could you help me ?

Thanks,
Alexandre

Add support for BSD

Span off from Issues#1.
As far as I know, for example, FreeBSD's sockaddr stracture defined in a system library has an extra field in comparison with Linux.

Some suggestion

At first, thanks for your contribution.
I was used to find serveral java pcap wrapper for a long time, at last, I find the way using JNA is much better. Because it supports the max number of platforms. And it is easy to deploy (no JNI wrapper need), easy to setup and use (only an app.jar and a jna.jar). so pcap4j is really very nice to me.
But I have some problems, wish to give you some help:
1.suggest you to split pcap4j to more functional jars. For example, such as pcap4j.jar for pure wrapper, analyzer4j.jar for analyzing various packet protocol, dump4j.jar for dumping and reading pcap files, other jars for other functions. splitting them to different project functionally make better to use them. sometimes, somebody maybe only want to get an analyzer but dumper. And sometimes oppositely.
2.I find that pcap4j.jar has many useless files, such as examples. When we use pcap4j.jar as a library, how can we use the example in the library? and the role of the pcap files in pcap4j.jar is confusing, either. In addition, I always find some class which have not been called for. If you prepare to release a jar, I suggest you to make it clean and tiny.
3.I don't think use log in a library is a good idea. you should use state code and exceptions to control the runtime, instead of output log. Log should be used by app or test. So there is a advice to wish you cancel the library output. Leave only jna.jar and pcap4j.jar.
4.Pcap4j is no longer compatible with the newest jna, please update it.
And some questions:
1.Does pcap4j support MacOS?
2.When does pcap4j prepare to support BSD?

evaluating pcap4j

Hi Kaitoy,

Just to let you know, I am evaluating pcap4j (and other pcap libs) for integration in netXStudio. (www.netxstudio.com).

I will need to process various telecommunications protocols (sigtran, MTP3, MAP, TCAP, SCCP etc...), I know the 'disectors' are likely not existing, but it would be interresting to see what your plans are on the long run?

Bye
Christophe

Create new PCAP file

Hello,

this is more a question than an issue.
Is there a way to create a pcap file from sketch, without having to load an existing file first?
In order to initiate a PcapDumper object, I am currently doing this:
PcapHandle handleRead = Pcaps.openOffline(filePath);
PcapDumper dumper = handleRead.dumpOpen(filePath);

But it seems odd to first open a file offline, just to overwrite it in the second call. Did I miss something in the handleRead class?
Thanks for helping!

Kind regards,
Sascha

ArrayIndexOutOfBoundsException when parsing Ip packets with TSO

When pcap4j receives IP packets with TSO (TCP segmentation offload) enabled an ArrayIndexOutOfBoundsException is raised.

In case of TSO the reported total length is 0 although it is actually not. So in this case the total length has to be derived from the captured packet. Please see the screenshot how Wireshark handles the same packet.

JNA: Callback org.pcap4j.core.PcapHandle$GotPacketFuncExecutor@6603557c threw the following exception:
java.lang.ArrayIndexOutOfBoundsException: array: 45 00 00 00 6f fd 40 00 ... offset: 20 length: -20
at org.pcap4j.util.ByteArrays.getSubArray(ByteArrays.java:660)
at org.pcap4j.packet.IpV4Packet.(IpV4Packet.java:62)
at org.pcap4j.packet.IpV4Packet.newPacket(IpV4Packet.java:44)
at org.pcap4j.packet.factory.StaticEtherTypePacketFactory$1.newInstance(StaticEtherTypePacketFactory.java:32)
at org.pcap4j.packet.factory.AbstractStaticPacketFactory.newInstance(AbstractStaticPacketFactory.java:41)
at org.pcap4j.packet.factory.AbstractStaticPacketFactory.newInstance(AbstractStaticPacketFactory.java:22)
at org.pcap4j.packet.EthernetPacket.(EthernetPacket.java:63)
at org.pcap4j.packet.EthernetPacket.newPacket(EthernetPacket.java:50)

image

TCP timestampが取得できない

TCPパケットの中に含まれるタイムスタンプを取得しようと思い、サンプルコードを改変したものを書いてみたのですが、うまく取得できませんでした。
コードは以下です。

https://gist.github.com/kurochan/77fc5edd382fc00e34b3

出力のうち、タイムスタンプの部分だけを抜き出すと、以下のようになりますが、常に、8a00000000が返ってきてしまいます。

=== TCP Option ===
8a00000000

自分の使い方が合っているのか分からなかったので、Issueを書かせて頂きました。
よろしくお願いします。

java.lang.NullPointerException: null for tun0 interface (is my fix reasonable?)

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO] 
[INFO] Pcap4J
[INFO] Pcap4J Core
[INFO] Pcap4J Packet Test
[INFO] Pcap4J Static Packet Factory
[INFO] Pcap4J Properties-Based Packet Factory
[INFO] Pcap4J Sample
[INFO] Pcap4J Distribution
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Pcap4J 1.4.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ pcap4j ---
[INFO] 
[INFO] --- maven-javadoc-plugin:2.9:aggregate-jar (aggregate-jar) @ pcap4j ---
[INFO] 
Loading source files for package org.pcap4j...
Loading source files for package org.pcap4j.core...
Loading source files for package org.pcap4j.packet...
Loading source files for package org.pcap4j.packet.constant...
Loading source files for package org.pcap4j.packet.factory...
Loading source files for package org.pcap4j.packet.namednumber...
Loading source files for package org.pcap4j.util...
Loading source files for package org.pcap4j.sample...
Constructing Javadoc information...
Standard Doclet version 1.7.0_80
Building tree for all the packages and classes...
Generating /root/IdeaProjects/pcap4j/target/apidocs/org/pcap4j/Pcap4jPropertiesLoader.html...
<<skipped other "Generating">>
Generating /root/IdeaProjects/pcap4j/target/apidocs/help-doc.html...
2 warnings
[WARNING] Javadoc Warnings
[WARNING] /root/IdeaProjects/pcap4j/pcap4j-core/src/main/java/org/pcap4j/packet/factory/PacketFactory.java:42: warning - Tag @link: can't find newInstance(byte[], NamedNumber) in org.pcap4j.packet.factory.PacketFactory
[WARNING] /root/IdeaProjects/pcap4j/pcap4j-core/src/main/java/org/pcap4j/packet/factory/PacketFactory.java:49: warning - Tag @link: can't find newInstance(byte[]) in org.pcap4j.packet.factory.PacketFactory
[INFO] Building jar: /root/IdeaProjects/pcap4j/target/pcap4j-1.4.1-SNAPSHOT-javadoc.jar
[INFO] 
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ pcap4j ---
[INFO] Installing /root/IdeaProjects/pcap4j/pom.xml to /root/.m2/repository/org/pcap4j/pcap4j/1.4.1-SNAPSHOT/pcap4j-1.4.1-SNAPSHOT.pom
[INFO] Installing /root/IdeaProjects/pcap4j/target/pcap4j-1.4.1-SNAPSHOT-javadoc.jar to /root/.m2/repository/org/pcap4j/pcap4j/1.4.1-SNAPSHOT/pcap4j-1.4.1-SNAPSHOT-javadoc.jar
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Pcap4J Core 1.4.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-enforcer-plugin:1.0:enforce (enforce-maven) @ pcap4j-core ---
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ pcap4j-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ pcap4j-core ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 191 source files to /root/IdeaProjects/pcap4j/pcap4j-core/target/classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ pcap4j-core ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ pcap4j-core ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.15:test (default-test) @ pcap4j-core ---
[INFO] Surefire report directory: /root/IdeaProjects/pcap4j/pcap4j-core/target/surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.pcap4j.core.PcapHandleTest
14:03:51,341 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Could NOT find resource [logback.groovy]
14:03:51,341 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback-test.xml] at [file:/root/IdeaProjects/pcap4j/pcap4j-core/target/test-classes/logback-test.xml]
14:03:51,414 |-INFO in ch.qos.logback.classic.joran.action.ConfigurationAction - debug attribute not set
14:03:51,417 |-INFO in ch.qos.logback.core.joran.action.StatusListenerAction - Adding status listener of type [ch.qos.logback.core.status.OnConsoleStatusListener]
14:03:51,434 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
14:03:51,438 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [CONSOLE]
14:03:51,471 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
14:03:51,524 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - About to instantiate appender of type [ch.qos.logback.core.FileAppender]
14:03:51,526 |-INFO in ch.qos.logback.core.joran.action.AppenderAction - Naming appender as [FILE]
14:03:51,533 |-INFO in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Assuming default type [ch.qos.logback.classic.encoder.PatternLayoutEncoder] for [encoder] property
14:03:51,535 |-INFO in ch.qos.logback.core.FileAppender[FILE] - File property is set to [target/test/test.log]
14:03:51,536 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting level of logger [org.pcap4j.core] to DEBUG
14:03:51,537 |-INFO in ch.qos.logback.classic.joran.action.LoggerAction - Setting additivity of logger [org.pcap4j.core] to true
14:03:51,537 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [CONSOLE] to Logger[org.pcap4j.core]
14:03:51,538 |-INFO in ch.qos.logback.classic.joran.action.RootLoggerAction - Setting level of ROOT logger to DEBUG
14:03:51,538 |-INFO in ch.qos.logback.core.joran.action.AppenderRefAction - Attaching appender named [FILE] to Logger[ROOT]
14:03:51,540 |-INFO in ch.qos.logback.classic.joran.JoranConfigurator@736afade - Registering current configuration as safe fallback point
Tests run: 3, Failures: 0, Errors: 3, Skipped: 0, Time elapsed: 0.859 sec <<< FAILURE! - in org.pcap4j.core.PcapHandleTest
testGetStats(org.pcap4j.core.PcapHandleTest)  Time elapsed: 0.29 sec  <<< ERROR!
java.lang.NullPointerException: null
    at org.pcap4j.core.PcapNetworkInterface.<init>(PcapNetworkInterface.java:55)
    at org.pcap4j.core.PcapNetworkInterface.newInstance(PcapNetworkInterface.java:115)
    at org.pcap4j.core.Pcaps.findAllDevs(Pcaps.java:84)
    at org.pcap4j.core.PcapHandleTest.setUp(PcapHandleTest.java:34)

testListDatalinks(org.pcap4j.core.PcapHandleTest)  Time elapsed: 0.139 sec  <<< ERROR!
java.lang.NullPointerException: null
    at org.pcap4j.core.PcapNetworkInterface.<init>(PcapNetworkInterface.java:55)
    at org.pcap4j.core.PcapNetworkInterface.newInstance(PcapNetworkInterface.java:115)
    at org.pcap4j.core.Pcaps.findAllDevs(Pcaps.java:84)
    at org.pcap4j.core.PcapHandleTest.setUp(PcapHandleTest.java:34)

testSetDlt(org.pcap4j.core.PcapHandleTest)  Time elapsed: 0.141 sec  <<< ERROR!
java.lang.NullPointerException: null
    at org.pcap4j.core.PcapNetworkInterface.<init>(PcapNetworkInterface.java:55)
    at org.pcap4j.core.PcapNetworkInterface.newInstance(PcapNetworkInterface.java:115)
    at org.pcap4j.core.Pcaps.findAllDevs(Pcaps.java:84)
    at org.pcap4j.core.PcapHandleTest.setUp(PcapHandleTest.java:34)

Running org.pcap4j.core.PcapDumperTest
14:03:52.139 [main] DEBUG org.pcap4j.core.PcapDumper - Dumping a packet: [Ethernet Header (14 bytes)]
  Destination address: ff:ff:ff:ff:ff:ff
  Source address: fe:00:00:00:00:01
  Type: 0x0806 (ARP)
[ARP Header (28 bytes)]
  Hardware type: 1 (Ethernet (10Mb))
  Protocol type: 0x0800 (IPv4)
  Hardware address length: 6 [bytes]
  Protocol address length: 4 [bytes]
  Operation: 1 (REQUEST)
  Source hardware address: fe:00:00:00:00:01
  Source protocol address: /192.0.2.1
  Destination hardware address: ff:ff:ff:ff:ff:ff
  Destination protocol address: /192.0.2.2
[Ethernet Pad (18 bytes)]
  Hex stream: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

14:03:52.146 [main] DEBUG org.pcap4j.core.PcapDumper - Dumped a packet: ff ff ff ff ff ff fe 00 00 00 00 01 08 06 00 01 08 00 06 04 00 01 fe 00 00 00 00 01 c0 00 02 01 ff ff ff ff ff ff c0 00 02 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
14:03:52.147 [main] INFO  org.pcap4j.core.PcapDumper - Closed.
14:03:52.147 [main] INFO  org.pcap4j.core.PcapHandle - Closed.
14:03:52.149 [main] INFO  org.pcap4j.core.PcapDumperTest - initialPosition: 24
14:03:52.149 [main] DEBUG org.pcap4j.core.PcapDumper - Dumping a packet: [Ethernet Header (14 bytes)]
  Destination address: ff:ff:ff:ff:ff:ff
  Source address: fe:00:00:00:00:01
  Type: 0x0806 (ARP)
[ARP Header (28 bytes)]
  Hardware type: 1 (Ethernet (10Mb))
  Protocol type: 0x0800 (IPv4)
  Hardware address length: 6 [bytes]
  Protocol address length: 4 [bytes]
  Operation: 1 (REQUEST)
  Source hardware address: fe:00:00:00:00:01
  Source protocol address: /192.0.2.1
  Destination hardware address: ff:ff:ff:ff:ff:ff
  Destination protocol address: /192.0.2.2
[Ethernet Pad (18 bytes)]
  Hex stream: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

14:03:52.156 [main] DEBUG org.pcap4j.core.PcapDumper - Dumped a packet: ff ff ff ff ff ff fe 00 00 00 00 01 08 06 00 01 08 00 06 04 00 01 fe 00 00 00 00 01 c0 00 02 01 ff ff ff ff ff ff c0 00 02 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
14:03:52.156 [main] INFO  org.pcap4j.core.PcapDumperTest - position: 100
14:03:52.157 [main] INFO  org.pcap4j.core.PcapDumper - Closed.
14:03:52.157 [main] INFO  org.pcap4j.core.PcapHandle - Closed.
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.013 sec - in org.pcap4j.core.PcapDumperTest
Running org.pcap4j.core.PcapsTest
14:03:52.385 [main] INFO  org.pcap4j.core.PcapsTest - 湥び
14:03:52.393 [main] INFO  org.pcap4j.core.PcapsTest - 1 (Ethernet) name: EN10MB
14:03:52.395 [main] INFO  org.pcap4j.core.PcapsTest - 9 (PPP) name: PPP
14:03:52.396 [main] INFO  org.pcap4j.core.PcapsTest - 1 (Ethernet) descr: Ethernet
14:03:52.397 [main] INFO  org.pcap4j.core.PcapsTest - 9 (PPP) descr: PPP
14:03:52.398 [main] INFO  org.pcap4j.core.PcapsTest - err: Operation not permitted
14:03:52.399 [main] INFO  org.pcap4j.core.PcapsTest - ver: libpcap version 1.6.2
Tests run: 15, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.377 sec <<< FAILURE! - in org.pcap4j.core.PcapsTest
testFindAllDevs(org.pcap4j.core.PcapsTest)  Time elapsed: 0.14 sec  <<< ERROR!
java.lang.NullPointerException: null
    at org.pcap4j.core.PcapNetworkInterface.<init>(PcapNetworkInterface.java:55)
    at org.pcap4j.core.PcapNetworkInterface.newInstance(PcapNetworkInterface.java:115)
    at org.pcap4j.core.Pcaps.findAllDevs(Pcaps.java:84)
    at org.pcap4j.core.PcapsTest.testFindAllDevs(PcapsTest.java:38)

Running org.pcap4j.core.PcapNetworkInterfaceTest
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.141 sec <<< FAILURE! - in org.pcap4j.core.PcapNetworkInterfaceTest
testOpenLive(org.pcap4j.core.PcapNetworkInterfaceTest)  Time elapsed: 0.139 sec  <<< ERROR!
java.lang.NullPointerException: null
    at org.pcap4j.core.PcapNetworkInterface.<init>(PcapNetworkInterface.java:55)
    at org.pcap4j.core.PcapNetworkInterface.newInstance(PcapNetworkInterface.java:115)
    at org.pcap4j.core.Pcaps.findAllDevs(Pcaps.java:84)
    at org.pcap4j.core.PcapNetworkInterfaceTest.testOpenLive(PcapNetworkInterfaceTest.java:39)


Results :

Tests in error: 
  PcapHandleTest.setUp:34 » NullPointer
  PcapHandleTest.setUp:34 » NullPointer
  PcapHandleTest.setUp:34 » NullPointer
  PcapsTest.testFindAllDevs:38 » NullPointer
  PcapNetworkInterfaceTest.testOpenLive:39 » NullPointer

Tests run: 21, Failures: 0, Errors: 5, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] Pcap4J ............................................ SUCCESS [12.034s]
[INFO] Pcap4J Core ....................................... FAILURE [7.915s]
[INFO] Pcap4J Packet Test ................................ SKIPPED
[INFO] Pcap4J Static Packet Factory ...................... SKIPPED
[INFO] Pcap4J Properties-Based Packet Factory ............ SKIPPED
[INFO] Pcap4J Sample ..................................... SKIPPED
[INFO] Pcap4J Distribution ............................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 20.422s
[INFO] Finished at: Tue Apr 21 14:03:52 MSK 2015
[INFO] Final Memory: 18M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.15:test (default-test) on project pcap4j-core: There are test failures.
[ERROR] 
[ERROR] Please refer to /root/IdeaProjects/pcap4j/pcap4j-core/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :pcap4j-core

I have tun0 interface, he is the cause of problem

# ifconfig 
enp2s0    Link encap:Ethernet  HWaddr 38:2C:62:4A:7F:11  
          inet addr:192.168.5.35  Bcast:192.168.255.255  Mask:255.255.0.0
          inet6 addr: fdc3:2c30:e480:0:3a2c:4faf:fe62:7f11/64 Scope:Global
          inet6 addr: fe80::3a2c:4aff:ef62:7f11/64 Scope:Link
          inet6 addr: fdc3:2c30:e408:0:3c82:6f64:abb1:9a71/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1492  Metric:1
          RX packets:304328 errors:0 dropped:0 overruns:0 frame:0
          TX packets:165721 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:381499233 (363.8 Mb)  TX bytes:12148624 (11.5 Mb)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:132121 errors:0 dropped:0 overruns:0 frame:0
          TX packets:132121 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:14190299 (13.5 Mb)  TX bytes:14190299 (13.5 Mb)

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:172.16.20.20  P-t-P:1.1.1.1  Mask:255.255.255.255
          UP POINTOPOINT RUNNING  MTU:1284  Metric:1
          RX packets:3 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:500 
          RX bytes:328 (328.0 b)  TX bytes:226 (226.0 b)

I have found that changing PcapNetworkInterface.java
from

for (
      pcap_addr pcapAddr = pif.addresses;
      pcapAddr != null;
      pcapAddr = pcapAddr.next
    ) {

to

    for (
      pcap_addr pcapAddr = pif.addresses;
      (pcapAddr != null) && (pcapAddr.addr != null);
      pcapAddr = pcapAddr.next
    ) {

solves the problem and build goes fine.

Linux Capabilities

Is it possible to alter Linux capabilities of the Java binary in order to use pcap4j without administrative privileges?

I have tried giving JAVA_HOME/bin/java capabilities such as CAP_NET_ADMIN and CAP_NET_BIND_SERVICE amongst many other capabilities, however making a very simple call such as Pcaps.getDevByName("lo") still returns null unless I specifically call my application using the sudo command.

Is it in anyway possible to use this library without administrative privileges?

When I set the setcap cap_net_raw,cap_net_admin=eip /path/to/java; the java can not run anymore, it report the error below

Initially, I would like to run java -cp pcap4j-core.jar:pcap4j-packetfactory-static.jar:pcap4j-sample.jar:jna-3.5.2.jar:slf4j-api-1.6.4.jar org.pcap4j.sample.SendArpRequest 192.168.209.1;
It required to choose with the following instruction:
NIF[0]: enp9s0
: link layer address:
: address: /
: address: /
: address: /
NIF[1]: any
: description: Pseudo-device that captures on all interfaces
NIF[2]: lo
: link layer address: 00:00:00:00:00:00
: address: /127.0.0.1
: address: /0:0:0:0:0:0:0:1
NIF[3]: wlp3s0
: link layer address:
NIF[4]: docker0
: link layer address:
: address: /

*_Some exception prompted after choosing the first device._*

However, it said I did not have permission withe the exception below:
Exception in thread "main" org.pcap4j.core.PcapNativeException: enp9s0: You don't have permission to capture on that device (socket: Operation not permitted)
at org.pcap4j.core.PcapNetworkInterface.openLive(PcapNetworkInterface.java:258)
at org.pcap4j.sample.SendArpRequest.main(SendArpRequest.java:74)

So I set the setcap cap_net_raw,cap_net_admin=eip /path/to/java in my Ubuntu. Then the java can not run anymore, it report the error below:
java: error while loading shared libraries: libjli.so: cannot open shared object file: No such file or directory

How to fix it?

Add benchmark testing

The library should be checked in terms of performance and should compare itself to other popular alternatives

Support to change buffer size when opening live capture

Hi,

we are using openLive method to get a handler and start the loop on it. We want to change the buffer size, but there is no API exposed for such functionality. Do you think you can provide the API to do so? We checked the code and it is only used inside of PcapHandler builder class.

Thank you and kind regards,

Petr

Packet direction capture support

openlive argument that allows specifying the capture direction: incoming packet, outgoing packets or both. like openlive100 of jnetPcap.
thanks.

libpcap.so.0.9.8: undefined symbol: pcap_free_datalinks

when using pcap4j (1.2.0-SNAPSHOT) with libpcap version0.9.8 I am getting the following error during initialization:

java.lang.UnsatisfiedLinkError: Error looking up function 'pcap_free_datalinks': /usr/lib64/libpcap.so.0.9.8: undefined symbol: pcap_free_datalinks] with root cause

java.lang.UnsatisfiedLinkError: Error looking up function 'pcap_free_datalinks': /usr/lib64/libpcap.so.0.9.8: undefined symbol: pcap_free_datalinks
at com.sun.jna.Function.(Function.java:208)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:536)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:513)
at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:499)
at com.sun.jna.Native.register(Native.java:1509)
at org.pcap4j.core.NativeMappings.(NativeMappings.java:62)
at org.pcap4j.core.Pcaps.findAllDevs(Pcaps.java:62)

According to the docs pcap4j requires libpcap 0.9.3+

Platform is Linux 2.6.32.54-0.3-default #1 SMP 2012-01-27 17:38:56 +0100 x86_64 x86_64 x86_64 GNU/Linux

Support to open live capture on iface without IP address

Hi,

it would be nice to add an option to open live capture on interface, which doesn't have any IP address assigned. Use case - on Solaris you can set up IPMP group to which you assign IP address. Such group has two underlying interfaces which doesn't have IP address assigned, but you want to capture on one of the underlying interface. We tried tcpdump and it supports it ... you can do tcpdump -I and it works.

We have checked the code and the problem is that findAllDevs method doesn't return such an interface and therefore with current API you can't open live capture on it. But if you call NativeMappings.pcap_open_live(deviceName, ...) the capturing works.

So maybe a static method on PcapNetworkInterface class

public static PcapHandle openLive(String deviceName, int snaplen, PromiscuousMode mode, int timeoutMillis)

which will allow to specify the deviceName directly would be useful.

Thank you and kind regards,

Petr

org.pcap4j.sample.Loop only shows Hex stream

In the example documentation for org.pcap4j.sample.Loop it shows user readable descriptions of each packet. See link below:
https://github.com/kaitoy/pcap4j/blob/master/www/sample_Loop.md

But for some reason when I run it, I get just a hex stream. Perhaps I'm doing something wrong? Thanks for your help!

Windows 8, WinPCap 4.1.3
Java 1.6.0_45

c:\git\pcap4j>java -cp C:\git\pcap4j\pcap4j-sample\target\pcap4j-sample-1.2.0-SNAPSHOT.jar;C:\git\pcap4j\pcap4j-core\target\pcap4j-core-1.2.0-SNAPSHOT.jar;C:\Users\jdrews\.m2\repository\net\java\dev\jna\jna\4.1.0\jna-4.1.0.jar;C:\Users\jdrews\.m2\repository\org\slf4j\slf4j-api\1.6.4\slf4j-api-1.6.4.jar -Dorg.pcap4j.sample.Loop.count=2 org.pcap4j.sample.Loop icmp
org.pcap4j.sample.Loop.count: 2
org.pcap4j.sample.Loop.readTimeout: 10
org.pcap4j.sample.Loop.snaplen: 65536


SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
NIF[0]: \Device\NPF_{2BF655AC-5148-4E45-880A-C347550A9016}
      : description: Realtek PCIe GBE Family Controller
NIF[1]: \Device\NPF_{6CAE8DF5-518E-4487-B7E5-130AA0E5A836}
      : description: Microsoft
      : address: /fe80:0:0:0:e5fe:a0ff:cff0:1a4c
      : address: /fe80:0:0:0:e5fe:a0ff:cff0:1a4c
NIF[2]: \Device\NPF_{6E9128D0-0819-4253-82C2-DD9477179E77}
      : description: Microsoft
      : address: /fe80:0:0:0:711e:20b9:6a71:a872
      : address: /192.168.3.35
NIF[3]: \Device\NPF_{0239C018-BC3B-493B-B3B3-5CD514F3B591}
      : description: TAP-Win32 Adapter OAS
      : address: /fe80:0:0:0:d9c9:2ac0:dae6:c0ac
      : address: /0.0.0.0
NIF[4]: \Device\NPF_{ED2111D2-D451-4B4D-84FC-026C4C223468}
      : description: Microsoft Corporation
      : address: /fe80:0:0:0:d4f6:ff3b:d8e0:d443
      : address: /0.0.0.0
NIF[5]: \Device\NPF_{740479C1-5477-4D1D-BA33-773F7763E646}
      : description: Microsoft Corporation
      : address: /10.9.8.177

Select a device number to capture packets, or enter 'q' to quit > 2
\Device\NPF_{6E9128D0-0819-4253-82C2-DD9477179E77}(Microsoft)
2014-05-11 15:42:35.418494
[data (98 bytes)]
  Hex stream: c0 18 85 c4 6d ff 00 15 5d 03 51 04 08 00 45 00 00 54 00 00 40 00 40 01 b2 e2 c0 a8 03 53 c0 a8 03 23 08 00 72 17 51 23 00 05 ab d2 6f 53 00 00 00 00 4d c7 0d 00 00 00 00 00 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37

2014-05-11 15:42:36.420863
[data (98 bytes)]
  Hex stream: c0 18 85 c4 6d ff 00 15 5d 03 51 04 08 00 45 00 00 54 00 00 40 00 40 01 b2 e2 c0 a8 03 53 c0 a8 03 23 08 00 b1 0a 51 23 00 06 ac d2 6f 53 00 00 00 00 0d d3 0d 00 00 00 00 00 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35 36 37

ps_recv: 12
ps_drop: 0
ps_ifdrop: 0
bs_capt: 0

c:\git\pcap4j>

util.ByteArrays.toHexString() performance slow compared to DatatypeConverter.printHexBinary()

Hello,

Have you considered using the native javax.xml.bind.DatatypeConverter.printHexBinary() instead of the util.ByteArrays.toHexString function? In my implementation of pcap4j (which is admittedly a very specific use case) I've noticed speeds orders of magnitudes faster by replacing calls to toHexString with DatatypeConverter.printHexBinary.

Thanks for this excellent project!

Can I run filter on PcapHandle created from Pcaps.openOffiline()?

Hello,
I'm working on a project where we've got pcap files that were created before my code gets called. Some of these pcap files can get fairly large (5-10GB). Is pcap4j able to support the scenario where my code would the pcap file offline and then call setFilter() so that I can create a much smaller dump file with only the packets that match the filter?

In my attempts to do this so for, the PcapHandle let's me set the filter but when I call getNextPacketEx() on the handle, it returns an EOFException.

Thanks for your time and consideration!

Read addresses for interfaces

Here a simple test case iterating all interfaces and all related addresses:

    List<PcapNetworkInterface> allDevs = Pcaps.findAllDevs();
    System.out.println("number of devices: " + allDevs.size());
    for (PcapNetworkInterface device : allDevs) {
        System.out.println(device);

        List<PcapAddress> addresses = device.getAddresses();
        System.out.println("number of addresses: " + addresses.size());
        for (PcapAddress address : addresses) {
            System.out.println("\t" + address);
        }
    }

Shouldn't that return anything? Actually I don't get any address for one of the interfaces. It only returns:
"number of addresses: 0"
for all network interfaces. Even the one's, that are connected!

Is this a bug of Pcap4J or did I miss anything?

Memory leak while reading packets from pcap file?

Hi,

I'm using pcap4j for reading large pcap files.
I just dump the rawdata to Standard stdout.

At around 400 000 - 450 000 packets the program start to get slow.
Then later on I get an OOM (heap space).

Is there any option to discard the packets as I read them ? I have the impression that the packets might be accumulated in PcapHandle ?

Here's the code (tested with 1.3.1-SNAPSHOT and 1.3.0):

        PcapHandle h = Pcaps.openOffline(pcapFilename);
        Packet p = null;
        long nbPackets = 0;
        while(true) {
            p = h.getNextPacket();
            if (p == null) {
                break;
            }
            UdpPacket up = p.get(UdpPacket.class);
            if (up != null) {
                System.out.println(nbPackets++ + " " + p.toString());
            }
        }

MacOSX malloc exception

I'm trying to run the GetNextPacket sample on MacOSX 10.9.2 and I'm getting the following exception after successfully intercepting some packets:

java(2395,0x10fde9000) malloc: *** error for object 0x7fa634a02208: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.