Index: tools/tools/netmap/pkt-gen.c =================================================================== --- tools/tools/netmap/pkt-gen.c +++ tools/tools/netmap/pkt-gen.c @@ -1816,6 +1816,7 @@ struct netmap_ring *rxring; int i; struct my_ctrs cur; + uint64_t n = targ->g->npackets / targ->g->nthreads; memset(&cur, 0, sizeof(cur)); @@ -1866,7 +1867,7 @@ int dump = targ->g->options & OPT_DUMP; nifp = targ->nmd->nifp; - while (!targ->cancel) { + while (!targ->cancel && (n == 0 || cur.pkts < n)) { /* Once we started to receive packets, wait at most 1 seconds before quitting. */ #ifdef BUSYWAIT