2012-10-26 167 views
0

當我嘗試使用JpCap Writer將數據包保存到文件時,會導致JVM崩潰。JpCapWriter崩潰JVM

代碼:

captor=JpcapCaptor.openDevice(interfaceList[interfaceNumber], 65535, true, 20); 
captor.setFilter("ip and tcp",true); 


JpcapWriter writer=JpcapWriter.openDumpFile(captor,"write.txt"); 
for(int i=0;i<10;i++){ 
    Packet packet=captor.getPacket(); 
    writer.writePacket(packet); 
    } 
writer.close(); 

崩潰信息:

# 
# A fatal error has been detected by the Java Runtime Environment: 
# 
# SIGSEGV (0xb) at pc=0x00007f283105953a, pid=3060, tid=139810797537024 
# 
# JRE version: 6.0_24-b24 
# Java VM: OpenJDK 64-Bit Server VM (20.0-b12 mixed mode linux-amd64 compressed oops) 
# Derivative: IcedTea6 1.11.4 
# Distribution: Ubuntu 12.04 LTS, package 6b24-1.11.4-1ubuntu0.12.04.1 
# Problematic frame: 
# v ~BufferBlob::jni_fast_GetLongField 
# 
# An error report file with more information is saved as: 
# /root/workspace/Sniff/hs_err_pid3060.log 
# 
# If you would like to submit a bug report, please include 
# instructions how to reproduce the bug and visit: 
# https://bugs.launchpad.net/ubuntu/+source/openjdk-6/ 
# The crash happened outside the Java Virtual Machine in native code. 
# See problematic frame for where to report the bug. 
# 

任何想法如何解決呢?或者任何其他的替代方式來保存TCPDump格式的數據包?

回答

0

我看到了你對我的問題的評論。我有這個相同的問題,這是我在試圖關閉作家之後關閉它的原因。你可能會在不知不覺中關閉它。檢查您的代碼,並查看刪除writer.close();對您有什麼影響。

如果你不需要操縱數據包,我會推薦使用Wireshark。它可以很容易地將數據包捕獲爲TCPDump並添加捕獲過濾器。

+0

已嘗試刪除writer.close();.不防止崩潰。 有沒有其他方式將數據包存儲到TCPDump格式的文件中? –

+0

如果因爲某個特定的原因(操縱數據包)而不需要Java,我只會使用Wireshark或類似的東西。 –