我正在用 eclipse 在 java 中开发嗅探器。我可以嗅探 HTTP 数据包、TCP、UDP。但是如果请求在一秒钟内限制超过 10 个,我需要控制或“状态”。我知道 jnetpcap 我们无法阻止,我只想知道我有可能得到这个。谢谢你 。在我的代码下面
PcapPacketHandler <String> jpacketHandler = new PcapPacketHandler<String> ()
{
private final Http h = new Http();
private final Tcp t = new Tcp();
@Override
public void nextPacket(PcapPacket packet, String user) {
if(packet.hasHeader(h)){
final JCaptureHeader header = packet.getCaptureHeader();
System.out.printf("---------1111--------" + header.toString()+ "-------1111--------");
System.out.printf("packet caplen= %d wiredlen = %d \n ",
header.caplen(),header.wirelen());
System.out.println(packet.toString());
// System.out.printf("---------+++++++++--------" + packet.getHeader(h).toString() + "-------++++++--------");
//packet.getHeader(h).toString();
//Find if the given packet is a Request/Response Pkt : First get the TCP header
packet.getHeader(t);
}