trafgen: Pre-calculate checksums if possible
commitb5d757ae6de3b28f326644c63f7e2b9df4109764
authorTobias Klauser <tklauser@distanz.ch>
Mon, 2 Nov 2015 15:33:54 +0000 (2 16:33 +0100)
committerTobias Klauser <tklauser@distanz.ch>
Mon, 2 Nov 2015 15:33:54 +0000 (2 16:33 +0100)
tree82db80b1e06ae1a25784d39b107bfcbea677e442
parentdddf36f0b747dde13fe6af4d368c927c8d1c76c9
trafgen: Pre-calculate checksums if possible

The TCP/UDP checksums cannot be calculated in the parser as the packet
payload following the TCP/UDP header is not yet know. However, we can
calculate these checksums before the send loop if the only dynamic
elements of the packet are checksums.

This change avoids the overhead of recalculating the checksums for every
iteration the send loop in these cases.

Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
trafgen.c