【问题标题】:How can iperf reporting packet loss in udpiperf如何在udp中报丢包
【发布时间】:2018-08-18 18:24:51
【问题描述】:

Iperf 是众所周知的吞吐量计算工具。 当我在我的 linuxpc 上使用 iperf 尝试 udp 吞吐量时, 它报告了 10% 的数据包丢失。

在 UDP 协议中,数据报没有收到任何确认。 但是,iperf 以什么方式报告或计算数据包丢失? iperf 工具如何知道是否接收到传输的数据报。 我想知道这个。

【问题讨论】:

  • 有趣的问题。我猜想在另一个端口上可能有一些元连接,用于传达发送和接收的数据包数量。也许这个问题更适合serverfault.com
  • Iperf 可以简单地在每个数据报中包含一个数据包序列号。然后可以检测到丢包和乱序接收。

标签: network-programming tcp-ip udpclient iperf


【解决方案1】:

由于两边都使用了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);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-21
    • 2018-03-18
    相关资源
    最近更新 更多