Line Rate Packet Generation and QDISC Bypass
To generate packets under linux and reach line rate bandwidth you where often forced to use the in-kernel packet generator, called pktgen. A patch from Daniel Borkmann and Jesper Dangaard Brouer added a new socket option to bypass the Linux internal QDISC to the driver directly and speed up things by bypassing a larger stack component.
This component makes less sense if used with a standard STREAM or DGRAM socket.
Rather a RAW (PF_PACKET
) socket is main user for this option, especially
bundled with an mmaped
memory area. The advantage over the pktgen generator
is that packets can be generated/modified in userspace.
int one = 1;
setsockopt(fd, SOL_PACKET, PACKET_QDISC_BYPASS, &one, sizeof(one));
Check out the d346a3fae3 the patch for more detail.