writePacket时的jpcap EXCEPTION_ACCESS_VIOLATION

时间:2011-11-09 18:48:02

标签: java jpcap packet-injection

我正在创建一个小实用程序,用于使用jpcap将各种数据有效负载写入pcap转储文件。对于每个有效负载,我创建一个数据包,如“通过网络接口发送数据包”示例中所述并发送它:

            byte[] data = new byte[messageLengthRead];
            long secs;  // initialized to a legit value based on other code

    TCPPacket p = new TCPPacket(12, 34, 56, 78, false, false, false, false,
            true, true, true, true, 10, 10);
    p.setIPv4Parameter(0, false, false, false, 0, false, false, false, 0,
            1010101, 100, IPPacket.IPPROTO_TCP, InetAddress
                    .getByName("www.microsoft.com"), InetAddress
                    .getByName("www.google.com"));
    p.data = data;
            p.len = data.length;
            p.sec = secs;
    EthernetPacket ether = new EthernetPacket();
    ether.frametype = EthernetPacket.ETHERTYPE_IP;
    ether.src_mac = new byte[] { (byte) 0, (byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5 };
    ether.dst_mac = new byte[] { (byte) 0, (byte) 6, (byte) 7, (byte) 8, (byte) 9, (byte) 10 };
    p.datalink = ether;
    writer.writePacket(p);

无论我尝试的数据有效负载如何,writePacket都会产生以下结果(null,“”,“”):

#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d7cfc0e, pid=6748, tid=4260
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_22-b03 mixed mode)
# Problematic frame:
# V  [jvm.dll+0x8fc0e]
#
# An error report file with more information is saved as hs_err_pid6748.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
# 

问题:

  1. 是否将新构造的数据包写入jpcap支持的转储?存在基于捕获的分组写入转储并通过网络接口发送新构造的分组的示例。
  2. 他们采取了哪些措施来解决错误。

1 个答案:

答案 0 :(得分:0)

相同的代码对我来说很好。 我也尝试过,没有错误出现。