3

I am running iperf between a set of hosts that are read from a txt file, here's how I am running it:

h1,h2 = net.getNodeByName(node_id_1, node_id_2)

net.iperf((h1, h2))

It runs well and displays the results. But, I want to save the output of iperf result in a separate txt file. Does anyone know how I can apply it on the above code?

rink.attendant.6
  • 44,500
  • 61
  • 101
  • 156
Rakhee Tiwari
  • 31
  • 1
  • 1
  • 3

7 Answers7

2

Do you already try:

--output test.log

(in newer versions --logfile)

or using

youriperfexpr > test.log

kwarunek
  • 12,141
  • 4
  • 43
  • 48
Paolo
  • 17
  • 2
  • Hi Paolo, I tried it as net.iperf((h1, h2)) > test.log and I got an error: NameError: global name 'test' is not defined – Rakhee Tiwari Sep 10 '14 at 02:28
  • if you use this command, mininet try to run test.log as one of its CLI command. What I used to do is h1 In this case it didn't work and I don't know why. What works for me is 1. run xterm h1 and xterm h2 in the CLI 2. iperf -s in h2 3. iperf -c in h1 That's all! – user3771522 Sep 11 '14 at 10:52
  • Paolo - I am running iperf in mininet (on ubuntu virtual box) that is installed on my macbook. – Rakhee Tiwari Sep 11 '14 at 19:14
  • user3771522 - It totally make sense. But I do not want to use xterm because my mininet has 24 switches and I want to run iperf for many instances. Like I have a set of server/cleint in a txt file and when I run iperf: it reads the server/client form that txt file and displays the result. Which works fine but for analyzing the output, I would like to save it in a file somewhere. – Rakhee Tiwari Sep 11 '14 at 19:17
  • Maybe this link can help you. https://mailman.stanford.edu/pipermail/mininet-discuss/2011-August/000487.html – user3771522 Sep 15 '14 at 10:12
  • So I figured using these commands, I can save the result of iperf in a output file: h1.cmd('iperf -s > server_output.txt &') h2.cmd('iperf -t 5 -c ', h1.IP() + ' > client_output.txt &') But the problem is it overwrites the previous results. I have a set of server-client between which I run iperf and want to save the output in a file but the above command overwrites the previous ones and saves the iperf result of only the last server-clinet set. Any idea how to get that fixed in the above commands I am using? – Rakhee Tiwari Oct 15 '14 at 19:34
2

In order to store the results of iperf test in a file , add | tee followed by the filename.txt to your command line for example :

iperf -c ipaddress -u -t 10 -i 1 | tee result.txt

1

I had this problem as well. Although the manpage specifies "-o" or "--output" to save your output to a file, this does not actually work.

It seems that this was marked as "WontFix": https://code.google.com/p/iperf/issues/detail?id=24:

Looks like -o/--output existed in a previous version but in not in the current version. The consensus in yesterday's meeting was that if --output existed then we should fix it, otherwise people should just use shell redirection and we'll mark this WontFix. So, WontFix.

So maybe just use typescript or ">test.log" as suggested by Paolo

Community
  • 1
  • 1
K.S.
  • 2,846
  • 4
  • 24
  • 32
1

I think the answer is given by Chiara Contoli in here: iperf result in output file

In summary:

h1.cmd('iperf -s > server_output.txt &')
h2.cmd('iperf -t 5 -c ', h1.IP() + '  >  client_output.txt &')
Anamort
  • 341
  • 4
  • 17
0

Since you are running it on python, another method to save the result is to use popen:

popen( '<command> > <filename>', shell=True)

For example:

popen('iperf -s -u -i 1 > outtest.txt', shell=True)

You can check this for further information:

https://github.com/mininet/mininet/wiki/Introduction-to-Mininet#popen

tgudtk
  • 39
  • 5
0

If you need to save a file in the txt format. On the client machine run cmd(adm) and after that you need to write this:

cd c:\iperf3 iperf3.exe -c "you server address" -p "port" -P 10 -w 32000 -t 0 >> c:\iperf3\text.txt

(-t 0) - infinity On the client machine, you will see a black screen in cmd. It's normal. You will see all the process in the server machine. After your test, on the client machine in cmd need push ctrl+ c and after (y). Your file in directory c:\iperf3\text.txt after that collect all information about this period. If you push close in cmd this file text.txt will be empty.

Recommended open this file in NotePad or WordPad for the correct view.

0

Server iperf3 -s -p -B >> &

Client iperf3 -p -c <server_ip> -B <client_ip> -t 5 >>

Make sure you kill the iperf process on the server when done

Sanober Sayyed
  • 172
  • 1
  • 10