Commit 8e6f7d95 authored by Jaroslava Fiedlerova's avatar Jaroslava Fiedlerova

Use requested bitrate in iperf2 UDP analysis function

Simplification of the code by replacing iperf_opt by target_bitrate (returned from Iperf_ComputeModifiedBW) - no need to repeat the steps to retrieve information about requested bitrate from iperf_opt. Compute iperf bitrate performance as receiver bitrate over requested (target) bitrate.
Fix an issue with misdetection of missing report line - "result" was defined 2x in the function. With this MR, result can be only None or stores output of re.search() for matching the report line pattern, which ensure proper detection of the report line as well as presence off all required components in the report line.
parent ef5df38f
...@@ -191,29 +191,21 @@ def Iperf_analyzeV3UDP(filename, iperf_bitrate_threshold, iperf_packetloss_thres ...@@ -191,29 +191,21 @@ def Iperf_analyzeV3UDP(filename, iperf_bitrate_threshold, iperf_packetloss_thres
else: else:
return (False, 'Could not analyze iperf report') return (False, 'Could not analyze iperf report')
def Iperf_analyzeV2UDP(server_filename, iperf_bitrate_threshold, iperf_packetloss_threshold, iperf_opt): def Iperf_analyzeV2UDP(server_filename, iperf_bitrate_threshold, iperf_packetloss_threshold, target_bitrate):
result = None
if (not os.path.isfile(server_filename)): if (not os.path.isfile(server_filename)):
return (False, 'Could not analyze, server report not found!') return (False, 'Iperf UDP: Server report not found!')
if (os.path.getsize(server_filename)==0):
return (False, 'Iperf UDP: Log file is empty')
# Computing the requested bandwidth in float # Computing the requested bandwidth in float
req_bw = 1.0 # default iperf throughput, in Mbps statusTemplate = r'(?:|\[ *\d+\].*) +0\.0-\s*(?P<duration>[0-9\.]+) +sec +[0-9\.]+ [kKMG]Bytes +(?P<bitrate>[0-9\.]+) (?P<magnitude>[kKMG])bits\/sec +(?P<jitter>[0-9\.]+) ms +(\d+\/ *\d+) +(\((?P<packetloss>[0-9\.]+)%\))'
result = re.search('-b *(?P<iperf_bandwidth>[0-9\.]+)(?P<magnitude>[kKMG])', iperf_opt)
if result is not None:
req_bw = float(result.group('iperf_bandwidth'))
magn = result.group('magnitude')
if magn == "k" or magn == "K":
req_bw /= 1000
elif magn == "G":
req_bw *= 1000
statusTemplate = '(?:|\[ *\d+\].*) +0\.0-\s*(?P<duration>[0-9\.]+) +sec +[0-9\.]+ [kKMG]Bytes +(?P<bitrate>[0-9\.]+) (?P<magnitude>[kKMG])bits\/sec +(?P<jitter>[0-9\.]+) ms +(\d+\/ *\d+) +(\((?P<packetloss>[0-9\.]+)%\))'
with open(server_filename, 'r') as server_file: with open(server_filename, 'r') as server_file:
for line in server_file.readlines(): for line in server_file.readlines():
res = re.search(statusTemplate, str(line)) result = re.search(statusTemplate, str(line))
if res is not None: if result is not None:
result = res break
if result is None: if result is None:
return (False, 'Could not parse server report!') return (False, 'Could not parse server report!')
bitrate = float(result.group('bitrate')) bitrate = float(result.group('bitrate'))
magn = result.group('magnitude') magn = result.group('magnitude')
if magn == "k" or magn == "K": if magn == "k" or magn == "K":
...@@ -222,16 +214,16 @@ def Iperf_analyzeV2UDP(server_filename, iperf_bitrate_threshold, iperf_packetlos ...@@ -222,16 +214,16 @@ def Iperf_analyzeV2UDP(server_filename, iperf_bitrate_threshold, iperf_packetlos
bitrate *= 1000 bitrate *= 1000
jitter = float(result.group('jitter')) jitter = float(result.group('jitter'))
packetloss = float(result.group('packetloss')) packetloss = float(result.group('packetloss'))
br_perf = float(bitrate)/float(req_bw) * 100 br_perf = float(bitrate)/float(target_bitrate) * 100
br_perf = '%.2f ' % br_perf br_perf = '%.2f ' % br_perf
result = float(br_perf) >= float(iperf_bitrate_threshold) and float(packetloss) <= float(iperf_packetloss_threshold) result = float(br_perf) >= float(iperf_bitrate_threshold) and float(packetloss) <= float(iperf_packetloss_threshold)
req_msg = f'Req Bitrate : {req_bw}' req_msg = f'Req Bitrate : {target_bitrate}'
bir_msg = f'Bitrate : {bitrate}' bir_msg = f'Bitrate : {bitrate}'
brl_msg = f'Bitrate Perf: {br_perf} %' brl_msg = f'Bitrate Perf: {br_perf} %'
if float(br_perf) < float(iperf_bitrate_threshold): if float(br_perf) < float(iperf_bitrate_threshold):
brl_msg += f' (too low! <{iperf_bitrate_threshold}%)' brl_msg += f' (too low! <{iperf_bitrate_threshold}%)'
jit_msg = f'Jitter : {jitter}' jit_msg = f'Jitter : {jitter}'
pal_msg = f'Packet Loss : {packetloss}' pal_msg = f'Packet Loss : {packetloss}'
if float(packetloss) > float(iperf_packetloss_threshold): if float(packetloss) > float(iperf_packetloss_threshold):
pal_msg += f' (too high! >{self.iperf_packetloss_threshold}%)' pal_msg += f' (too high! >{self.iperf_packetloss_threshold}%)'
...@@ -821,7 +813,7 @@ class OaiCiTest(): ...@@ -821,7 +813,7 @@ class OaiCiTest():
cmd_svr.run(f'{svr.getCmdPrefix()} iperf -c {ueIP} -B {svrIP} {iperf_opt} -i1 2>&1 | tee {client_filename}', timeout=iperf_time*1.5) cmd_svr.run(f'{svr.getCmdPrefix()} iperf -c {ueIP} -B {svrIP} {iperf_opt} -i1 2>&1 | tee {client_filename}', timeout=iperf_time*1.5)
cmd_ue.run(f'cp {client_filename} {logPath}/{client_filename}') cmd_ue.run(f'cp {client_filename} {logPath}/{client_filename}')
cmd_ue.run(f'cp {server_filename} {logPath}/{server_filename}') cmd_ue.run(f'cp {server_filename} {logPath}/{server_filename}')
status, msg = Iperf_analyzeV2UDP(server_filename, self.iperf_bitrate_threshold, self.iperf_packetloss_threshold, iperf_opt) status, msg = Iperf_analyzeV2UDP(server_filename, self.iperf_bitrate_threshold, self.iperf_packetloss_threshold, target_bitrate)
else: else:
with cls_cmd.getConnection(ue.getHost()) as cmd_ue, cls_cmd.getConnection(EPC.IPAddress) as cmd_svr: with cls_cmd.getConnection(ue.getHost()) as cmd_ue, cls_cmd.getConnection(EPC.IPAddress) as cmd_svr:
port = 5002 + idx port = 5002 + idx
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment