{"id":338,"date":"2009-09-02T02:04:00","date_gmt":"2009-09-02T02:04:00","guid":{"rendered":"http:\/\/marvelliu.wordpress.com\/2009\/09\/02\/ns2-segment-fault"},"modified":"2009-09-02T02:04:00","modified_gmt":"2009-09-02T02:04:00","slug":"ns2-segment-fault","status":"publish","type":"post","link":"https:\/\/marvelliu.space\/?p=338","title":{"rendered":"ns2 segment fault"},"content":{"rendered":"<p>\u5b8c\u6210\u4e86\u4e00\u4e2a\u53d1\u9001beacon\u7684\u7a0b\u5e8f\uff0c\u4f46\u662f\u51fa\u73b0segment fault\u4e86\uff0c\u8c03\u8bd5\u5230\u6700\u540e\u53d1\u73b0\u662fchannel.cc\u4e2d\u5728\u66f4\u65b0\u8282\u70b9\u7684\u65f6\u5019\u94fe\u8868\u51fa\u95ee\u9898\u4e86\u3002\u518d\u4ed4\u7ec6\u4e00\u770b\uff0c\u53d1\u73b0\u662f\u539f\u6765\u7684\u903b\u8f91\u662f\u9700\u8981\u94fe\u8868\u662f\u6709\u5e8f\u7684\uff0c\u7ed3\u679c\u51e0\u6b21\u8c03\u7528\u4e4b\u540e\u5c45\u7136\u65e0\u5e8f\u4e86\uff0c\u6709\u4e00\u4e9b\u8282\u70b9\u7684\u503c\u8fdb\u884c\u53d8\u5316\uff0c\u4f46\u662f\u8282\u70b9\u94fe\u8868\u4e2d\u7684\u987a\u5e8f\u59cb\u7ec8\u4e0d\u53d8\uff0c\u5bfc\u81f4\u95ee\u9898\u51fa\u73b0\u4e86\u3002<br \/>\u518d\u6df1\u5165\u770b\u4e00\u4e0b\uff0c\u539f\u6765\u662fTransV1.2\u4e2d\u7adf\u7136\u624b\u52a8\u8bbe\u7f6e\u8282\u70b9\u7684\u4f4d\u7f6e\uff0c\u800c\u4e0d\u662f\u8c03\u7528set_destination\u51fd\u6570\uff1a<br \/>\/\/ set node exactly to old destination<br \/>            node-&gt;X_ = node-&gt;destX_;<br \/>            node-&gt;Y_ = node-&gt;destY_;<br \/>            \/\/ move node to position<br \/>            \/\/ velocity = space \/ time<br \/>            if (destTime &gt; now)<br \/>            {<br \/>                speed = sqrt((node-&gt;X_ &#8211; x)*(node-&gt;X_ &#8211; x) + (node-&gt;Y_ &#8211; y)*(node-&gt;Y_ &#8211; y)) \/ (destTime &#8211; now);<br \/>                \/\/ set_destination returns 0 on success<br \/>                if ( node-&gt;set_destination(x, y, speed) )<\/p>\n<p>\u5947\u602a\u7684\u662f\u4f5c\u8005\u4e00\u8fb9\u624b\u52a8\u8d4b\u503c\uff0c\u4e00\u8fb9\u53c8\u8c03\u7528\u51fd\u6570\uff0c\u771f\u5f97\u4e0d\u77e5\u9053\u600e\u4e48\u60f3\u7684\uff0csigh<\/p>\n<p>\u7ed9\u6211\u7684\u611f\u89c9\u662fns2\u8ddf\u5176\u4ed6\u7684\u6269\u5c55\u7ed3\u5408\u7684\u592a\u7d27\u5bc6\u4e86\uff0c\u5f88\u5bb9\u6613\u5c31\u51fa\u9519\u554a\u2026\u2026<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b8c\u6210\u4e86\u4e00\u4e2a\u53d1\u9001beacon\u7684\u7a0b\u5e8f\uff0c\u4f46\u662f\u51fa\u73b0segment fault\u4e86\uff0c\u8c03\u8bd5\u5230\u6700\u540e\u53d1\u73b0\u662fchannel.cc\u4e2d\u5728\u66f4\u65b0\u8282\u70b9\u7684\u65f6\u5019\u94fe\u8868\u51fa\u95ee\u9898\u4e86\u3002\u518d\u4ed4\u7ec6\u4e00\u770b\uff0c\u53d1\u73b0\u662f\u539f\u6765\u7684\u903b\u8f91\u662f\u9700\u8981\u94fe\u8868\u662f\u6709\u5e8f\u7684\uff0c\u7ed3\u679c\u51e0\u6b21\u8c03\u7528\u4e4b\u540e\u5c45\u7136\u65e0\u5e8f\u4e86\uff0c\u6709\u4e00\u4e9b\u8282\u70b9\u7684\u503c\u8fdb\u884c\u53d8\u5316\uff0c\u4f46\u662f\u8282\u70b9\u94fe\u8868\u4e2d\u7684\u987a\u5e8f\u59cb\u7ec8\u4e0d\u53d8\uff0c\u5bfc\u81f4\u95ee\u9898\u51fa\u73b0\u4e86\u3002\u518d\u6df1\u5165\u770b\u4e00\u4e0b\uff0c\u539f\u6765\u662fTransV1.2\u4e2d\u7adf\u7136\u624b\u52a8\u8bbe\u7f6e\u8282\u70b9\u7684\u4f4d\u7f6e\uff0c\u800c\u4e0d\u662f\u8c03\u7528set_destination\u51fd\u6570\uff1a\/\/ set node exactly to old destination node-&gt;X_ = node-&gt;destX_; node-&gt;Y_ = node-&gt;destY_; \/\/ move node to position \/\/ velocity = space \/ time if (destTime &gt; now) { speed = sqrt((node-&gt;X_ &#8211; x)*(node-&gt;X_ &#8211; x) + (node-&gt;Y_ &#8211; y)*(node-&gt;Y_ &#8211; y)) \/ (destTime &#8211; now); \/\/ set_destination returns 0 on success if ( &hellip; <a href=\"https:\/\/marvelliu.space\/?p=338\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;ns2 segment fault&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-338","post","type-post","status-publish","format-standard","hentry","category-ns2"],"_links":{"self":[{"href":"https:\/\/marvelliu.space\/index.php?rest_route=\/wp\/v2\/posts\/338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/marvelliu.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/marvelliu.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/marvelliu.space\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/marvelliu.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=338"}],"version-history":[{"count":0,"href":"https:\/\/marvelliu.space\/index.php?rest_route=\/wp\/v2\/posts\/338\/revisions"}],"wp:attachment":[{"href":"https:\/\/marvelliu.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/marvelliu.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/marvelliu.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}