{"id":95,"date":"2021-08-23T01:56:25","date_gmt":"2021-08-22T17:56:25","guid":{"rendered":"http:\/\/139.224.63.49\/?p=95"},"modified":"2021-08-23T02:05:23","modified_gmt":"2021-08-22T18:05:23","slug":"%e4%bd%bf%e7%94%a8scapy%e5%af%b9%e6%8a%93%e5%8c%85%e8%bf%9b%e8%a1%8c%e6%95%b0%e6%8d%ae%e7%bb%9f%e8%ae%a1","status":"publish","type":"post","link":"http:\/\/iamnear.top\/?p=95","title":{"rendered":"\u4f7f\u7528scapy\u5bf9\u6293\u5305\u8fdb\u884c\u6570\u636e\u7edf\u8ba1"},"content":{"rendered":"\n<p>\u524d\u51e0\u5929\u5bf9dll\u8fdb\u884c\u4e86\u4fee\u6539\uff0c\u89e3\u51b3\u4e86\u591a\u7ebf\u7a0b\u51b2\u7a81\u7684\u95ee\u9898\u3002\u7136\u540e\u5c06\u4e32\u884c\u771f\u6b63\u6539\u6210\u4e86\u5e76\u884c\uff0c\u4f46\u662f\uff0c\u5728\u5b9e\u9645\u6d4b\u8bd5\u65f6\u53d1\u73b0\u5b9e\u9645\u5ef6\u65f6\u66f4\u9ad8\u4e86\u3002<\/p>\n\n\n\n<p>\u627e\u6765\u627e\u53bb\u627e\u4e0d\u5230\u539f\u56e0\uff0c\u60f3\u4e0d\u660e\u767d\u4e3a\u4ec0\u4e48\u3002\u7406\u8bba\u4e0a\u6765\u8bf4\uff0c\u591a\u4e2a\u7f51\u7edc\u8bf7\u6c42\uff0c\u5f02\u6b65\u8fdb\u884c\u591a\u4e2a\u7f51\u7edc\u8bf7\u6c42\u5e94\u8be5\u662f\u6bd4\u540c\u6b65\u963b\u585e\u7684\u4e00\u4e2a\u8bf7\u6c42\u4e00\u4e2a\u8bf7\u6c42\u8981\u5feb\u5f88\u591a\u624d\u5bf9\u554a\u3002<\/p>\n\n\n\n<p>\u6211\u5bf9\u5f02\u6b65\u7684\u4ee3\u7801\u548c\u540c\u6b65\u7684\u4ee3\u7801\u6267\u884c\u8fc7\u7a0b\u4e2d\u90fd\u7528wireshark\u8fdb\u884c\u4e86\u6293\u5305\u3002\u4f46\u662f\u6211\u53d1\u73b0\u6211\u7f3a\u5c11\u4e00\u4e2a\u65b9\u6cd5\u6765\u5bf9\u6293\u5305\u5f97\u5230\u7684\u6570\u636e\u8fdb\u884c\u5206\u6790\u3002\u56e0\u4e3a\u8fd9\u4e2a\u901a\u8baf\u7684\u8fc7\u7a0b\u7528\u7684\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u81ea\u5b9a\u4e49\u8fc7\u7a0b\u3002\u5373\u6bcf\u6b21\u53d1\u9001\u8fc7\u53bb\u662f\u4e00\u4e2a\u5f62\u5982{&#8220;idx&#8221;: 123, &#8220;c&#8221;: &#8220;getVel&#8221;}\u7684json\u5b57\u7b26\u4e32\uff0c\u6536\u5230\u7684\u662f\u5f62\u5982{&#8220;idx&#8221;: 123, &#8220;r&#8221;: 12}\u7684json\u5b57\u7b26\u4e32\u3002\u901a\u8fc7idx\u5b57\u6bb5\u6765\u6807\u8bc6\u8bf7\u6c42\u548c\u56de\u7b54\u4e4b\u95f4\u7684\u5bf9\u5e94\u5173\u7cfb\u3002\u6bcf\u4e2ajson\u5b57\u7b26\u4e32\u90fd\u5728\u4e00\u4e2a\u5305\u4e2d\uff0c\u5305\u6709\u4e94\u4e2a\u56fa\u5b9a\u7684\u524d\u7f00\u548c\u56db\u4e2a\u56fa\u5b9a\u7684\u540e\u7f00\u3002\u5305\u4e2d\u8fd8\u67092\u5b57\u8282\u6765\u6807\u8bc6json\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u3002<\/p>\n\n\n\n<p>\u8bf4\u7684\u6709\u70b9\u4e71\uff0c\u603b\u4e4b\uff0c\u6bcf\u4e2a\u5305\u5305\u62ec\uff1a\u4e94\u4e2a\u56fa\u5b9a\u524d\u7f00+\u4e24\u5b57\u8282\u7684json\u5b57\u7b26\u4e32\u957f\u5ea6+json\u5b57\u7b26\u4e32+\u56db\u4e2a\u56fa\u5b9a\u540e\u7f00\u3002<\/p>\n\n\n\n<p>\u7136\u800cwireshark\u53ea\u80fd\u8bc6\u522b\u4e00\u4e9b\u5e38\u7528\u7684\u534f\u8bae\uff0c\u5bf9\u4e8e\u8fd9\u79cd\u81ea\u5b9a\u4e49\u7684\uff0c\u57fa\u4e8etcp\u4e4b\u4e0a\u7684\u534f\u8bae\uff0c\u5c31\u6ca1\u5565\u5185\u7f6e\u7684\u597d\u7684\u7edf\u8ba1\u529e\u6cd5\u4e86\u3002\u6211\u5728\u7f51\u7edc\u4e0a\u67e5\u4e86\u67e5\uff0c\u4e00\u79cd\u529e\u6cd5\u662f\u81ea\u5df1\u5199lua\u811a\u672c\u6765\u4f5c\u4e3awireshark\u7684\u63d2\u4ef6\u3002\u4f46\u662f\u6211\u7b80\u5355\u770b\u4e86\u770b\u653e\u5f03\u4e86\uff0c\u5b66\u4e0d\u4f1a\u3002\u3002\u8fd8\u597d\u6211\u53d1\u73b0\u4e86python\u6709\u4e2a\u5305\u53ebscapy\uff0c\u53ef\u4ee5\u6293\u5305\u89e3\u5305\uff0c\u8fd8\u53ef\u4ee5\u8bfbpcap\u6587\u4ef6\uff01\u56e0\u6b64\u53ef\u4ee5\u7528scapy\u8bfb\u53d6wireshark\u6293\u7684\u5305\uff0c\u7136\u540e\u81ea\u5df1\u5bf9tcp\u4e0a\u7684\u81ea\u5b9a\u4e49\u534f\u8bae\u8fdb\u884c\u89e3\u6790\u3002\u4ece\u800c\u53ef\u4ee5\u5f97\u5230\u6bcf\u4e2a\u5305\u7684\u65f6\u95f4\u3002<\/p>\n\n\n\n<p>\u7ecf\u8fc7\u7edf\u8ba1\u4e0d\u540c\u547d\u4ee4\u7684\u54cd\u5e94\u65f6\u95f4\uff0c\u6bcf\u79cd\u547d\u4ee4\u54cd\u5e94\u65f6\u95f4\u7684\u5206\u5e03\uff0c\u53d1\u9001\u547d\u4ee4\u6570\u636e\u5305\u7684\u95f4\u9694\u7b49\u7edf\u8ba1\u6570\u636e\u540e\uff0c\u53d1\u73b0\u3002\u3002\u95ee\u9898\u4e0d\u662f\u51fa\u5728\u670d\u52a1\u5668\uff0c\u800c\u662f\u5728\u5ba2\u6237\u7aef\u3002<\/p>\n\n\n\n<p>\u6bd4\u5982\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>            Task add_task = Task.Run(()=&gt;\n            {\n                int a = random.Next(0, 1000);\n                int b = random.Next(1, 1000);\n                int r = client.Add(a, b);\n            });\n            Task sub_task = Task.Run(() =&gt;\n            {\n                int a = random.Next(0, 1000);\n                int b = random.Next(1, 1000);\n                int r = client.Sub(a, b);\n            });\n            Task mul_task = Task.Run(() =&gt;\n            {\n                int a = random.Next(0, 1000);\n                int b = random.Next(1, 1000);\n                int r = client.Multiply(a, b);\n            });\n            Task div_task = Task.Run(() =&gt;\n            {\n                int a = random.Next(0, 1000);\n                int b = random.Next(1, 1000);\n                int r = client.Divide(a, b);\n            });\n            Task.WaitAll(add_task, sub_task, mul_task, div_task);<\/code><\/pre>\n\n\n\n<p>\u7406\u60f3\u60c5\u51b5\u4e0b\uff0c\u8fd9\u56db\u4e2a\u7f51\u7edc\u8bf7\u6c42\u5e94\u8be5\u662f\u95f4\u9694\u5f88\u77ed\uff0c\u51e0\u4e4e\u4e00\u8d77\u53d1\u9001\u51fa\u53bb\u624d\u5bf9\u3002<\/p>\n\n\n\n<p>\u4f46\u662f\u4ece\u6570\u636e\u6765\u770b\uff0cmul_task\u548cadd_task\u4e4b\u95f4\u5dee\uff0c\u5f88\u4e0d\u7406\u60f3<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"554\" height=\"413\" src=\"http:\/\/139.224.63.49\/wp-content\/uploads\/2021\/08\/output1.png\" alt=\"\" class=\"wp-image-97\" srcset=\"http:\/\/iamnear.top\/wp-content\/uploads\/2021\/08\/output1.png 554w, http:\/\/iamnear.top\/wp-content\/uploads\/2021\/08\/output1-300x224.png 300w\" sizes=\"auto, (max-width: 554px) 100vw, 554px\" \/><\/figure>\n\n\n\n<p>\u8fd9\u4e2a\u56fe\u662f\u5ef6\u65f6\u7684\u6563\u70b9\u56fe\uff0c\u7eb5\u5750\u6807\u5355\u4f4d\u662fms\u3002\u53ef\u4ee5\u770b\u5230\u6709\u5927\u91cf\u5ef6\u65f6\u975e\u5e38\u5927\u7684\u70b9\u3002\u4e0d\u8981\u6c42\u4f60\u5f02\u6b65\u4e4b\u95f4\u5b8c\u5168\u6ca1\u95f4\u9694\uff0c\u4f46\u4e5f\u4e0d\u80fd\u95f4\u969450ms\u4ee5\u4e0a\u5427\u3002\u3002\u4e00\u6b21\u7f51\u7edc\u8bf7\u6c42\u4ece\u53d1\u9001\u5230\u63a5\u53d7\uff0c\u5feb\u7684\u8bdd\u8fd8\u4e0d\u523010ms\u3002\u7ed3\u679c\u8fd9\u4e2a\u5f02\u6b65\u4efb\u52a1\u542f\u52a8\u4e4b\u95f4\u95f4\u9694\u5c31\u8d85\u8fc7\u4e8650ms\uff0c\u8fd9\u5c31\u9020\u6210\u4e86\u5f02\u6b65\u8fd8\u6ca1\u540c\u6b65\u4ee3\u7801\u5feb\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"552\" height=\"413\" src=\"http:\/\/139.224.63.49\/wp-content\/uploads\/2021\/08\/output2.png\" alt=\"\" class=\"wp-image-98\" srcset=\"http:\/\/iamnear.top\/wp-content\/uploads\/2021\/08\/output2.png 552w, http:\/\/iamnear.top\/wp-content\/uploads\/2021\/08\/output2-300x224.png 300w\" sizes=\"auto, (max-width: 552px) 100vw, 552px\" \/><figcaption>\u5ef6\u65f6\u5206\u5e03\u76f4\u65b9\u56fe\uff0c\u6a2a\u5750\u6807\u5355\u4f4d\u662fms\uff0c\u7eb5\u5750\u6807\u662f\u6570\u91cf<\/figcaption><\/figure>\n\n\n\n<p>\u4ece\u76f4\u65b9\u56fe\u4e5f\u80fd\u770b\u51fa\u6765\u3002<\/p>\n\n\n\n<p>c#\u4e2d\u57fa\u4e8eTask\u7684\u5f02\u6b65\uff0c\u662f\u628a\u6bcf\u4e2a\u5f02\u6b65\u4efb\u52a1\u4ea4\u7ed9ThreadPool\u6765\u6267\u884c\u7684\u3002\u6240\u4ee5\u5bf9\u4e8e\u8fd9\u4e2a\u5ef6\u65f6\u8fd9\u4e48\u5927\u7684\u60c5\u51b5\uff0c\u6211\u6000\u7591\u53ef\u80fd\u662f\u7531\u4e8eThreadPool\u4e2d\u7ebf\u7a0b\u4efb\u52a1\u961f\u5217\u6bd4\u8f83\u957f\uff0c\u7cfb\u7edf\u4e2d\u9700\u8981ThreadPool\u6267\u884c\u7684\u4efb\u52a1\u592a\u591a\u4e86\u5bfc\u81f4\u7684\uff1f\u8fd9\u4e2a\u6211\u540e\u9762\u4e5f\u6ca1\u8c03\u8bd5\u4e86\u3002\u6211\u6709\u60f3\u901a\u8fc7\u8bbe\u7f6eThreadPool.SetMaxThreads\u6765\u6539\u53d8ThreadPool\u4e2d\u7684\u7ebf\u7a0b\u6570\u91cf\uff0c\u4e0d\u8fc7\u901a\u8fc7ThreadPool.GetMaxThreads\u5f97\u5230\u7684\u6700\u5927\u7ebf\u7a0b\u6570\u91cf\u4f3c\u4e4e\u662f16384\uff1f\u5982\u679c\u662f\u8fd9\u6837\u7684\u8bdd\uff0c\u90a3\u53ef\u80fd\u5c31\u4e0d\u662f\u4efb\u52a1\u961f\u5217\u7684\u95ee\u9898\uff0c\u800c\u662f\u5904\u7406\u5668\u8c03\u5ea6\u7684\u95ee\u9898\u4e86\u3002\u3002\u603b\u4e4b\u4e5f\u6ca1\u8fdb\u4e00\u6b65\u8c03\u8bd5\u4e86\u3002<\/p>\n\n\n\n<p>\u6211\u5728\u81ea\u5df1\u7684\u7535\u8111\u4e0a\u6a21\u4eff\u8fd9\u4e2a\u534f\u8bae\u5199\u4e86\u4e2a\u670d\u52a1\u5668\uff0c\u7528\u6765\u8ba1\u7b97\u52a0\u51cf\u4e58\u9664\u3002\u7136\u540e\u7528\u540c\u6b65\u548c\u5f02\u6b65\u7684c#\u7a0b\u5e8f\u5206\u522b\u8f6e\u8be2\uff0c\u7528wireshark\u6293\u5305\uff0c\u518d\u7528scapy\u8fdb\u884c\u7edf\u8ba1\uff0c\u540c\u6837\u53d1\u73b0\u540c\u6b65\u4ee3\u7801\u7684\u54cd\u5e94\u65f6\u95f4\u6bd4\u5f02\u6b65\u8981\u5feb\u4e00\u4e9b\uff0c\u540c\u6b65\u4ee3\u7801\u7684\u5e73\u5747\u54cd\u5e94\u65f6\u95f4\u662f24ms\uff0c\u5f02\u6b65\u4ee3\u7801\u7684\u5e73\u5747\u54cd\u5e94\u65f6\u95f4\u662f32ms\u3002\u4e0d\u8fc7\u8fd9\u4e2a\u5dee\u8ddd\u4e0d\u5927\uff0c\u800c\u4e14\u5f02\u6b65\u4ee3\u7801\u867d\u7136\u54cd\u5e94\u65f6\u95f4\u6162\u4e00\u4e9b\uff0c\u4f46\u662f\u541e\u5410\u91cf\u660e\u663e\u6bd4\u540c\u6b65\u8981\u5927\u4e0d\u5c11\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u51e0\u5929\u5bf9dll\u8fdb\u884c\u4e86\u4fee\u6539\uff0c\u89e3\u51b3\u4e86\u591a\u7ebf\u7a0b\u51b2\u7a81\u7684\u95ee\u9898\u3002\u7136\u540e\u5c06\u4e32\u884c\u771f\u6b63\u6539\u6210\u4e86\u5e76\u884c\uff0c\u4f46\u662f\uff0c\u5728\u5b9e\u9645\u6d4b\u8bd5\u65f6\u53d1\u73b0\u5b9e&hellip; <a href=\"http:\/\/iamnear.top\/?p=95\" class=\"more-link read-more\" rel=\"bookmark\">\u7ee7\u7eed\u9605\u8bfb <span class=\"screen-reader-text\">\u4f7f\u7528scapy\u5bf9\u6293\u5305\u8fdb\u884c\u6570\u636e\u7edf\u8ba1<\/span><i class=\"fa fa-arrow-right\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":{"0":"post-95","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-uncategorized","7":"h-entry","9":"h-as-article"},"_links":{"self":[{"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/posts\/95","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/iamnear.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=95"}],"version-history":[{"count":2,"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/posts\/95\/revisions"}],"predecessor-version":[{"id":99,"href":"http:\/\/iamnear.top\/index.php?rest_route=\/wp\/v2\/posts\/95\/revisions\/99"}],"wp:attachment":[{"href":"http:\/\/iamnear.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/iamnear.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/iamnear.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}