def __init__(self, name, params): base.BenchmarkBaseClass.__init__(self, name, params) self.base_dir = common.get_base_dir() + fp.EXPERIMENTAL_FRAMEWORK_DIR + fp.DPDK_PKTGEN_DIR self.results_file = self.base_dir + PACKETS_FILE_NAME self.lua_file = self.base_dir + 'constant_traffic.lua' self.res_dir = '' self.interface_name = '' # Set the packet checker command self.pkt_checker_command = common.get_base_dir() self.pkt_checker_command += 'experimental_framework/libraries/' self.pkt_checker_command += 'packet_checker/' self.pkt_checker_command += PACKET_CHECKER_PROGRAM_NAME + ' '
def __init__(self, name, params): base.BenchmarkBaseClass.__init__(self, name, params) self.base_dir = os.path.join(common.get_base_dir(), fp.EXPERIMENTAL_FRAMEWORK_DIR, fp.DPDK_PKTGEN_DIR) self.results_file = self.base_dir + PACKETS_FILE_NAME self.lua_file = self.base_dir + 'constant_traffic.lua' self.res_dir = '' self.interface_name = '' # Set the packet checker command self.pkt_checker_command = os.path.join( common.get_base_dir(), 'experimental_framework/libraries/', 'packet_checker/', PACKET_CHECKER_PROGRAM_NAME + ' ')
def test_get_base_dir_for_success(self): base_dir = common.BASE_DIR common.BASE_DIR = 'base_dir' expected = 'base_dir' output = common.get_base_dir() self.assertEqual(expected, output) common.BASE_DIR = base_dir
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)
def __init__(self, name, params): benchmark_base_class.BenchmarkBaseClass.__init__(self, name, params) self.base_dir = common.get_base_dir() + \ fp.EXPERIMENTAL_FRAMEWORK_DIR + fp.DPDK_PKTGEN_DIR self.results_file = self.base_dir + 'experiment.res' self.lua_file = self.base_dir + 'rfc2544.lua'
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)