{"id":130,"date":"2022-01-14T14:06:29","date_gmt":"2022-01-14T14:06:29","guid":{"rendered":"https:\/\/www.hfrtc.top\/wordpress\/?p=130"},"modified":"2022-01-27T08:51:56","modified_gmt":"2022-01-27T08:51:56","slug":"ns-3-for-webrtc-congestion-control","status":"publish","type":"post","link":"https:\/\/www.fanyamin.com\/wordpress\/?p=130","title":{"rendered":"network simulator 3"},"content":{"rendered":"\n<p>NS-3 is a network simulator tool <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>An open source discrete event simulator<br><ul><li>Event model packet transmission , receipt , timers etc.<\/li><li>Future events maintained in sorted Event List <\/li><\/ul><ul><li>Processing events results in zero or more new events<\/li><\/ul><\/li><li>Written in C++<br>Extensive use of Templates , Smart Pointers, Callbacks C++ namespace (ns3)<br><\/li><li>Simulation programs are C++ executables <\/li><li>Python is used to bind public APIs provided<br>NS-3 is built as a library which may be linked to a C++ main program defines the simulation topology and start the simulation.<\/li><\/ul>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-1 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"254\" src=\"https:\/\/www.hfrtc.top\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-2022-01-18-9.18.19-AM-1024x254.png\" alt=\"\" class=\"wp-image-193 img-fluid\" srcset=\"https:\/\/www.fanyamin.com\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-2022-01-18-9.18.19-AM-1024x254.png 1024w, https:\/\/www.fanyamin.com\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-2022-01-18-9.18.19-AM-300x74.png 300w, https:\/\/www.fanyamin.com\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-2022-01-18-9.18.19-AM-768x191.png 768w, https:\/\/www.fanyamin.com\/wordpress\/wp-content\/uploads\/2022\/01\/Screenshot-2022-01-18-9.18.19-AM.png 1128w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n<\/div>\n<\/div>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"\u5b89\u88c5\">\u5b89\u88c5<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ns-3\">NS-3<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/gitlab.com\/nsnam\/ns-3-allinone.git\ncd ns-3-allinone\n.\/download.py\n#.\/build.py --enable-examples --enable-tests\n\n\n\u63a8\u8350\u7528 waf \n-------------\n\n\ncd ns-3-dev\n.\/waf clean\n.\/waf configure --build-profile=debug --disable-werror --enable-examples --enable-tests\n.\/waf build\n.\/waf --run hello-simulator\n\n\n\n\n\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u57fa\u672c\u6982\u5ff5\">\u57fa\u672c\u6982\u5ff5<\/h2>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"523\" height=\"1024\" src=\"https:\/\/www.hfrtc.top\/wordpress\/wp-content\/uploads\/2022\/01\/ns-3-1-523x1024.png\" alt=\"\" class=\"wp-image-183 img-fluid\" srcset=\"https:\/\/www.fanyamin.com\/wordpress\/wp-content\/uploads\/2022\/01\/ns-3-1-523x1024.png 523w, https:\/\/www.fanyamin.com\/wordpress\/wp-content\/uploads\/2022\/01\/ns-3-1-153x300.png 153w, https:\/\/www.fanyamin.com\/wordpress\/wp-content\/uploads\/2022\/01\/ns-3-1.png 541w\" sizes=\"(max-width: 523px) 100vw, 523px\" \/><\/figure>\n\n\n\n<ul class=\"has-medium-font-size wp-block-list\"><li>Nodes: hosts, routers, servers,\u2026  \u8282\u70b9, \u53ef\u7531 NodeContainer \u6765\u7ba1\u7406<\/li><li>Applications: generate and consume traffic in network <\/li><li>Protocols: broker connections, access, addressing, routing,\u2026 <\/li><li>NetDevices: e.g., ethernet &amp; wireless cards <\/li><li>Channels: transmission medium (cable, EM waves,\u2026) <\/li><li>Packets: make up network traffic<\/li><\/ul>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u7b2c\u4e00\u4e2a\u4f8b\u5b50\">\u7b2c\u4e00\u4e2a\u4f8b\u5b50<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"618\" height=\"323\" src=\"https:\/\/www.hfrtc.top\/wordpress\/wp-content\/uploads\/2022\/01\/ns-3.png\" alt=\"\" class=\"wp-image-170 img-fluid\" srcset=\"https:\/\/www.fanyamin.com\/wordpress\/wp-content\/uploads\/2022\/01\/ns-3.png 618w, https:\/\/www.fanyamin.com\/wordpress\/wp-content\/uploads\/2022\/01\/ns-3-300x157.png 300w\" sizes=\"(max-width: 618px) 100vw, 618px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Default Network Topology\n\/\/\n\/\/       10.1.1.0\n\/\/ n0 -------------- n1\n\/\/    point-to-point\n\/\/\n \nusing namespace ns3;\n\nNS_LOG_COMPONENT_DEFINE (\"FirstScriptExample\");\n\nint\nmain (int argc, char *argv&#91;])\n{\n  <strong>\/\/\u89e3\u6790\u547d\u4ee4\u884c<\/strong>\n  CommandLine cmd (__FILE__);\n  cmd.Parse (argc, argv);\n  \n  Time::SetResolution (Time::NS);\n  LogComponentEnable (\"UdpEchoClientApplication\", LOG_LEVEL_INFO);\n  LogComponentEnable (\"UdpEchoServerApplication\", LOG_LEVEL_INFO);\n\n  \n\n  <strong>\/\/<\/strong>\u521b\u5efa\u4e24\u4e2a\u8282\u70b9\n\n  NodeContainer nodes;\n  nodes.Create (2);\n\n\n\n  <strong>\/\/\u8bbe\u7f6e\u7aef\u5230\u7aef\u62d3\u6251\u7f51\u7edc\u7ed3\u6784\uff0c\u8bbe\u5907\u901f\u7387\u4e3a5Mbps, \u901a\u9053\u5ef6\u8fdf\u4e3a 2ms<\/strong>\n  \/\/\u7f51\u7edc\u62d3\u6251\u4e2d\u5b89\u88c5\u8fd9\u4e9b\u8282\u70b9\n\n\n  PointToPointHelper pointToPoint;\n  pointToPoint.SetDeviceAttribute (\"DataRate\", StringValue (\"5Mbps\"));\n  pointToPoint.SetChannelAttribute (\"Delay\", StringValue (\"2ms\"));\n\n  NetDeviceContainer devices;\n  devices = pointToPoint.Install (nodes);\n\n\n  <strong>\/\/ \u4e92\u8054\u7f51\u534f\u8bae\u6808<\/strong>\u4e2d\u5b89\u88c5\u8fd9\u4e9b\u8282\u70b9\n\n  InternetStackHelper stack;\n  stack.Install (nodes);\n\n  Ipv4AddressHelper address;\n  address.SetBase (\"10.1.1.0\", \"255.255.255.0\");\n\n  Ipv4InterfaceContainer interfaces = address.Assign (devices);\n\n\n  <strong>\/\/ \u521b\u5efa\u4e00\u4e2a UdpEchoServer<\/strong>\n  UdpEchoServerHelper echoServer (9);\n\n\n  <strong>\/\/ UdpEchoServer \u5e94\u7528\u91cc\u5b89\u88c5 Server \u8282\u70b9\uff0c1\u79d2\u540e\u542f\u52a8\uff0c10\u79d2\u540e\u505c\u6b62<\/strong>\n  ApplicationContainer serverApps = echoServer.Install (nodes.Get (1));\n  serverApps.Start (Seconds (1.0));\n  serverApps.Stop (Seconds (10.0));\n\n  <strong>\/\/ \u521b\u5efa\u4e00\u4e2a UdpEchoClient, \u8bbe\u7f6e MaxPackets=1, Interval=1 \u79d2, PacketSize=1024<\/strong>\n  UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);\n  echoClient.SetAttribute (\"MaxPackets\", UintegerValue (1));\n  echoClient.SetAttribute (\"Interval\", TimeValue (Seconds (1.0)));\n  echoClient.SetAttribute (\"PacketSize\", UintegerValue (1024));\n\n  \n\n  <strong>\/\/ UdpEchoClient \u5e94\u7528\u91cc\u5b89\u88c5 Client \u8282\u70b9\uff0c 2 \u79d2\u540e\u542f\u52a8\uff0c 10 \u79d2\u540e\u505c\u6b62<\/strong>\n\n  ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));\n  clientApps.Start (Seconds (2.0));\n  clientApps.Stop (Seconds (10.0));\n\n  <strong>\/\/ \u6a21\u62df\u5668\u8fd0\u884c\uff0c\u4e4b\u540e\u9500\u6bc1<\/strong>\n  Simulator::Run ();\n  Simulator::Destroy ();\n  return 0;\n}\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>cp examples\/tutorial\/first.cc scratch\/myfirst.cc<br>.\/waf<br>.\/waf --run scratch\/myfirst<\/p>\n\n\n\n<p>At time +2s client sent 1024 bytes to 10.1.1.2 port 9<br>At time +2.00369s server received 1024 bytes from 10.1.1.1 port 49153<br>At time +2.00369s server sent 1024 bytes to 10.1.1.1 port 49153<br>At time +2.00737s client received 1024 bytes from 10.1.1.2 port 9<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>To avoid compile error with new version gcc<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> CXXFLAGS=\"-Wall\" .\/waf configure\n .\/waf -vv<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"todo\">TODO<\/h2>\n\n\n\n<p>\u5982\u4f55\u5f15\u7528\u7b2c\u4e09\u65b9\u5e93<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u5982\u4f55\u6dfb\u52a0\u81ea\u5df1\u7684\u6a21\u5757<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>NS-3 is a network simulator tool An open source discrete event simulator Event model packet transmission , receipt , timers etc. Future events maintained in sorted Event List Processing events results in zero or more new events Written in C++Extensive use of Templates , Smart Pointers, Callbacks C++ namespace (ns3) Simulation programs are C++ executables [&hellip;] <a class=\"read-more\" href=\"https:\/\/www.fanyamin.com\/wordpress\/?p=130\" title=\"Permanent Link to: network simulator 3\">&rarr;Read&nbsp;more<\/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":[12,10,11],"class_list":["post-130","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-c","tag-network","tag-webrtc"],"_links":{"self":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/130"}],"collection":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=130"}],"version-history":[{"count":19,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/130\/revisions"}],"predecessor-version":[{"id":261,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/130\/revisions\/261"}],"wp:attachment":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}