2014 YU-ANTL Lab Seminar NS-3 Simulation April 1, 2014 Yashashree Jadhav Advanced Networking Technology Lab. (YU-ANTL) Dept. of Information & Comm. Eng, Graduate School, Yeungnam University, KOREA (Tel : +82-53-810-3940; Fax : +82-53-810-4742 http://antl.yu.ac.kr/; E-mail : yashashree@ynu.ac.kr) Outline (1) Introduction What is NS-3? NS-3 Vs. NS-2 NS-3 Features Building, installation and configuration NS-3 Getting NS-3 Source (installation) Building and Configuration NS-3 Testing NS-3 Abstractions Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 2 YU-ANTL Lab. Seminar Yashashree Jadhav Outline (2) Example Example - Conceptual NS-3 Models NS-3 Script Wired-Script Building wired-script Wireless-Script Building wireless-script DCE IEEE802.11n Standard References Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 3 YU-ANTL Lab. Seminar Yashashree Jadhav Introduction (1) What is NS-3? NS-3 is a discrete-event network simulator for Internet systems NS-3 allows researchers to study Internet protocols and large-scale systems in a controlled environment NS-3 is a new simulator (not backwards-compatible with ns-2) NS-3 is a free, open source software project organized around research community development and maintenance Developed for network research and education Developed after ns-2 Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 4 YU-ANTL Lab. Seminar Yashashree Jadhav Introduction (2) NS-3 Vs. NS-2 NS-2 uses OTcl as its scripting environment NS-3 uses C++ programs or python scripts to define simulations Simulation programs are C++ executables or Python programs NS-3 is a new simulator (not backwards-compatible with NS-2) Some NS-2 models that are mostly written in C++ have already been ported to NS-3 OTcl-based models can not be ported Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 5 YU-ANTL Lab. Seminar Yashashree Jadhav Introduction (3) NS-3 Features It is a discrete event simulator Modular design / Open source Actively developed (Contrast NS-2) Developed in C++ (Python binding available) Live visualize Logging facility for debugging Tracing facility for getting output Can be connected to a real network Direct Code Execution (DCE) Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 6 YU-ANTL Lab. Seminar Yashashree Jadhav Getting NS-3 Source (Installation) (1) Getting NS-3 source (installation) http://www.nsnam.org/ Latest release: ns-3.19 ( 20 December 2013 ) Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 7 YU-ANTL Lab. Seminar Yashashree Jadhav Getting NS-3 Source (Installation) (2) Procedure 1 Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 8 YU-ANTL Lab. Seminar Yashashree Jadhav Getting NS-3 Source (Installation) (3) Procedure 1 Ready to build the NS-3 distribution Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 9 YU-ANTL Lab. Seminar Yashashree Jadhav Building and Configuration NS-3 (1) Building with build.py sudo ./build.py --enable-examples –enable-tests Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 10 YU-ANTL Lab. Seminar Yashashree Jadhav Building and Configuration NS-3 (2) Building with waf cd ns-3.19 sudo ./waf clean sudo ./waf -d optimized --enable-examples --enable-tests confi gure Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 11 YU-ANTL Lab. Seminar Yashashree Jadhav Building and Configuration NS-3 (3) Debug build that includes the examples and tests sudo ./waf clean sudo ./waf -d debug --enable-examples --enable-tests configure Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 12 YU-ANTL Lab. Seminar Yashashree Jadhav Building and Configuration NS-3 (4) Build the debug versions of the ns-3 programs sudo ./waf sudo ./waf -d debug –enable-sudo --enable-examples --enabletests configure sudo ./waf -d debug -o build/debug --enable-examples --enable -tests configure Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 13 YU-ANTL Lab. Seminar Yashashree Jadhav Testing NS-3 (1) Testing ns-3 sudo ./test.py sudo ./test.py -c core Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 14 YU-ANTL Lab. Seminar Yashashree Jadhav Testing NS-3 (2) Running a Script sudo ./waf --run hello-simulator Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 15 YU-ANTL Lab. Seminar Yashashree Jadhav Abstractions Key Abstractions Node Application Net device Channel Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 16 YU-ANTL Lab. Seminar Yashashree Jadhav Example (1) Example - Conceptual Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 17 YU-ANTL Lab. Seminar Yashashree Jadhav Example (2) NS-3 Models Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 18 YU-ANTL Lab. Seminar Yashashree Jadhav Wired-Script (1) Module Includes The code proper starts with a number of include statements Namespace Declaration The next line in the wired script is a namespace declaration Logging Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 19 YU-ANTL Lab. Seminar Yashashree Jadhav Wired-Script (2) Main Functions Ns3 : 1.NS_LOG_ERROR — Log error messages; 2.NS_LOG_WARN — Log warning messages; 3.NS_LOG_DEBUG — Log relatively rare, ad-hoc debugging messages; 4.NS_LOG_INFO — Log informational messages about program progress; 5.NS_LOG_FUNCTION — Log a message describing each function called; 6.NS_LOG_LOGIC – Log messages describing logical flow within a function; 7.NS_LOG_ALL — Log everything. 8.NS_LOG_UNCOND – Log the associated message unconditionally. Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 20 YU-ANTL Lab. Seminar Yashashree Jadhav Wired-Script (3) Create the ns-3 Node objects that will represent the computers in the simulation We are constructing a point to point link We will need to have a list of all of the NetDevice objects that are created Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 21 YU-ANTL Lab. Seminar Yashashree Jadhav Wired-Script (4) Protocol stacks installed on our nodes TCP,IP,UDP etc. Ipv4AddressHelper Make the association between an IP address and a device Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 22 YU-ANTL Lab. Seminar Yashashree Jadhav Wired-Script (5) Two specializations of the core ns-3 class Application called UdpEchoServerApplication UdpEchoClientApplication UdpEchoServerHelper UdpEchoClientHelper Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 23 YU-ANTL Lab. Seminar Yashashree Jadhav Wired-Script (6) Simulator What we need to do at this point is to actually run the simulation scheduled events in the simulator at 1.0 seconds, 2.0 seconds and two events at 10.0 seconds Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 24 YU-ANTL Lab. Seminar Yashashree Jadhav Building wired-script (1) Building Your Script Drop your script into the scratch directory Now build your script using waf Run the example Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 25 YU-ANTL Lab. Seminar Yashashree Jadhav Wireless-Script (1) Add the Wi-Fi and the mobility modules The network topology illustration follows Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 26 YU-ANTL Lab. Seminar Yashashree Jadhav Wireless-Script (2) Wireless Network Topology For enabling or disabling logging components and for changing the number of devices created Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 27 YU-ANTL Lab. Seminar Yashashree Jadhav Wireless-Script (3) Part of the Wi-Fi Network Configure the PHY and channel helpers Create a channel object and associate it to our PHY layer object manager Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 28 YU-ANTL Lab. Seminar Yashashree Jadhav Wireless-Script (4) NqosWifiMacHelper object to set MAC parameters rate control algorithm AARF (Adaptive Auto-Rate Fallback ) algorithm The SSID of the infrastructure network Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 29 YU-ANTL Lab. Seminar Yashashree Jadhav Simulation Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 30 YU-ANTL Lab. Seminar Yashashree Jadhav Wireless-Script (5) Create the wifi devices of these stations Configure the AP (access point) node Shares the same set of PHY-level Attributes (and channel) as the stations Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 31 YU-ANTL Lab. Seminar Yashashree Jadhav Wireless-Script (6) Set some Attributes controlling the “position allocator” functionality Need to tell them how to move RandomWalk2dMobilityModel random direction random speed Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 32 YU-ANTL Lab. Seminar Yashashree Jadhav Wireless-Script (7) Need to tell them how to move Rectangle (double _xMin, double _xMax, double _yMin, double _yMax) Want the access point to remain in a fixed position during the simulation Protocol stacks Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 33 YU-ANTL Lab. Seminar Yashashree Jadhav Wireless-Script (8) Assign IP addresses to the device interfaces Enable internetwork routing Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 34 YU-ANTL Lab. Seminar Yashashree Jadhav Wireless-Script (9) Create just enough tracing to cover all three networks Run the simulation, clean up and then exit the program Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 35 YU-ANTL Lab. Seminar Yashashree Jadhav Building wireless-script Building Your Script Drop your script into the scratch directory Now build your script using waf Run the example Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 36 YU-ANTL Lab. Seminar Yashashree Jadhav Simulation Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 37 YU-ANTL Lab. Seminar Yashashree Jadhav DCE (1) Direct Code Execution DCE ns-3 module provides facilities to execute network protocols within ns-3 existing implementations of user space and kernel space DCE with iperf(dce-iperf) The example uses iperf traffic generator in a simulation DCE use we need to include the file ns3/dce-module.h Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 38 YU-ANTL Lab. Seminar Yashashree Jadhav DCE (2) The network topology illustration follows Main function Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 39 YU-ANTL Lab. Seminar Yashashree Jadhav DCE (3) DceManagerHelper It is the tool you will use within your script to parameter and install DceManager on the ns-3 nodes where you plan to run binaries LinuxStackHelper It is used to configure parameters of Linux kernel Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 40 YU-ANTL Lab. Seminar Yashashree Jadhav DCE (4) Assign IP addresses to the device DceApplicationHelper this helper in order to define which application you want to run within ns-3 Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 41 YU-ANTL Lab. Seminar Yashashree Jadhav DCE (5) Launch Iperf on client node Launch Iperf on server node Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 42 YU-ANTL Lab. Seminar Yashashree Jadhav DCE (6) Run the simulation Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 43 YU-ANTL Lab. Seminar Yashashree Jadhav DCE (7) Run the simulation Server output Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 44 YU-ANTL Lab. Seminar Yashashree Jadhav DCE (8) Client output Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 45 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (1) MAC configuration “QosSupported” feature allows configuration of 802.11e/WMM-style QoS support “HtSupported” feature Allows configuration of 802.11n High Throughput style support ns3::EdcaTxopN used by QoS-enabled high MACs and also performs QoS operations like 802.11 n-style MSDU aggregation Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 46 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (2) WifiMacHelper Used to configure MAC parameters ns3::QosWifiMacHelper Create MAC instances with QoS support enabled An MSDU aggregator for a particular Access Category (AC) in order to use 802.11n MSDU aggregation feature block ack parameters Following example shows ns3::QosWifiMacHelper to create an AP with QoS enabled, aggregation on AC_VO, and Block Ack on AC_BE Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 47 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (3) ns3::HtWifiMacHelper Creation of MAC instances that have 802.11n-style High throughput (Ht) and QoS support enabled Rate control algorithms ARF Rate control algorithm minstrel Rate control algorithm Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 48 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (4) PHY configuration YansWifiPhyHelper To enable 802.11n High Throughput style parameters the following line of code could be used WifiHelper It sets the default wifi standard to 802.11a and sets the RemoteStationManager to ns3::ArfWifiManager Change the RemoteStationManager by calling the WifiHelper::SetRemote StationManager To change the wifi standard, call the WifiHelper::SetStandard Wifi_PHY_STANDARD_80211n_2_4GHZ Wifi_PHY_STANDARD_80211n_5GHZ Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 49 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (5) Library Topology Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 50 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (6) Feature Set 802.11n Mac and PHY layer properties Also check how frame aggregation feature (A-MSDU) work Packet in this simulation belonging to best effort traffic Create Node Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 51 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (7) Set WiFi Standard Set Physical Data Rate Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 52 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (8) Set Physical Layer Set Mac Layer Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 53 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (9) Set AP and Station Set Mobility Model Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 54 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (10) Assign IP address to AP and STA Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 55 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (11) Set Client and Server Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 56 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (12) Set Flow Monitor Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 57 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (13) Throughput 1 AP 1 STA Packet Size : 1500 Byte Max Packet : 100,000 Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 58 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (14) Throughput Vs Offer Load 1 Ap 1 Station Packet Size : 1500 Byte Max Packet :100,000 Throughput 70 Throughput in MBPS 60 50 40 30 20 10 0 0 20 40 Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 60 80 Offered Load in MBPS 100 120 59 140 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (15) Topology Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 60 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (16) Main Function Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 61 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (17) Set point to point Channel Set WiFi Nodes Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 62 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (18) Set standard and Physical data rate Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 63 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (19) Set Physical Layer Set Mac Layer and Create WiFi Net Device Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 64 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (20) Set Mobility Stack Install and Address assign to device Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 65 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (21) Set Server and Client Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 66 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (22) Flow Monitor Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 67 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (23) Aggregated Throughput Vs Offer Load Packet Size : 1500 Byte Max Packet : 100,000 STA5 STA10 50 45 Throughput in MBPS 40 35 30 25 20 15 10 5 0 0 20 40 60 80 100 120 140 Offered Load in MBPS Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 68 YU-ANTL Lab. Seminar Yashashree Jadhav IEEE802.11n Standard (24) Aggregated Throughput Vs No of Stations 1 Ap N Station Packet Size : 1500 Byte Offer Load/STA : 2.91589 Mbps/STA Aggregated Throughput Aggregated Throughput in MBPS 40 35 30 25 20 15 10 5 0 0 10 20 30 40 50 60 Number of STA (N) Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 69 YU-ANTL Lab. Seminar Yashashree Jadhav References [1] http://www.nsnam.org [2] http://www.nsnam.org/docs/tutorial/tutorial.html [3] http://www.nsnam.org/wiki/index.php/MainPage Advanced Networking Tech. Lab. Yeungnam University (YU-ANTL) 70 YU-ANTL Lab. Seminar Yashashree Jadhav