iperf是计算吞吐量的著名工具。
当我在linuxpc上使用iperf尝试UDP吞吐量时,
据报道有10%的数据包丢失。
在UDP协议中,数据图没有收到任何确认。
但是,iperf以什么方式报告或计算包丢失?
IPERF工具如何知道传输的数据报是否收到。
我想知道这件事。

最佳答案

由于iperf用于两边,所以iperf确定在每个包之后接收什么。
基本上,
IPERF工具检查接收到的每个数据报中的序列号是否递增。如果序列号没有增加1,则会丢失数据报。如果我们接收到序列号小于前一序列号的数据报,则IPERF接收到无序数据包。
您可以参考iperf源代码以获得更好的理解。
https://github.com/esnet/iperf/blob/master/src/iperf_udp.c
来自IPERF源代码-

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);
}

关于network-programming - iperf如何报告udp中的数据包丢失,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51911474/

10-10 10:49