Iperf Menu
The Iperf menu provides access to the Iperf tool, which is used for network performance measurement and tuning. It allows users to test the bandwidth between two hosts over a network. It uses the Cli to provide a command line interface (CLI) to start an iperf client/server or abort the existing execution, if any.
API Reference
Header File
Classes
-
class IperfMenu
A CLI menu for running iperf tests.
Example
espp::WifiSta wifi_sta({.ssid = "", // CONFIG_ESP_WIFI_SSID, .password = "", // CONFIG_ESP_WIFI_PASSWORD, .num_connect_retries = 5, // CONFIG_ESP_MAXIMUM_RETRY, .on_connected = nullptr, .on_disconnected = nullptr, .on_got_ip = [&](ip_event_got_ip_t *eventdata) { logger.info("got IP: {}.{}.{}.{}", IP2STR(&eventdata->ip_info.ip)); }, .log_level = espp::Logger::Verbosity::DEBUG}); auto sta_menu = espp::WifiStaMenu(wifi_sta); auto iperf_menu = espp::IperfMenu(); // Now make the cli and start it auto root_menu = std::make_unique<cli::Menu>("example"); root_menu->Insert(sta_menu.get()); root_menu->Insert(iperf_menu.get()); cli::Cli cli(std::move(root_menu)); cli::SetColor(); cli.ExitAction([](auto &out) { out << "Goodbye and thanks for all the fish.\n"; }); espp::Cli input(cli); input.SetInputHistorySize(10); input.Start();
Public Functions
-
inline std::unique_ptr<cli::Menu> get(std::string_view name = "iperf", std::string_view description = "Iperf menu")
Get the CLI menu for the Iperf functionality.
- Parameters:
name – The name of the menu.
description – The description of the menu.
- Returns:
A unique pointer to the Iperf menu that you can use to add to a CLI.
-
inline void abort(std::ostream &out)
Abort the current iperf test if running.
- Parameters:
out – The output stream to write the result to.
-
inline void get_ipv6(std::ostream &out) const
Get the current IPv6 setting.
Note
This function is only available if IPERF_IPV6_ENABLED is defined.
- Parameters:
out – The output stream to write the result to.
-
inline void set_ipv6(std::ostream &out, bool ipv6)
Set the IPv6 mode for iperf tests.
Note
This function is only available if IPERF_IPV6_ENABLED is defined.
- Parameters:
out – The output stream to write the result to.
ipv6 – True to use IPv6 mode, false for IPv4 mode.
-
inline void get_udp(std::ostream &out) const
Get the current UDP mode setting.
- Parameters:
out – The output stream to write the result to.
-
inline void set_udp(std::ostream &out, bool udp)
Set the UDP mode for iperf tests.
- Parameters:
out – The output stream to write the result to.
udp – True to use UDP mode, false for TCP mode.
-
inline void get_interval(std::ostream &out) const
Get the current reporting interval setting.
- Parameters:
out – The output stream to write the result to.
-
inline void set_interval(std::ostream &out, int interval)
Set the reporting interval for iperf tests.
- Parameters:
out – The output stream to write the result to.
interval – The interval in seconds to set.
-
inline void get_time(std::ostream &out) const
Get the current time (duration) setting.
- Parameters:
out – The output stream to write the result to.
-
inline void set_time(std::ostream &out, int time)
Set the time for iperf tests.
- Parameters:
out – The output stream to write the result to.
time – The time in seconds to set.
-
inline void get_format(std::ostream &out) const
Get the current formatting setting (kibits/sec or mbits/sec)
- Parameters:
out – The output stream to write the result to.
-
inline void set_format(std::ostream &out, char format)
Set the output format for iperf tests.
- Parameters:
out – The output stream to write the result to.
format – The format character to set (‘k’ for kibits/sec, ‘m’ for mbits/sec).
-
inline void get_length(std::ostream &out) const
Get the current buffer length setting.
- Parameters:
out – The output stream to write the result to.
-
inline void set_length(std::ostream &out, int length)
Set the buffer length for iperf tests.
- Parameters:
out – The output stream to write the result to.
length – The length in bytes to set.
-
inline void iperf_client(std::ostream &out, const std::string &host, int port = 0, int bandwidth = IPERF_DEFAULT_NO_BW_LIMIT)
Start an iperf client.
- Parameters:
out – The output stream to write the result to.
host – The host to connect to. Can be an IP address in IPv4 or IPv6 format, or a hostname that resolves to an IP address.
port – The port to connect to. If 0, the default port (5000) is used.
bandwidth – The bandwidth limit for UDP tests. If <= 0, no limit is set.
-
inline void iperf_server(std::ostream &out, const std::string &source = "", int port = 0)
Start an iperf server.
- Parameters:
out – The output stream to write the result to.
host – The source IP to listen on. This helps select which interface to bind to, if provided.
port – The port to listen on. If 0, the default port (5000) is used.
-
inline std::unique_ptr<cli::Menu> get(std::string_view name = "iperf", std::string_view description = "Iperf menu")