On Sun, Jul 13, 2014 at 06:02:19PM +1200, Nikola Pajkovsky wrote:
Vitezslav Samel <vitezslav(a)samel.cz> writes:
> Vitezslav Samel (3):
> introduce packet capturing abstraction
> capt.c: add capturing using recvmmsg()
> capt.c: add capturing using mmap()ed PACKET_RX_RING memory
why do we using now recvmsg, recvmmsg and mmap? Which one is faster?
Please elaborate deeply, because you don't have useful commit message.
It's all about speed:
- in recvmsg() case there are 2 syscalls per packet (poll() and
then recvmsg() gives us one packet);
- in recvmmsg() case there are 2 syscalls (poll() and then recvmmsg() can
give us more packets if available);
- in mmaped case there is syscall only in case there's no packet (poll())
On my workloads going from recvmsg() to mmap-style receiver lowers
number of dropped packets 100x (from ten thousands to hundreds). And
this is still with one thread.
The packet capturing abstraction was chosen to have modular packet
receiving techniques: in our case recvmsg(), recvmmsg() and mmap.
recvmsg() is available (almost) always, recvmmsg() is available only
in linux-2.6.34+ and glibc-2.12+ and mmap-style receiver can be turned off
in the kernel. The capturing interface tries mmap-style first, then
tries recvmmsg() (if configured in) and recvmsg() is the slowest fallback.
Hope this helps.
Cheers,
Vita
> Makefile | 15 +++++
> src/capt-mmap-v2.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++
> src/capt-mmap-v2.h | 6 ++
> src/capt-recvmmsg.c | 138 ++++++++++++++++++++++++++++++++++++++++++++
> src/capt-recvmmsg.h | 6 ++
> src/capt-recvmsg.c | 89 ++++++++++++++++++++++++++++
> src/capt-recvmsg.h | 6 ++
> src/capt.c | 153 +++++++++++++++++++++++++++++++++++++++++++++++++
> src/capt.h | 31 ++++++++++
> src/capture-pkt.c | 18 +++---
> src/detstats.c | 27 ++++-----
> src/hostmon.c | 26 ++++-----
> src/ifstats.c | 21 ++++---
> src/iptraf-ng-compat.h | 1 +
> src/itrafmon.c | 23 +++-----
> src/packet.c | 92 +----------------------------
> src/packet.h | 13 +----
> src/pktsize.c | 25 ++++----
> src/serv.c | 26 ++++-----
> 19 files changed, 663 insertions(+), 200 deletions(-)
> create mode 100644 src/capt-mmap-v2.c
> create mode 100644 src/capt-mmap-v2.h
> create mode 100644 src/capt-recvmmsg.c
> create mode 100644 src/capt-recvmmsg.h
> create mode 100644 src/capt-recvmsg.c
> create mode 100644 src/capt-recvmsg.h
> create mode 100644 src/capt.c
> create mode 100644 src/capt.h
--
Nikola