API

Slow Send Speed

I am able to send about 15kpps (thousand packets per second), and that uses up about 25 mb/s for what I am using it for. Changing the bandwidth has no effect on the pps unless I approach my 1gbps limit.

I am running JNetPcap 1.3.0 on Windows 8.1. My program only uses 5% of the CPU, leaves 12GB ram free, no noticeable disk I/O, and there is a 1gbps line.

The code I am using is very basic, taken from the example and ran in a loop. b in this case is a bytebuffer of a valid packet, and returns 0 each time.

int snaplen = 0;
int flags = Pcap.MODE_NON_BLOCKING;
int timeout = 0;
Pcap pcap = Pcap.openLive(device.getName(), snaplen, flags, timeout, errbuf);

for(int i=0; i<packetCount; i++) {
   pcap.sendPacket(b);
}

I have tried multi-threading, which had no effect on the pps. I noticed that the sendPacket method does return an integer after the packet has been sent, so the method itself might be blocking execution.

help with JFlowMap

hi in JFlowMap example the data return like this

Quote:

superFlowMap::total packet count=418
total flow count=18

flow[0] 10.1.1.101:3198 -> 10.1.1.1:80 Tcp fw/rev/tot pkts=[9/10/19],
flow[1] 10.1.1.101:3199 -> 10.1.1.1:80 Tcp fw/rev/tot pkts=[9/11/20],
flow[2] 209.225.11.237:80 -> 10.1.1.101:3179 Tcp fw/rev/tot pkts=[1/0/1],
flow[3] 10.1.1.101:3196 -> 10.1.1.1:80 Tcp fw/rev/tot pkts=[6/6/12],
flow[4] 10.1.1.101:3197 -> 10.1.1.1:80 Tcp fw/rev/tot pkts=[6/6/12],
flow[5] 10.1.1.101:3195 -> 10.1.1.1:80 Tcp fw/rev/tot pkts=[5/5/10],
flow[6] 209.225.0.6:80 -> 10.1.1.101:3183 Tcp fw/rev/tot pkts=[6/6/12],
flow[7] 10.1.1.101:3190 -> 10.1.1.1:80 Tcp fw/rev/tot pkts=[5/5/10],
flow[8] 209.225.0.6 -> 10.1.1.101:6 Ip4 tot pkts=[18],
flow[9] 10.1.1.101:3189 -> 10.1.1.1:80 Tcp fw/rev/tot pkts=[1/1/2],
flow[10] 10.1.1.101:3200 -> 10.1.1.1:80 Tcp fw/rev/tot pkts=[74/135/209],
flow[11] 10.1.1.101:3193 -> 209.225.0.6:80 Tcp fw/rev/tot pkts=[9/6/15],
flow[12] 10.1.1.101:3192 -> 209.225.0.6:80 Tcp fw/rev/tot pkts=[8/6/14],
flow[13] 10.1.1.101:3194 -> 209.225.0.6:80 Tcp fw/rev/tot pkts=[8/6/14],
flow[14] 209.225.0.6:80 -> 10.1.1.101:3185 Tcp fw/rev/tot pkts=[6/6/12],
flow[15] 209.225.0.6:80 -> 10.1.1.101:3184 Tcp fw/rev/tot pkts=[6/6/12],
flow[16] 209.225.0.6:80 -> 10.1.1.101:3187 Tcp fw/rev/tot pkts=[6/6/12],
flow[17] 10.1.1.101:3191 -> 209.225.0.6:80 Tcp fw/rev/tot pkts=[8/6/14],

i want understand what this part exactly mean fw/rev/tot pkts=[9/6/15]?

Converting a bytes[] to a pcap file

Hi,

I currently have java code that is reading DatagramPackets from a MulticastSocket

Code follows the below pattern -

MulticastSocket socket = new MulticastSocket(PORT);
socket.setSoTimeout(500);
socket.setInterface(InetAddress.getByName(INTERFACE));
socket.joinGroup(InetAddress.getByName(MULTICAST));

I then have a read() method which I continuously poll -

public void read() throws IOException {
byte[] buffer = new byte[65 * 1024];
DatagramPacket recv = new DatagramPacket(buffer, buffer.length);
try {
socket.receive(recv);
} catch (SocketTimeoutException ignore) {
return;
}

byte[] byteData = recv.getData();

}

I now want to load this byteData into a PcapPacket object to eventually write to a pcap file. I tried doing the following -

PcapPacket pcapPacket = new PcapPacket(byteData);

but I get an error -java.lang.IndexOutOfBoundsException: Invalid [200,1380930833,1380930633) range.

I'm completely new to Jnetpcap - so any guidance would be much appreciated.

How to read full pcap file

for creating loop in jnetpcap we use-

pcap.loop(10, jpacketHandler, "jNetPcap rocks!");

This will run loop for 10 times to read 10 packets from pcap file
I want to run this loop to read pcap file till EOF (end of file).
What modification do I need to make in the loop ?

First timer

Syndicate content