diff options
author | Ivan Koveshnikov <ivan.koveshnikov@gcorelabs.com> | 2021-03-29 16:12:15 +0500 |
---|---|---|
committer | Tobias Klauser <tobias.klauser@gmail.com> | 2021-04-06 12:26:32 +0200 |
commit | 5a9ca6230ed00f5cb15401dbdb516734f8d17328 (patch) | |
tree | e626bf1e01714d0d469bed8094a9d936edc40249 | |
parent | 02d9fbd7397bd6c0ba30ee35edd48d085620aebf (diff) |
trafgen: allow to set packet rate in kpps and Mpps
Signed-off-by: Ivan Koveshnikov <ivan.koveshnikov@gcorelabs.com>
-rw-r--r-- | trafgen.8 | 2 | ||||
-rw-r--r-- | trafgen.c | 8 |
2 files changed, 8 insertions, 2 deletions
@@ -156,7 +156,7 @@ and TX_RING performance, Furthermore, the TX_RING interface does not cope with interpacket gaps. .TP .B -b <rate>, --rate <rate> -Specify the packet send rate <num>pps/B/kB/MB/GB/kbit/Mbit/Gbit/KiB/MiB/GiB units. +Specify the packet send rate <num>pps/kpps/Mpps/B/kB/MB/GB/kbit/Mbit/Gbit/KiB/MiB/GiB units. Like with the \fB-t\fP/\fB--gap\fP option, the packets are sent in slow mode. .TP .B -S <size>, --ring-size <size> @@ -197,7 +197,7 @@ static void __noreturn help(void) " -r|--rand Randomize packet selection (def: round robin)\n" " -P|--cpus <uint> Specify number of forks(<= CPUs) (def: #CPUs)\n" " -t|--gap <time> Set approx. interpacket gap (s/ms/us/ns, def: us)\n" - " -b|--rate <rate> Send traffic at specified rate (pps/B/kB/MB/GB/kbit/Mbit/Gbit/KiB/MiB/GiB)\n" + " -b|--rate <rate> Send traffic at specified rate (pps/kpps/Mpps/B/kB/MB/GB/kbit/Mbit/Gbit/KiB/MiB/GiB)\n" " -S|--ring-size <size> Manually set mmap size (KiB/MiB/GiB)\n" " -E|--seed <uint> Manually set srand(3) seed\n" " -u|--user <userid> Drop privileges and change to userid\n" @@ -1153,6 +1153,12 @@ int main(int argc, char **argv) if (strncmp(ptr, "pps", strlen("pps")) == 0) { shape_type = SHAPER_PKTS; + } else if (strncmp(ptr, "kpps", strlen("kpps")) == 0) { + shape_type = SHAPER_PKTS; + rate *= 1000; + } else if (strncmp(ptr, "Mpps", strlen("Mpps")) == 0) { + shape_type = SHAPER_PKTS; + rate *= 1000 * 1000; } else if (strncmp(ptr, "B", strlen("B")) == 0) { shape_type = SHAPER_BYTES; } else if (strncmp(ptr, "kB", strlen("kB")) == 0) { |