From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id F0749A0559; Mon, 16 Mar 2020 03:25:26 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DD57A1C024; Mon, 16 Mar 2020 03:25:26 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 72679CF3 for ; Mon, 16 Mar 2020 03:25:23 +0100 (CET) IronPort-SDR: 3C2PRqjFCG8nZxqf3gg21SWeGUfp8HSGiCsCl8FsTar/oWyLyyDRiStq8fBfsvh/L5TX0I4HiW 7GoMxwPh8yLg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2020 19:25:23 -0700 IronPort-SDR: b3BiiWHfknyG3CdyyEGNUdqS9NRwCRxKcZ3Cz9TgviynSgDuMH4KAIa35oLUAvP+0G3t5wKN1B fEP+pEjv5Jew== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,558,1574150400"; d="scan'208";a="443156052" Received: from dpdk-moyufen06.sh.intel.com ([10.67.116.222]) by fmsmga005.fm.intel.com with ESMTP; 15 Mar 2020 19:25:21 -0700 From: yufengmx To: dts@dpdk.org, lijuan.tu@intel.com, yingyax.han@intel.com Cc: yufengmx Date: Mon, 16 Mar 2020 10:28:30 +0800 Message-Id: <20200316022830.11028-2-yufengx.mo@intel.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20200316022830.11028-1-yufengx.mo@intel.com> References: <20200316022830.11028-1-yufengx.mo@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dts] [PATCH V1 1/1] framework/pktgen: add actual line rate return for loss. X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" measure_rfc2544_dichotomy/loss rate add actual line rate return value. Signed-off-by: yufengmx --- framework/pktgen_base.py | 47 ++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/framework/pktgen_base.py b/framework/pktgen_base.py index 7e1ff48..049142f 100644 --- a/framework/pktgen_base.py +++ b/framework/pktgen_base.py @@ -263,6 +263,7 @@ class PacketGenerator(object): """ delay = options.get('delay') duration = options.get('duration') or 10 + throughput_stat_flag = options.get('throughput_stat_flag') or False self._prepare_transmission(stream_ids=stream_ids) # start warm up traffic self.__warm_up_pktgen(stream_ids, options, delay) @@ -270,6 +271,8 @@ class PacketGenerator(object): self._start_transmission(stream_ids, options) # keep traffic within a duration time time.sleep(duration) + if throughput_stat_flag: + _throughput_stats = self.__get_single_throughput_statistic(stream_ids) self._stop_transmission(None) result = {} used_rx_port = [] @@ -287,7 +290,10 @@ class PacketGenerator(object): if loss_rate < 0: loss_rate = 0 result[port_id] = (loss_rate, tx_pkts, rx_pkts) - return result + if throughput_stat_flag: + return result, _throughput_stats + else: + return result def measure_loss(self, stream_ids=[], options={}): ''' @@ -491,6 +497,7 @@ class PacketGenerator(object): accuracy = options.get('accuracy') or 0.001 permit_loss_rate = options.get('pdr') or 0.0 duration = options.get('duration') or 10.0 + throughput_stat_flag = options.get('throughput_stat_flag') or False # start warm up traffic delay = options.get('delay') _options = {'duration': duration} @@ -505,10 +512,14 @@ class PacketGenerator(object): traffic_rate_min = min_rate while True: # run loss rate testing - _options = {'duration': duration} + _options = { + 'throughput_stat_flag': throughput_stat_flag, + 'duration': duration, } result = self._measure_loss(stream_ids, _options) loss_rate_table.append([rate, result]) - status = self._check_loss_rate(result, permit_loss_rate) + status = self._check_loss_rate( + result[0] if throughput_stat_flag else result, + permit_loss_rate) # if upper bound rate percent hit, quit the left flow if rate == max_rate and status: hit_result = result @@ -528,16 +539,28 @@ class PacketGenerator(object): # set stream rate percent to custom value self._set_stream_rate_percent(rate) - if not hit_result: - msg = ('expected permit loss rate <{0}> ' - 'not between rate {1} and rate {2}').format( - permit_loss_rate, max_rate, min_rate) - self.logger.error(msg) - self.logger.info(pformat(loss_rate_table)) - ret_value = 0, result[0][1], result[0][2] + if throughput_stat_flag: + if not hit_result or not hit_result[0]: + msg = ('expected permit loss rate <{0}> ' + 'not between rate {1} and rate {2}').format( + permit_loss_rate, max_rate, min_rate) + self.logger.error(msg) + self.logger.info(pformat(loss_rate_table)) + ret_value = 0, result[0][0][1], result[0][0][2], 0 + else: + self.logger.debug(pformat(loss_rate_table)) + ret_value = rate, hit_result[0][0][1], hit_result[0][0][2], hit_result[1][1] else: - self.logger.debug(pformat(loss_rate_table)) - ret_value = rate, hit_result[0][1], hit_result[0][2] + if not hit_result: + msg = ('expected permit loss rate <{0}> ' + 'not between rate {1} and rate {2}').format( + permit_loss_rate, max_rate, min_rate) + self.logger.error(msg) + self.logger.info(pformat(loss_rate_table)) + ret_value = 0, result[0][1], result[0][2] + else: + self.logger.debug(pformat(loss_rate_table)) + ret_value = rate, hit_result[0][1], hit_result[0][2] self.logger.info("zero loss rate is %f" % rate) return ret_value -- 2.21.0