{"id":160581,"date":"2019-10-22T10:10:47","date_gmt":"2019-10-22T02:10:47","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=160581"},"modified":"2019-10-07T18:12:21","modified_gmt":"2019-10-07T10:12:21","slug":"linux-tcp-ip-protocol-stack","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-tcp-ip-protocol-stack.html","title":{"rendered":"Linux TCP\/IP\u534f\u8bae\u6808\u5168\u8fc7\u7a0b"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u53ef\u4ee5\u6beb\u4e0d\u5938\u5f20\u7684\u8bf4\u73b0\u5982\u4eca\u7684\u4e92\u8054\u7f51\u662f\u57fa\u4e8eTCP\/IP\u6784\u5efa\u8d77\u6765\u7684\u7f51\u7edc\u3002\u5f04\u61c2\u534f\u8bae\u6808\u7684\u539f\u7406\uff0c\u65e0\u8bba\u5bf9\u8c03\u8bd5\u7f51\u7edcIO\u6027\u80fd\u8fd8\u662f\u89e3\u51b3\u7f51\u7edc\u95ee\u9898\u90fd\u662f\u6709\u5f88\u5927\u5e2e\u52a9\u7684\u3002\u672c\u7247\u6587\u7ae0\u5c31\u5e26\u9886\u5927\u5bb6\u6765\u770b\u770b\u5185\u6838\u662f\u5982\u4f55\u63a7\u5236\u7f51\u7edc\u6570\u636e\u6d41\u7684\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

TCP\u7279\u70b9<\/strong><\/div>\n

\u6211\u4eec\u90fd\u975e\u5e38\u6e05\u695aTCP\u534f\u8bae\u8bbe\u8ba1\u7684\u521d\u8877\uff0c\u5c31\u662f\u4fdd\u8bc1\u6570\u636e\u4f20\u8f93\u7684\u5feb\u901f\uff0c\u6709\u5e8f\uff0c\u65e0\u8bef\u3002\u6240\u4ee5\u7279\u70b9\u603b\u7ed3\u5982\u4e0b\uff1a<\/p>\n

    \n<\/ul>\n
      \n1\u3001\u9762\u5411\u8fde\u63a5\uff0c\u53ef\u4ee5\u7528\u4e94\u5143\u7ec4\u6765\u8868\u793a\u4e00\u6761\u8fde\u63a5(\u8fdc\u7a0bip\uff0c\u8fdc\u7a0b\u7aef\u53e3\uff0c\u672c\u5730ip\uff0c\u672c\u5730\u7aef\u53e3\uff0c\u4f20\u8f93\u5c42\u534f\u8bae)\u3002
      \n2\u3001\u6570\u636e\u662f\u5168\u53cc\u5de5\u7684
      \n3\u3001\u6570\u636e\u662f\u6709\u5e8f\u7684\uff0c\u4e5f\u5c31\u662f\u63a5\u53d7\u7684\u6570\u636e\u4e00\u5b9a\u662f\u6309\u7167\u53d1\u9001\u65f6\u7684\u987a\u5e8f\u7684\u3002
      \n4\u3001\u6d41\u91cf\u63a7\u5236\uff0c\u53d1\u9001\u65b9\u53ef\u4ee5\u901a\u8fc7\u63a5\u6536\u65b9\u6ed1\u52a8\u7a97\u53e3\u5927\u5c0f\u6765\u52a8\u6001\u8c03\u6574\u53d1\u9001\u6570\u636e\u7684\u5927\u5c0f\u3002
      \n5\u3001\u62e5\u585e\u63a7\u5236\uff0c\u53d1\u9001\u65b9\u901a\u8fc7ACK\u7684\u72b6\u6001\u7ed3\u5408\u62e5\u585e\u7b97\u6cd5\u7efc\u5408\u8ba1\u7b97\u7ed9\u51fa\u7a97\u53e3\u5927\u5c0f\u3002\n<\/ul>\n

      \u4e86\u89e3\u5b8cTCP\u7279\u70b9\u5b57\u540e\uff0c\u6211\u4eec\u5c31\u6765\u771f\u6b63\u7684\u770b\u770b\u6570\u636e\u53d1\u9001\u5230\u5e95\u662f\u600e\u6837\u7684\u8fc7\u7a0b?<\/p>\n

      \u6570\u636e\u53d1\u9001<\/strong><\/div>\n

      \u6211\u4eec\u9996\u5148\u6765\u770b\u5f20\u56fe\uff1a
      \n\"\"
      \n\u4e0a\u56fe\u5c55\u793a\u7684\u662f\u6570\u636e\u6d41\u52a8\u7684\u5728\u786c\u4ef6\u4e2d\u7684\u8fc7\u7a0b\uff0c\u4e0b\u56fe\u5c55\u793a\u7684\u662f\u6570\u636e\u5728\u534f\u8bae\u6808\u7684\u8fc7\u7a0b\uff1a
      \n\"\"
      \n\u6574\u4e2a\u8fc7\u7a0b\u5206\u4e3a\u4e09\u4e2a\u5927\u533a\u57df\uff1a\u7528\u6237\u533a\uff0c\u5185\u6838\u533a\uff0c\u8bbe\u5907\u3002\u8fd9\u91cc\u6240\u8bf4\u7684\u8bbe\u5907\u5c31\u662f\u7f51\u5361\u3002\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n

        \n1\u3001\u7528\u6237\u5e94\u7528\u7a0b\u5e8f\u8c03\u7528write\u7cfb\u7edf\u8c03\u7528
        \n2\u3001\u786e\u8ba4\u6587\u4ef6\u63cf\u8ff0\u7b26
        \n3\u3001\u62f7\u8d1d\u6570\u636e\u5230socket buffer\u4e2d
        \n4\u3001\u521b\u5efatcp\u7247\u6bb5\uff0c\u8ba1\u7b97checksum
        \n5\u3001\u6dfb\u52a0IP\u5934\uff0c\u6267\u884cip\u8def\u7531\uff0c\u8ba1\u7b97checksum
        \n6\u3001\u6dfb\u52a0\u4ee5\u592a\u7f51\u534f\u8bae\u5934\u90e8\uff0c\u6267\u884cARP
        \n7\u3001\u544a\u8bc9\u7f51\u5361\u82af\u7247\u8981\u53d1\u9001\u6570\u636e\u4e86
        \n8\u3001\u7f51\u5361\u4ece\u5185\u5b58\u4e2d\u83b7\u53d6\u6570\u636e\u53d1\u9001\uff0c\u53d1\u9001\u5b8c\u6210\u4e2d\u65ad\u544a\u8bc9CPU\n<\/ul>\n
        \u6570\u636e\u63a5\u6536<\/strong><\/div>\n

        \u76f4\u63a5\u770b\u786c\u4ef6\u6570\u636e\u6d41\u56fe\uff1a
        \n\"\"
        \n\u9996\u5148\u7f51\u5361\u628a\u63a5\u6536\u5230\u7684\u6570\u636e\u5305\u5199\u5165\u5230\u5b83\u7684\u5185\u5b58\u4e4b\u4e2d\u3002\u7136\u540e\u5bf9\u5176\u8fdb\u884c\u6821\u9a8c\uff0c\u901a\u8fc7\u540e\u53d1\u9001\u5230\u4e3b\u673a\u7684\u4e3b\u5b58\u4e4b\u4e2d\u3002\u4e3b\u5b58\u4e2d\u7684buffer\u662f\u9a71\u52a8\u5206\u914d\u597d\u7684\uff0c\u9a71\u52a8\u4f1a\u628a\u5206\u914d\u597d\u7684buffer\u63cf\u8ff0\u544a\u8bc9\u7f51\u5361\uff0c\u5982\u679c\u6ca1\u6709\u8db3\u591f\u7684buffer\u63a5\u53d7\u7f51\u5361\u7684\u6570\u636e\u5305\uff0c\u7f51\u5361\u4f1a\u5c06\u6570\u636e\u5305\u4e22\u5f03\u3002\u4e00\u65e6\u6570\u636e\u5305\u62f7\u8d1d\u5230\u4e3b\u5b58\u5b8c\u6210\uff0c\u7f51\u5361\u4f1a\u901a\u8fc7\u4e2d\u65ad\u544a\u77e5\u4e3b\u673aOS\u3002<\/p>\n

        \u4e4b\u540e\u9a71\u52a8\u4f1a\u68c0\u67e5\u5b83\u662f\u5426\u80fd\u5904\u7406\u8fd9\u4e2a\u65b0\u7684\u5305\u3002\u5982\u679c\u80fd\u5904\u7406\uff0c\u9a71\u52a8\u4f1a\u628a\u6570\u636e\u5305\u5305\u88c5\u6210OS\u8ba4\u8bc6\u7684\u7ed3\u6784(linux sk_buffer)\u5e76\u63a8\u9001\u5230\u4e0a\u5c42\u3002 \u94fe\u8def\u5c42\u63a5\u6536\u5230\u5e27\u540e\u68c0\u67e5\u901a\u8fc7\u7684\u8bdd\u4f1a\u6309\u7167\u534f\u8bae\u89e3\u5e27\u5e76\u63a8\u9001\u81f3IP\u5c42\u3002<\/p>\n

        IP\u5c42\u4f1a\u5728\u89e3\u5305\u4e4b\u540e\u6839\u636e\u5305\u4e2d\u5305\u542b\u7684IP\u4fe1\u606f\u51b3\u5b9a\u63a8\u9001\u81f3\u4e0a\u5c42\u8fd8\u662f\u8f6c\u53d1\u5230\u5176\u4ed6IP\u3002\u5982\u679c\u5224\u65ad\u9700\u8981\u63a8\u9001\u81f3\u4e0a\u5c42\uff0c\u5219\u4f1a\u89e3\u6389IP\u5305\u5934\u5e76\u63a8\u9001\u81f3TCP\u5c42\u3002<\/p>\n

        TCP\u5728\u89e3\u62a5\u4e4b\u540e\u4f1a\u6839\u636e\u5176\u56db\u5143\u7ec4\u627e\u5230\u5bf9\u5e94\u7684TCB\uff0c\u4e4b\u540e\u901a\u8fc7TCP\u534f\u8bae\u5904\u7406\u8fd9\u4e2a\u62a5\u6587\u3002\u5728\u63a5\u6536\u5230\u62a5\u6587\u540e\uff0c\u4f1a\u628a\u62a5\u6587\u52a0\u5230\u63a5\u53d7\u62a5\u6587\uff0c\u4e4b\u540e\u6839\u636eTCP\u7684\u72b6\u6001\u53d1\u9001\u4e00\u4e2aACK\u7ed9\u5bf9\u7aef\u3002<\/p>\n

        \u5f53\u7136\u4e0a\u8ff0\u8fc7\u7a0b\u4f1a\u53d7\u5230NAT\u7b49\u7b49Netfilter\u7684\u4f5c\u7528\uff0c\u8fd9\u91cc\u4e0d\u8c08\u4e86\uff0c\u4e5f\u6ca1\u6df1\u7814\u7a76\u8fc7\u3002\u5f53\u7136\u4e3a\u4e86\u6027\u80fd\uff0c\u5927\u725b\u4eec\u65b9\u65b9\u9762\u9762\u4e5f\u505a\u4e86\u5f88\u591a\u52aa\u529b\uff0c\u6bd4\u5982\u5927\u5230RDMA\u3001DPDK\u7b49\u5927\u7684\u8f6f\u786c\u4ef6\u6280\u672f\uff0c\u5c0f\u5230zero-copy\u3001checksum offload\u7b49;<\/p>\n

        \u603b\u7ed3<\/strong><\/div>\n

        \u73b0\u4ee3\u7684\u8f6f\u786c\u4ef6TCP\/IP\u534f\u8bae\u6808\u5355\u94fe\u63a5\u53d1\u9001\u901f\u7387\u52301~2GiB\/s\u5b8c\u5168\u6ca1\u6709\u4efb\u4f55\u95ee\u9898(\u7ecf\u8fc7\u5b9e\u6d4b)\u3002\u5982\u679c\u4f60\u60f3\u63a2\u7d22\u66f4\u4f18\u79c0\u7684\u6027\u80fd\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5RMDA\u7b49\u6280\u672f\uff0c\u4ed6\u4eec\u901a\u8fc7\u7ed5\u8fc7\u5185\u6838\u4ee5\u51cf\u5c11\u62f7\u8d1d\u7b49\u65b9\u5f0f\u4f18\u5316\u4e86\u6027\u80fd\uff0c\u5f53\u7136\u53ef\u80fd\u4f9d\u8d56\u786c\u4ef6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

        \u6211\u4eec\u90fd\u975e\u5e38\u6e05\u695aTCP\u534f\u8bae\u8bbe\u8ba1\u7684\u521d\u8877\uff0c\u5c31\u662f\u4fdd\u8bc1\u6570\u636e\u4f20\u8f93\u7684\u5feb\u901f\uff0c\u6709\u5e8f\uff0c\u65e0\u8bef\u3002\u6240\u4ee5\u7279\u70b9\u603b\u7ed3\u5982\u4e0b\uff1a 1\u3001\u9762\u5411\u8fde\u63a5\uff0c\u53ef\u4ee5 […]<\/p>\n","protected":false},"author":1329,"featured_media":160587,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-160581","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/160581","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1329"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=160581"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/160581\/revisions"}],"predecessor-version":[{"id":160588,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/160581\/revisions\/160588"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/160587"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=160581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=160581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=160581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}