开源的 TCP 连接分析工具:tproxy

tproxy是一款开源的 TCP 连接分析工具。可用于监控网络连接,分析请求内容。基于Go语言编写,遵守MIT开源协议。分析请求内容包括: 分析 gRPC 连接何时连接、何时重连分析 MySQL 连接池,当前多少连接,连接的生命周期, 观察和分析任何 TCP 连接。
命令行工具安装:

$ GOPROXY=https://goproxy.cn/,direct go install github.com/kevwan/tproxy@latest

 

Windows:

$ scoop install tproxy

用法

$ tproxy --help
Usage of tproxy:
  -d duration
        the delay to relay packets
  -l string
        Local address to listen on (default "localhost")
  -p int
        Local port to listen on, default to pick a random port
  -q    Quiet mode, only prints connection open/close and stats, default false
  -r string
        Remote address (host:port) to connect
  -s    Enable statistics
  -t string
        The type of protocol, currently support grpc

源码:
https://github.com/kevwan/tproxy

--------------------------------------------

分布式压力测试工具tcpcopy

tcpcopy是一款开源的分布式在线压力测试工具,可以将线上流量拷贝到测试机器,实时的模拟线上环境,测试实时承担线上流量的效果,提前发现bug,增加上线信心。通过对比试验,同样请求,针对不同或不同版本程序,可以做性能对比试验。   tcpcopy原理为请求复制基于 TCP 的 packets ,通过复制在线数据包,修改 TCP/IP 头部信息,发送给测试服务器,达到欺骗测试服务器的TCP 程序的目的。tcpcopy运行需要intercept的支持,tcpcopy负责抓包和发包工作,而intercept负责截获应答包。

tcpcopy代码下载地址:

http://github.com/session-replay-tools/tcpcopy
http://github.com/session-replay-tools/intercept

------------------------------------------------------------

HTTP负载测试工具-ali

ali,一款基于 Go 编写的 HTTP 负载测试工具,遵守MIT开源协议。ali可在命令行中实时展示指定 URL 的延迟、速率限制、加载时间、表头信息等内容。

使用:

ali http://host.xz

替代 http://host.xz 为测试网址.之后将模拟攻击。 (rate=50, duration=10s).
选项:

ali -h
使用:
  ali [flags] <target URL>

其他:
  -b, --body string                发送 body .
  -c, --connections int            最大空闲连接量(default 10000)
      --debug                      debug 模式.
  -d, --duration duration          发起的时间量,0s无限攻击 (default 10s)
  -H, --header stringArray         发送header.
      --insecure                   跳过TLS验证
      --local-addr string          本机 IP 地址. (default "0.0.0.0")
  -M, --max-body int               Max bytes to capture from response bodies. Give -1 for no limit. (default -1)
  -K, --no-keepalive               不使用HTTP持续连接.
      --query-range duration       显示阶段时间的测试结果 (default 30s)
  -r, --rate int                   每秒的攻击频率 (default 50)
      --redraw-interval duration   空档刷新表格率(default 250ms)
      --resolvers string           自定义DNS 解析; 逗号分隔.
  -t, --timeout duration           超时设置. 设置0s 不超时. (default 30s)
  -v, --version                    显示版本.

举例:
  ali --duration=10m --rate=100 http://host.xz

https://github.com/nakabonne/ali