forked from mlainani/perf_test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiperf3.py
More file actions
executable file
·106 lines (85 loc) · 3.54 KB
/
iperf3.py
File metadata and controls
executable file
·106 lines (85 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env python
import pexpect, time
import re
# Serial ports for devices under test
dut_ports = ['/dev/ttyUSB1', '/dev/ttyUSB2']
# Serial port for server (RPi)
server_port = '/dev/ttyUSB0'
# modulations = {'FSK150': 8, 'OFDM600': 46}
modulations = {'OFDM600': 46}
# IPERF Settings
client_ip_addr = 'bbbb::1' # CLient IP Addr
duration = '5'
report_interval = '1'
# Client side bandwidth in Kbits/sec
bandwidths = [10, 15, 20, 25, 30, 35, 40, 50, 65, 70, 75, 100, 120, 125, 130, 150, 275, 295, 300, 310, 325, 350, 400]
for item in list(modulations.items()):
# print(item[0])
# print(item[1])
# cmd = 'pib -sn .rf_mac.static_config.pkt_mgr.forceTxModulation -v ' + str(item[1])
# print(cmd)
for port in dut_ports:
# Connect to the Device Under Test and set RF modulation
# cmd = 'screen ' + port + ' 115200'
# print(cmd)
dut = pexpect.spawn('screen ' + port + ' 115200', timeout=60)
dut.sendline()
# dut.sendcontrol('c')
dut.expect_exact('# ')
# set the modulation
dut.sendline('pib -sn .rf_mac.static_config.pkt_mgr.forceTxModulation -v ' + str(item[1]))
# dut.sendline('date > /root/foobar')
dut.expect_exact('# ')
dut.sendcontrol('a')
dut.send('k')
dut.send('y')
dut.kill(1)
print('Set RF modulation to ' + item[0] + ' for DUT on serial port ' + port)
# for payload_len in [64, 128, 256, 1024]:
for payload_len in [1024]:
for bandwidth in bandwidths:
goodputs = []
iperf_server_cmd = 'iperf3 -1 -s'
iperf_client_cmd = 'iperf3 -b ' + str(bandwidth) + 'K -c ' + client_ip_addr + ' -l ' + str(payload_len) + ' -t ' + duration + ' -u'
# print(iperf_server_cmd)
print(iperf_client_cmd)
# Start Iperf3 server
# server = pexpect.spawn('screen ' + server_port + ' 115200', timeout=60)
# server.sendline()
# server.expect_exact('pi@raspberrypi:~$ ')
# server.sendline(iperf_server_cmd)
server = pxssh.pxssh()
server.login('10.0.30.2', 'pi')
server.sendline(iperf_server_cmd) # run a command
# delay between starting server and client
time.sleep(0.5)
# Start Iperf3 client and wait for it to finish
# Set command prompt to something more specific
COMMAND_PROMPT = r"\[PEXPECT\]\$ "
client = pexpect.spawn('/bin/bash', timeout=60)
client.sendline (r"PS1='[PEXPECT]\$ '")
client.expect(COMMAND_PROMPT)
client.sendline(iperf_client_cmd)
ret = client.expect(COMMAND_PROMPT)
if ret == 0:
print 'Client has finished\n'
client.kill(1)
# server.sendline()
# server.expect_exact('pi@raspberrypi:~$ ')
server.prompt() # match the prompt
if ret == 0:
lines = server.before.split('\n')
for line in lines:
# print line
m = re.search(r'\s(\d+|\d+\.\d+)\sKbits/sec', line)
if m is not None:
# print m.groups()[0]
goodputs.append(float(m.groups()[0]))
# goodputs.sort()
avg_goodput = round(sum(goodputs) / len(goodputs), 1)
print avg_goodput
server.logout
# server.sendcontrol('a')
# server.send('k')
# server.send('y')
# server.kill(1)