Support multiple packet sizes for ping

Change-Id: I4af268e68bb7e299ba47a1d26eaa52e16d47e447
This commit is contained in:
ahothan 2016-08-04 15:56:33 -07:00
parent 3a33e062fb
commit 2ac7fbaec2
5 changed files with 58 additions and 26 deletions

View File

@ -152,7 +152,7 @@ Then copy it to OpenStack using the glance CLI:
.. code-block:: bash .. 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: Then list the images to verify:

View File

@ -152,6 +152,10 @@ tcp_pkt_sizes: [65536]
# Can be overridden at the command line using --udpbuf # Can be overridden at the command line using --udpbuf
udp_pkt_sizes: [128, 1024, 8192] 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 # UDP packet loss rate threshold in percentage beyond which bandwidth
# iterations stop and below which iteration with a higher # iterations stop and below which iteration with a higher
# bandwidth continues # bandwidth continues

View File

@ -91,6 +91,8 @@ class Credentials(object):
self.rc_cacert = value self.rc_cacert = value
elif name == "REGION_NAME": elif name == "REGION_NAME":
self.rc_region_name = value self.rc_region_name = value
elif name == "PASSWORD" and not pwd:
pwd = value
else: else:
LOG.error('Error: rc file does not exist %s', openrc_file) LOG.error('Error: rc file does not exist %s', openrc_file)
success = False success = False

View File

@ -229,7 +229,7 @@ class PingTool(PerfTool):
def __init__(self, instance): def __init__(self, instance):
PerfTool.__init__(self, 'ping', 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 '''Perform the ping operation
:return: a dict containing the results stats :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 rtt min/avg/max/mdev = 0.455/0.528/0.596/0.057 ms
''' '''
if self.instance.config.ipv6_mode: if self.instance.config.ipv6_mode:
cmd = "ping6 -c " + str(ping_count) + " " + str(target_ip) ping_cmd = "ping6"
else: 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) cmd_out = self.instance.exec_command(cmd)
if not cmd_out: if not cmd_out:
res = {'protocol': 'ICMP', res = {'protocol': 'ICMP',
@ -270,8 +272,7 @@ class PingTool(PerfTool):
rtt_max = 0 rtt_max = 0
rtt_avg = 0 rtt_avg = 0
rtt_stddev = 0 rtt_stddev = 0
res = {'protocol': 'ICMP', res = {'packet_size': size,
'tool': 'ping',
'tx_packets': tx_packets, 'tx_packets': tx_packets,
'rx_packets': rx_packets, 'rx_packets': rx_packets,
'rtt_min_ms': rtt_min, 'rtt_min_ms': rtt_min,
@ -280,6 +281,16 @@ class PingTool(PerfTool):
'rtt_stddev': rtt_stddev} 'rtt_stddev': rtt_stddev}
return res 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): def get_server_launch_cmd(self):
# not applicable # not applicable
return None return None

View File

@ -545,18 +545,26 @@ def gen_report_data(proto, result):
if 'jitter' in item: if 'jitter' in item:
retval[item['pkt_size']]['jitter'] = item['jitter'] retval[item['pkt_size']]['jitter'] = item['jitter']
elif proto == 'ICMP': elif proto == 'ICMP':
for key in ['rtt_avg_ms', 'rtt_max_ms', 'rtt_min_ms', 'rtt_stddev']: pkt_size_results = {}
retval[key] = item[key] 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']: if proto in ['TCP', 'Upload', 'Download']:
for key in retval: for key in retval:
retval[key] = '{0:n}'.format(retval[key] / tcp_test_count) retval[key] = '{0:n}'.format(retval[key] / tcp_test_count)
except Exception: except Exception:
retval = "ERROR! Check JSON outputs for more details." retval = "ERROR! Check JSON outputs for more details."
traceback.print_exc()
return retval return retval
def print_report(results): def print_report(results):
# In order to parse the results with less logic, we are encoding the results as below: # In order to parse the results with less logic, we are encoding the results as below:
# Same Network = 0, Different Network = 1 # Same Network = 0, Different Network = 1
# Fixed IP = 0, Floating IP = 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)', 'e.g. --udpbuf 128,2048. (default=128,1024,8192)',
metavar='<udp_pkt_size1,...>') metavar='<udp_pkt_size1,...>')
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='<icmp_pkt_size1,...>')
parser.add_argument('--reuse_network_name', dest='reuse_network_name', parser.add_argument('--reuse_network_name', dest='reuse_network_name',
action='store', action='store',
default=None, default=None,
@ -875,6 +890,17 @@ def parse_opts_from_cli():
return parser.parse_known_args()[0] 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): def merge_opts_to_configs(opts):
default_cfg_file = resource_string(__name__, "cfg.default.yaml") 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))) 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: if opts.tcp_pkt_sizes:
try: config.tcp_pkt_sizes = decode_size_list('--tcpbuf', opts.tcp_pkt_sizes)
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)
if opts.udp_pkt_sizes: if opts.udp_pkt_sizes:
try: config.udp_pkt_sizes = decode_size_list('--udpbuf', opts.udp_pkt_sizes)
config.udp_pkt_sizes = opts.udp_pkt_sizes.split(',')
for i in xrange(len(config.udp_pkt_sizes)): if opts.icmp_pkt_sizes:
config.udp_pkt_sizes[i] = int(config.udp_pkt_sizes[i]) config.icmp_pkt_sizes = decode_size_list('--icmp_pkt_sizes', opts.icmp_pkt_sizes)
except ValueError:
LOG.error('Invalid --udpbuf parameter. A valid input must be '
'integers seperated by comma.')
sys.exit(1)
if opts.reuse_network_name: if opts.reuse_network_name:
config.reuse_network_name = opts.reuse_network_name config.reuse_network_name = opts.reuse_network_name