# device-simulator **Repository Path**: demonpolly/device-simulator ## Basic Information - **Project Name**: device-simulator - **Description**: 基于netty的设备模拟器,模拟设备消息收发,压力测试。 - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 98 - **Created**: 2023-04-16 - **Last Updated**: 2023-04-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 设备模拟器 运行前请先安装`java8`. ## 交互式CLI ```bash $ git clone https://github.com/jetlinks/device-simulator.git $ cd device-simulator $ ./run-cli.sh ``` ##交互式CLI ```bash $ git clone https://github.com/jetlinks/device-simulator.git $ cd device-simulator $ mvn clean package -DskipTests $ java \ -Dfile.encoding=UTF-8 \ -Xmx1G \ -Dsimulator.max-ports=50000 \ "-Dsimulator.network-interfaces=.*" \ -jar ${PWD}/simulator-cli/target/simulator-cli.jar ``` JVM参数说明: 1. `-Dsimulator.network-interfaces`: 指定可用的网卡,正则表达式. 如: eth0|eth1 2. `-Dsimulator.max-ports`: 指定可用的端口数量,默认为50000 ## DEMO ### MQTT 官方协议模拟 在项目根目录启动模拟器后执行命令: ```bash benchmark mqtt --size=5000 --name=mqtt --host=127.0.0.1 --port=1883 --script=benchmark/mqtt/benchmark.js ``` ### TCP 官方协议模拟 在项目根目录启动模拟器后执行命令: ```bash benchmark tcp --interface=192.168.31.239 --size=1 --id=1644914896550584320 --name=tcp --host=192.168.31.239 --port=8803 --script=benchmark/tcp/benchmark.js ``` ```bash benchmark tcp --size=1 --name=tcp --host=127.0.0.1 --port=8801 --script=benchmark/tcp/benchmark.js ``` ### HTTP 官方协议模拟 在项目根目录启动模拟器后执行命令: ```bash benchmark http --url http://192.168.31.239:8810 report=true reportLimit=1000 --size=1 --script=benchmark/http/benchmark.js ``` ### 常见问题 1. 连接提示`no further information ...`,请在启动或者创建连接时指定网卡信息 `benchmark --interface=192.168.31.239`