MCPcopy Create free account
hub / github.com/esnet/iperf / iperf_stats_callback

Function iperf_stats_callback

src/iperf_api.c:3704–3827  ·  view source on GitHub ↗

* Gather statistics during a test. * This function works for both the client and server side. */

Source from the content-addressed store, hash-verified

3702 * This function works for both the client and server side.
3703 */
3704void
3705iperf_stats_callback(struct iperf_test *test)
3706{
3707 struct iperf_stream *sp;
3708 struct iperf_stream_result *rp = NULL;
3709 struct iperf_interval_results *irp, temp;
3710 struct iperf_time temp_time;
3711 iperf_size_t total_interval_bytes_transferred = 0;
3712#if defined(HAVE_SCTP_H)
3713 struct iperf_sctp_info sctp_info;
3714#endif /* HAVE_SCTP_H */
3715
3716 temp.omitted = test->omitting;
3717 temp.rtt = 0;
3718 temp.rttvar = 0;
3719 temp.pmtu = 0;
3720 SLIST_FOREACH(sp, &test->streams, streams) {
3721 rp = sp->result;
3722 temp.bytes_transferred = sp->sender ? rp->bytes_sent_this_interval : rp->bytes_received_this_interval;
3723
3724 // Total bytes transferred this interval
3725 total_interval_bytes_transferred += rp->bytes_sent_this_interval + rp->bytes_received_this_interval;
3726
3727 irp = TAILQ_LAST(&rp->interval_results, irlisthead);
3728 /* result->end_time contains timestamp of previous interval */
3729 if ( irp != NULL ) /* not the 1st interval */
3730 memcpy(&temp.interval_start_time, &rp->end_time, sizeof(struct iperf_time));
3731 else /* or use timestamp from beginning */
3732 memcpy(&temp.interval_start_time, &rp->start_time, sizeof(struct iperf_time));
3733 /* now save time of end of this interval */
3734 iperf_time_now(&rp->end_time);
3735 memcpy(&temp.interval_end_time, &rp->end_time, sizeof(struct iperf_time));
3736 iperf_time_diff(&temp.interval_start_time, &temp.interval_end_time, &temp_time);
3737 temp.interval_duration = iperf_time_in_secs(&temp_time);
3738 if (test->protocol->id == Ptcp) {
3739 if ( has_tcpinfo()) {
3740 save_tcpinfo(sp, &temp);
3741 if (test->sender_has_retransmits == 1) {
3742 long total_retrans = get_total_retransmits(&temp);
3743 temp.interval_retrans = total_retrans - rp->stream_prev_total_retrans;
3744 rp->stream_retrans += temp.interval_retrans;
3745 rp->stream_prev_total_retrans = total_retrans;
3746
3747 temp.snd_cwnd = get_snd_cwnd(&temp);
3748 if (temp.snd_cwnd > rp->stream_max_snd_cwnd) {
3749 rp->stream_max_snd_cwnd = temp.snd_cwnd;
3750 }
3751
3752 temp.snd_wnd = get_snd_wnd(&temp);
3753 if (temp.snd_wnd > rp->stream_max_snd_wnd) {
3754 rp->stream_max_snd_wnd = temp.snd_wnd;
3755 }
3756
3757 temp.rtt = get_rtt(&temp);
3758 if (temp.rtt > rp->stream_max_rtt) {
3759 rp->stream_max_rtt = temp.rtt;
3760 }
3761 if (rp->stream_min_rtt == 0 ||

Callers

nothing calls this directly

Calls 15

iperf_time_nowFunction · 0.85
iperf_time_diffFunction · 0.85
iperf_time_in_secsFunction · 0.85
has_tcpinfoFunction · 0.85
save_tcpinfoFunction · 0.85
get_total_retransmitsFunction · 0.85
get_snd_cwndFunction · 0.85
get_snd_wndFunction · 0.85
get_rttFunction · 0.85
get_rttvarFunction · 0.85
get_pmtuFunction · 0.85
get_reorderFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…