Skip to content

Commit

Permalink
Improved iperf_udp_recv() debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
davidBar-On committed Nov 5, 2024
1 parent 0586e1c commit da42eba
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/iperf_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ iperf_udp_recv(struct iperf_stream *sp)
int first_packet = 0;
double transit = 0, d = 0;
struct iperf_time sent_time, arrival_time, temp_time;
struct iperf_test *test = sp->test;

r = Nread_no_select(sp->socket, sp->buffer, size, Pudp);

Expand All @@ -73,7 +74,7 @@ iperf_udp_recv(struct iperf_stream *sp)
return r;

/* Only count bytes received while we're in the correct state. */
if (sp->test->state == TEST_RUNNING) {
if (test->state == TEST_RUNNING) {

/*
* For jitter computation below, it's important to know if this
Expand All @@ -87,7 +88,7 @@ iperf_udp_recv(struct iperf_stream *sp)
sp->result->bytes_received_this_interval += r;

/* Dig the various counters out of the incoming UDP packet */
if (sp->test->udp_counters_64bit) {
if (test->udp_counters_64bit) {
memcpy(&sec, sp->buffer, sizeof(sec));
memcpy(&usec, sp->buffer+4, sizeof(usec));
memcpy(&pcount, sp->buffer+8, sizeof(pcount));
Expand All @@ -109,7 +110,7 @@ iperf_udp_recv(struct iperf_stream *sp)
sent_time.usecs = usec;
}

if (sp->test->debug_level >= DEBUG_LEVEL_DEBUG)
if (test->debug_level >= DEBUG_LEVEL_DEBUG)
fprintf(stderr, "pcount %" PRIu64 " packet_count %" PRIu64 "\n", pcount, sp->packet_count);

/*
Expand All @@ -131,6 +132,8 @@ iperf_udp_recv(struct iperf_stream *sp)
if (pcount > sp->packet_count + 1) {
/* There's a gap so count that as a loss. */
sp->cnt_error += (pcount - 1) - sp->packet_count;
if (test->debug_level >= DEBUG_LEVEL_INFO)
fprintf(stderr, "LOST %" PRIu64 " PACKETS - received packet %" PRIu64 " but expected sequence %" PRIu64 " on stream %d\n", (pcount - sp->packet_count + 1), pcount, sp->packet_count + 1, sp->socket);
}
/* Update the highest sequence number seen so far. */
sp->packet_count = pcount;
Expand All @@ -152,8 +155,8 @@ iperf_udp_recv(struct iperf_stream *sp)
sp->cnt_error--;

/* Log the out-of-order packet */
if (sp->test->debug)
fprintf(stderr, "OUT OF ORDER - incoming packet sequence %" PRIu64 " but expected sequence %" PRIu64 " on stream %d", pcount, sp->packet_count + 1, sp->socket);
if (test->debug_level >= DEBUG_LEVEL_INFO)
fprintf(stderr, "OUT OF ORDER - received packet %" PRIu64 " but expected sequence %" PRIu64 " on stream %d\n", pcount, sp->packet_count + 1, sp->socket);
}

/*
Expand Down Expand Up @@ -183,7 +186,7 @@ iperf_udp_recv(struct iperf_stream *sp)
sp->jitter += (d - sp->jitter) / 16.0;
}
else {
if (sp->test->debug)
if (test->debug_level >= DEBUG_LEVEL_INFO)
printf("Late receive, state = %d\n", sp->test->state);
}

Expand Down

0 comments on commit da42eba

Please sign in to comment.