{"id":234874,"date":"2022-02-03T08:21:46","date_gmt":"2022-02-03T00:21:46","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=234874"},"modified":"2022-01-25T22:22:53","modified_gmt":"2022-01-25T14:22:53","slug":"linux-tcp-test","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-tcp-test.html","title":{"rendered":"Linux\u4e0b\u7684TCP\u6d4b\u8bd5\u5de5\u5177"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | tcpping\u4f5c\u4e3a shell \u811a\u672c\u5b9e\u73b0\uff0c\u8be5\u811a\u672c\u54cd\u5e94\u5916\u90e8\u5de5\u5177\u6765\u6267\u884c\u548c\u62a5\u544a RTT \u6d4b\u91cf\u3002\u56e0\u6b64\uff0c\u4e3a\u4e86\u5b89\u88c5tcpping\uff0c\u4f60\u9996\u5148\u9700\u8981\u5148\u5b89\u88c5\u8fd9\u4e9b\u5148\u51b3\u6761\u4ef6\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n <\/p>\n \u5982\u4f55\u5728 Linux \u4e0a\u5b89\u88c5 tcpping<\/strong><\/div>\n \u6d4b\u91cf\u5230\u8fdc\u7a0b\u4e3b\u673a\u7684\u7f51\u7edc\u5ef6\u8fdf\u7684\u4e00\u79cd\u5e38\u7528\u65b9\u6cd5\u662f\u4f7f\u7528ping\u5e94\u7528\u7a0b\u5e8f\u3002\u8be5ping\u5de5\u5177\u4f9d\u8d56 ICMP ECHO \u8bf7\u6c42\u548c\u56de\u590d\u6570\u636e\u5305\u6765\u6d4b\u91cf\u8fdc\u7a0b\u4e3b\u673a\u7684\u5f80\u8fd4\u5ef6\u8fdf\u3002\u4f46\u662f\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0cICMP \u6d41\u91cf\u53ef\u80fd\u4f1a\u88ab\u9632\u706b\u5899\u963b\u6b62\uff0c\u8fd9\u4f7f\u5f97\u8be5ping\u5e94\u7528\u7a0b\u5e8f\u5bf9\u4e8e\u53d7\u9650\u5236\u7684\u9632\u706b\u5899\u540e\u9762\u7684\u4e3b\u673a\u6beb\u65e0\u7528\u5904\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u5c06\u9700\u8981\u4f9d\u8d56\u4f7f\u7528 TCP\/UDP \u6570\u636e\u5305\u7684\u7b2c 3 \u5c42\u6d4b\u91cf\u5de5\u5177\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u7b2c 3 \u5c42\u6570\u636e\u5305\u66f4\u6709\u53ef\u80fd\u7ed5\u8fc7\u5e38\u89c1\u7684\u9632\u706b\u5899\u89c4\u5219\u3002<\/p>\n \u4e00\u79cd\u8fd9\u6837\u7684\u7b2c 3 \u5c42\u6d4b\u91cf\u5de5\u5177\u662ftcpping. \u4e3a\u4e86\u6d4b\u91cf\u5ef6\u8fdf\uff0ctcpping\u5229\u7528\u6240\u8c13\u7684\u534a\u5f00\u653e\u8fde\u63a5\u6280\u672f\uff0c\u57fa\u4e8e TCP \u4e09\u8def\u63e1\u624b\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u5b83\u901a\u8fc7\u7aef\u53e3\u53f7\uff08\u9ed8\u8ba4\u4e3a 80\uff09\u5411\u8fdc\u7a0b\u4e3b\u673a\u53d1\u9001 TCP SYN \u6570\u636e\u5305\u3002\u5982\u679c\u8fdc\u7a0b\u4e3b\u673a\u6b63\u5728\u4fa6\u542c\u8be5\u7aef\u53e3\uff0c\u5b83\u5c06\u4ee5 TCP ACK \u6570\u636e\u5305\u54cd\u5e94\u3002\u5426\u5219\uff0c\u5b83\u5c06\u4ee5 TCP RST \u6570\u636e\u5305\u54cd\u5e94\u3002\u65e0\u8bba\u54ea\u79cd\u65b9\u5f0f\uff0ctcpping\u90fd\u53ef\u4ee5\u901a\u8fc7\u5b9a\u65f6\u4f20\u51fa SYN \u6570\u636e\u5305\u548c\u4f20\u5165 ACK\uff08\u6216 RST\uff09\u6570\u636e\u5305\u6765\u6d4b\u91cf\u8fdc\u7a0b\u4e3b\u673a\u7684\u5f80\u8fd4\u65f6\u95f4 (RTT) \u5ef6\u8fdf\u3002<\/p>\n \u5728 Linux \u4e0a\u5b89\u88c5tcpping<\/strong><\/div>\n tcpping\u4f5c\u4e3a shell \u811a\u672c\u5b9e\u73b0\uff0c\u8be5\u811a\u672c\u54cd\u5e94\u5916\u90e8\u5de5\u5177\u6765\u6267\u884c\u548c\u62a5\u544a RTT \u6d4b\u91cf\u3002\u56e0\u6b64\uff0c\u4e3a\u4e86\u5b89\u88c5tcpping\uff0c\u4f60\u9996\u5148\u9700\u8981\u5148\u5b89\u88c5\u8fd9\u4e9b\u5148\u51b3\u6761\u4ef6\u3002<\/p>\n \u5b89\u88c5\u4f9d\u8d56 tcptraceroute<\/strong><\/span><\/div>\n \u8981\u5728 Ubuntu \u6216 Debian \u4e0a\u5b89\u88c5tcptraceroute\uff1a<\/p>\n \r\n$ sudo apt-get install tcptraceroute\r\n<\/pre>\n |