{"id":313,"date":"2011-12-19T19:25:57","date_gmt":"2011-12-19T11:25:57","guid":{"rendered":"http:\/\/ykyi.net\/?p=313"},"modified":"2011-12-19T19:25:57","modified_gmt":"2011-12-19T11:25:57","slug":"unix-%e7%bd%91%e7%bb%9c%e7%bc%96%e7%a8%8b-%e7%ac%ac%e5%8d%81%e7%ab%a0-sctp-clientserver-example","status":"publish","type":"post","link":"https:\/\/ykyi.net\/?p=313","title":{"rendered":"Unix \u7f51\u7edc\u7f16\u7a0b \u7b2c\u5341\u7ae0 SCTP Client\/Server Example"},"content":{"rendered":"<p>\u8fd9\u4e00\u7ae0\u7684\u5185\u5bb9\u8fd8\u662f\u6ee1\u5c11\u7684\u3002\u4e5f\u5c31\u662f\u7ed9\u51fa\u4e00\u4e2aSCTP\u7684\u7b80\u5355\u4f8b\u5b50\u3002\u6240\u4ee5\u4e5f\u6ca1\u6709\u592a\u591a\u9700\u8981\u505a\u7b14\u8bb0\u7684\u3002<\/p>\n<p>1.<strong> \u4ec0\u4e48\u662f head-of-line blocking.<\/strong><\/p>\n<p>Head-of-line blocking occurs when a TCP segment is lost and a subsequent TCP segment arrives out of order. That subsequent segment is held until the first TCP segment is retransmitted and arrives at the receiver.<\/p>\n<p>2. <strong>\u600e\u4e48\u66f4\u6539SCTP\u8fde\u63a5\u7684stream\u7684\u6570\u91cf\u3002<\/strong><\/p>\n<p>SCTP\u8fde\u63a5\u7684streams\u7684\u6570\u91cf\u662f\u5728association\u7684\u63e1\u624b\u4e4b\u524d\u534f\u5546\u597d\u7684\u3002\u5bf9\u4e8eFreeBSD\u7684KAME\u5b9e\u73b0\uff0cSCTP\u7684outbound streams\u9ed8\u8ba4\u4e3a10\u3002\u8fd9\u4e2a\u503c\u53ef\u4ee5\u7528setsocket\u51fd\u6570\u66f4\u6539\u3002\u4e0eSCTP_INITMSG scoket option\u76f8\u5173\uff0c\u8bbe\u7f6estruct sctp_initmsg\u7ed3\u6784\u4f53\u3002<\/p>\n<p>\u4e5f\u53ef\u4ee5\u7528sendmsg\u51fd\u6570\u53d1\u9001ancillary\u6570\u636e\u6765\u5230\u8fbe\u540c\u6837\u7684\u76ee\u6807\u3002\u4f46\u53d1\u9001ancillary data\u53ea\u5bf9one-to-many\u5f62\u5f0f\u7684sctp socket\u6709\u6548\u3002<\/p>\n<p>3. <strong>\u600e\u4e48\u7ed3\u675f\u4e00\u4e2aSCTP\u8fde\u63a5\u3002<\/strong><\/p>\n<p>\u53ef\u4ee5\u8bbe\u7f6esctp_sndrcvinfo\u7ed3\u6784\u7684sinfo_flags\u503c\u7684MSG_EOF flag\u6765\u5173\u95ed\u4e00\u4e2asctp\u8fde\u63a5gracefully. This flag forces an association to shut down after the message being sent is acknowledged.<\/p>\n<p>\u8fd8\u53ef\u4ee5\u7ed9sinfo_flags\u8bbe\u7f6e MSG_ABORT\u3002\u8fd9\u6837\u5c31\u4f1a\u7acb\u5373\u53d1\u9001\u4e00\u4e2aABORT\u7ed9peer\u7aef\u3002\u4efb\u4f55\u8fd8\u6ca1\u6765\u5f97\u53ca\u53d1\u9001\u51fa\u7684\u6570\u636e\u4f1a\u88ab\u4e22\u5f03\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u4e00\u7ae0\u7684\u5185\u5bb9\u8fd8\u662f\u6ee1\u5c11\u7684\u3002\u4e5f\u5c31\u662f\u7ed9\u51fa\u4e00\u4e2aSCTP\u7684\u7b80\u5355\u4f8b\u5b50\u3002\u6240\u4ee5\u4e5f\u6ca1\u6709\u592a\u591a\u9700\u8981\u505a\u7b14\u8bb0\u7684\u3002 1. \u4ec0\u4e48\u662f head-of-line blocking. Head-of-line blocking occurs when a TCP segment is lost and a subsequent TCP segment arrives out of order. That subsequent segment is held until the first TCP segment is retransmitted and arrives at the receiver. 2. \u600e\u4e48\u66f4\u6539SCTP\u8fde\u63a5\u7684stream\u7684\u6570\u91cf\u3002 SCTP\u8fde\u63a5\u7684streams\u7684\u6570\u91cf\u662f\u5728association\u7684\u63e1\u624b\u4e4b\u524d\u534f\u5546\u597d\u7684\u3002\u5bf9\u4e8eFreeBSD\u7684KAME\u5b9e\u73b0\uff0cSCTP\u7684outbound streams\u9ed8\u8ba4\u4e3a10\u3002\u8fd9\u4e2a\u503c\u53ef\u4ee5\u7528setsocket\u51fd\u6570\u66f4\u6539\u3002\u4e0eSCTP_INITMSG scoket option\u76f8\u5173\uff0c\u8bbe\u7f6estruct sctp_initmsg\u7ed3\u6784\u4f53\u3002 \u4e5f\u53ef\u4ee5\u7528sendmsg\u51fd\u6570\u53d1\u9001ancillary\u6570\u636e\u6765\u5230\u8fbe\u540c\u6837\u7684\u76ee\u6807\u3002\u4f46\u53d1\u9001ancillary data\u53ea\u5bf9one-to-many\u5f62\u5f0f\u7684sctp socket\u6709\u6548\u3002 3. \u600e\u4e48\u7ed3\u675f\u4e00\u4e2aSCTP\u8fde\u63a5\u3002 \u53ef\u4ee5\u8bbe\u7f6esctp_sndrcvinfo\u7ed3\u6784\u7684sinfo_flags\u503c\u7684MSG_EOF flag\u6765\u5173\u95ed\u4e00\u4e2asctp\u8fde\u63a5gracefully. This &hellip; <a href=\"https:\/\/ykyi.net\/?p=313\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Unix \u7f51\u7edc\u7f16\u7a0b \u7b2c\u5341\u7ae0 SCTP Client\/Server Example&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,6,7],"tags":[81,118],"class_list":["post-313","post","type-post","status-publish","format-standard","hentry","category-network","category-tech_articles","category-unix_linux","tag-unix","tag-118"],"_links":{"self":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts\/313","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=313"}],"version-history":[{"count":0,"href":"https:\/\/ykyi.net\/index.php?rest_route=\/wp\/v2\/posts\/313\/revisions"}],"wp:attachment":[{"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=313"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=313"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ykyi.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=313"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}