主题
TCPing 和 iPerf3 工具使用
- TCPing 可以同时测试 IP 地址和端口的连通性,这对于分析端口状态及网络服务运行状况非常有帮助。
- iPerf3是用于主动测试IP网络上最大可用带宽的工具。它支持时序、缓冲区、协议(TCP,UDP,SCTP与IPv4和IPv6)有关的各种参数。对于每次测试,它都会详细的带宽报告,延迟抖动和数据包丢失。
一、TCPing 工具使用
1.1 Linux 下安装方法
- 安装依赖,这里用到的是tcptraceroute和bc
yum install -y tcptraceroute bc
# openeuler系统 用这个
apt-get install -y tcptraceroute bc
# Debian/Ubuntu系统 用这个
- 下载TCPing到/usr/bin目录
wget https://raw.githubusercontent.com/sunpma/cdn/master/other/tcping -O /usr/bin/tcping
- 赋予TCPing工具执行权限
chmod +x /usr/bin/tcping
1.2 windows 下安装方法
- 将tcping.exe程序复制到c:\windows\system32目录下
1.3 tcping 基本使用
- 测试端口连通性
tcping baidu.com 80 # 测试 example.com 的 80 端口
tcping 192.168.1.1 443 # 测试本地 IP 的 443 端口
- 常用参数
参数 | 说明 | 示例 |
---|---|---|
-n 5 | 指定测试次数 | tcping -n 5 google.com 80 |
-i 1 | 设置请求间隔(秒) | tcping -i 1 example.com 443 |
-t 5 | 设置超时时间(秒) | tcping -t 5 192.168.1.1 22 |
-6 | 使用 IPv6 地址 | tcping -6 ipv6.google.com 80 |
-d | 显示时间戳 | tcping -d example.com 80 |
- 批量测试端口
结合脚本测试多个端口:
for port in {80,443,22}; do
tcping example.com $port -n 3
done
- 保存结果到文件
tcping example.com 80 -n 5 | tee tcping.log
二、iPerf3工具使用
2.1 安装方法
- Windows
bash
https://files.budman.pw
https://github.com/ar51an/iperf3-win-builds
- macOS
bash
brew install iperf3
- Ubuntu / Debian / Mint
bash
sudo apt-get install iperf3
- Fedora Fedora / Red Hat / CentOS / Rocky/openeuler
bash
yum install iperf3
2.2 使用方法
- 服务端运行
iperf3 -s -p 18888
- 客户端运行
iperf3 -c 172.22.33.220 -p 18888
- 运行在客户端,反向测试(服务器端发送数据到客户端)
iperf3 -c 172.22.33.220 -R -p 18888