mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 1 | import os, time, re, logging |
mbligh | 67a72f9 | 2009-01-13 19:31:08 +0000 | [diff] [blame] | 2 | from autotest_lib.client.bin import test, utils |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 3 | from autotest_lib.client.bin.net import net_utils |
mbligh | 67a72f9 | 2009-01-13 19:31:08 +0000 | [diff] [blame] | 4 | from autotest_lib.client.common_lib import error |
mbligh | 9f85792 | 2008-06-05 16:19:07 +0000 | [diff] [blame] | 5 | |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 6 | MPSTAT_IX = 0 |
| 7 | NETPERF_IX = 1 |
mbligh | 56a91f0 | 2006-09-14 17:55:19 +0000 | [diff] [blame] | 8 | |
| 9 | class netperf2(test.test): |
Kelly Lucas | 8acfcfa | 2010-03-01 10:19:31 -0800 | [diff] [blame] | 10 | version = 4 |
mbligh | 56a91f0 | 2006-09-14 17:55:19 +0000 | [diff] [blame] | 11 | |
lmr | 0570b97 | 2010-05-25 20:07:00 +0000 | [diff] [blame] | 12 | # ftp://ftp.netperf.org/netperf/netperf-2.4.5.tar.bz2 |
| 13 | def setup(self, tarball = 'netperf-2.4.5.tar.bz2'): |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 14 | self.job.require_gcc() |
mbligh | 8b35285 | 2008-06-07 01:07:08 +0000 | [diff] [blame] | 15 | tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) |
mbligh | 53da18e | 2009-01-05 21:13:26 +0000 | [diff] [blame] | 16 | utils.extract_tarball_to_dir(tarball, self.srcdir) |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 17 | os.chdir(self.srcdir) |
mbligh | 56a91f0 | 2006-09-14 17:55:19 +0000 | [diff] [blame] | 18 | |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 19 | utils.system('patch -p0 < ../wait_before_data.patch') |
Kenneth Waters | f5ca5ac | 2010-03-24 11:28:55 -0700 | [diff] [blame] | 20 | utils.configure() |
Eric Li | 6f27d4f | 2010-09-29 10:55:17 -0700 | [diff] [blame^] | 21 | utils.make() |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 22 | utils.system('sync') |
mbligh | 54e5684 | 2006-09-23 06:02:54 +0000 | [diff] [blame] | 23 | |
Kelly Lucas | 8acfcfa | 2010-03-01 10:19:31 -0800 | [diff] [blame] | 24 | self.job.setup_dep(['sysstat']) |
| 25 | |
mbligh | 54e5684 | 2006-09-23 06:02:54 +0000 | [diff] [blame] | 26 | |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 27 | def initialize(self): |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 28 | self.server_prog = '%s&' % os.path.join(self.srcdir, 'src/netserver') |
| 29 | self.client_prog = '%s' % os.path.join(self.srcdir, 'src/netperf') |
| 30 | self.valid_tests = ['TCP_STREAM', 'TCP_MAERTS', 'TCP_RR', 'TCP_CRR', |
| 31 | 'TCP_SENDFILE', 'UDP_STREAM', 'UDP_RR'] |
mbligh | a5630a5 | 2008-09-03 22:09:50 +0000 | [diff] [blame] | 32 | self.results = [] |
mbligh | 865ee82 | 2008-10-03 16:03:34 +0000 | [diff] [blame] | 33 | self.actual_times = [] |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 34 | self.netif = '' |
| 35 | self.network = net_utils.network() |
| 36 | self.network_utils = net_utils.network_utils() |
mbligh | 56a91f0 | 2006-09-14 17:55:19 +0000 | [diff] [blame] | 37 | |
Kelly Lucas | ae35227 | 2010-03-05 15:42:10 -0800 | [diff] [blame] | 38 | dep = 'sysstat' |
| 39 | dep_dir = os.path.join(self.autodir, 'deps', dep) |
| 40 | self.job.install_pkg(dep, 'dep', dep_dir) |
| 41 | |
mbligh | 6f5bbce | 2007-08-10 19:18:37 +0000 | [diff] [blame] | 42 | |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 43 | def run_once(self, server_ip, client_ip, role, test = 'TCP_STREAM', |
| 44 | test_time = 15, stream_list = [1], test_specific_args = '', |
| 45 | cpu_affinity = '', dev = '', bidi = False, wait_time = 5): |
| 46 | """ |
| 47 | server_ip: IP address of host running netserver |
| 48 | client_ip: IP address of host running netperf client(s) |
| 49 | role: 'client' or 'server' |
| 50 | test: one of TCP_STREAM, TCP_MEARTS, TCP_RR, TCP_CRR, TCP_SENDFILE, |
| 51 | UDP_STREAM or UDP_RR |
| 52 | test_time: time to run the test for in seconds |
| 53 | stream_list: list of number of netperf streams to launch |
| 54 | test_specific_args: Optional test specific args. For example to set |
| 55 | the request,response size for RR tests to 200,100, set it |
| 56 | to: '-- -r 200,100'. Or, to set the send buffer size of STREAM |
| 57 | tests to 200, set it to: '-- -m 200' |
| 58 | cpu_affinity: netperf/netserver processes will get taskset to the |
| 59 | cpu_affinity. cpu_affinity is specified as a bitmask in hex |
| 60 | without the leading 0x. For example, to run on CPUs 0 & 5, |
| 61 | cpu_affinity needs to be '21' |
| 62 | dev: device on which to run traffic on. For example, to run on |
| 63 | inteface eth1, set it to 'eth1'. |
| 64 | bidi: bi-directional traffic. This is supported for TCP_STREAM |
| 65 | test only. The RR & CRR tests are bi-directional by nature. |
| 66 | wait_time: Time to wait after establishing data/control connections |
| 67 | but before sending data traffic. |
| 68 | """ |
mbligh | a5630a5 | 2008-09-03 22:09:50 +0000 | [diff] [blame] | 69 | if test not in self.valid_tests: |
| 70 | raise error.TestError('invalid test specified') |
| 71 | self.role = role |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 72 | self.test = test |
mbligh | 865ee82 | 2008-10-03 16:03:34 +0000 | [diff] [blame] | 73 | self.test_time = test_time |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 74 | self.wait_time = wait_time |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 75 | self.stream_list = stream_list |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 76 | self.bidi = bidi |
mbligh | a5630a5 | 2008-09-03 22:09:50 +0000 | [diff] [blame] | 77 | |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 78 | server_tag = server_ip + '#netperf-server' |
| 79 | client_tag = client_ip + '#netperf-client' |
| 80 | all = [server_tag, client_tag] |
mbligh | a5630a5 | 2008-09-03 22:09:50 +0000 | [diff] [blame] | 81 | |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 82 | # If a specific device has been requested, configure it. |
| 83 | if dev: |
| 84 | timeout = 60 |
| 85 | if role == 'server': |
| 86 | self.configure_interface(dev, server_ip) |
| 87 | self.ping(client_ip, timeout) |
| 88 | else: |
| 89 | self.configure_interface(dev, client_ip) |
| 90 | self.ping(server_ip, timeout) |
| 91 | |
mbligh | a5630a5 | 2008-09-03 22:09:50 +0000 | [diff] [blame] | 92 | for num_streams in stream_list: |
| 93 | if role == 'server': |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 94 | self.server_start(cpu_affinity) |
mbligh | a5630a5 | 2008-09-03 22:09:50 +0000 | [diff] [blame] | 95 | try: |
mbligh | 15b8a26 | 2008-09-16 16:50:49 +0000 | [diff] [blame] | 96 | # Wait up to ten minutes for the client to reach this |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 97 | # point. |
mbligh | 15b8a26 | 2008-09-16 16:50:49 +0000 | [diff] [blame] | 98 | self.job.barrier(server_tag, 'start_%d' % num_streams, |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 99 | 600).rendezvous(*all) |
mbligh | 15b8a26 | 2008-09-16 16:50:49 +0000 | [diff] [blame] | 100 | # Wait up to test_time + 5 minutes for the test to |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 101 | # complete |
mbligh | 15b8a26 | 2008-09-16 16:50:49 +0000 | [diff] [blame] | 102 | self.job.barrier(server_tag, 'stop_%d' % num_streams, |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 103 | test_time+300).rendezvous(*all) |
mbligh | a5630a5 | 2008-09-03 22:09:50 +0000 | [diff] [blame] | 104 | finally: |
| 105 | self.server_stop() |
| 106 | |
| 107 | elif role == 'client': |
mbligh | 15b8a26 | 2008-09-16 16:50:49 +0000 | [diff] [blame] | 108 | # Wait up to ten minutes for the server to start |
| 109 | self.job.barrier(client_tag, 'start_%d' % num_streams, |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 110 | 600).rendezvous(*all) |
| 111 | self.client(server_ip, test, test_time, num_streams, |
| 112 | test_specific_args, cpu_affinity) |
mbligh | 15b8a26 | 2008-09-16 16:50:49 +0000 | [diff] [blame] | 113 | # Wait up to 5 minutes for the server to also reach this point |
| 114 | self.job.barrier(client_tag, 'stop_%d' % num_streams, |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 115 | 300).rendezvous(*all) |
mbligh | a5630a5 | 2008-09-03 22:09:50 +0000 | [diff] [blame] | 116 | else: |
| 117 | raise error.TestError('invalid role specified') |
mbligh | 54e5684 | 2006-09-23 06:02:54 +0000 | [diff] [blame] | 118 | |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 119 | self.restore_interface() |
mbligh | 56a91f0 | 2006-09-14 17:55:19 +0000 | [diff] [blame] | 120 | |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 121 | |
| 122 | def configure_interface(self, dev, ip_addr): |
| 123 | self.netif = net_utils.netif(dev) |
| 124 | self.netif.up() |
| 125 | if self.netif.get_ipaddr() != ip_addr: |
| 126 | self.netif.set_ipaddr(ip_addr) |
| 127 | |
| 128 | |
| 129 | def restore_interface(self): |
| 130 | if self.netif: |
| 131 | self.netif.restore() |
| 132 | |
| 133 | |
| 134 | def server_start(self, cpu_affinity): |
mbligh | 78be24a | 2008-06-13 21:40:08 +0000 | [diff] [blame] | 135 | utils.system('killall netserver', ignore_status=True) |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 136 | cmd = self.server_prog |
| 137 | if cpu_affinity: |
| 138 | cmd = 'taskset %s %s' % (cpu_affinity, cmd) |
| 139 | |
| 140 | self.results.append(utils.system_output(cmd, retain_output=True)) |
mbligh | 56a91f0 | 2006-09-14 17:55:19 +0000 | [diff] [blame] | 141 | |
mbligh | 54e5684 | 2006-09-23 06:02:54 +0000 | [diff] [blame] | 142 | |
jadmanski | 0afbb63 | 2008-06-06 21:10:57 +0000 | [diff] [blame] | 143 | def server_stop(self): |
mbligh | a5630a5 | 2008-09-03 22:09:50 +0000 | [diff] [blame] | 144 | utils.system('killall netserver', ignore_status=True) |
mbligh | 56a91f0 | 2006-09-14 17:55:19 +0000 | [diff] [blame] | 145 | |
mbligh | 54e5684 | 2006-09-23 06:02:54 +0000 | [diff] [blame] | 146 | |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 147 | def client(self, server_ip, test, test_time, num_streams, |
| 148 | test_specific_args, cpu_affinity): |
| 149 | args = '-H %s -t %s -l %d' % (server_ip, test, test_time) |
Kelly Lucas | 8acfcfa | 2010-03-01 10:19:31 -0800 | [diff] [blame] | 150 | |
Kelly Lucas | ae35227 | 2010-03-05 15:42:10 -0800 | [diff] [blame] | 151 | if os.path.exists('/usr/bin/mpstat'): |
| 152 | mpstat = '/usr/bin/mpstat' |
| 153 | else: |
| 154 | mpstat = os.path.join(self.autodir + '/deps/sysstat/src/mpstat') |
Kelly Lucas | 8acfcfa | 2010-03-01 10:19:31 -0800 | [diff] [blame] | 155 | |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 156 | if self.wait_time: |
| 157 | args += ' -s %d ' % self.wait_time |
| 158 | |
| 159 | # Append the test specific arguments. |
| 160 | if test_specific_args: |
| 161 | args += ' ' + test_specific_args |
| 162 | |
| 163 | cmd = '%s %s' % (self.client_prog, args) |
| 164 | |
| 165 | if cpu_affinity: |
| 166 | cmd = 'taskset %s %s' % (cpu_affinity, cmd) |
mbligh | 56a91f0 | 2006-09-14 17:55:19 +0000 | [diff] [blame] | 167 | |
mbligh | a5630a5 | 2008-09-03 22:09:50 +0000 | [diff] [blame] | 168 | try: |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 169 | cmds = [] |
| 170 | |
| 171 | # Get 5 mpstat samples. Since tests with large number of streams |
| 172 | # take a long time to start up all the streams, we'll toss out the |
| 173 | # first and last sample when recording results |
| 174 | interval = max(1, test_time / 5) |
Kelly Lucas | ae35227 | 2010-03-05 15:42:10 -0800 | [diff] [blame] | 175 | cmds.append('sleep %d && %s -P ALL %s 5' % (self.wait_time, mpstat, |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 176 | interval)) |
| 177 | |
| 178 | # Add the netperf commands |
| 179 | for i in xrange(num_streams): |
| 180 | cmds.append(cmd) |
| 181 | if self.bidi and test == 'TCP_STREAM': |
| 182 | cmds.append(cmd.replace('TCP_STREAM', 'TCP_MAERTS')) |
| 183 | |
mbligh | 865ee82 | 2008-10-03 16:03:34 +0000 | [diff] [blame] | 184 | t0 = time.time() |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 185 | # Launch all commands in parallel |
| 186 | out = utils.run_parallel(cmds, timeout=test_time + 500, |
| 187 | ignore_status=True) |
mbligh | 865ee82 | 2008-10-03 16:03:34 +0000 | [diff] [blame] | 188 | t1 = time.time() |
| 189 | |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 190 | self.results.append(out) |
| 191 | self.actual_times.append(t1 - t0 - self.wait_time) |
| 192 | # Log test output |
| 193 | logging.info(out) |
mbligh | 865ee82 | 2008-10-03 16:03:34 +0000 | [diff] [blame] | 194 | |
mbligh | a5630a5 | 2008-09-03 22:09:50 +0000 | [diff] [blame] | 195 | except error.CmdError, e: |
| 196 | """ Catch errors due to timeout, but raise others |
| 197 | The actual error string is: |
| 198 | "Command did not complete within %d seconds" |
| 199 | called in function join_bg_job in the file common_lib/utils.py |
mbligh | e8fa3af | 2006-09-28 23:14:56 +0000 | [diff] [blame] | 200 | |
mbligh | a5630a5 | 2008-09-03 22:09:50 +0000 | [diff] [blame] | 201 | Looking for 'within' is probably not the best way to do this but |
| 202 | works for now""" |
| 203 | |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 204 | if ('within' in e.additional_text |
| 205 | or 'non-zero' in e.additional_text): |
lmr | 4c607f2 | 2009-06-02 11:50:38 +0000 | [diff] [blame] | 206 | logging.debug(e.additional_text) |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 207 | self.results.append(None) |
mbligh | 865ee82 | 2008-10-03 16:03:34 +0000 | [diff] [blame] | 208 | self.actual_times.append(1) |
mbligh | a5630a5 | 2008-09-03 22:09:50 +0000 | [diff] [blame] | 209 | else: |
| 210 | raise |
| 211 | |
| 212 | |
| 213 | def postprocess(self): |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 214 | if self.role == 'client': |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 215 | # if profilers are enabled, the test gets runs twice |
| 216 | if (len(self.stream_list) != len(self.results) and |
| 217 | 2*len(self.stream_list) != len(self.results)): |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 218 | raise error.TestError('Mismatched number of results') |
| 219 | |
| 220 | function = None |
| 221 | keys = None |
| 222 | |
| 223 | # Each of the functions return tuples in which the keys define |
| 224 | # what that item in the tuple represents |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 225 | if self.test in ['TCP_STREAM', 'TCP_MAERTS', 'TCP_SENDFILE']: |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 226 | function = self.process_tcp_stream |
| 227 | keys = ('Throughput',) |
| 228 | elif self.test == 'UDP_STREAM': |
| 229 | function = self.process_udp_stream |
| 230 | keys = ('Throughput', 'Errors') |
| 231 | elif self.test in ['TCP_RR', 'TCP_CRR', 'UDP_RR']: |
| 232 | function = self.process_request_response |
| 233 | keys = ('Transfer_Rate',) |
| 234 | else: |
| 235 | raise error.TestError('Unhandled test') |
| 236 | |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 237 | for i, streams in enumerate(self.stream_list): |
| 238 | attr = {'stream_count':streams} |
| 239 | keyval = {} |
| 240 | temp_vals = [] |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 241 | |
| 242 | # Short circuit to handle errors due to client timeouts |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 243 | if not self.results[i]: |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 244 | self.write_iteration_keyval(attr, keyval) |
| 245 | continue |
| 246 | |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 247 | # Collect output of netperf sessions |
| 248 | failed_streams_count = 0 |
| 249 | for result in self.results[i][NETPERF_IX:]: |
| 250 | if result.exit_status: |
| 251 | failed_streams_count += 1 |
| 252 | else: |
| 253 | temp_vals.append(function(result.stdout)) |
| 254 | |
| 255 | keyval['Failed_streams_count'] = failed_streams_count |
| 256 | |
| 257 | # Process mpstat output |
| 258 | mpstat_out = self.results[i][MPSTAT_IX].stdout |
| 259 | cpu_stats = self.network_utils.process_mpstat(mpstat_out, 5) |
| 260 | keyval['CPU_C'] = 100 - cpu_stats['idle'] |
| 261 | keyval['CPU_C_SYS'] = cpu_stats['sys'] |
| 262 | keyval['CPU_C_HI'] = cpu_stats['irq'] |
| 263 | keyval['CPU_C_SI'] = cpu_stats['soft'] |
| 264 | keyval['INTRS_C'] = cpu_stats['intr/s'] |
| 265 | |
| 266 | actual_time = self.actual_times[i] |
| 267 | keyval['actual_time'] = actual_time |
| 268 | logging.info('actual_time: %f', actual_time) |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 269 | |
mbligh | 6d858fa | 2008-09-19 21:19:03 +0000 | [diff] [blame] | 270 | # Compute the sum of elements returned from function which |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 271 | # represent the string contained in keys |
| 272 | for j, key in enumerate(keys): |
| 273 | vals = [x[j] for x in temp_vals] |
mbligh | 865ee82 | 2008-10-03 16:03:34 +0000 | [diff] [blame] | 274 | # scale result by the actual time taken |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 275 | keyval[key] = sum(vals) |
mbligh | 865ee82 | 2008-10-03 16:03:34 +0000 | [diff] [blame] | 276 | |
| 277 | # record 'Efficiency' as perf/CPU |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 278 | if keyval['CPU_C'] != 0: |
| 279 | keyval['Efficieny_C'] = keyval[keys[0]]/keyval['CPU_C'] |
| 280 | else: |
| 281 | keyval['Efficieny_C'] = keyval[keys[0]] |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 282 | |
| 283 | self.write_iteration_keyval(attr, keyval) |
| 284 | |
| 285 | |
| 286 | def process_tcp_stream(self, output): |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 287 | """Parses the following (works for both TCP_STREAM, TCP_MAERTS and |
| 288 | TCP_SENDFILE) and returns a singleton containing throughput. |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 289 | |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 290 | TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to foo.bar.com \ |
| 291 | (10.10.10.3) port 0 AF_INET |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 292 | Recv Send Send |
| 293 | Socket Socket Message Elapsed |
| 294 | Size Size Size Time Throughput |
| 295 | bytes bytes bytes secs. 10^6bits/sec |
| 296 | |
| 297 | 87380 16384 16384 2.00 941.28 |
| 298 | """ |
| 299 | |
| 300 | return float(output.splitlines()[6].split()[4]), |
| 301 | |
| 302 | |
| 303 | def process_udp_stream(self, output): |
| 304 | """Parses the following and returns a touple containing throughput |
| 305 | and the number of errors. |
| 306 | |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 307 | UDP UNIDIRECTIONAL SEND TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET \ |
| 308 | to foo.bar.com (10.10.10.3) port 0 AF_INET |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 309 | Socket Message Elapsed Messages |
| 310 | Size Size Time Okay Errors Throughput |
| 311 | bytes bytes secs # # 10^6bits/sec |
| 312 | |
| 313 | 129024 65507 2.00 3673 0 961.87 |
| 314 | 131072 2.00 3673 961.87 |
| 315 | """ |
| 316 | |
| 317 | line_tokens = output.splitlines()[5].split() |
| 318 | return float(line_tokens[5]), int(line_tokens[4]) |
| 319 | |
| 320 | |
| 321 | def process_request_response(self, output): |
| 322 | """Parses the following which works for both rr (TCP and UDP) and crr |
| 323 | tests and returns a singleton containing transfer rate. |
| 324 | |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 325 | TCP REQUEST/RESPONSE TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET \ |
| 326 | to foo.bar.com (10.10.10.3) port 0 AF_INET |
mbligh | 52fa692 | 2008-09-05 20:37:08 +0000 | [diff] [blame] | 327 | Local /Remote |
| 328 | Socket Size Request Resp. Elapsed Trans. |
| 329 | Send Recv Size Size Time Rate |
| 330 | bytes Bytes bytes bytes secs. per sec |
| 331 | |
| 332 | 16384 87380 1 1 2.00 14118.53 |
| 333 | 16384 87380 |
| 334 | """ |
| 335 | |
| 336 | return float(output.splitlines()[6].split()[5]), |
mbligh | 4439424 | 2009-06-15 21:31:32 +0000 | [diff] [blame] | 337 | |
| 338 | |
| 339 | def ping(self, ip, timeout): |
| 340 | curr_time = time.time() |
| 341 | end_time = curr_time + timeout |
| 342 | while curr_time < end_time: |
| 343 | if not os.system('ping -c 1 ' + ip): |
| 344 | # Ping succeeded |
| 345 | return |
| 346 | # Ping failed. Lets sleep a bit and try again. |
| 347 | time.sleep(5) |
| 348 | curr_time = time.time() |
| 349 | |
| 350 | return |