diff --git a/.gitignore b/.gitignore index 1cb4c860..ded2050b 100644 --- a/.gitignore +++ b/.gitignore @@ -95,4 +95,5 @@ test/*1 COPYING .vscode/ .idea/ -build/ +build*/ +.run/ diff --git a/docs/CHANGELOG b/docs/CHANGELOG index bb49a45c..80507066 100644 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,7 @@ - remove invalid assert in tree (#756) - program exit after send error (#751) - make libpcap version test more robust (#750) + - looping inflates some packet counters (#749) 08/28/2022 Version 4.4.2 - remove autogen.sh from distribution tarballs (#745) diff --git a/src/tcpreplay.c b/src/tcpreplay.c index ef31ca7a..144594b8 100644 --- a/src/tcpreplay.c +++ b/src/tcpreplay.c @@ -227,8 +227,8 @@ static void flow_stats(const tcpreplay_t *ctx) COUNTER flows_total = stats->flows; COUNTER flows_unique = stats->flows_unique; COUNTER flows_expired = stats->flows_expired; - COUNTER flow_packets; - COUNTER flow_non_flow_packets; + COUNTER flow_packets = stats->flow_packets; + COUNTER flow_non_flow_packets = stats->flow_non_flow_packets; COUNTER flows_sec = 0; u_int32_t flows_sec_100ths = 0; @@ -239,28 +239,32 @@ static void flow_stats(const tcpreplay_t *ctx) return; /* - * When packets are read into cache, flows + * When packets are read into cache, flows * are only counted in first iteration * If flows are unique from one loop iteration * to the next then multiply by the number of * successful iterations. */ - if (options->preload_pcap) { - if (ctx->options->unique_ip) { - flows_total *= ctx->last_unique_iteration; - flows_unique *= ctx->last_unique_iteration; - flows_expired *= ctx->last_unique_iteration; -#ifdef TCPREPLAY_EDIT - } else if (tcpedit->seed) { - flows_total *= ctx->iteration; - flows_unique *= ctx->iteration; - flows_expired *= ctx->iteration; -#endif - } + if (options->preload_pcap && ctx->last_unique_iteration) { + flows_total *= ctx->last_unique_iteration; + flows_unique *= ctx->last_unique_iteration; + flows_expired *= ctx->last_unique_iteration; + flow_packets *= ctx->last_unique_iteration; + flow_non_flow_packets *= ctx->last_unique_iteration; + } else { + /* adjust for --unique-ip-loops */ + flow_packets = (flow_packets * (ctx->last_unique_iteration ?: ctx->iteration)) / + ctx->iteration; } - flow_packets = stats->flow_packets * ctx->iteration; - flow_non_flow_packets = stats->flow_non_flow_packets * ctx->iteration; +#ifdef TCPREPLAY_EDIT + if (tcpedit->seed) { + flow_non_flow_packets *= ctx->iteration; + flows_total *= ctx->iteration; + flows_unique *= ctx->iteration; + flows_expired *= ctx->iteration; + } +#endif if (diff_us) { COUNTER flows_sec_X100; @@ -271,11 +275,11 @@ static void flow_stats(const tcpreplay_t *ctx) } if (ctx->options->flow_expiry) - printf("Flows: " COUNTER_SPEC " flows, " COUNTER_SPEC " unique, "COUNTER_SPEC " expired, %llu.%02u fps, " COUNTER_SPEC " flow packets, " COUNTER_SPEC " non-flow\n", + printf("Flows: " COUNTER_SPEC " flows, " COUNTER_SPEC " unique, "COUNTER_SPEC " expired, %llu.%02u fps, " COUNTER_SPEC " unique flow packets, " COUNTER_SPEC " unique non-flow packets\n", flows_total, flows_unique, flows_expired, flows_sec, flows_sec_100ths, flow_packets, flow_non_flow_packets); else - printf("Flows: " COUNTER_SPEC " flows, %llu.%02u fps, " COUNTER_SPEC " flow packets, " COUNTER_SPEC " non-flow\n", + printf("Flows: " COUNTER_SPEC " flows, %llu.%02u fps, " COUNTER_SPEC " unique flow packets, " COUNTER_SPEC " unique non-flow packets\n", flows_total, flows_sec, flows_sec_100ths, flow_packets, flow_non_flow_packets); }