如何使用jnetpcap将捕获的数据包转发到另一个网络设备?

时间:2013-09-22 10:46:32

标签: java networking packet-sniffers jnetpcap packet-injection

我想发送从网络设备1嗅探的捕获数据包,并将其注入网络设备2而不更改其内容(将充当线路)

到目前为止,我已经尝试了

 byte[] buf = new byte[packet.getTotalSize()];

   System.out.println(packet); // packet is the captured/sniffed packet
   System.out.println(packet.transferStateAndDataTo(buf));//packet contents to buffer

   ByteBuffer b = ByteBuffer.wrap(buf);   

   Injector injector = new Injector(b); //Injector contains the pcap.sendPacket(b) method

   injector.run(); 

0 个答案:

没有答案