Ejemplo n.º 1
0
    def perf_stat(node, cpu_list=None, duration=1):
        """Get perf stat read for duration.

        :param node: Node in the topology.
        :param cpu_list: CPU List as a string separated by comma.
        :param duration: Measure time in seconds.
        :type node: dict
        :type cpu_list: str
        :type duration: int
        """
        if cpu_list:
            cpu_list = list(dict.fromkeys(cpu_list.split(u",")))
            cpu_list = ",".join(str(cpu) for cpu in cpu_list)

        cmd_opts = OptionString(prefix=u"--")
        cmd_opts.add(u"no-aggr")
        cmd_opts.add_with_value_if(u"cpu", cpu_list, cpu_list)
        cmd_opts.add_if(u"all-cpus", not (cpu_list))
        cmd_opts.add_with_value_if(u"event",
                                   f"'{{{Constants.PERF_STAT_EVENTS}}}'",
                                   Constants.PERF_STAT_EVENTS)
        cmd_opts.add_with_value(u"interval-print", 1000)
        cmd_opts.add_with_value(u"field-separator", u"';'")

        cmd_base = OptionString()
        cmd_base.add(f"perf stat")
        cmd_base.extend(cmd_opts)
        cmd_base.add(u"--")
        cmd_base.add_with_value(u"sleep", int(duration))

        exec_cmd(node, cmd_base, sudo=True)
Ejemplo n.º 2
0
    def get_l3fwd_args(**kwargs):
        """Get DPDK l3fwd command line arguments.

        :param kwargs: Key-value l3fwd parameters.
        :type kwargs: dict
        :returns: Command line string.
        :rtype: OptionString
        """
        options = OptionString()
        options.extend(DpdkUtil.get_eal_options(**kwargs))
        options.add(u"--")
        options.extend(DpdkUtil.get_l3fwd_pmd_options(**kwargs))
        return options
Ejemplo n.º 3
0
    def dpdk_testpmd_start(node, **kwargs):
        """Start DPDK testpmd app on VM node.

        :param node: VM Node to start testpmd on.
        :param kwargs: Key-value testpmd parameters.
        :type node: dict
        :type kwargs: dict
        """
        cmd_options = OptionString()
        cmd_options.add(u"/start-testpmd.sh")
        cmd_options.extend(DpdkUtil.get_eal_options(**kwargs))
        cmd_options.add(u"--")
        cmd_options.extend(DpdkUtil.get_testpmd_pmd_options(**kwargs))
        exec_cmd_no_error(node, cmd_options, sudo=True, disconnect=True)
Ejemplo n.º 4
0
    def get_testpmd_cmdline(**kwargs):
        """Get DPDK testpmd command line arguments with testpmd command.

        :param kwargs: Key-value testpmd parameters.
        :type kwargs: dict
        :returns: Command line string.
        :rtype: OptionString
        """
        options = OptionString()
        options.add(u"testpmd")
        options.extend(DpdkUtil.get_eal_options(**kwargs))
        options.add(u"--")
        options.extend(DpdkUtil.get_testpmd_pmd_options(**kwargs))
        return options
Ejemplo n.º 5
0
    def qemu_start(self):
        """Start QEMU and wait until VM boot.

        :returns: VM node info.
        :rtype: dict
        """
        cmd_opts = OptionString()
        cmd_opts.add(f"{Constants.QEMU_BIN_PATH}/qemu-system-{self._arch}")
        cmd_opts.extend(self._params)
        message = f"QEMU: Start failed on {self._node[u'host']}!"
        try:
            DUTSetup.check_huge_page(
                self._node, u"/dev/hugepages", int(self._opt.get(u"mem")))

            exec_cmd_no_error(
                self._node, cmd_opts, timeout=300, sudo=True, message=message
            )
            self._wait_until_vm_boot()
        except RuntimeError:
            self.qemu_kill_all()
            raise
        return self._vm_info
Ejemplo n.º 6
0
    def qemu_start(self):
        """Start QEMU and wait until VM boot.

        :returns: VM node info.
        :rtype: dict
        """
        cmd_opts = OptionString()
        cmd_opts.add('{bin_path}/qemu-system-{arch}'.format(
            bin_path=Constants.QEMU_BIN_PATH,
            arch=Topology.get_node_arch(self._node)))
        cmd_opts.extend(self._params)
        message = ('QEMU: Start failed on {host}!'.
                   format(host=self._node['host']))
        try:
            DUTSetup.check_huge_page(
                self._node, '/dev/hugepages', self._opt.get('mem'))

            exec_cmd_no_error(
                self._node, cmd_opts, timeout=300, sudo=True, message=message)
            self._wait_until_vm_boot()
        except RuntimeError:
            self.qemu_kill_all()
            raise
        return self._vm_info
