How to install tcpping on Linux

本文介绍了一种在ICMP流量被防火墙阻止时测量网络延迟的方法:利用名为tcpping的工具,它采用TCP半开连接技术来测量远程主机的响应时间。文章还提供了在Linux系统上安装和使用tcpping的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A common way to measure network latency to a remote host is by using ping utility which uses ICMP echo request and reply packets. In some cases, however, ICMP traffic is blocked by firewalls, which renders ping utility useless with hosts behind restrictive firewalls. In such case, you will need to rely on layer-3 measurement tools that use TCP/UDP packets since these layer-3 packets are more likely to bypass common firewall rules.

One such layer-3 measurement tool is tcpping. To measure latency, tcpping takes advantage of so-called half-open connection technique, based on TCP three-way handshake. That is, it sends a TCP SYN packet to a remote host on a port number (80 by default). If the remote host is listening on the port, it will respond with TCP ACK packet. Otherwise, it will respond with TCP RST packet. Either way, tcpping can measure round-trip-time (RTT) delay of a remote host, by timing outgoing SYN packet and incoming ACK (or RST) packet.

The same half-open connection technique is already implemented by tcptraceroute tool. So tcpping simply relies on tcptraceroute to perform latency measurement.

In order to install tcpping on Linux, you first need to install tcptraceroute, and then download tcpping script from the web.

To install tcptraceroute on Debian/Ubuntu:


$ sudo apt-get install tcptraceroute

To install tcptraceroute on CentOS/REHL, first set up RepoForge on your system, and then:

$ sudo yum install tcptraceroute

Finally, download tcpping from the web.

$ cd /usr/bin
$ sudo wget http://www.vdberg.org/~richard/tcpping
$ sudo chmod 755 tcpping

To measure network latency by using tcpping, simply run it as follows.

$ tcpping www.cnn.com
seq 0: tcp response from 157.166.240.13 [open] 82.544 ms
seq 1: tcp response from 157.166.241.10 [open] 80.771 ms
seq 2: tcp response from 157.166.241.11 [open] 80.838 ms
seq 3: tcp response from 157.166.241.10 [open] 80.145 ms
seq 4: tcp response from 157.166.240.11 [open] 86.253 ms

要在 Linux 上安装 Node.js 环境,可以根据你的需求选择合适的版本(稳定版或最新版)。以下是详细的分步指南: --- ### **方法一:通过包管理器安装** 这是最简单的方式之一,适合大多数用户。 #### 1. 更新系统的包索引 打开终端并输入以下命令: ```bash sudo apt update # 对于 Debian/Ubuntu 系统 # 或者 sudo yum check-update # 对于 CentOS/Fedora 系统 ``` #### 2. 安装 Node.js 和 npm 对于 Ubuntu/Debian 用户: ```bash sudo apt install nodejs npm ``` 对于 CentOS/Fedora 用户: ```bash sudo yum install epel-release sudo yum install nodejs npm ``` #### 3. 验证安装 检查 Node.js 和 npm 是否安装成功: ```bash node -v # 显示 Node.js 版本号 npm -v # 显示 npm 版本号 ``` 如果一切正常,你会看到对应的版本信息。 --- ### **方法二:从官方源安装特定版本** 如果你想安装指定的 Node.js 版本(比如 LTS 或最新版),推荐使用 [NodeSource](https://github.com/nodesource/distributions) 提供的脚本来配置官方仓库。 #### 1. 下载对应版本的设置脚本 运行以下命令下载最新的 Node.js 设置脚本: ```bash curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - # 替换 setup_lts.x 为具体的版本号,如 setup_18.x 表示 v18 的长期支持版本。 ``` #### 2. 安装 Node.js 继续执行安装命令: ```bash sudo apt install -y nodejs ``` 验证版本号是否正确: ```bash node -v npm -v ``` --- ### **方法三:手动编译安装** 如果你需要完全自定义的环境或者没有网络连接的情况,可以选择从源码编译安装。 #### 1. 准备依赖项 确保系统具备构建所需的工具链: ```bash sudo apt install build-essential libssl-dev ``` #### 2. 下载源码压缩包 访问 [Node.js 官方网站](https://nodejs.org/) 找到你需要的版本链接,然后下载: ```bash wget https://nodejs.org/dist/vXX.XX.XX/node-vXX.XX.XX-linux-x64.tar.gz tar xzf node-v*.tar.gz cd node-v* ``` #### 3. 编辑路径变量 复制解压后的目录至 `/usr/local/bin` 或其他全局可用位置,并添加 PATH 变量: ```bash sudo cp -r * /usr/local/ export PATH=$PATH:/usr/local/bin ``` 完成后测试一下节点服务状态即可! --- ### 小提示 为了方便切换不同版本的 Node.js ,还可以考虑利用工具 `nvm(Node Version Manager)` 实现多版本共存管理功能。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值