Example #1
0
    def run(self):
        # Setup packet generator
        traffic_time = '10'
        packet_size = '512'
        traffic_rate_percentage = self.params[THROUGHPUT]

        dpdk_pktgen_vars = common.get_dpdk_pktgen_vars()
        # bus_address = dpdk_pktgen_vars[cfs.CFSP_DPDK_BUS_SLOT_NIC_2]
        self.interface_name = dpdk_pktgen_vars[cfs.CFSP_DPDK_NAME_IF_2]
        packetgen = dpdk.DpdkPacketGenerator()
        self._configure_lua_file(traffic_rate_percentage, traffic_time)
        packetgen.init_dpdk_pktgen(dpdk_interfaces=1,
                                   pcap_file_0='packet_' + packet_size +
                                   '.pcap',
                                   pcap_file_1='igmp.pcap',
                                   lua_script='constant_traffic.lua',
                                   vlan_0=self.params[VLAN_SENDER],
                                   vlan_1=self.params[VLAN_RECEIVER])

        self._init_packet_checker()
        # Send constant traffic at a specified rate
        common.LOG.debug('Start the packet generator')
        packetgen.send_traffic()
        common.LOG.debug('Stop the packet generator')
        time.sleep(5)
        self._finalize_packet_checker()
        self._reset_lua_file(traffic_rate_percentage, traffic_time)
        return self._get_results()
    def run(self):
        # Setup packet generator
        traffic_time = '10'
        packet_size = '512'
        traffic_rate_percentage = self.params[THROUGHPUT]

        dpdk_pktgen_vars = common.get_dpdk_pktgen_vars()
        # bus_address = dpdk_pktgen_vars[cfs.CFSP_DPDK_BUS_SLOT_NIC_2]
        self.interface_name = dpdk_pktgen_vars[cfs.CFSP_DPDK_NAME_IF_2]
        packetgen = dpdk.DpdkPacketGenerator()
        self._configure_lua_file(traffic_rate_percentage, traffic_time)
        packetgen.init_dpdk_pktgen(dpdk_interfaces=1,
                                   pcap_file_0='packet_' + packet_size +
                                               '.pcap',
                                   pcap_file_1='igmp.pcap',
                                   lua_script='constant_traffic.lua',
                                   vlan_0=self.params[VLAN_SENDER],
                                   vlan_1=self.params[VLAN_RECEIVER])

        self._init_packet_checker()
        # Send constant traffic at a specified rate
        common.LOG.debug('Start the packet generator')
        packetgen.send_traffic()
        common.LOG.debug('Stop the packet generator')
        time.sleep(5)
        self._finalize_packet_checker()
        self._reset_lua_file(traffic_rate_percentage, traffic_time)
        return self._get_results()
 def send_traffic(self):
     '''
     Calls the packet generator and starts to send traffic
     Blocking call
     '''
     current_dir = os.path.dirname(os.path.realpath(__file__))
     DpdkPacketGenerator._chdir(self.directory)
     dpdk_vars = common.get_dpdk_pktgen_vars()
     self._init_physical_nics(self.dpdk_interfaces, dpdk_vars)
     common.run_command(self.command)
     self._finalize_physical_nics(self.dpdk_interfaces, dpdk_vars)
     DpdkPacketGenerator._chdir(current_dir)
Example #4
0
 def send_traffic(self):
     '''
     Calls the packet generator and starts to send traffic
     Blocking call
     '''
     current_dir = os.path.dirname(os.path.realpath(__file__))
     DpdkPacketGenerator._chdir(self.directory)
     dpdk_vars = common.get_dpdk_pktgen_vars()
     self._init_physical_nics(self.dpdk_interfaces, dpdk_vars)
     common.run_command(self.command)
     self._finalize_physical_nics(self.dpdk_interfaces, dpdk_vars)
     DpdkPacketGenerator._chdir(current_dir)
