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 358CBA00E6 for ; Tue, 6 Aug 2019 08:57:55 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2B86E1B9D6; Tue, 6 Aug 2019 08:57:55 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id C86951B9A0 for ; Tue, 6 Aug 2019 08:57:52 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Aug 2019 23:57:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,352,1559545200"; d="scan'208";a="192598347" Received: from dpdk-moyufen01.sh.intel.com ([10.67.111.77]) by fmsmga001.fm.intel.com with ESMTP; 05 Aug 2019 23:57:51 -0700 From: yufengmx To: dts@dpdk.org Cc: yufengmx Date: Tue, 6 Aug 2019 14:58:42 +0800 Message-Id: <1565074724-216584-4-git-send-email-yufengx.mo@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1565074724-216584-1-git-send-email-yufengx.mo@intel.com> References: <1565074724-216584-1-git-send-email-yufengx.mo@intel.com> Subject: [dts] [PATCH V1 3/5] framework/pktgen_base: measure throughput supports multiple 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" return values *. add test method(latency/loss/throughput) delay/duration options new usage definition and relevant process source code. *. set delay option to be the warm up time after start transmission. *. add __get_single_throughput_statistic/__get_multi_throughput_statistic methods to realize measure_throughput support return several throughput numbers in a duration. *. set duration option default value to 10 second. *. add test method(latency/loss/throughput/rfc2544) options parameter usage comment, which is the same as doc pktgen_prog_guide.rst. Signed-off-by: yufengmx --- framework/pktgen_base.py | 143 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 131 insertions(+), 12 deletions(-) diff --git a/framework/pktgen_base.py b/framework/pktgen_base.py index e9d3fcb..6bfc49a 100644 --- a/framework/pktgen_base.py +++ b/framework/pktgen_base.py @@ -163,18 +163,23 @@ class PacketGenerator(object): def reset_streams(self): self.__streams = [] - def measure_throughput(self, stream_ids=[], options={}): - """ - Measure throughput on each tx ports - """ + def __warm_up_pktgen(self, stream_ids, options, delay): + ''' run warm up traffic before start main traffic ''' + if not delay: + return + msg = 'run traffic {0}s to warm up {1} packet generator '.format( + delay, self.pktgen_type) + self.logger.info(msg) + self._start_transmission(stream_ids, options) + time.sleep(delay) + self._stop_transmission(stream_ids) + + def __get_single_throughput_statistic(self, stream_ids): bps_rx = [] pps_rx = [] - self._prepare_transmission(stream_ids=stream_ids) - self._start_transmission(stream_ids) - - delay = options.get('delay') or 5 - time.sleep(delay) used_rx_port = [] + msg = 'begin get port statistic ...' + self.logger.info(msg) for stream_id in stream_ids: if self.__streams[stream_id]['rx_port'] not in used_rx_port: rxbps_rates, rxpps_rates = self._retrieve_port_statistic( @@ -182,20 +187,80 @@ class PacketGenerator(object): used_rx_port.append(self.__streams[stream_id]['rx_port']) bps_rx.append(rxbps_rates) pps_rx.append(rxpps_rates) - self._stop_transmission(stream_id) - bps_rx_total = self._summary_statistic(bps_rx) pps_rx_total = self._summary_statistic(pps_rx) self.logger.info("throughput: pps_rx %f, bps_rx %f" % (pps_rx_total, bps_rx_total)) return bps_rx_total, pps_rx_total + def __get_multi_throughput_statistic(self, stream_ids, duration, interval): + """ + duration: define the measure duration (second) + interval: define the interval of get throughput number (second) + + Return: a list of throughput instead of a single tuple of pps/bps rate + """ + time_elapsed = 0 + stats = [] + while time_elapsed < duration: + time.sleep(interval) + stats.append(self.__get_single_throughput_statistic(stream_ids)) + time_elapsed += interval + return stats + + def measure_throughput(self, stream_ids=[], options={}): + """ + Measure throughput on each tx ports + + options usage: + rate: + port rate percent, float(0--100). Default value is 100. + + delay: + warm up time before start main traffic. If it is set, it will start + a delay time traffic to make sure packet generator under good status. + Warm up flow is ignored by default. + + interval: + a interval time of get throughput statistic (second) + If set this key value, pktgen will return several throughput statistic + data within a duration traffic. If not set this key value, only return one statistic + data. It is ignored by default. + + duration: + traffic lasting time(second). Default value is 10 second. + """ + interval = options.get('interval') + duration = options.get('duration') or 10 + delay = options.get('delay') + self._prepare_transmission(stream_ids=stream_ids) + # start warm up traffic + self.__warm_up_pktgen(stream_ids, options, delay) + # main traffic + self._start_transmission(stream_ids) + # keep traffic within a duration time and get throughput statistic + if interval and duration: + stats = self.__get_multi_throughput_statistic( + stream_ids, duration, interval) + else: + time.sleep(duration) + stats = self.__get_single_throughput_statistic(stream_ids) + self._stop_transmission(stream_ids) + return stats + def _measure_loss(self, stream_ids=[], options={}): """ Measure lost rate on each tx/rx ports """ + delay = options.get('delay') + duration = options.get('duration') or 10 self._prepare_transmission(stream_ids=stream_ids) + # start warm up traffic + self.__warm_up_pktgen(stream_ids, options, delay) + # main traffic self._start_transmission(stream_ids, options) + # keep traffic within a duration time + time.sleep(duration) self._stop_transmission(None) result = {} used_rx_port = [] @@ -216,6 +281,19 @@ class PacketGenerator(object): return result def measure_loss(self, stream_ids=[], options={}): + ''' + options usage: + rate: + port rate percent, float(0--100). Default value is 100. + + delay: + warm up time before start main traffic. If it is set, it will + start a delay time traffic to make sure packet generator + under good status. Warm up flow is ignored by default. + + duration: + traffic lasting time(second). Default value is 10 second. + ''' result = self._measure_loss(stream_ids, options) # here only to make sure that return value is the same as dts/etgen format # In real testing scenario, this method can offer more data than it @@ -224,9 +302,28 @@ class PacketGenerator(object): def measure_latency(self, stream_ids=[], options={}): """ Measure latency on each tx/rx ports + + options usage: + rate: + port rate percent, float(0--100). Default value is 100. + + delay: + warm up time before start main traffic. If it is set, it will + start a delay time transmission to make sure packet generator + under correct status. Warm up flow is ignored by default. + + duration: + traffic lasting time(second). Default value is 10 second. """ + delay = options.get('delay') + duration = options.get('duration') or 10 self._prepare_transmission(stream_ids=stream_ids, latency=True) + # start warm up traffic + self.__warm_up_pktgen(stream_ids, options, delay) + # main traffic self._start_transmission(stream_ids, options) + # keep traffic within a duration time + time.sleep(duration) self._stop_transmission(None) result = {} @@ -254,7 +351,26 @@ class PacketGenerator(object): return True def measure_rfc2544(self, stream_ids=[], options={}): - """ check loss rate with rate percent dropping """ + """ check loss rate with rate percent dropping + + options usage: + rate: + port rate percent at first round testing(0 ~ 100), default is 100. + + pdr: + permit packet drop rate, , default is 0. + + drop_step: + port rate percent drop step(0 ~ 100), default is 1. + + delay: + warm up time before start main traffic. If it is set, it will + start a delay time traffic to make sure packet generator + under good status. Warm up flow is ignored by default. + + duration: + traffic lasting time(second). Default value is 10 second. + """ loss_rate_table = [] rate_percent = float(100) permit_loss_rate = options.get('pdr') or 0 @@ -271,6 +387,9 @@ class PacketGenerator(object): # here only pick one return result.values()[0] _options = deepcopy(options) + # if warm up option 'delay' is set, ignore it in next work flow + if 'delay' in _options: + _options.pop('delay') while not status and rate_percent > 0: rate_percent = rate_percent - rate_step if rate_percent <= 0: -- 1.9.3