【查看WIFI日志】
sudo grep -i wpa_supplicant /var/log/syslog — 查看有没有断连的情况
例如 wlan0: CTRL-EVENT-DISCONNECTED bssid=2c:52:af:a3:36:31 reason=3 locally_generated=1, CTRL-EVENT-DISCONNECTED表示有断连。
【WIFI压测工具】
【安装】
sudo apt install iperf
【运行】
在服务器上运行 iperf
在服务器上打开终端,并执行以下命令以启动 iperf 服务器:
iperf -s
这将启动 iperf 服务器,监听默认端口(5001)等待客户端连接。
确认服务器已成功启动,并等待客户端连接。
在客户端上运行 iperf
在另一台设备上打开终端,并执行以下命令连接到服务器进行测试:
iperf -c server_ip_address
将 server_ip_address 替换为你服务器的实际 IP 地址或主机名。
iperf 将连接到服务器并开始测试。默认情况下,它将使用 TCP 连接并在双向传输 10 秒钟的数据。测试结束后,将显示包含吞吐量和其他性能指标的结果。
【可选项】
指定测试时长:使用 -t 参数指定测试持续时间,例如 -t 30 表示测试运行 30 秒。
使用 UDP 进行测试:通过 -u 参数启用 UDP 测试模式。
调整并发连接数:使用 -P 参数指定并发连接数,例如 -P 5 表示使用 5 个并发连接进行测试。
【结果 - 客户端】
Client connecting to 192.168.112.221, TCP port 5001
TCP window size: 320 KByte (default)
[ 3] local 192.168.112.248 port 45268 connected with 192.168.112.221 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 1.09 GBytes 934 Mbits/sec
Client 连接信息:
Client IP 地址:192.168.112.248
Client 端口:45268
Server IP 地址:192.168.112.221
Server 端口:5001
测试持续时间:10.0 秒
总传输量:1.09 GBytes (1090 MBytes)
带宽:934 Mbits/sec(约合934 Mbps)
【结果 - 服务器】
Server listening on TCP port 5001
TCP window size: 128 KByte (default)
[ 4] local 192.168.112.221 port 5001 connected with 192.168.112.248 port 45268
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-10.0 sec 1.09 GBytes 933 Mbits/sec
【修改内核的日志等级】
在用串口控制台的时候总是输出一些信息,严重影响正常的操作,用下面这个指令能暂时关闭日志打印
sudo sysctl kernel.printk="3 4 1 3"
【自启动】
linux下想设置一些脚本自启动,除了改rcS外还有其他方法
使用 systemd
创建 myapp.service
写入
[Unit]
Description=My Application
After=network.target
[Service]
Type=simple
ExecStart=/path/to/your/script_or_executable
[Install]
WantedBy=multi-user.target
Description:服务的描述
After:定义服务启动的顺序,可以根据需要调整
ExecStart:指定要执行的脚本或可执行文件的路径
WantedBy:定义服务启动的目标,默认为 multi-user.target
文件需要保存到/etc/systemd/system/myapp.service
启用服务
sudo systemctl enable myapp.service
sudo systemctl start myapp.service
多个自启动脚本顺序启动
假设有 service-a, service-b, service-c, service-d。
a
[Unit]
Description=Service A
After=network.target
[Service]
Type=simple
ExecStart=/path/to/script-a
[Install]
WantedBy=multi-user.target
b
[Unit]
Description=Service B
After=service-a.service
Requires=service-a.service
[Service]
Type=simple
ExecStart=/path/to/script-b
[Install]
WantedBy=multi-user.target
c
[Unit]
Description=Service C
After=service-b.service
Requires=service-b.service
[Service]
Type=simple
ExecStart=/path/to/script-c
[Install]
WantedBy=multi-user.target
d
[Unit]
Description=Service D
After=service-c.service
Requires=service-c.service
[Service]
Type=simple
ExecStart=/path/to/script-d
[Install]
WantedBy=multi-user.target
Requires=service-c.service这个选项是 依赖
【linux指令】
在普通用户状态下用echo导出IO 提示没有权限,可以使用sudo bash -c 'echo 36 > /sys/class/gpio/export'
指令解决权限问题