echoping
v0.3.0
一个 golang 网络实用程序,使用 TCP/UDP-Datagram/QUIC 消息来检测网络稳定性。
在现实生活中检测网络问题是很困难的。
echoping
使用 TCP 和 UDP(数据报或 QUIC)协议代替传统ping
使用的 ICMP,并且发送消息更频繁。
echoping
工作方式更像是一个真实的网络应用程序,并像真实的问题一样报告网络问题。
./echoping -listen IP:PORT
启动echoping
服务器echoping
客户端以使用echoping
服务器: ./echoping -connect SERVER_IP:SERVER_PORT
echoping
客户端都会向服务器发送 TCP/UDP 数据报/QUIC 请求用法:
-connect string
Connect to 'tcp://ip:port/,udp://ip:port/,quic://ip:port/' (can be repeated, use comma as delimiter), or use 'ip:port' for all TCP/UDP/QUIC
-listen string
Listen both TCP and UDP on ip:port (UDP also works for QUIC)
-listen-tcp string
Listen TCP on ip:port
-listen-udp string
Listen UDP on ip:port (UDP also works for QUIC)
-loss-ratio string
The simulated UDP loss ratio on client side (must be used with "-connect"). "0.1"" means 10% packet loss, "0.1,0.2" means 0.1 for sending and 0.2 for receiving
-payload-size int
The payload size of ping request (default 1300)
-ping-interval duration
The interval between ping requests sent by client (default 20ms)
服务器输出:
2020/12/26 01:24:54 server stat udp:127.0.0.1:52032 (20201226-012449.458182): pps=10.0, tmperr=0
2020/12/26 01:24:54 server stat tcp:127.0.0.1:56524 (20201226-012449.458231): pps=10.0, tmperr=0
客户端输出:
2020/12/26 01:24:54 client stat udp:127.0.0.1:12345 (20201226-012449.458182): pps=11.0, recv=0.01MB/s, loss=0.0%, round-trip time (ms): avg=0.4, min=0.2, max=0.6, stddev=0.1
2020/12/26 01:24:54 client stat tcp:127.0.0.1:12345 (20201226-012449.458231): pps=11.0, recv=0.01MB/s, loss=0.0%, round-trip time (ms): avg=0.3, min=0.2, max=0.4, stddev=0.1
pps
表示“每秒 ping”loss
始终是0%(当然) ./echoping -listen :12345 -connect 127.0.0.1:12345
在 Linux 上模拟延迟和丢弃的数据包:https://stackoverflow.com/questions/614795/simulate-delayed-and-dropped-packets-on-linux