From 2ac7fbaec25ad8579b3bddfc9b839f93194eebac Mon Sep 17 00:00:00 2001 From: ahothan Date: Thu, 4 Aug 2016 15:56:33 -0700 Subject: [PATCH] Support multiple packet sizes for ping Change-Id: I4af268e68bb7e299ba47a1d26eaa52e16d47e447 --- doc/source/quickstart_git.rst | 2 +- vmtp/cfg.default.yaml | 4 +++ vmtp/credentials.py | 2 ++ vmtp/perf_tool.py | 21 +++++++++---- vmtp/vmtp.py | 55 ++++++++++++++++++++++------------- 5 files changed, 58 insertions(+), 26 deletions(-) diff --git a/doc/source/quickstart_git.rst b/doc/source/quickstart_git.rst index 4ada4af..1e0c261 100644 --- a/doc/source/quickstart_git.rst +++ b/doc/source/quickstart_git.rst @@ -152,7 +152,7 @@ Then copy it to OpenStack using the glance CLI: .. code-block:: bash - glance --os-image-api-version 1 image-create --file /tmp/vmtp/trusty-server-cloudimg-amd64-uefi1.img --disk-format qcow2 --container-format bare --name 'Ubuntu 14.04' + glance --os-image-api-version 1 image-create --file /tmp/vmtp/trusty-server-cloudimg-amd64-uefi1.img --disk-format qcow2 --container-format bare --name 'Ubuntu Server 14.04' Then list the images to verify: diff --git a/vmtp/cfg.default.yaml b/vmtp/cfg.default.yaml index 1d106bb..f434b5f 100644 --- a/vmtp/cfg.default.yaml +++ b/vmtp/cfg.default.yaml @@ -152,6 +152,10 @@ tcp_pkt_sizes: [65536] # Can be overridden at the command line using --udpbuf udp_pkt_sizes: [128, 1024, 8192] +# List of packet sizes to measure with ping +# By default we measure for 64 (small), 391 (IMIX average) and 1500 (large) +icmp_pkt_sizes: [64, 391, 1500] + # UDP packet loss rate threshold in percentage beyond which bandwidth # iterations stop and below which iteration with a higher # bandwidth continues diff --git a/vmtp/credentials.py b/vmtp/credentials.py index 2a554e8..b2342e1 100644 --- a/vmtp/credentials.py +++ b/vmtp/credentials.py @@ -91,6 +91,8 @@ class Credentials(object): self.rc_cacert = value elif name == "REGION_NAME": self.rc_region_name = value + elif name == "PASSWORD" and not pwd: + pwd = value else: LOG.error('Error: rc file does not exist %s', openrc_file) success = False diff --git a/vmtp/perf_tool.py b/vmtp/perf_tool.py index aa9cbeb..12c7b06 100644 --- a/vmtp/perf_tool.py +++ b/vmtp/perf_tool.py @@ -229,7 +229,7 @@ class PingTool(PerfTool): def __init__(self, instance): PerfTool.__init__(self, 'ping', instance) - def run_client(self, target_ip, ping_count=5): + def _run_client(self, target_ip, ping_count, size=32): '''Perform the ping operation :return: a dict containing the results stats @@ -241,9 +241,11 @@ class PingTool(PerfTool): rtt min/avg/max/mdev = 0.455/0.528/0.596/0.057 ms ''' if self.instance.config.ipv6_mode: - cmd = "ping6 -c " + str(ping_count) + " " + str(target_ip) + ping_cmd = "ping6" else: - cmd = "ping -c " + str(ping_count) + " " + str(target_ip) + ping_cmd = "ping" + cmd = "%s -c %d -s %d %s" % (ping_cmd, ping_count, size, target_ip) + print cmd cmd_out = self.instance.exec_command(cmd) if not cmd_out: res = {'protocol': 'ICMP', @@ -270,8 +272,7 @@ class PingTool(PerfTool): rtt_max = 0 rtt_avg = 0 rtt_stddev = 0 - res = {'protocol': 'ICMP', - 'tool': 'ping', + res = {'packet_size': size, 'tx_packets': tx_packets, 'rx_packets': rx_packets, 'rtt_min_ms': rtt_min, @@ -280,6 +281,16 @@ class PingTool(PerfTool): 'rtt_stddev': rtt_stddev} return res + def run_client(self, target_ip, ping_count=10): + size_results = [] + res = {'protocol': 'ICMP', + 'tool': 'ping', + 'results': size_results} + size_list = self.instance.config.icmp_pkt_sizes + for size in size_list: + size_results.append(self._run_client(target_ip, ping_count, size)) + return res + def get_server_launch_cmd(self): # not applicable return None diff --git a/vmtp/vmtp.py b/vmtp/vmtp.py index ac75cf1..4cb6889 100755 --- a/vmtp/vmtp.py +++ b/vmtp/vmtp.py @@ -545,18 +545,26 @@ def gen_report_data(proto, result): if 'jitter' in item: retval[item['pkt_size']]['jitter'] = item['jitter'] elif proto == 'ICMP': - for key in ['rtt_avg_ms', 'rtt_max_ms', 'rtt_min_ms', 'rtt_stddev']: - retval[key] = item[key] + pkt_size_results = {} + for pkt_size_res in item['results']: + + pkt_size_results[str(pkt_size_res['packet_size']) + '-byte'] = \ + '%s/%s/%s/%s' % (pkt_size_res['rtt_avg_ms'], + pkt_size_res['rtt_min_ms'], + pkt_size_res['rtt_max_ms'], + pkt_size_res['rtt_stddev']) + retval['rtt avg/min/max/stddev msec'] = pkt_size_results if proto in ['TCP', 'Upload', 'Download']: for key in retval: retval[key] = '{0:n}'.format(retval[key] / tcp_test_count) except Exception: retval = "ERROR! Check JSON outputs for more details." - + traceback.print_exc() return retval def print_report(results): + # In order to parse the results with less logic, we are encoding the results as below: # Same Network = 0, Different Network = 1 # Fixed IP = 0, Floating IP = 1 @@ -798,6 +806,13 @@ def parse_opts_from_cli(): 'e.g. --udpbuf 128,2048. (default=128,1024,8192)', metavar='') + parser.add_argument('--icmp_pkt_sizes', dest='icmp_pkt_sizes', + action='store', + default=0, + help='list of ICMP packet sizes in Bytes, ' + 'e.g. --icmp_pkt_sizes 128,2048. (default=64,391,1500 391=IMIX avg)', + metavar='') + parser.add_argument('--reuse_network_name', dest='reuse_network_name', action='store', default=None, @@ -875,6 +890,17 @@ def parse_opts_from_cli(): return parser.parse_known_args()[0] +def decode_size_list(argname, size_list): + try: + pkt_sizes = size_list.split(',') + for i in xrange(len(pkt_sizes)): + pkt_sizes[i] = int(pkt_sizes[i]) + except ValueError: + LOG.error('Invalid %s parameter. A valid input must be ' + 'integers seperated by comma.' % argname) + sys.exit(1) + return pkt_sizes + def merge_opts_to_configs(opts): default_cfg_file = resource_string(__name__, "cfg.default.yaml") @@ -968,26 +994,15 @@ def merge_opts_to_configs(opts): config.vm_bandwidth = int(val * (10 ** (ex_unit * 3))) - # the pkt size for TCP and UDP + # the pkt size for TCP, UDP and ICMP if opts.tcp_pkt_sizes: - try: - config.tcp_pkt_sizes = opts.tcp_pkt_sizes.split(',') - for i in xrange(len(config.tcp_pkt_sizes)): - config.tcp_pkt_sizes[i] = int(config.tcp_pkt_sizes[i]) - except ValueError: - LOG.error('Invalid --tcpbuf parameter. A valid input must be ' - 'integers seperated by comma.') - sys.exit(1) + config.tcp_pkt_sizes = decode_size_list('--tcpbuf', opts.tcp_pkt_sizes) if opts.udp_pkt_sizes: - try: - config.udp_pkt_sizes = opts.udp_pkt_sizes.split(',') - for i in xrange(len(config.udp_pkt_sizes)): - config.udp_pkt_sizes[i] = int(config.udp_pkt_sizes[i]) - except ValueError: - LOG.error('Invalid --udpbuf parameter. A valid input must be ' - 'integers seperated by comma.') - sys.exit(1) + config.udp_pkt_sizes = decode_size_list('--udpbuf', opts.udp_pkt_sizes) + + if opts.icmp_pkt_sizes: + config.icmp_pkt_sizes = decode_size_list('--icmp_pkt_sizes', opts.icmp_pkt_sizes) if opts.reuse_network_name: config.reuse_network_name = opts.reuse_network_name