{"id":12122,"date":"2024-11-25T15:06:30","date_gmt":"2024-11-25T23:06:30","guid":{"rendered":"https:\/\/www.xh86.me\/?p=12122"},"modified":"2024-11-25T15:06:30","modified_gmt":"2024-11-25T23:06:30","slug":"%e5%9c%a8-linux-%e7%b3%bb%e7%bb%9f%e4%b8%8b%ef%bc%8c%e6%89%93%e5%bc%80%e5%92%8c%e9%85%8d%e7%bd%ae-tcp-%e5%a4%9a%e8%b7%af%e5%be%84%e4%bc%a0%e8%be%93","status":"publish","type":"post","link":"https:\/\/www.xh86.me\/?p=12122","title":{"rendered":"\u5728 Linux \u7cfb\u7edf\u4e0b\uff0c\u6253\u5f00\u548c\u914d\u7f6e TCP \u591a\u8def\u5f84\u4f20\u8f93"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>\u5728 Linux \u7cfb\u7edf\u4e0b\uff0c\u6253\u5f00\u548c\u914d\u7f6e TCP \u591a\u8def\u5f84\u4f20\u8f93\uff08Multipath TCP, MPTCP\uff09\u901a\u5e38\u6d89\u53ca\u4ee5\u4e0b\u51e0\u4e2a\u6b65\u9aa4\u3002MPTCP \u662f\u4e00\u79cd\u6269\u5c55\u7684 TCP \u534f\u8bae\uff0c\u5b83\u5141\u8bb8\u5728\u591a\u4e2a\u8def\u5f84\u4e4b\u95f4\u5206\u53d1\u6d41\u91cf\uff0c\u4ece\u800c\u63d0\u9ad8\u5e26\u5bbd\u5229\u7528\u7387\u548c\u8fde\u63a5\u5197\u4f59\u3002<\/p>\n<hr \/>\n<h3>1. <strong>\u786e\u8ba4\u5185\u6838\u652f\u6301 MPTCP<\/strong><\/h3>\n<p>MPTCP \u529f\u80fd\u9700\u8981 Linux \u5185\u6838\u652f\u6301\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u5e76\u975e\u6240\u6709 Linux \u53d1\u884c\u7248\u90fd\u5185\u7f6e MPTCP \u652f\u6301\u3002<\/p>\n<h4>\u68c0\u67e5\u5185\u6838\u7248\u672c<\/h4>\n<p>MPTCP \u652f\u6301\u4ece Linux \u5185\u6838 5.6 \u5f00\u59cb\u9010\u6b65\u5f15\u5165\uff0c\u5e76\u5728\u540e\u7eed\u7248\u672c\u4e2d\u66f4\u6210\u719f\u3002<\/p>\n<pre><code class=\"language-bash\">uname -r\r\n<\/code><\/pre>\n<p>\u786e\u8ba4\u5185\u6838\u7248\u672c\u662f\u5426\u4e3a 5.6 \u6216\u66f4\u9ad8\u7248\u672c\u3002<\/p>\n<h4>\u68c0\u67e5 MPTCP \u6a21\u5757<\/h4>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u68c0\u67e5\u5185\u6838\u662f\u5426\u542f\u7528\u4e86 MPTCP\uff1a<\/p>\n<pre><code class=\"language-bash\">sysctl net.mptcp.enabled\r\n<\/code><\/pre>\n<p>\u5982\u679c\u8fd4\u56de <code>net.mptcp.enabled = 1<\/code>\uff0c\u5219 MPTCP \u5df2\u542f\u7528\u3002<\/p>\n<hr \/>\n<h3>2. <strong>\u542f\u7528 MPTCP<\/strong><\/h3>\n<p>\u5982\u679c MPTCP \u672a\u542f\u7528\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u542f\u7528\uff1a<\/p>\n<h4>\u4fee\u6539\u5185\u6838\u53c2\u6570<\/h4>\n<p>\u7f16\u8f91 <code>\/etc\/sysctl.conf<\/code> \u6587\u4ef6\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u884c\uff1a<\/p>\n<pre><code class=\"language-bash\">net.mptcp.enabled = 1\r\n<\/code><\/pre>\n<p>\u7136\u540e\u4f7f\u914d\u7f6e\u751f\u6548\uff1a<\/p>\n<pre><code class=\"language-bash\">sysctl -p\r\n<\/code><\/pre>\n<hr \/>\n<h3>3. <strong>\u5b89\u88c5\u652f\u6301 MPTCP \u7684\u5de5\u5177<\/strong><\/h3>\n<p>\u60a8\u53ef\u80fd\u9700\u8981\u5b89\u88c5\u4e00\u4e9b\u7528\u6237\u7a7a\u95f4\u5de5\u5177\u6765\u7ba1\u7406 MPTCP\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-bash\">sudo apt update\r\nsudo apt install mptcp-tools\r\n<\/code><\/pre>\n<h4>\u68c0\u67e5 MPTCP \u652f\u6301\u72b6\u6001<\/h4>\n<p>\u901a\u8fc7 <code>mptcpize<\/code> \u6216\u5176\u4ed6\u5de5\u5177\u6765\u9a8c\u8bc1 MPTCP \u662f\u5426\u5de5\u4f5c\uff1a<\/p>\n<pre><code class=\"language-bash\">mptcpize --version\r\n<\/code><\/pre>\n<hr \/>\n<h3>4. <strong>\u914d\u7f6e MPTCP \u7ed1\u5b9a\u63a5\u53e3<\/strong><\/h3>\n<p>MPTCP \u53ef\u4ee5\u901a\u8fc7\u591a\u8def\u5f84\u7ed1\u5b9a\u591a\u4e2a\u7f51\u7edc\u63a5\u53e3\u3002\u914d\u7f6e\u63a5\u53e3\u7ed1\u5b9a\u5982\u4e0b\uff1a<\/p>\n<h4>\u914d\u7f6e\u8def\u7531\u8868<\/h4>\n<p>\u786e\u4fdd\u591a\u4e2a\u7f51\u7edc\u63a5\u53e3\uff08\u5982 eth0 \u548c wlan0\uff09\u5df2\u6b63\u786e\u914d\u7f6e IP \u5730\u5740\u3002\u4f7f\u7528 <code>ip<\/code> \u547d\u4ee4\u914d\u7f6e\uff1a<\/p>\n<pre><code class=\"language-bash\">ip addr add 192.168.1.100\/24 dev eth0\r\nip addr add 192.168.2.100\/24 dev wlan0\r\n<\/code><\/pre>\n<h4>\u914d\u7f6e\u7b56\u7565\u8def\u7531<\/h4>\n<p>\u4e3a\u6bcf\u4e2a\u63a5\u53e3\u6dfb\u52a0\u8def\u7531\u89c4\u5219\uff1a<\/p>\n<pre><code class=\"language-bash\">ip rule add from 192.168.1.100 table 1\r\nip route add default via 192.168.1.1 dev eth0 table 1\r\n\r\nip rule add from 192.168.2.100 table 2\r\nip route add default via 192.168.2.1 dev wlan0 table 2\r\n<\/code><\/pre>\n<hr \/>\n<h3>5. <strong>\u8fd0\u884c\u652f\u6301 MPTCP \u7684\u5e94\u7528<\/strong><\/h3>\n<p>\u786e\u4fdd\u5e94\u7528\u7a0b\u5e8f\u4f7f\u7528 MPTCP \u534f\u8bae\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528 <code>mptcpize<\/code> \u8fd0\u884c\u7a0b\u5e8f\uff1a\n<pre><code class=\"language-bash\">mptcpize -f &lt;application&gt;\r\n<\/code><\/pre>\n<\/li>\n<li>\u4f7f\u7528 netcat \u6d4b\u8bd5\u591a\u8def\u5f84\u4f20\u8f93\uff1a\n<pre><code class=\"language-bash\">nc -l -p 12345\r\n<\/code><\/pre>\n<\/li>\n<\/ul>\n<hr \/>\n<h3>6. <strong>\u9a8c\u8bc1 MPTCP \u662f\u5426\u5de5\u4f5c<\/strong><\/h3>\n<p>\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u786e\u8ba4 MPTCP \u662f\u5426\u6210\u529f\u4f7f\u7528\uff1a<\/p>\n<h4>\u68c0\u67e5\u8fde\u63a5\u72b6\u6001<\/h4>\n<p>\u4f7f\u7528 <code>ss<\/code> \u6216 <code>netstat<\/code> \u68c0\u67e5\u5f53\u524d\u8fde\u63a5\u662f\u5426\u542f\u7528\u4e86 MPTCP\uff1a<\/p>\n<pre><code class=\"language-bash\">ss -M\r\n<\/code><\/pre>\n<p>\u8f93\u51fa\u4e2d\u5e94\u5305\u542b <code>mptcp<\/code>\u3002<\/p>\n<h4>\u6d4b\u8bd5\u591a\u8def\u5f84\u4f20\u8f93<\/h4>\n<p>\u53ef\u4ee5\u901a\u8fc7\u65ad\u5f00\u4e00\u4e2a\u7f51\u7edc\u63a5\u53e3\u6765\u6d4b\u8bd5\u591a\u8def\u5f84\u7684\u5bb9\u9519\u6027\u548c\u5207\u6362\u80fd\u529b\u3002<\/p>\n<hr \/>\n<p>\u901a\u8fc7\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u60a8\u53ef\u4ee5\u5728 Linux \u7cfb\u7edf\u4e0b\u6210\u529f\u6253\u5f00\u548c\u4f7f\u7528 MPTCP\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u4e0d\u662f\u6240\u6709\u5e94\u7528\u7a0b\u5e8f\u90fd\u9ed8\u8ba4\u652f\u6301 MPTCP\uff0c\u56e0\u6b64\u5728\u6d4b\u8bd5\u6216\u90e8\u7f72\u4e2d\u9700\u8981\u7279\u522b\u5173\u6ce8\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; \u5728 Linux \u7cfb\u7edf\u4e0b\uff0c\u6253\u5f00\u548c\u914d\u7f6e TCP \u591a\u8def\u5f84\u4f20\u8f93\uff08Multipath TCP, MPTCP [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,3],"tags":[],"class_list":["post-12122","post","type-post","status-publish","format-standard","hentry","category-linux","category-system"],"_links":{"self":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/12122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12122"}],"version-history":[{"count":1,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/12122\/revisions"}],"predecessor-version":[{"id":12123,"href":"https:\/\/www.xh86.me\/index.php?rest_route=\/wp\/v2\/posts\/12122\/revisions\/12123"}],"wp:attachment":[{"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xh86.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}