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