-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(modem): Added iperf test for PPP netifs
- Loading branch information
1 parent
18b2ae1
commit 976e98d
Showing
10 changed files
with
631 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# The following five lines of boilerplate have to be in your project's | ||
# CMakeLists in this exact order for cmake to work correctly | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/system/console/advanced/components | ||
$ENV{IDF_PATH}/examples/common_components/iperf | ||
"../..") | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
project(pppd_test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Target test for measuring TCP/UDP network performance | ||
|
||
## Overview | ||
|
||
The aim of this test is to run `iperf` application to measure network throughput of the esp_modem library. | ||
|
||
### Configure PPP server | ||
|
||
This test uses a network DCE device, which only needs a PPP server. To run the PPP server, use this command: | ||
``` | ||
sudo pppd /dev/ttyUSB1 115200 192.168.11.1:192.168.11.2 ms-dns 8.8.8.8 modem local noauth debug nocrtscts nodetach +ipv6 | ||
``` | ||
|
||
### Running using pytest | ||
|
||
For checking the performance, you only need to execute the pytest, which will measure the network throughput automatically and report the resultant values. For running the pytest, you need to: | ||
* install IDF pytest packages by running: `./install.sh --enable-pytest` | ||
* add IDF internal packages to python path: `export PYTHONPATH=${DIF_PATH}/tools/ci/python_packages/` | ||
* run the pytest as **superuser** | ||
|
||
It's useful to note that when running the test multiple times, you can use `pytest --skip-autoflash y` so the pytest wouldn't have to always reprogram the DUT. | ||
|
||
### Performance summary | ||
|
||
Here's an example of the resultant summary logged by the pytest | ||
``` | ||
2023-11-29 18:28:25 INFO [Performance][tcp_tx_throughput]: 0.75 Mbps | ||
2023-11-29 18:28:25 INFO [Performance][tcp_rx_throughput]: 0.70 Mbps | ||
2023-11-29 18:28:25 INFO [Performance][udp_tx_throughput]: 0.73 Mbps | ||
2023-11-29 18:28:25 INFO [Performance][udp_rx_throughput]: 0.70 Mbps | ||
``` | ||
|
||
### Running the iperf manually | ||
|
||
Execute `idf.py flash monitor` in one terminal and after connecting to the PPP server (after getting an IP address), you can use standard `iperf` commands. | ||
In another terminal, you need to execute the iperf counterpart. | ||
For example running for checking UDP performance, and running server on ESP32, please run: | ||
* iperf -u -s -i 3 (in ESP32 terminal) | ||
* iperf -u -c SERVER_IP -t 60 -i 3 (on the host side) | ||
|
||
Note that command `pppd info` will print actual IP addresses: | ||
``` | ||
iperf> pppd info | ||
ppp: | ||
IP: 192.168.11.2 | ||
MASK: 255.255.255.255 | ||
GW: 192.168.11.3 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
idf_component_register(SRCS "NetworkDCE.cpp" | ||
"cmd_pppclient.c" | ||
"pppd_iperf_main.c") |
96 changes: 96 additions & 0 deletions
96
components/esp_modem/test/target_iperf/main/NetworkDCE.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Unlicense OR CC0-1.0 | ||
*/ | ||
#include "cxx_include/esp_modem_dte.hpp" | ||
#include "esp_modem_config.h" | ||
#include "cxx_include/esp_modem_api.hpp" | ||
#include "cxx_include/esp_modem_dce_factory.hpp" | ||
#include <memory> | ||
#include <utility> | ||
|
||
using namespace esp_modem; | ||
using namespace esp_modem::dce_factory; | ||
|
||
class NetModule; | ||
typedef DCE_T<NetModule> NetDCE; | ||
|
||
/** | ||
* @brief Custom factory which can build and create a DCE using a custom module | ||
*/ | ||
class NetDCE_Factory: public Factory { | ||
public: | ||
template <typename T, typename ...Args> | ||
static DCE_T<T> *create(const config *cfg, Args &&... args) | ||
{ | ||
return build_generic_DCE<T>(cfg, std::forward<Args>(args)...); | ||
} | ||
}; | ||
|
||
/** | ||
* @brief This is a null-module, doesn't define any AT commands, just passes everything to pppd | ||
*/ | ||
class NetModule: public ModuleIf { | ||
public: | ||
explicit NetModule(std::shared_ptr<DTE> dte, const esp_modem_dce_config *cfg): | ||
dte(std::move(dte)) {} | ||
|
||
bool setup_data_mode() override | ||
{ | ||
return true; | ||
} | ||
|
||
bool set_mode(modem_mode mode) override | ||
{ | ||
return true; | ||
} | ||
|
||
static esp_err_t init(esp_netif_t *netif) | ||
{ | ||
// configure | ||
esp_modem_dte_config_t dte_config = ESP_MODEM_DTE_DEFAULT_CONFIG(); | ||
dte_config.uart_config.baud_rate = 921600; // check also 460800 | ||
esp_modem_dce_config dce_config = ESP_MODEM_DCE_DEFAULT_CONFIG(""); | ||
|
||
// create DTE and minimal network DCE | ||
auto uart_dte = create_uart_dte(&dte_config); | ||
dce = NetDCE_Factory::create<NetModule>(&dce_config, uart_dte, netif); | ||
return dce == nullptr ? ESP_FAIL : ESP_OK; | ||
} | ||
|
||
static void deinit() | ||
{ | ||
delete dce; | ||
} | ||
static void start() | ||
{ | ||
dce->set_data(); | ||
} | ||
static void stop() | ||
{ | ||
dce->exit_data(); | ||
} | ||
|
||
private: | ||
static NetDCE *dce; | ||
std::shared_ptr<DTE> dte; | ||
}; | ||
|
||
NetDCE *NetModule::dce = nullptr; | ||
|
||
extern "C" esp_err_t modem_init_network(esp_netif_t *netif) | ||
{ | ||
return NetModule::init(netif); | ||
} | ||
|
||
extern "C" esp_err_t modem_start_network() | ||
{ | ||
NetModule::start(); | ||
return ESP_OK; | ||
} | ||
|
||
extern "C" void modem_stop_network() | ||
{ | ||
NetModule::stop(); | ||
} |
Oops, something went wrong.