@@ -98,6 +98,9 @@ tcpreplay_init()
9898 /* set the default MTU size */
9999 ctx -> options -> mtu = DEFAULT_MTU ;
100100
101+ /* disable periodic statistics */
102+ ctx -> options -> stats = -1 ;
103+
101104 /* disable limit send */
102105 ctx -> options -> limit_send = -1 ;
103106
@@ -1149,7 +1152,7 @@ tcpreplay_prepare(tcpreplay_t *ctx)
11491152int
11501153tcpreplay_replay (tcpreplay_t * ctx )
11511154{
1152- int rcode ;
1155+ int rcode , loop , total_loops ;
11531156
11541157 assert (ctx );
11551158
@@ -1172,21 +1175,36 @@ tcpreplay_replay(tcpreplay_t *ctx)
11721175 return -1 ;
11731176 }
11741177
1175-
11761178 ctx -> running = true;
1179+ total_loops = ctx -> options -> loop ;
1180+ loop = 0 ;
11771181
11781182 /* main loop, when not looping forever (or until abort) */
11791183 if (ctx -> options -> loop > 0 ) {
11801184 while (ctx -> options -> loop -- && !ctx -> abort ) { /* limited loop */
1185+ if (ctx -> options -> stats == 0 )
1186+ printf ("Loop %d of %d...\n" , ++ loop , total_loops );
11811187 if ((rcode = tcpr_replay_index (ctx )) < 0 )
11821188 return rcode ;
1183- if (ctx -> options -> loop > 0 && !ctx -> abort && ctx -> options -> loopdelay_ms > 0 )
1184- usleep (ctx -> options -> loopdelay_ms * 1000 );
1189+ if (ctx -> options -> loop > 0 ) {
1190+ if (!ctx -> abort && ctx -> options -> loopdelay_ms > 0 ) {
1191+ usleep (ctx -> options -> loopdelay_ms * 1000 );
1192+ gettimeofday (& ctx -> stats .end_time , NULL );
1193+ }
1194+
1195+ if (ctx -> options -> stats == 0 )
1196+ packet_stats (& ctx -> stats );
1197+ }
11851198 }
11861199 } else {
11871200 while (!ctx -> abort ) { /* loop forever unless user aborts */
1201+ if (ctx -> options -> stats == 0 )
1202+ printf ("Loop %d...\n" , ++ loop );
11881203 if ((rcode = tcpr_replay_index (ctx )) < 0 )
11891204 return rcode ;
1205+
1206+ if (ctx -> options -> stats == 0 && !ctx -> abort )
1207+ packet_stats (& ctx -> stats );
11901208 }
11911209 }
11921210
0 commit comments