trafgen#

Installation#

sudo apt install netsniff-ng

Usage#

# Run cpp configs
sudo trafgen --dev <DEVICE> --conf ./test.cfg --cpp --num 10 -J

Configuration Examples#

#include <stddef.h>

{
        /* --- Ethernet Header --- */
        /* Destination MAC */
        0xb8, 0xe9, 0x24, 0xee, 0xa7, 0x0a,
        /* Source MAC */
        0xb8, 0xe9, 0x24, 0xee, 0xa7, 0x0b,
        /* Protocol (IPv4) */
        c16(ETH_P_IP),

        /* --- IPv4 Header --- */
        /* Version, IHL, TOS */
        0b01000101, 0,

        /* Total Len */
        c16(28 + 16 + 1024),

        /* Ident */
        drnd(2),

        /* Flags, Frag Off */
        0b01000000, 0,

        /* TTL */
        64,

        /* Proto UDP */
        0x11,

        /* Checksum (IP header from, to) */
        csumip(14, 33),

        /* Source IP */
        192, 168, 42, 10,

        /* Dest IP */
        192, 168, 42, 11,

        /* --- UDP Header --- */
        /* Source Port */
        c16(9000),

        /* Dest Port */
        c16(9100),

        /* Length */
        c16(8 + 16 + 1024),

        /* Checksum */
        c16(0),

        /* --- Payload --- */
        "hello-caden-gate",
        fill(0xaa, 1024)
}