940 likes | 1.93k Views
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
E N D
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
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
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
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
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)
Getting NS-3 Source (Installation) (1) • Getting NS-3 source (installation) • http://www.nsnam.org/ • Latest release: ns-3.19 ( 20 December 2013 )
Getting NS-3 Source (Installation) (2) • Procedure 1
Getting NS-3 Source (Installation) (3) • Procedure 1 • Ready to build the NS-3 distribution
Building and Configuration NS-3 (1) • Building with build.py • sudo ./build.py --enable-examples –enable-tests
Building and Configuration NS-3 (2) • Building with waf • cd ns-3.19 • sudo ./waf clean • sudo ./waf -d optimized --enable-examples --enable-tests configure
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
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 --enable-tests configure • sudo ./waf -d debug -o build/debug --enable-examples --enable-tests configure
Testing NS-3 (1) • Testing ns-3 • sudo ./test.py • sudo ./test.py -c core
Testing NS-3 (2) • Running a Script • sudo ./waf --run hello-simulator
Abstractions • Key Abstractions • Node • Application • Net device • Channel
Example (1) • Example - Conceptual
Example (2) • NS-3 Models
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
Wired-Script (2) • Main Functions Ns3 : NS_LOG_ERROR — Log error messages; NS_LOG_WARN — Log warning messages; NS_LOG_DEBUG — Log relatively rare, ad-hoc debugging messages; NS_LOG_INFO — Log informational messages about program progress; NS_LOG_FUNCTION — Log a message describing each function called; NS_LOG_LOGIC – Log messages describing logical flow within a function; NS_LOG_ALL — Log everything. NS_LOG_UNCOND – Log the associated message unconditionally.
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
Wired-Script (4) • Protocol stacks installed on our nodes • TCP,IP,UDP etc. • Ipv4AddressHelper • Make the association between an IP address and a device
Wired-Script (5) • Two specializations of the core ns-3 class Application called • UdpEchoServerApplication • UdpEchoClientApplication • UdpEchoServerHelper • UdpEchoClientHelper
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
Building wired-script (1) • Building Your Script • Drop your script into the scratch directory • Now build your script using waf • Run the example
Wireless-Script (1) • Add the Wi-Fi and the mobility modules • The network topology illustration follows
Wireless-Script (2) • Wireless Network Topology • For enabling or disabling logging components and for changing the number of devices created
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
Wireless-Script (4) • NqosWifiMacHelper object to set MAC parameters • rate control algorithm • AARF (Adaptive Auto-Rate Fallback ) algorithm • The SSID of the infrastructure network
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
Wireless-Script (6) • Set some Attributes controlling the “position allocator” functionality • Need to tell them how to move • RandomWalk2dMobilityModel • random direction • random speed
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
Wireless-Script (8) • Assign IP addresses to the device interfaces • Enable internetwork routing
Wireless-Script (9) • Create just enough tracing to cover all three networks • Run the simulation, clean up and then exit the program
Building wireless-script • Building Your Script • Drop your script into the scratch directory • Now build your script using waf • Run the example
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
DCE (2) • The network topology illustration follows • Main function
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
DCE (4) • Assign IP addresses to the device • DceApplicationHelper • this helper in order to define which application you want to run within ns-3
DCE (5) • Launch Iperf on client node • Launch Iperf on server node
DCE (6) • Run the simulation
DCE (7) • Run the simulation • Server output
DCE (8) • Client output
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.11n-style MSDU aggregation
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
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
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::SetRemoteStationManager • To change the wifi standard, call the WifiHelper::SetStandard • Wifi_PHY_STANDARD_80211n_2_4GHZ • Wifi_PHY_STANDARD_80211n_5GHZ
IEEE802.11n Standard (5) • Library • Topology