From 71fdd4509631e4c36d65910e01db69a9bdbe9692 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=AD=99=E6=98=A5=E9=98=B3?= Date: Wed, 17 Sep 2025 23:22:43 +0800 Subject: [PATCH] =?utf8?q?=E6=B7=BB=E5=8A=A0tcp=20client=E6=B5=8B=E8=AF=95?= =?utf8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- code/sdk/zhihui/ppp/CMakeLists.txt | 2 + code/sdk/zhihui/ppp/example/Makefile | 83 ++ .../sdk/zhihui/ppp/example/README_TCP_TEST.md | 1 + code/sdk/zhihui/ppp/example/ppp_at_cmd.c | 197 +++++ code/sdk/zhihui/ppp/example/ppp_example.c | 6 + code/sdk/zhihui/ppp/example/ppp_tcp_test.c | 737 ++++++++++++++++++ .../zhihui/ppp/example/ppp_tcp_test_main.c | 264 +++++++ code/sdk/zhihui/ppp/include/ppp_lwip.h | 24 + .../zhihui/ppp/include/ppp_tcp_lwip_compat.h | 106 +++ code/sdk/zhihui/ppp/include/ppp_tcp_test.h | 266 +++++++ code/sdk/zhihui/ppp/src/ppp_lwip.c | 276 +++---- 11 files changed, 1824 insertions(+), 138 deletions(-) create mode 100644 code/sdk/zhihui/ppp/example/Makefile create mode 100644 code/sdk/zhihui/ppp/example/README_TCP_TEST.md create mode 100644 code/sdk/zhihui/ppp/example/ppp_tcp_test.c create mode 100644 code/sdk/zhihui/ppp/example/ppp_tcp_test_main.c create mode 100644 code/sdk/zhihui/ppp/include/ppp_tcp_lwip_compat.h create mode 100644 code/sdk/zhihui/ppp/include/ppp_tcp_test.h diff --git a/code/sdk/zhihui/ppp/CMakeLists.txt b/code/sdk/zhihui/ppp/CMakeLists.txt index 739a9f9fd..4e83333a7 100644 --- a/code/sdk/zhihui/ppp/CMakeLists.txt +++ b/code/sdk/zhihui/ppp/CMakeLists.txt @@ -10,6 +10,7 @@ set(PPP_AT_CMD_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/example/ppp_example.c # ${CMAKE_CURRENT_SOURCE_DIR}/example/ppp_power_example.c ${CMAKE_CURRENT_SOURCE_DIR}/example/api_shell.c + ${CMAKE_CURRENT_SOURCE_DIR}/example/ppp_tcp_test.c ) # 源文件列表 set(SOURCES @@ -76,6 +77,7 @@ set(PUBLIC_DEFINES # PPP_OPTIONS=1 SUPPORT_PPP_SERVICE SUPPORT_AT_PPP + SUPPORT_TCP_TEST ) set(PRIVATE_DEFINES diff --git a/code/sdk/zhihui/ppp/example/Makefile b/code/sdk/zhihui/ppp/example/Makefile new file mode 100644 index 000000000..208b52e11 --- /dev/null +++ b/code/sdk/zhihui/ppp/example/Makefile @@ -0,0 +1,83 @@ +# Makefile for PPP TCP Test Client +# 基于Python版本tcp_test_client.py实现的C语言版本 + +# 编译器设置 +CC = gcc +CFLAGS = -Wall -Wextra -std=c99 -O2 -g +LDFLAGS = -pthread + +# 目录设置 +SRC_DIR = . +INC_DIR = ../include +BUILD_DIR = build + +# 目标程序 +TARGET = ppp_tcp_test + +# 源文件 +SRCS = ppp_tcp_test.c ppp_tcp_test_main.c + +# 目标文件 +OBJS = $(SRCS:%.c=$(BUILD_DIR)/%.o) + +# 头文件依赖 +INCLUDES = -I$(INC_DIR) -I. + +# 默认目标 +all: $(BUILD_DIR)/$(TARGET) + +# 创建构建目录 +$(BUILD_DIR): + mkdir -p $(BUILD_DIR) + +# 编译目标程序 +$(BUILD_DIR)/$(TARGET): $(BUILD_DIR) $(OBJS) + $(CC) $(OBJS) -o $@ $(LDFLAGS) + @echo "Build complete: $@" + +# 编译源文件 +$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c + $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ + +# 清理 +clean: + rm -rf $(BUILD_DIR) + +# 安装 +install: $(BUILD_DIR)/$(TARGET) + cp $(BUILD_DIR)/$(TARGET) /usr/local/bin/$(TARGET) + @echo "Installed to /usr/local/bin/$(TARGET)" + +# 卸载 +uninstall: + rm -f /usr/local/bin/$(TARGET) + @echo "Uninstalled $(TARGET)" + +# 测试运行 +test: $(BUILD_DIR)/$(TARGET) + @echo "Running basic test..." + $(BUILD_DIR)/$(TARGET) --help + +# 示例运行 +example: $(BUILD_DIR)/$(TARGET) + @echo "Running example test (需要服务器支持)..." + $(BUILD_DIR)/$(TARGET) --host 127.0.0.1 --port 8910 --connections 2 --time 10 --verbose + +# 显示帮助 +help: + @echo "Available targets:" + @echo " all - Build the TCP test client" + @echo " clean - Remove build files" + @echo " install - Install to /usr/local/bin" + @echo " uninstall - Remove from /usr/local/bin" + @echo " test - Run basic functionality test" + @echo " example - Run example test (needs server)" + @echo " help - Show this help" + @echo "" + @echo "Usage examples:" + @echo " make" + @echo " make test" + @echo " make example" + @echo " ./build/$(TARGET) --host 192.168.1.100 --port 8080 --connections 5 --time 30" + +.PHONY: all clean install uninstall test example help \ No newline at end of file diff --git a/code/sdk/zhihui/ppp/example/README_TCP_TEST.md b/code/sdk/zhihui/ppp/example/README_TCP_TEST.md new file mode 100644 index 000000000..0519ecba6 --- /dev/null +++ b/code/sdk/zhihui/ppp/example/README_TCP_TEST.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/code/sdk/zhihui/ppp/example/ppp_at_cmd.c b/code/sdk/zhihui/ppp/example/ppp_at_cmd.c index eb178ea9b..f34636a41 100644 --- a/code/sdk/zhihui/ppp/example/ppp_at_cmd.c +++ b/code/sdk/zhihui/ppp/example/ppp_at_cmd.c @@ -13,6 +13,7 @@ #include "ppp_api.h" #include "ppp_at_handler.h" #include "ppp_debug_manager.h" +#include "ppp_tcp_test.h" #include "ppp_example.h" @@ -1714,6 +1715,199 @@ static errcode_t at_ppp_debug_reset_level(uint8_t *para, uint32_t paraLen) } } +/** + * @brief AT^PPPTCPPERF - PPP TCP性能测试 + * @param para 参数: 服务器地址,端口,连接数,测试时间 + * @param paraLen 参数长度 + */ +static errcode_t at_ppp_tcp_performance_test(uint8_t *para, uint32_t paraLen) +{ + if (!para || paraLen == 0) { + PRINT("[PPP_ERR]PPP TCP PERF: Missing parameters\r\n"); + PRINT("[PPP_INFO]Usage: AT^PPPTCPPERF=,,,