1

Iperf is the well known tool to calculate throughput. When i tried udp throughput using iperf on my linuxpc, It reported that 10% of packet loss.

In UDP protocol, data gram did not receice any acknowledgements. But, in what way iperf is reporting or calculating packet loss ? How would iperf tool know whether transmitted datagram received or not. I wonder about this.

sawdust
  • 16,103
  • 3
  • 40
  • 50
Vijay Kalyanam
  • 327
  • 1
  • 3
  • 15
  • Interesting question. I'd guess there maybe is some meta-connection on another port that is used to communicate how many packets were sent and received. Maybe this question is better suited at https://serverfault.com – Tobias K. Aug 18 '18 at 20:01
  • 1
    Iperf can simply include a packet sequence number in each datagram. Then packet loss as well as out-of-order reception can be detected. – sawdust Aug 18 '18 at 22:38

1 Answers1

1

As iperf is used on both the sides, iperf is sure what to recieve after each packet.

Basically, Iperf tool checks the sequence number is incrementing in each datagram it is received. If the sequence number is not incrementing by 1 , there is a loss of datagram. If we receive a datagram with sequence number lesser than previous sequence , then iperf received an out of order packet.
You can refer the iperf source code for better understanding. https://github.com/esnet/iperf/blob/master/src/iperf_udp.c

From iperf source code-

if (pcount >= sp->packet_count + 1) {

    /* Forward, but is there a gap in sequence numbers? */
    if (pcount > sp->packet_count + 1) {
    /* There's a gap so count that as a loss. */
    sp->cnt_error += (pcount - 1) - sp->packet_count;
    }
    /* Update the highest sequence number seen so far. */
    sp->packet_count = pcount;
} else {

    /* 
     * Sequence number went backward (or was stationary?!?).
     * This counts as an out-of-order packet.
     */
    sp->outoforder_packets++;

    /*
     * If we have lost packets, then the fact that we are now
     * seeing an out-of-order packet offsets a prior sequence
     * number gap that was counted as a loss.  So we can take
     * away a loss.
     */
    if (sp->cnt_error > 0)
    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 %d on stream %d", pcount, sp->packet_count, sp->socket);
}
Rilwan
  • 2,251
  • 2
  • 19
  • 28