Iperf CSV 输出格式

Iperf CSV 输出格式

如果我使用带有 -y C 和 -r 参数的 iperf 来测试双向传输并将其导出为 CSV。

我得到了一些输出,但问题是我不知道列名是什么。例如,它显示了三行数据,但我不知道哪一行对应于发送,哪一行对应于接收。

其他列我可以猜,但我宁愿确定。

我在任何地方都找不到这个记录!

答案1

这些字段是

时间戳、源地址、源端口、目标地址、目标端口、间隔、传输字节数、每秒位数

我通过观察得出了这一结论

$ iperf -c localhost -r
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
------------------------------------------------------------
Client connecting to localhost, TCP port 5001
TCP window size:  648 KByte (default)
------------------------------------------------------------
[  5] local 127.0.0.1 port 54401 connected with 127.0.0.1 port 5001
[  4] local 127.0.0.1 port 5001 connected with 127.0.0.1 port 54401
[ ID] Interval       Transfer     Bandwidth
[  5]  0.0-10.0 sec  50.3 GBytes  43.2 Gbits/sec
[  4]  0.0-10.0 sec  50.3 GBytes  43.2 Gbits/sec

$ iperf -c localhost -r -y C
20140114124826,127.0.0.1,54402,127.0.0.1,5001,5,0.0-10.0,52551090176,42041052917
20140114124826,127.0.0.1,5001,127.0.0.1,54402,4,0.0-10.0,52551090200,41999020136

编辑:您可以找到相关的源代码这里

// TCP Reporting
printf( reportCSV_bw_format,
timestamp,
(stats->reserved_delay == NULL ? ",,," : stats->reserved_delay),
stats->transferID,
stats->startTime,
stats->endTime,
stats->TotalLen,
speed);
} else {
// UDP Reporting
printf( reportCSV_bw_jitter_loss_format,
timestamp,
(stats->reserved_delay == NULL ? ",,," : stats->reserved_delay),
stats->transferID,
stats->startTime,
stats->endTime,
stats->TotalLen,
speed,
stats->jitter*1000.0,
stats->cntError,
stats->cntDatagrams,
(100.0 * stats->cntError) / stats->cntDatagrams, stats->cntOutofOrder );
} 

答案2

接受的答案跳过一个奇数字段:位于源和目标 IP + 端口对之后的字段:

timestamp,
source_address,
source_port,
destination_address,
destination_port,
XXX,                  <---- this one
interval,
transferred_bytes,
bits_per_second

接受答案中的代码表明这来自transferID变量。这里的其他一些答案似乎认为它代表连接标识符或连接方向。但是,快速浏览代码表明这transferID来自名为的全局变量groupID。它是已初始化归零:

// Global ID that we increment to be used 
// as identifier for SUM reports
int groupID = 0;

但是,快速浏览一下代码似乎表明它增加和减少了很多,非常令人困惑。似乎没有任何定义的常量可以说明它的含义。手动测试(iperf version 2.0.9 (9 Sept 2016) pthreads)显示该数字在连接之间被重复使用。所以我想这个故事的寓意是...忽略那个数字?或者使用 iperf3。

答案3

日期和时间、源 IP、源端口、目标 IP、目标端口、iperf 进程号、时间间隔、传输的数据量(字节)、带宽(比特/秒)、抖动(毫秒)、丢失的数据报数量、发送的数据报总数、丢失百分比、无序接收的数据报数量

上述信息是我从以下渠道获得:

http://www.jb.man.ac.uk/~jcullen/code/python/iperf_tests.py

答案4

这是一个使用 CSV 值并循环运行检查是否满足给定 bps 的简单演示。

我还发现上面的答案中有一个额外的字段,其值为 3/4/5。4 和 5 似乎是方向。3 我不确定它是什么意思。无论如何,如果这有帮助的话:

#!/usr/bin/python

import sys
import subprocess
from subprocess import Popen

def runProcess(exe):
    p = subprocess.Popen(exe, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
    while(True):
      retcode = p.poll() #returns None while subprocess is running
      line = p.stdout.readline()
      yield line
      if(retcode is not None):
        break

#
# do an iperf to a peer and check the bps calculated is at least
# what we asked for
#
def peer_run_until_target_bps_not_met (peer, sample_period, target_bps):

    debug = 0
    target_kbps = target_bps / 1024.0
    target_mbps = target_bps / (1024.0 * 1024.0)
    cmd = "iperf -c %s -t %d -i %d -y C" % (peer, sample_period, sample_period)

    while (True):
        bps=0
        for line in runProcess(cmd.split()):
            if line == "":
                break

            if (debug):
                print "timestamp           %s" % line.split(',')[0]
                print "source_address      %s" % line.split(',')[1]
                print "source_port         %s" % line.split(',')[2]
                print "destination_address %s" % line.split(',')[3]
                print "destination_port    %s" % line.split(',')[4]

                #
                # "3" ???
                # "5" indicates client -> server connection,
                # "4" indicates "server -> client"
                #
                print "direction           %s" % line.split(',')[5]

                print "interval            %s" % line.split(',')[6]
                print "transferred_bytes   %s" % line.split(',')[7]
                print "bits_per_second     %s" % line.split(',')[8]

            transferred_bytes = float(line.split(',')[7])
            bps = (transferred_bytes * 8) / float(sample_period)

        kbps = bps / 1024.0
        mbps = bps / (1024.0 * 1024.0)
        print "OK: %12.2f bps / %10.2f Kbps / %10.2f Mbps (target %-10.2f Mbps)" % (bps, kbps, mbps, target_mbps)

        if (bps < target_bps):
            print "FAILED: need %.2f bps / %.2fKbps / %.2f Mbps" % \
        (target_bps, target_kbps, target_mbps)
            return

peer_run_until_target_bps_not_met("10.2.0.0", 5, 0.2 * 1024 * 1024) # 10 Mbps

相关内容