
-y C および -r 引数を指定した iperf を使用して双方向転送をテストし、CSV としてエクスポートします。
出力は得られますが、問題は列名がわからないことです。たとえば、3 行のデータが表示されますが、どれが送信に対応し、どれが受信に対応しているかわかりません。
他の列は推測できますが、確実に知りたいです。
このことが文書化されているところがどこにも見つかりません!
答え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 + ポートのペアの後に続く 1 つの奇妙なフィールドがスキップされます。
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;
しかし、コードをざっと grep してみると、非常に紛らわしいほどに、数値が増減していることが分かります。それが何を意味するかを示す定数は定義されていないようです。手動テスト ( iperf version 2.0.9 (9 Sept 2016) pthreads
) では、接続間で数値が再利用されていることが示されています。つまり、この話の教訓は、その数値を無視するか、iperf3 を使用することです。
答え3
日付と時刻、送信元 IP、送信元ポート、宛先 IP、宛先ポート、iperf プロセス番号、時間間隔、転送されたデータ量 (バイト)、帯域幅 (ビット/秒)、ジッター (ミリ秒)、失われたデータグラムの数、送信されたデータグラムの合計数、損失率、順序どおりに受信されなかったデータグラムの数
上記の情報は以下から入手しました:
答え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