コード例 #1
0
ファイル: tg_rfc2544_ixia.py プロジェクト: PLVision/yardstick
    def generate_samples(self, ports, duration):
        stats = self.get_stats()

        samples = {}
        # this is not DPDK port num, but this is whatever number we gave
        # when we selected ports and programmed the profile
        for port_num in ports:
            try:
                # reverse lookup port name from port_num so the stats dict is descriptive
                intf = self.vnfd_helper.find_interface_by_port(port_num)
                port_name = intf['name']
                avg_latency = stats['Store-Forward_Avg_latency_ns'][port_num]
                min_latency = stats['Store-Forward_Min_latency_ns'][port_num]
                max_latency = stats['Store-Forward_Max_latency_ns'][port_num]
                samples[port_name] = {
                    'rx_throughput_kps': float(stats['Rx_Rate_Kbps'][port_num]),
                    'tx_throughput_kps': float(stats['Tx_Rate_Kbps'][port_num]),
                    'rx_throughput_mbps': float(stats['Rx_Rate_Mbps'][port_num]),
                    'tx_throughput_mbps': float(stats['Tx_Rate_Mbps'][port_num]),
                    'in_packets': int(stats['Valid_Frames_Rx'][port_num]),
                    'out_packets': int(stats['Frames_Tx'][port_num]),
                    'RxThroughput': float(stats['Valid_Frames_Rx'][port_num]) / duration,
                    'TxThroughput': float(stats['Frames_Tx'][port_num]) / duration,
                    'Store-Forward_Avg_latency_ns': utils.safe_cast(avg_latency, int, 0),
                    'Store-Forward_Min_latency_ns': utils.safe_cast(min_latency, int, 0),
                    'Store-Forward_Max_latency_ns': utils.safe_cast(max_latency, int, 0)
                }
            except IndexError:
                pass

        return samples
コード例 #2
0
    def generate_samples(self,
                         stats=None,
                         ports=None,
                         port_pg_id=None,
                         latency=False):
        samples = {}
        if stats is None:
            stats = self.get_stats(ports)
        for pname in (intf['name'] for intf in self.vnfd_helper.interfaces):
            port_num = self.vnfd_helper.port_num(pname)
            port_stats = stats.get(port_num, {})
            samples[pname] = {
                'rx_throughput_fps': float(port_stats.get('rx_pps', 0.0)),
                'tx_throughput_fps': float(port_stats.get('tx_pps', 0.0)),
                'rx_throughput_bps': float(port_stats.get('rx_bps', 0.0)),
                'tx_throughput_bps': float(port_stats.get('tx_bps', 0.0)),
                'in_packets': int(port_stats.get('ipackets', 0)),
                'out_packets': int(port_stats.get('opackets', 0)),
            }

            if latency:
                pg_id_list = port_pg_id.get_pg_ids(port_num)
                samples[pname]['latency'] = {}
                for pg_id in pg_id_list:
                    latency_global = stats.get('latency', {})
                    pg_latency = latency_global.get(pg_id, {}).get('latency')

                    t_min = safe_cast(pg_latency.get("total_min", 0.0), float,
                                      -1.0)
                    t_avg = safe_cast(pg_latency.get("average", 0.0), float,
                                      -1.0)
                    t_max = safe_cast(pg_latency.get("total_max", 0.0), float,
                                      -1.0)

                    latency = {
                        "min_latency": t_min,
                        "max_latency": t_max,
                        "avg_latency": t_avg,
                    }
                    samples[pname]['latency'][pg_id] = latency

        return samples
コード例 #3
0
 def get_priority_flows_stats(self, samples, duration):
     results = {}
     priorities = set([flow['IP_Priority'] for flow in samples])
     for priority in priorities:
         tx_frames = sum([
             int(flow['Tx_Frames']) for flow in samples
             if flow['IP_Priority'] == priority
         ])
         rx_frames = sum([
             int(flow['Rx_Frames']) for flow in samples
             if flow['IP_Priority'] == priority
         ])
         prio_flows_num = len(
             [flow for flow in samples if flow['IP_Priority'] == priority])
         avg_latency_ns = sum([
             int(flow['Store-Forward_Avg_latency_ns'])
             for flow in samples if flow['IP_Priority'] == priority
         ]) / prio_flows_num
         min_latency_ns = min([
             int(flow['Store-Forward_Min_latency_ns']) for flow in samples
             if flow['IP_Priority'] == priority
         ])
         max_latency_ns = max([
             int(flow['Store-Forward_Max_latency_ns']) for flow in samples
             if flow['IP_Priority'] == priority
         ])
         tx_throughput = float(tx_frames) / duration
         rx_throughput = float(rx_frames) / duration
         results[priority] = {
             'InPackets': rx_frames,
             'OutPackets': tx_frames,
             'RxThroughput': round(rx_throughput, 3),
             'TxThroughput': round(tx_throughput, 3),
             'LatencyAvg': utils.safe_cast(avg_latency_ns, int, 0),
             'LatencyMin': utils.safe_cast(min_latency_ns, int, 0),
             'LatencyMax': utils.safe_cast(max_latency_ns, int, 0)
         }
     return results
