-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathait-client-netperf-2.4.5-udp_stream
executable file
·37 lines (33 loc) · 1.36 KB
/
ait-client-netperf-2.4.5-udp_stream
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
#! /usr/bin/python
# -*- python -*-
# -*- coding: utf-8 -*-
import sys, subprocess as sp
def netperf_udp_stream(server, msgsize=4096, duration=15):
cmd = "netperf -H %s -t UDP_STREAM -l %d -- -m %d" % (server, duration, msgsize)
p = sp.Popen(cmd, shell=True, stdin=sp.PIPE, stdout=sp.PIPE,
stderr=sp.PIPE, close_fds=True)
lines = p.stdout.readlines()[-3:]
if lines[0].startswith("establish control: are you sure there is a netserver listening on "):
print "Please start netserver on %s" % server
return True
(local_socket_size, msg_size, local_elapsed_time,
local_msg_ok, msg_err, local_throughput) = lines[0].strip().split()
(remote_socket_size, remote_elapsed_time,
remote_msg_ok, remote_throughput) = lines[1].strip().split()
print "%s, %s, %s, %s, %s, %s, %s, %s, %s, %s" % \
(msg_size, msg_err,
local_socket_size, local_elapsed_time,
local_msg_ok, local_throughput,
remote_socket_size, remote_elapsed_time,
remote_msg_ok, remote_throughput)
return False
def main(server, metric_range):
for msgsize in range(metric_range[0], metric_range[1] + 1, metric_range[2]):
if netperf_udp_stream(server, msgsize):
return True
return False
if __name__ == '__main__':
server = sys.argv[1]
metric_range = [ int (m) for m in sys.argv[2].strip().split(',') ]
if main(server,metric_range):
sys.exit(1)