Example #5
0
    def test_get_dpdk_pktgen_vars_test(self):
        # Test 1
        common.PKTGEN = 'dpdk_pktgen'
        common.PKTGEN_DIR = 'var'
        common.PKTGEN_PROGRAM = 'var'
        common.PKTGEN_COREMASK = 'var'
        common.PKTGEN_MEMCHANNEL = 'var'
        common.PKTGEN_BUS_SLOT_NIC_1 = 'var'
        common.PKTGEN_BUS_SLOT_NIC_2 = 'var'
        common.PKTGEN_NAME_NIC_1 = 'var'
        common.PKTGEN_NAME_NIC_2 = 'var'
        common.PKTGEN_DPDK_DIRECTORY = 'var'
        expected = {
            'bus_slot_nic_1': 'var',
            'bus_slot_nic_2': 'var',
            'name_if_1': 'var',
            'name_if_2': 'var',
            'coremask': 'var',
            'dpdk_directory': 'var',
            'memory_channels': 'var',
            'pktgen_directory': 'var',
            'program_name': 'var'
        }
        output = common.get_dpdk_pktgen_vars()
        self.assertEqual(expected, output)

        # Test 2
        common.PKTGEN = 'something_else'
        common.PKTGEN_DIR = 'var'
        common.PKTGEN_PROGRAM = 'var'
        common.PKTGEN_COREMASK = 'var'
        common.PKTGEN_MEMCHANNEL = 'var'
        common.PKTGEN_BUS_SLOT_NIC_1 = 'var'
        common.PKTGEN_BUS_SLOT_NIC_2 = 'var'
        common.PKTGEN_DPDK_DIRECTORY = 'var'
        expected = {}
        output = common.get_dpdk_pktgen_vars()
        self.assertEqual(expected, output)
Example #6
0
    def test_get_dpdk_pktgen_vars_test(self):
        # Test 1
        common.PKTGEN = 'dpdk_pktgen'
        common.PKTGEN_DIR = 'var'
        common.PKTGEN_PROGRAM = 'var'
        common.PKTGEN_COREMASK = 'var'
        common.PKTGEN_MEMCHANNEL = 'var'
        common.PKTGEN_BUS_SLOT_NIC_1 = 'var'
        common.PKTGEN_BUS_SLOT_NIC_2 = 'var'
        common.PKTGEN_NAME_NIC_1 = 'var'
        common.PKTGEN_NAME_NIC_2 = 'var'
        common.PKTGEN_DPDK_DIRECTORY = 'var'
        expected = {
            'bus_slot_nic_1': 'var',
            'bus_slot_nic_2': 'var',
            'name_if_1': 'var',
            'name_if_2': 'var',
            'coremask': 'var',
            'dpdk_directory': 'var',
            'memory_channels': 'var',
            'pktgen_directory': 'var',
            'program_name': 'var'
        }
        output = common.get_dpdk_pktgen_vars()
        self.assertEqual(expected, output)

        # Test 2
        common.PKTGEN = 'something_else'
        common.PKTGEN_DIR = 'var'
        common.PKTGEN_PROGRAM = 'var'
        common.PKTGEN_COREMASK = 'var'
        common.PKTGEN_MEMCHANNEL = 'var'
        common.PKTGEN_BUS_SLOT_NIC_1 = 'var'
        common.PKTGEN_BUS_SLOT_NIC_2 = 'var'
        common.PKTGEN_DPDK_DIRECTORY = 'var'
        expected = {}
        output = common.get_dpdk_pktgen_vars()
        self.assertEqual(expected, output)
    def init_dpdk_pktgen(self,
                         dpdk_interfaces,
                         lua_script='generic_test.lua',
                         pcap_file_0='',
                         pcap_file_1='',
                         vlan_0='',
                         vlan_1=''):
        """
        Initializes internal parameters and configuration of the module.
        Needs to be called before the send_traffic
        :param dpdk_interfaces: Number of interfaces to be used (type: int)
        :param lua_script: Full path of the Lua script to be used (type: str)
        :param pcap_file_0: Full path of the Pcap file to be used for port 0
                            (type: str)
        :param pcap_file_1: Full path of the Pcap file to be used for port 1
                            (type: str)
        :param vlan_0: VLAN tag to be used for port 0 (type: str)
        :param vlan_1: VLAN tag to be used for port 1 (type: str)
        :return:
        """
        # Input Validation
        if pcap_file_0 and not vlan_0:
            message = 'In order to use NIC_0, the parameter vlan_0 is required'
            raise ValueError(message)
        if dpdk_interfaces > 1 and pcap_file_1 and not vlan_1:
            message = 'in order to use NIC_1, the parameter vlan_1 is required'
            raise ValueError(message)

        self.dpdk_interfaces = dpdk_interfaces
        vars = common.get_dpdk_pktgen_vars()

        lua_directory = common.get_base_dir()
        lua_directory += fp.EXPERIMENTAL_FRAMEWORK_DIR
        lua_directory += fp.DPDK_PKTGEN_DIR

        pcap_directory = common.get_base_dir()
        pcap_directory += fp.EXPERIMENTAL_FRAMEWORK_DIR
        pcap_directory += fp.PCAP_DIR

        DpdkPacketGenerator._init_input_validation(pcap_file_0,
                                                   pcap_file_1,
                                                   lua_script,
                                                   pcap_directory,
                                                   lua_directory,
                                                   vars)

        self.directory = vars[conf_file.CFSP_DPDK_PKTGEN_DIRECTORY]
        self.program_name = vars[conf_file.CFSP_DPDK_PROGRAM_NAME]

        core_nics = DpdkPacketGenerator.\
            _get_core_nics(dpdk_interfaces, vars[conf_file.CFSP_DPDK_COREMASK])
        self.command_options = ['-c ' + vars[conf_file.CFSP_DPDK_COREMASK],
                                '-n ' + vars[conf_file.
                                             CFSP_DPDK_MEMORY_CHANNEL],
                                '--proc-type auto',
                                '--file-prefix pg',
                                '-- -T',
                                '-P',
                                '-m "' + core_nics + '"',
                                '-f ' + lua_directory + lua_script,
                                '-s 0:' + pcap_directory + pcap_file_0]

        if pcap_file_1:
            self.command_options.append('-s 1:' + pcap_directory + pcap_file_1)

        # Avoid to show the output of the packet generator
        self.command_options.append('> /dev/null')
        # Prepare the command to be invoked
        self.command = 'sudo ' + self.directory + self.program_name
        for opt in self.command_options:
            self.command += (' ' + opt)
        if pcap_file_0 and vlan_0:
            DpdkPacketGenerator._change_vlan(pcap_directory, pcap_file_0,
                                             vlan_0)
        if pcap_file_1 and vlan_1:
            DpdkPacketGenerator._change_vlan(pcap_directory, pcap_file_1,
                                             vlan_1)