コード例 #4
0
    def generate_samples(self, resource_helper, ports, duration):

        stats = self._get_stats()
        samples = {}
        ports_stats = stats['port_statistics']
        flows_stats = stats['flow_statistic']
        pppoe_subs_per_port = stats['pppox_client_per_port']

        # Get sorted list of ixia ports names
        ixia_port_names = sorted([data['port_name'] for data in ports_stats])

        # Set 'port_id' key for ports stats items
        for item in ports_stats:
            port_id = item.pop('port_name').split('-')[-1].strip()
            item['port_id'] = int(port_id)

        # Set 'id' key for flows stats items
        for item in flows_stats:
            flow_id = item.pop('Flow_Group').split('-')[1].strip()
            item['id'] = int(flow_id)

        # Set 'port_id' key for pppoe subs per port stats
        for item in pppoe_subs_per_port:
            port_id = item.pop('subs_port').split('-')[-1].strip()
            item['port_id'] = int(port_id)

        # Map traffic flows to ports
        port_flow_map = collections.defaultdict(set)
        for item in flows_stats:
            tx_port = item.pop('Tx_Port')
            tx_port_index = ixia_port_names.index(tx_port)
            port_flow_map[tx_port_index].update([item['id']])

        # Sort ports stats
        ports_stats = sorted(ports_stats, key=lambda k: k['port_id'])

        # Get priority flows stats
        prio_flows_stats = self.get_priority_flows_stats(flows_stats, duration)
        samples['priority_stats'] = prio_flows_stats

        # this is not DPDK port num, but this is whatever number we gave
        # when we selected ports and programmed the profile
        for port_num in ports:
            try:
                # reverse lookup port name from port_num so the stats dict is descriptive
                intf = resource_helper.vnfd_helper.find_interface_by_port(
                    port_num)
                port_name = intf['name']
                port_id = ports_stats[port_num]['port_id']
                port_subs_stats = \
                    [port_data for port_data in pppoe_subs_per_port
                     if port_data.get('port_id') == port_id]

                avg_latency = \
                    sum([float(self.get_flow_id_data(
                        flows_stats, flow, 'Store-Forward_Avg_latency_ns'))
                        for flow in port_flow_map[port_num]]) / len(port_flow_map[port_num])
                min_latency = \
                    min([float(self.get_flow_id_data(
                        flows_stats, flow, 'Store-Forward_Min_latency_ns'))
                        for flow in port_flow_map[port_num]])
                max_latency = \
                    max([float(self.get_flow_id_data(
                        flows_stats, flow, 'Store-Forward_Max_latency_ns'))
                        for flow in port_flow_map[port_num]])

                samples[port_name] = {
                    'RxThroughputBps':
                    float(ports_stats[port_num]['Bytes_Rx']) / duration,
                    'TxThroughputBps':
                    float(ports_stats[port_num]['Bytes_Tx']) / duration,
                    'InPackets':
                    int(ports_stats[port_num]['Valid_Frames_Rx']),
                    'OutPackets':
                    int(ports_stats[port_num]['Frames_Tx']),
                    'InBytes':
                    int(ports_stats[port_num]['Bytes_Rx']),
                    'OutBytes':
                    int(ports_stats[port_num]['Bytes_Tx']),
                    'RxThroughput':
                    float(ports_stats[port_num]['Valid_Frames_Rx']) / duration,
                    'TxThroughput':
                    float(ports_stats[port_num]['Frames_Tx']) / duration,
                    'LatencyAvg':
                    utils.safe_cast(avg_latency, int, 0),
                    'LatencyMin':
                    utils.safe_cast(min_latency, int, 0),
                    'LatencyMax':
                    utils.safe_cast(max_latency, int, 0)
                }

                if port_subs_stats:
                    samples[port_name].update({
                        'SessionsUp':
                        int(port_subs_stats[0]['Sessions_Up']),
                        'SessionsDown':
                        int(port_subs_stats[0]['Sessions_Down']),
                        'SessionsNotStarted':
                        int(port_subs_stats[0]['Sessions_Not_Started']),
                        'SessionsTotal':
                        int(port_subs_stats[0]['Sessions_Total'])
                    })

            except IndexError:
                pass

        return samples
コード例 #5
0
    def fmt_latency(lat_min, lat_avg, lat_max):
        t_min = int(round(safe_cast(lat_min, float, -1.0)))
        t_avg = int(round(safe_cast(lat_avg, float, -1.0)))
        t_max = int(round(safe_cast(lat_max, float, -1.0)))

        return "/".join(str(tmp) for tmp in (t_min, t_avg, t_max))