Skip to content

Commit

Permalink
Merge pull request #699 from appneta/Bug_#674_multiplier_lt_1_fails
Browse files Browse the repository at this point in the history
Bug #674 - Revert "send_packet: Avoid clock drift by using time since first packet"
  • Loading branch information
fklassen authored Jan 28, 2022
2 parents 22cecbb + b53d916 commit 266966f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 27 deletions.
3 changes: 2 additions & 1 deletion docs/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
- add a security policy document (#689)
- ability to specify directory of pcap files (#682)
- incorrect PPS rate for long-running sessions (#679)
- revert #630 to fix --multiplier issues (#674)
- option --skipbroadcast not working (#677)
- latest macOS SDK selected by default (#668)
- add feature VLAN Q-in-Q (#625)

06/19/2021 Version 4.3.5-beta1
06/19/2021 Version 4.3.5-beta1f
- gcc 9.3 compiler warnings (#670)
- installed netmap not automatically detected (#669)
- heap-buffer-overflow with flow_decode() (#665)
Expand Down
2 changes: 0 additions & 2 deletions src/common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ typedef struct {
struct timeval end_time;
struct timeval pkt_ts_delta;
struct timeval last_print;
struct timeval first_packet_sent_wall_time;
struct timeval first_packet_pcap_timestamp;
COUNTER flow_non_flow_packets;
COUNTER flows;
COUNTER flows_unique;
Expand Down
36 changes: 12 additions & 24 deletions src/send_packets.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ send_packets(tcpreplay_t *ctx, pcap_t *pcap, int idx)

ctx->skip_packets = 0;
timerclear(&last_pkt_ts);
timerclear(&stats->first_packet_sent_wall_time);
if (options->limit_time > 0)
end_us = TIMEVAL_TO_MICROSEC(&stats->start_time) +
SEC_TO_MICROSEC(options->limit_time);
Expand Down Expand Up @@ -436,23 +435,18 @@ send_packets(tcpreplay_t *ctx, pcap_t *pcap, int idx)
ctx->skip_packets = 0;

if (options->speed.mode == speed_multiplier) {
if(!timerisset(&stats->first_packet_sent_wall_time)) {
/* We're sending the first packet, so we have an absolute time reference. */
TIMEVAL_SET(&stats->first_packet_sent_wall_time, &now);
TIMEVAL_SET(&stats->first_packet_pcap_timestamp, &pkthdr.ts);
}

if (!timerisset(&last_pkt_ts)) {
TIMEVAL_SET(&last_pkt_ts, &pkthdr.ts);
} else if (timercmp(&pkthdr.ts, &last_pkt_ts, >)) {
/* pkt_ts_delta is the packet time stamp difference since the first packet */
timersub(&pkthdr.ts, &stats->first_packet_pcap_timestamp, &stats->pkt_ts_delta);

/* time_delta is the wall time difference since sending the first packet */
timersub(&now, &stats->first_packet_sent_wall_time, &stats->time_delta);
struct timeval delta;

timersub(&pkthdr.ts, &last_pkt_ts, &delta);
timeradd(&stats->pkt_ts_delta, &delta, &stats->pkt_ts_delta);
TIMEVAL_SET(&last_pkt_ts, &pkthdr.ts);
}

if (!timerisset(&stats->time_delta))
TIMEVAL_SET(&stats->pkt_ts_delta, &stats->pkt_ts_delta);
}

if (!top_speed) {
Expand Down Expand Up @@ -602,7 +596,6 @@ send_dual_packets(tcpreplay_t *ctx, pcap_t *pcap1, int cache_file_idx1, pcap_t *

ctx->skip_packets = 0;
timerclear(&last_pkt_ts);
timerclear(&stats->first_packet_sent_wall_time);
if (options->limit_time > 0)
end_us = TIMEVAL_TO_MICROSEC(&stats->start_time) +
SEC_TO_MICROSEC(options->limit_time);
Expand Down Expand Up @@ -718,23 +711,18 @@ send_dual_packets(tcpreplay_t *ctx, pcap_t *pcap1, int cache_file_idx1, pcap_t *
ctx->skip_packets = 0;

if (options->speed.mode == speed_multiplier) {
if(!timerisset(&stats->first_packet_sent_wall_time)) {
/* We're sending the first packet, so we have an absolute time reference. */
TIMEVAL_SET(&stats->first_packet_sent_wall_time, &now);
TIMEVAL_SET(&stats->first_packet_pcap_timestamp, &pkthdr_ptr->ts);
}

if (!timerisset(&last_pkt_ts)) {
TIMEVAL_SET(&last_pkt_ts, &pkthdr_ptr->ts);
} else if (timercmp(&pkthdr_ptr->ts, &last_pkt_ts, >)) {
/* pkt_ts_delta is the packet time stamp difference since the first packet */
timersub(&pkthdr_ptr->ts, &stats->first_packet_pcap_timestamp, &stats->pkt_ts_delta);

/* time_delta is the wall time difference since sending the first packet */
timersub(&now, &stats->first_packet_sent_wall_time, &stats->time_delta);
struct timeval delta;

timersub(&pkthdr_ptr->ts, &last_pkt_ts, &delta);
timeradd(&stats->pkt_ts_delta, &delta, &stats->pkt_ts_delta);
TIMEVAL_SET(&last_pkt_ts, &pkthdr_ptr->ts);
}

if (!timerisset(&stats->time_delta))
TIMEVAL_SET(&stats->pkt_ts_delta, &stats->pkt_ts_delta);
}

if (!top_speed) {
Expand Down

0 comments on commit 266966f

Please sign in to comment.