Ejemplo n.º 7
0
Archivo: Iperf3.py Proyecto: gvnn3/csit
    def iperf3_cmdline(**kwargs):
        """Get iPerf3 server command line.

        :param kwargs: List of iPerf3 server parameters.
        :type kwargs: dict
        :returns: iPerf3 server command line.
        :rtype: OptionString
        """
        cmd = OptionString()
        if kwargs['namespace']:
            cmd.add(f"ip netns exec {kwargs['namespace']}")
        cmd.add(f"iperf3")

        cmd_options = OptionString(prefix=u"--")
        # Run iPerf in server mode. (This will only allow one iperf connection
        # at a time)
        cmd_options.add(u"server")

        # Run the server in background as a daemon.
        cmd_options.add_if_from_dict(u"daemon", u"daemon", kwargs, True)

        # Write a file with the process ID, most useful when running as a
        # daemon.
        cmd_options.add_with_value_from_dict(u"pidfile", u"pidfile", kwargs,
                                             f"/tmp/iperf3_server.pid")

        # Send output to a log file.
        cmd_options.add_with_value_from_dict(u"logfile", u"logfile", kwargs,
                                             f"/tmp/iperf3.log")

        # The server port for the server to listen on and the client to
        # connect to. This should be the same in both client and server.
        # Default is 5201.
        cmd_options.add_with_value_from_dict(u"port", u"port", kwargs, 5201)

        # Set the CPU affinity, if possible (Linux and FreeBSD only).
        cmd_options.add_with_value_from_dict(u"affinity", u"affinity", kwargs)

        # Output in JSON format.
        cmd_options.add_if_from_dict(u"json", u"json", kwargs, True)

        # Give more detailed output.
        cmd_options.add_if_from_dict(u"verbose", u"verbose", kwargs, True)

        return cmd.extend(cmd_options)
Ejemplo n.º 8
0
    def get_cmd_options(**kwargs):
        """Create  parameters options.

        :param kwargs: Dict of cmd parameters.
        :type kwargs: dict
        :returns: Cmd parameters.
        :rtype: OptionString
        """
        cmd = OptionString()
        cmd.add(u"python3")
        dirname = f"{Constants.REMOTE_FW_DIR}/resources/tools/ab"
        cmd.add(f"{dirname}/ABFork.py")
        cmd_options = OptionString(prefix=u"-")
        # Number of requests to perform.
        cmd_options.add_with_value_from_dict(u"r", u"requests", kwargs)
        # Server port number to use.
        cmd_options.add_with_value_from_dict(u"p", u"port", kwargs)
        # Number of clients being processed at the same time.
        cmd_options.add_with_value_from_dict(u"c", u"clients", kwargs)
        # Filename to be requested from the servers.
        cmd_options.add_with_value_from_dict(u"f", u"files", kwargs)
        # Server ip address.
        cmd_options.add_with_value_from_dict(u"i", u"ip", kwargs)
        # tg ip address.
        cmd_options.add_with_value_from_dict(u"g", u"tip", kwargs)
        # Specify SSL/TLS cipher suite.
        cmd_options.add_with_value_from_dict(u"z",
                                             u"cipher",
                                             kwargs,
                                             default=0)
        # Specify SSL/TLS protocol.
        cmd_options.add_with_value_from_dict(u"t",
                                             u"protocol",
                                             kwargs,
                                             default=0)
        # Mode: RPS or CPS.
        cmd_options.add_with_value_from_dict(u"m", u"mode", kwargs)
        return cmd.extend(cmd_options)
Ejemplo n.º 9
0
Archivo: Iperf3.py Proyecto: gvnn3/csit
    def iperf3_cmdline(**kwargs):
        """Get iperf_client driver command line.

        :param kwargs: List of iperf_client driver parameters.
        :type kwargs: dict
        :returns: iperf_client driver command line.
        :rtype: OptionString
        """
        cmd = OptionString()
        cmd.add(u"python3")
        dirname = f"{Constants.REMOTE_FW_DIR}/resources/tools/iperf"
        cmd.add(f"'{dirname}/iperf_client.py'")

        cmd_options = OptionString(prefix=u"--")
        # Namespace to execute iPerf3 client on.
        cmd_options.add_with_value_from_dict(u"namespace", u"namespace",
                                             kwargs)

        # Client connecting to an iPerf3 server running on host.
        cmd_options.add_with_value_from_dict(u"host", u"host", kwargs)

        # Client bind IP address.
        cmd_options.add_with_value_from_dict(u"bind", u"bind", kwargs)

        # Use UDP rather than TCP.
        cmd_options.add_if_from_dict(u"udp", u"udp", kwargs, False)

        # Set the CPU affinity, if possible.
        cmd_options.add_with_value_from_dict(u"affinity", u"affinity", kwargs)

        # Time expressed in seconds for how long to send traffic.
        cmd_options.add_with_value_from_dict(u"duration", u"duration", kwargs)

        # Send bi- (2) or uni- (1) directional traffic.
        cmd_options.add_with_value_from_dict(u"traffic_directions",
                                             u"traffic_directions", kwargs, 1)

        # Traffic warm-up time in seconds, (0=disable).
        cmd_options.add_with_value_from_dict(u"warmup_time", u"warmup_time",
                                             kwargs, 5.0)

        # L2 frame size to send (without padding and IPG).
        cmd_options.add_with_value_from_dict(u"frame_size", u"frame_size",
                                             kwargs)

        # Traffic rate expressed with units.
        cmd_options.add_with_value_from_dict(u"rate", u"rate", kwargs)

        # If enabled then don't wait for all incoming traffic.
        cmd_options.add_if_from_dict(u"async_start", u"async_call", kwargs,
                                     False)

        # Number of iPerf3 client parallel instances.
        cmd_options.add_with_value_from_dict(u"instances", u"instances",
                                             kwargs, 1)

        # Number of iPerf3 client parallel flows.
        cmd_options.add_with_value_from_dict(u"parallel", u"parallel", kwargs,
                                             8)

        return cmd.extend(cmd_options)