Example #8
0
    def init_dpdk_pktgen(self,
                         dpdk_interfaces,
                         lua_script='generic_test.lua',
                         pcap_file_0='',
                         pcap_file_1='',
                         vlan_0='',
                         vlan_1=''):
        """
        Initializes internal parameters and configuration of the module.
        Needs to be called before the send_traffic
        :param dpdk_interfaces: Number of interfaces to be used (type: int)
        :param lua_script: Full path of the Lua script to be used (type: str)
        :param pcap_file_0: Full path of the Pcap file to be used for port 0
                            (type: str)
        :param pcap_file_1: Full path of the Pcap file to be used for port 1
                            (type: str)
        :param vlan_0: VLAN tag to be used for port 0 (type: str)
        :param vlan_1: VLAN tag to be used for port 1 (type: str)
        :return:
        """
        # Input Validation
        if pcap_file_0 and not vlan_0:
            message = 'In order to use NIC_0, the parameter vlan_0 is required'
            raise ValueError(message)
        if dpdk_interfaces > 1 and pcap_file_1 and not vlan_1:
            message = 'in order to use NIC_1, the parameter vlan_1 is required'
            raise ValueError(message)

        self.dpdk_interfaces = dpdk_interfaces
        vars = common.get_dpdk_pktgen_vars()

        lua_directory = common.get_base_dir()
        lua_directory += fp.EXPERIMENTAL_FRAMEWORK_DIR
        lua_directory += fp.DPDK_PKTGEN_DIR

        pcap_directory = common.get_base_dir()
        pcap_directory += fp.EXPERIMENTAL_FRAMEWORK_DIR
        pcap_directory += fp.PCAP_DIR

        DpdkPacketGenerator._init_input_validation(pcap_file_0, pcap_file_1,
                                                   lua_script, pcap_directory,
                                                   lua_directory, vars)

        self.directory = vars[conf_file.CFSP_DPDK_PKTGEN_DIRECTORY]
        self.program_name = vars[conf_file.CFSP_DPDK_PROGRAM_NAME]

        core_nics = DpdkPacketGenerator.\
            _get_core_nics(dpdk_interfaces, vars[conf_file.CFSP_DPDK_COREMASK])
        self.command_options = [
            '-c ' + vars[conf_file.CFSP_DPDK_COREMASK],
            '-n ' + vars[conf_file.CFSP_DPDK_MEMORY_CHANNEL],
            '--proc-type auto', '--file-prefix pg', '-- -T', '-P',
            '-m "' + core_nics + '"', '-f ' + lua_directory + lua_script,
            '-s 0:' + pcap_directory + pcap_file_0
        ]

        if pcap_file_1:
            self.command_options.append('-s 1:' + pcap_directory + pcap_file_1)

        # Avoid to show the output of the packet generator
        self.command_options.append('> /dev/null')
        # Prepare the command to be invoked
        self.command = 'sudo ' + self.directory + self.program_name
        for opt in self.command_options:
            self.command += (' ' + opt)
        if pcap_file_0 and vlan_0:
            DpdkPacketGenerator._change_vlan(pcap_directory, pcap_file_0,
                                             vlan_0)
        if pcap_file_1 and vlan_1:
            DpdkPacketGenerator._change_vlan(pcap_directory, pcap_file_1,
                                             vlan_1)