1

I'm looking for a efficient way to capture packets in Java. Java's native network interface seems to be very slow compared to the C's native socket API (Java seems to capture only 1k pps while C's socket API can capture about 11k pps without any difficulty). Is there any alternative and fast way to capture packets (more specifically UDP packets) for Java? I've seen some pcap wrappers for java, but I've no idea about their performance.

systemsfault
  • 15,207
  • 12
  • 59
  • 66
  • 1
    Did you look at the NIO stuff? Apache Mina has low-level stuff that could be used. With direct buffers it should be possible to reach speeds close to the native OS operations. – vasquez Feb 11 '12 at 09:20
  • No I've not look at the NIO stuff. I'll check it out. Thanks for that. – systemsfault Feb 14 '12 at 03:46

1 Answers1

1

Show us some code. Java's 'Java's native network interface' is 'the C's native socket API'.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • Ok EJP, as soon as I've time I'll put the benchmark code. Basically I'm capturing the Cisco's Netflow v9 UDP flows. – systemsfault Feb 14 '12 at 03:46