Skip to content

Commit

Permalink
reset packet count every loop iteration - This closes appneta#75
Browse files Browse the repository at this point in the history
  • Loading branch information
fklassen committed Mar 22, 2014
1 parent 3523dfb commit 7937989
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$Id$

xx/xx/xxxx Version 4.0.4
- Number of packets inaccurate when using --netmap method (#76)
- Unexpected packet counts with --loop and --cachefile enabled (#75)
- Improved error messages when interface is a file (#74)
- Missing interfaces with --listnics option (#67)
- Compile issue with netmap v10 and debugging (#66)
Expand Down
17 changes: 9 additions & 8 deletions src/send_packets.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ send_packets(tcpreplay_t *ctx, pcap_t *pcap, int idx)
{
struct timeval print_delta, now;
tcpreplay_opt_t *options = ctx->options;
COUNTER packetnum = ctx->stats.pkts_sent;
COUNTER packetnum = 0;
int limit_send = options->limit_send;
struct pcap_pkthdr pkthdr;
u_char *pktdata = NULL;
Expand Down Expand Up @@ -488,10 +488,10 @@ send_packets(tcpreplay_t *ctx, pcap_t *pcap, int idx)
return;

/* stop sending based on the limit -L? */
packetnum++;
if (limit_send > 0 && packetnum > (COUNTER)limit_send)
if (limit_send > 0 && ctx->stats.pkts_sent > (COUNTER)limit_send)
break;

packetnum++;
#if defined TCPREPLAY || defined TCPREPLAY_EDIT
/* do we use the snaplen (caplen) or the "actual" packet len? */
pktlen = options->use_pkthdr_len ? pkthdr.len : pkthdr.caplen;
Expand Down Expand Up @@ -588,7 +588,7 @@ send_packets(tcpreplay_t *ctx, pcap_t *pcap, int idx)
*/
if (!do_not_timestamp && timercmp(&ctx->stats.last_time, &pkthdr.ts, <))
memcpy(&ctx->stats.last_time, &pkthdr.ts, sizeof(struct timeval));
ctx->stats.pkts_sent ++;
ctx->stats.pkts_sent++;
ctx->stats.bytes_sent += pktlen;

/* print stats during the run? */
Expand Down Expand Up @@ -626,7 +626,7 @@ send_dual_packets(tcpreplay_t *ctx, pcap_t *pcap1, int cache_file_idx1, pcap_t *
{
struct timeval print_delta, now;
tcpreplay_opt_t *options = ctx->options;
COUNTER packetnum = ctx->stats.pkts_sent;
COUNTER packetnum = 0;
int limit_send = options->limit_send;
int cache_file_idx;
pcap_t *pcap;
Expand Down Expand Up @@ -670,10 +670,11 @@ send_dual_packets(tcpreplay_t *ctx, pcap_t *pcap1, int cache_file_idx1, pcap_t *
return;

/* stop sending based on the limit -L? */
packetnum++;
if (limit_send > 0 && packetnum > (COUNTER)limit_send)
if (limit_send > 0 && ctx->stats.pkts_sent > (COUNTER)limit_send)
break;

packetnum++;

/* figure out which pcap file we need to process next
* when get_next_packet() returns null for pktdata, the pkthdr
* will still have the old values from the previous call. This
Expand Down Expand Up @@ -799,7 +800,7 @@ send_dual_packets(tcpreplay_t *ctx, pcap_t *pcap1, int cache_file_idx1, pcap_t *
if (!do_not_timestamp && timercmp(&ctx->stats.last_time, &pkthdr_ptr->ts, <))
memcpy(&ctx->stats.last_time, &pkthdr_ptr->ts, sizeof(struct timeval));

ctx->stats.pkts_sent ++;
ctx->stats.pkts_sent++;
ctx->stats.bytes_sent += pktlen;

/* print stats during the run? */
Expand Down

0 comments on commit 7937989

Please sign in to comment.