{"id":329,"date":"2011-10-12T18:16:02","date_gmt":"2011-10-12T10:16:02","guid":{"rendered":"http:\/\/guoh.ai\/lifelog\/?p=329"},"modified":"2012-03-14T00:10:48","modified_gmt":"2012-03-13T16:10:48","slug":"things-about-io-network-protocol-etc","status":"publish","type":"post","link":"https:\/\/guoh.ai\/lifelog\/2011\/10\/things-about-io-network-protocol-etc\/","title":{"rendered":"IO\uff0cNetwork\uff0cProtocol\u7b49\u7b49\u6807\u8bb0\u5e16"},"content":{"rendered":"<p>\u8fd9\u91cc\u90fd\u662f\u4e00\u4e9b\u611f\u89c9\u5199\u7684\u597d\u6216\u7740\u5199\u7684\u660e\u767d\u7684\u7ecf\u5178\u5185\u5bb9<\/p>\n<p><strong>IO<\/strong><br \/>\n<a href=\"http:\/\/blog.csdn.net\/historyasamirror\/article\/details\/5778378\" target=\"_blank\">IO &#8211; \u540c\u6b65\uff0c\u5f02\u6b65\uff0c\u963b\u585e\uff0c\u975e\u963b\u585e \uff08\u4ea1\u7f8a\u8865\u7262\u7bc7\uff09<br \/>http:\/\/blog.csdn.net\/historyasamirror\/article\/details\/5778378<\/a><\/p>\n<p><strong>HTTP<\/strong><br \/>\n<a href=\"http:\/\/www.blogjava.net\/zjusuyong\/articles\/304788.html\" target=\"_blank\">\u6df1\u5165\u7406\u89e3HTTP\u534f\u8bae\uff08\u8f6c\uff09<br \/>http:\/\/www.blogjava.net\/zjusuyong\/articles\/304788.html<\/a><\/p>\n<p><strong>TCP<\/strong><br \/>\n\u4f4d\u7801\u5373TCP\u6807\u5fd7\u4f4d,\u67096\u79cd\u6807\u793a:SYN(synchronous\u5efa\u7acb\u8054\u673a) ACK(acknowledgement \u786e\u8ba4) PSH(push\u4f20\u9001) FIN(finish\u7ed3\u675f) RST(reset\u91cd\u7f6e) URG(urgent\u7d27\u6025)<br \/>\nSequence number(\u987a\u5e8f\u53f7\u7801) Acknowledge number(\u786e\u8ba4\u53f7\u7801)<\/p>\n<p>TCP\u72b6\u6001\u8868<br \/>\nCLOSED<br \/>\nLISTEN<br \/>\nSYN RCVD<br \/>\nSYN SENT<br \/>\nESTABLISHED<br \/>\nFIN WAIT 1<br \/>\nFIN WAIT 2<br \/>\nTIME WAIT (\u53cc\u65b9\u5747\u5df2\u65ad\u5f00)<br \/>\nCLOSING<br \/>\nCLOSE WAIT (\u88ab\u52a8\u5173\u95ed)\u6536\u5230\u5bf9\u65b9\u5173\u95ed\u8bf7\u6c42\uff0c\u5e76\u4e14\u5df2\u7ecf\u786e\u8ba4<br \/>\nLAST ACK (\u88ab\u52a8\u5173\u95ed)\u7b49\u5f85\u6700\u540e\u4e00\u4e2a\u5173\u95ed\u786e\u8ba4<\/p>\n<p>\u5efa\u7acb\u8fde\u63a5\u8fc7\u7a0b<br \/>\n\u4e00\u822c\u60c5\u51b5\u662f\u670d\u52a1\u7aef\u6267\u884cLISTEN\u539f\u8bed\u8fdb\u5165LISTEN(\u88ab\u52a8\u6253\u5f00)\u72b6\u6001<br \/>\n\u5ba2\u6237\u7aef\u53d1\u51faCONNECT\u547d\u4ee4\uff0c\u521b\u5efa\u62a5\u6587\u6bb5(\u5e26SYN)\u5e76\u53d1\u9001\uff0c\u8fdb\u5165SYN SENT\u72b6\u6001<br \/>\n\u670d\u52a1\u7aef\u6536\u5230\u4e00\u4e2aSYN\u62a5\u6587\u6bb5\uff0c\u7ed9\u5ba2\u6237\u7aef\u56de\u5e94ACK\u540c\u65f6\u53d1\u9001\u4e00\u4e2aSYN\uff0c\u8fdb\u5165SYN RCVD\u72b6\u6001<br \/>\n\u5ba2\u6237\u7aef\u6536\u5230SYN+ACK\u62a5\u6587\u6bb5\uff0c\u5e76\u53d1\u9001\u4e09\u6b21\u63e1\u624b\u7684\u6700\u540e\u4e00\u4e2aACK\u62a5\u6587\u6bb5\uff0c\u8fdb\u5165ESTABLISHED\u72b6\u6001<br \/>\n\u670d\u52a1\u7aef\u6536\u5230\u786e\u8ba4\u7684ACK\u62a5\u6587\u6bb5\uff0c\u5b8c\u6210\u4e09\u6b21\u63e1\u624b\uff0c\u8fdb\u5165ESTABLISHED\u72b6\u6001<\/p>\n<p>\u5173\u95ed\u8fde\u63a5\u8fc7\u7a0b<br \/>\n\u5ba2\u6237\u7aef\u6267\u884cCLOSE\u539f\u8bed\uff0c\u521b\u5efa\u62a5\u6587\u6bb5(\u5e26FIN)\u5e76\u53d1\u9001\uff0c\u8fdb\u5165FIN WAIT 1\u72b6\u6001<br \/>\n\u670d\u52a1\u7aef\u6536\u5230\u4e00\u4e2aFIN\u62a5\u6587\u6bb5\uff0c\u786e\u8ba4\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u5e76\u56de\u53d1\u4e00\u4e2aACK\u62a5\u6587\u6bb5\uff0c\u8fdb\u5165CLOSE WAIT\u72b6\u6001<br \/>\n\u5ba2\u6237\u7aef\u6536\u5230\u670d\u52a1\u7aef\u7684\u786e\u8ba4ACK\u62a5\u6587\u6bb5\uff0c\u8f6c\u79fb\u5230FIN WAIT 2\u72b6\u6001\uff0c\u6b64\u65f6\u4ece\u5ba2\u6237\u7aef\u5230\u670d\u52a1\u5668\u65b9\u5411\u7684\u8fde\u63a5\u5df2\u7ecf\u65ad\u5f00<br \/>\n\u670d\u52a1\u7aef\u5e94\u7528\u5f97\u5230\u901a\u544a\u540e\uff0c\u6267\u884cCLOSE\u539f\u8bed\uff0c\u521b\u5efa\u62a5\u6587\u6bb5(\u5e26FIN)\u5e76\u53d1\u9001\uff0c\u8fdb\u5165LAST ACK\u72b6\u6001<br \/>\n\u5ba2\u6237\u7aef\u6536\u5230FIN\u62a5\u6587\u6bb5\u5e76\u786e\u8ba4\uff0c\u8fdb\u5165TIME WAIT\u72b6\u6001\uff0c\u6b64\u65f6\u53cc\u65b9\u8fde\u63a5\u5747\u5df2\u7ecf\u65ad\u5f00<br \/>\n\u4f46TCP\u8981\u7b49\u5f85\u4e00\u4e2a2\u500d\u62a5\u6587\u6700\u5927\u751f\u5b58\u65f6\u95f4(2MSL)\uff0c\u786e\u4fdd\u3002\u3002\u3002\uff0c\u5230\u8d85\u65f6\u65f6\u95f4\u540e\uff0c\u5220\u9664\u8bb0\u5f55\uff0c\u8fdb\u5165CLOSED\u72b6\u6001<br \/>\n\u670d\u52a1\u7aef\u6536\u5230\u6700\u540e\u4e00\u4e2aACK\u62a5\u6587\u6bb5\uff0c\u91ca\u653e\u8fde\u63a5\uff0c\u5220\u9664\u8bb0\u5f55\uff0c\u8fdb\u5165CLOSED\u72b6\u6001<\/p>\n<p>http:\/\/www.cs.berkeley.edu\/~kfall\/EE122\/lec23\/sld001.htm<br \/>\nThree-way handshake<br \/>\n&#8211; A &#8212;&#8212;> Seq k, SYN &#8212;&#8212;> B<br \/>\n&#8211; A <--- Seq j, ACK k + 1, SYN + ACK <--- B\n- A ----> Seq k + 1, ACK j + 1, ACK &#8212;-><\/p>\n<p>Four-way handshake<br \/>\n&#8211; A &#8212;- Seq k, ACK j + 1, FIN + ACK &#8212;-> B<br \/>\n&#8211; A <--- Seq j, ACK k + 1, ACK <--- B\n\n- ... sometime later ...\n\n- A <--- Seq j, ACK k + 1, FIN + ACK <--- B\n- A ---> Seq k, ACK j + 1, ACK &#8212;><\/p>\n<p>Wireshark\u771f\u5b9e\u6293\u5305\u6570\u636e<br \/>\n\u4e09\u6b21\u63e1\u624b<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">33\t44.679312\t192.168.1.102\t58.215.40.94\tTCP\t53902 &gt; smtp &#x5B;SYN] Seq=0 Win=5840 Len=0 MSS=1460 TSV=3199582 TSER=0 WS=6\r\n34\t44.761376\t58.215.40.94\t192.168.1.102\tTCP\tsmtp &gt; 53902 &#x5B;SYN, ACK] Seq=0 Ack=1 Win=5792 Len=0 MSS=1440 TSV=1575891196 TSER=3199582 WS=7\r\n35\t44.761442\t192.168.1.102\t58.215.40.94\tTCP\t53902 &gt; smtp &#x5B;ACK] Seq=1 Ack=1 Win=5888 Len=0 TSV=3199602 TSER=1575891196\r\n<\/pre>\n<p>\u56db\u6b21\u5206\u624b<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">181\t279.133008\t192.168.1.102\t58.215.40.94\tTCP\t59658 &gt; smtp &#x5B;ACK] Seq=7 Ack=93 Win=5888 Len=0 TSV=3258195 TSER=1576125611\r\n182\t279.133545\t58.215.40.94\t192.168.1.102\tTCP\tsmtp &gt; 59658 &#x5B;FIN, ACK] Seq=93 Ack=7 Win=5888 Len=0 TSV=1576125611 TSER=3258186\r\n183\t279.133630\t192.168.1.102\t58.215.40.94\tTCP\t59658 &gt; smtp &#x5B;FIN, ACK] Seq=7 Ack=94 Win=5888 Len=0 TSV=3258195 TSER=1576125611\r\n186\t279.264675\t58.215.40.94\t192.168.1.102\tTCP\tsmtp &gt; 59658 &#x5B;ACK] Seq=94 Ack=8 Win=5888 Len=0 TSV=1576125739 TSER=3258195<\/pre>\n<p>http:\/\/blog.chinaunix.net\/space.php?uid=20587912&#038;do=blog&#038;cuid=2201855<br \/>\nhttp:\/\/wenku.baidu.com\/view\/2fd4a6d126fff705cc170af3.html<br \/>\nOSI 7\u5c42\u534f\u8bae<br \/>\n\u7269\u7406\u5c42<br \/>\n\u6570\u636e\u94fe\u8def\u5c42<br \/>\n\u7f51\u7edc\u5c42<br \/>\n\u4f20\u8f93\u5c42<br \/>\n\u4f1a\u8bdd\u5c42<br \/>\n\u8868\u793a\u5c42<br \/>\n\u5e94\u7528\u5c42<\/p>\n<p>TCP 4\u5c42\u534f\u8bae<br \/>\n\u7f51\u7edc\u63a5\u53e3\u5c42(ARP,RARP&#8230;)<br \/>\n\u7f51\u95f4\u5c42(ICMP,IP)<br \/>\n\u4f20\u8f93\u5c42(TCP,UDP)<br \/>\n\u5e94\u7528\u5c42(SMTP,HTTP,FTP,DNS)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u91cc\u90fd\u662f\u4e00\u4e9b\u611f\u89c9\u5199\u7684\u597d\u6216\u7740\u5199\u7684\u660e\u767d\u7684\u7ecf\u5178\u5185\u5bb9 IO IO &#8211; \u540c\u6b65\uff0c\u5f02\u6b65\uff0c\u963b\u585e\uff0c\u975e\u963b\u585e \uff08\u4ea1\u7f8a\u8865\u7262\u7bc7\uff09http:\/\/blog.csdn.net\/historyasamirror\/article\/details\/5778378 HTTP \u6df1\u5165\u7406\u89e3HTTP\u534f\u8bae\uff08\u8f6c\uff09http:\/\/www.blogjava.net\/zjusuyong\/articles\/304788.html TCP \u4f4d\u7801\u5373TCP\u6807\u5fd7\u4f4d,\u67096\u79cd\u6807\u793a:SYN(synchronous\u5efa\u7acb\u8054\u673a) ACK(acknowledgement \u786e\u8ba4) PSH(push\u4f20\u9001) FIN(finish\u7ed3\u675f) RST(reset\u91cd\u7f6e) URG(urgent\u7d27\u6025) Sequence number(\u987a\u5e8f\u53f7\u7801) Acknowledge number(\u786e\u8ba4\u53f7\u7801) TCP\u72b6\u6001\u8868 CLOSED LISTEN SYN RCVD SYN SENT ESTABLISHED FIN WAIT 1 FIN WAIT 2 TIME WAIT (\u53cc\u65b9\u5747\u5df2\u65ad\u5f00) CLOSING CLOSE WAIT (\u88ab\u52a8\u5173\u95ed)\u6536\u5230\u5bf9\u65b9\u5173\u95ed\u8bf7\u6c42\uff0c\u5e76\u4e14\u5df2\u7ecf\u786e\u8ba4 LAST ACK (\u88ab\u52a8\u5173\u95ed)\u7b49\u5f85\u6700\u540e\u4e00\u4e2a\u5173\u95ed\u786e\u8ba4 \u5efa\u7acb\u8fde\u63a5\u8fc7\u7a0b \u4e00\u822c\u60c5\u51b5\u662f\u670d\u52a1\u7aef\u6267\u884cLISTEN\u539f\u8bed\u8fdb\u5165LISTEN(\u88ab\u52a8\u6253\u5f00)\u72b6\u6001 \u5ba2\u6237\u7aef\u53d1\u51faCONNECT\u547d\u4ee4\uff0c\u521b\u5efa\u62a5\u6587\u6bb5(\u5e26SYN)\u5e76\u53d1\u9001\uff0c\u8fdb\u5165SYN SENT\u72b6\u6001 \u670d\u52a1\u7aef\u6536\u5230\u4e00\u4e2aSYN\u62a5\u6587\u6bb5\uff0c\u7ed9\u5ba2\u6237\u7aef\u56de\u5e94ACK\u540c\u65f6\u53d1\u9001\u4e00\u4e2aSYN\uff0c\u8fdb\u5165SYN RCVD\u72b6\u6001 \u5ba2\u6237\u7aef\u6536\u5230SYN+ACK\u62a5\u6587\u6bb5\uff0c\u5e76\u53d1\u9001\u4e09\u6b21\u63e1\u624b\u7684\u6700\u540e\u4e00\u4e2aACK\u62a5\u6587\u6bb5\uff0c\u8fdb\u5165ESTABLISHED\u72b6\u6001 \u670d\u52a1\u7aef\u6536\u5230\u786e\u8ba4\u7684ACK\u62a5\u6587\u6bb5\uff0c\u5b8c\u6210\u4e09\u6b21\u63e1\u624b\uff0c\u8fdb\u5165ESTABLISHED\u72b6\u6001 \u5173\u95ed\u8fde\u63a5\u8fc7\u7a0b \u5ba2\u6237\u7aef\u6267\u884cCLOSE\u539f\u8bed\uff0c\u521b\u5efa\u62a5\u6587\u6bb5(\u5e26FIN)\u5e76\u53d1\u9001\uff0c\u8fdb\u5165FIN WAIT &hellip; <a href=\"https:\/\/guoh.ai\/lifelog\/2011\/10\/things-about-io-network-protocol-etc\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">IO\uff0cNetwork\uff0cProtocol\u7b49\u7b49\u6807\u8bb0\u5e16<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_gfmr_meta_descriptions":[],"_gfmr_multilingual_taxonomy_terms":[],"footnotes":""},"categories":[5,1,8],"tags":[],"class_list":["post-329","post","type-post","status-publish","format-standard","hentry","category-cs","category-misc","category-paste"],"_links":{"self":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/comments?post=329"}],"version-history":[{"count":7,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/329\/revisions"}],"predecessor-version":[{"id":333,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/posts\/329\/revisions\/333"}],"wp:attachment":[{"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/media?parent=329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/categories?post=329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/guoh.ai\/lifelog\/wp-json\/wp\/v2\/tags?post=329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}