Closed acrophy closed 7 years ago
It looks Pcap4J's bug. I've already found the cause. I will fix it very soon.
BTW, if you are only interested in timestamps and orig lengths, you can use raw packet API getNextRawPacket()
and getNextRawPacketEx()
instead. Packet dissection doesn't happen in these methods, so the error won't happen.
I made the fix. Please try the snapshot build: https://oss.sonatype.org/content/repositories/snapshots/org/pcap4j/pcap4j-distribution/1.7.1-SNAPSHOT/pcap4j-distribution-1.7.1-20161124.163248-2-bin.zip
I’ve tried the snapshot, and it works fine. Thanks a lot!
在 2016年11月25日,00:39,Kaito Yamada notifications@github.com 写道:
I made the fix. Please try the snapshot build: https://oss.sonatype.org/content/repositories/snapshots/org/pcap4j/pcap4j-distribution/1.7.1-SNAPSHOT/pcap4j-distribution-1.7.1-20161124.163248-2-bin.zip https://oss.sonatype.org/content/repositories/snapshots/org/pcap4j/pcap4j-distribution/1.7.1-SNAPSHOT/pcap4j-distribution-1.7.1-20161124.163248-2-bin.zip — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kaitoy/pcap4j/issues/76#issuecomment-262814601, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3qgtMM0_eOr8scKHLgq6kDbhfjhnJ0ks5rBb3VgaJpZM4K7Ruu.
I run the first demo DefragmentEcho with src code ,but there come some errors,
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. Exception in thread "main" java.lang.NullPointerException: Cannot invoke "org.pcap4j.packet.IpV4Packet.getHeader()" because the return value of "org.pcap4j.packet.Packet.get(java.lang.Class)" is null at org.pcap4j.sample/org.pcap4j.sample.DefragmentEcho.main(DefragmentEcho.java:36)
I've encountered a "NullPointerException" when I try to read packets from a public trace without payload. Since I only care about the origin length and timestamp, I don't literally instruct the packets to be parsed(i.e. I only use PcapHandle rather than Packet). Yet, the exception still occurs when it tries to parse the packets.
I suppose packets are automatically parsed when packet factory module is included. When I remove the packet factory module in the pom file, the exception is gone. However, I do intend to inspect into packet headers in the future. So, please help me to deal with the exception.
Below is my code snippet which aims to do the byte count & packet count per millisecond:
Below is the error message: