CprE 543x – ns-2 Tutorial Zak Abichar, Dept of Electrical and Computer Engineering Iowa State University Ames,

Slides:



Advertisements
Similar presentations
1 NS-2 Tutorial COMP R2 University of Manitoba March 4, 2009.
Advertisements

Katz, Stoica F04 EECS 122 Introduction to Computer Networks (Fall 2004) Network simulator 2 (ns-2) Department of Electrical Engineering and Computer Sciences.
Wireless Communication : LAB 3
NS-2 (network simulator) NS by example παρουσίαση Κων/νος Τρούλος.
Introduction to Network Simulator NS-2 Part I
Network Simulation One tool to simulation network protocols for the Internet is the network simulator (NS) The simulation environment needs to be set-
An Introduction to NS-2 * Gayatri Swamynathan CS 276 TA *some slides are from a presentation by Haobo Yu & Nader Salehi, USC/ISI.
NS-2 Shahin Shayandeh December 2004 Session 2. Ns programming  Create the event scheduler  Turn on tracing  Create network  Setup routing  Insert.
Brief Intro to ns2: The most widely used Network Simulator COMP5416 Advanced Network Technologies Based on: Marc Greis's
Ns-2 Tutorial Exercise (1) Multimedia Networking Group, The Department of Computer Science, UVA Jianping Wang Adopted from Nicolas’s slides Jianping Wang,
Ns-2 tutorial Karthik Sadasivam Banuprasad Samudrala CSCI 5931 Network Security Instructor : Dr. T. Andrew Yang.
NS-2 網路模擬器介紹與使用 吳賢明國立中興大學 計算機及資訊網路中心中華民國九十三年十月二十七日.
How to Add a New Protocol in NS2 Xu Leiming CSCW Lab. at CS Dept., Tsinghua Univ. June 1, 2001.
5-Jul-141 S.Pushpalatha, Associate Professor, PSNACET.
Introduction to NS. Information Main website Documentation, mailing list archive, tutorial Location of Source codes –C++ files.
Winter 2008 Evaluation Tools1 Brief Overview of Networking Evaluation Methods and Tools.
NS TUTORIAL Padma Haldar USC/ISI 09/04/02.
15-744: Computer Networking ns-2 Tutorial Based on slides from John Heidemann, Polly Huang, and Amit Manjhi.
Katz, Stoica F04 EECS 122 Introduction to Computer Networks (Fall 2003) Network simulator 2 (ns-2) Department of Electrical Engineering and Computer Sciences.
1 Ns Tutorial Alhussein A. Abouzeid Elect. Eng. Dept./U. of Washington Parts of this educational presentation use examples available.
Day 3 Outline Multicast example (from Day 2) Wireless Misc. utilities
15-744: Computer Networking L-3 The network simulator ns-2 Slides loosely based on a tutorial by Polly Huang, ETH Zurich.
1 Modified Schedule Day 2 Network AniMator (nam) Examples simple.tcl mcast.tcl Day 3 Wireless (ad-hoc)
1 Network Simulator (NS-2) Tutorial These slides can be downloaded from:
1 2nd European ns-2 Workshop Polly Huang ETH Zurich April 18 & 19, 2001.
Wireless Sensor Network for Tracking the Traffic in INTERNET Network Routers Supervisor: Mark Shifrin Students: Yuriy Kipnis Nir Bar-Or Networked Software.
EECS122 - UCB1 Measurements and Modeling Table of Contents 1. Measurements Measurements 2. Modeling and its Shortcomings Modeling and its Shortcomings.
Network Simulator 2(NS2) Yingyue Xu 8/25/2015. Overview: The Network simulator (NS): discrete event simulator for networks. supports wired, wireless,
Network Simulator (NS2) 1 Tutorial on Network Simulator (NS2) Hemant Kumar Rath Infonet Lab, Dept of Electrical Engineering IIT Bombay, Mumbai
Wireless Networking and Systems CSE 590 ns2 tutorial.
10b_ns: CSci551 SP2002 Friday © 2002 John Heidemann1 NS Tutorial, Class 10 CSci551: Computer Networks SP2002 Friday Section John Heidemann.
Introduction to NS2 -Network Simulator- -Prepared by Changyong Jung.
1 Introduction to Ns-2 Zhibin WU WINLAB, ECE Dept. Rutgers U.
NS2 - Appendix Ming-Feng Yang. 2 2 Outline NS2 Models NS2 Directory Structure Extending NS2 in OTcl Extending NS2 in C++ NS2 related links.
JIA-HUI HUANG INSTITUTE OF COMPUTER SCIENCE AND INFORMATION ENGINEERING NATIONAL TAIPEI UNIVERSITY OF TECHNOLOGY Network Simulator – NS-2 1.
Network Simulator-2 Sandeep singla 1998A2A7540. NS-2 A discrete event simulator Focused on modeling network protocols –Wired, wireless –TCP,UDP,unicast,multicast.
TNK092: Network Simulation - Nätverkssimulering Lecture 3: TCP Vangelis Angelakis.
NetFlow Very useful for traffic analysis Very useful for traffic analysis Standard sampler: Standard sampler: –Cisco Netflow –Juniper Traffic Sampling.
1 Network Simulator Tutorial. 2 Network Simulation * Motivation: Learn fundamentals of evaluating network performance via simulation Overview: fundamentals.
Internet Computing KUT Youn-Hee Han
NS-2 Tutorial. Motivation What’s NS-2 Network simulator –Discrete event simulator It covers multiple layers –Application layer, transport layer, network.
Quality evaluation of MPEG4 video transmission over GPRS networks.. Presented by: Abdullah M. Rana Multimedia Communication.
1 Network Simulation and Testing Polly Huang EE NTU
1 ns-2 Tutorial Haobo Yu, Nader Salehi USC/ISI
1 NS Fundamentals. USC INFORMATION SCIENCES INSTITUTE 2 OTcl and C++: The Duality C++ OTcl Pure C++ objects Pure OTcl objects C++/OTcl split objects ns.
Ns-2 Tutorial (1) Multimedia Networking Group, The Department of Computer Science, UVA Jianping Wang Jianping Wang, 2002 cs757 1.
1 Introduction to NS-2 r Tutorial overview of NS m Create basic NS simulation r Walk-through a simple example m Model specification m Execution and trace.
NS2-TCP Internet Computing KUT ( Youn-Hee Han It is licensed under a Creative Commons Attribution.
Lab 2, Network Simulator ns2 Shiv Kalyanaraman Yong Xia (TA) Satish Raghunath Sept 4,
Network Simulator Tutorial Wireless Networks. Acknowledgements Material is taken from the presentations by Jim Kurose, University of Massachusetts, Amherst.
Network Simulator 2. Introduction Open source network simulator NS uses two languages: C++ and OTcl  C++ is fast to run but slower to change Kernel 
The Creation of NS2 Simulated Environment ( 1 ) LI Chengbo
TNK092: Network Simulation - Nätverkssimulering Lecture #1: Course basics and a first taste of NS2 Vangelis Angelakis Ph.D.
July 7, 2003 Building a Wireless LAN traffic test case in ns2 Radio Science Laboratory Department of Electrical and Computer Engineering The University.
NS-2 Shahin Shayandeh December 2004 Session 1. Ns-2, the Network Simulator  A discrete event simulator Simple model  Focused on modeling network protocols.
Network Simulation Using NS2
Lab 2, Network Simulator ns2
© Algirdas Pakstas CS3026N Network Analysis, Design and Simulation 1 CT3020: Network Planning and Simulation Week 6b Prof.DrTech. Algirdas Pakštas.
DMET 602: Networks and Media Lab Amr El Mougy Yasmeen EssamAlaa Tarek.
NS-2 Training 12/12/2011. Introduction  NS-2: Network Simulator Generation 2  Latest Release: 2.35 / Nov. 4, 2011 
Perl & TCL Vijay Subramanian, Modified from : perl_basics_06.ppt.
NS-2 Simulator 최 종 훈 Contents  About NS  Installation  Based on Linux  Based on Windows  Architecture  Using NS-2  Example  References.
ECE 6610 Sandeep Kakumanu GNAN research Lab
DMET 602: Networks and Media Lab
(Modified from Polly Huang’s and last year’s original)
Choe, Hyun Jung (Stella)
Introduction to ns-2: “The” Network Simulator
Introduction to NS Srinath Perur.
Ns By Kulveer Singh.
Karthik Sadasivam Banuprasad Samudrala
Presentation transcript:

CprE 543x – ns-2 Tutorial Zak Abichar, Dept of Electrical and Computer Engineering Iowa State University Ames, IA Based on a presentation by Polly Huang (2 nd European ns-2 Workshop, April 2001)

2 Tutorial Goals overview/intro/essentials/getting started tcl/otcl/ns-2 fundamentals designing a simulation examples

3 Outline Introduction –The project, the software, the philosophy –Software architecture –Installation and getting started –About extending ns-2 tcl/otcl/ns-2 fundamentals –Programming tcl/otcl Running a ns-2 simulation –Simulation design –Example scripts

4 The VINT Project Virtual InterNet Testbed –a common platform for network research –focus on multi-protocol interactions and scale – Follow-up projects –SAMAN: scenario and performance –CONSER: educational use

5 Multi-state collaboration AT&T Research Lawrence Berkeley National Laboratory UC Berkeley USC/ISI Xerox PARC ETH TIK (Swiss Federal Institute of Technology)

6 Project Goal To support collaborative simulation effort –promote sharing incorporate recent simulation models –increase confidence in results establish regression test suite –establish common reference current and periodic availability of source code Base software is ns-2

7 ns-2 Discrete event simulator Packet level Link layer and up Wired and wireless

8 Development Status Columbia NEST UCB REAL ns-1 ns-2 –100K lines of C++ code –70K lines of otcl support code –30K lines of test suites –20K lines of documentation

9 Usage and Releases Users from approximately –600 institutes –50 countries Releases –periodic official releases –nightly snapshots (probably compiles and works, but buyers beware) –available from USC/ISI or UK mirror

10 Platforms Most UNIX and UNIX-like systems  FreeBSD or *BSD  Linux  Sun Solaris  HP, SGI Window 95/98/NT... Emulation only for FreeBSD for now

11 Words of Caution While we have considerable confidence in ns, ns is not a polished and finished product, but the result of an ongoing effort of research and development. In particular, bugs in the software are still being discovered and corrected. Users of ns are responsible for verifying for themselves that their simulations are not invalidated by bugs.

12 Preliminary for NS-2 Ability to write correct programs Familiarity with object-oriented programming Patience to debug NS source code when needed –Simple usage will not need NS source code debugging –More complex simulations may need modification to NS source code Debugging skills –NS uses C++ and Otcl –User scripts are in Otcl

13 What you can do using NS-2 Simulate different scenarios with existing protocols (TCP/UDP) Wired Routing protocols - Distance Vector and Link State (with the link state patch) Ad-Hoc Routing protocols - DSR, AODV, TORA MAC protocols , (Wireless MAC) Scheduling disciplines - DropTail, RED, WFQ, DRR, LQD etc. Different traffic characterizations - Poisson, Exponential, Pareto etc.

14 What you can do using NS-2 Modify NS-2 to implement your own versions of the above protocols or even code totally new protocols Measurement of Statistics: –Throughput, Delay, Jitter etc. –Queue Monitoring, Drops at Queues. –Literally all that you will need to know with your simulations. Graphic visualization - using “nam” (Network Animator)

15 The downside Cannot capture all the nuances of the real world networks. Very large scale simulations take a lot of time – they may not be feasible Still in the research phase, and there may be many more bugs lurking out there Documentation not adequate No fancy user interface – often perceived as “unfriendly” (at least by people who are new to ns-2)

16 Outline Introduction –The project, the software, the philosophy –Software architecture –Installation and getting started –About extending ns-2 tcl/otcl/ns-2 fundamentals –Programming tcl/otcl Running a ns-2 simulation –Simulation design –Example scripts

17 Object-Oriented +Reusability +Maintainability –Careful planning ahead –Performance

18 C++ and otcl Separation C++ for data –per packet action otcl for control –periodic or triggered action +Compromize between composibility and speed –Learning & debugging

19 otcl and C++: The Duality C++ otcl

20 tcl Interpreter With Extents otcl: Object-oriented support tclcl: C++ and otcl linkage Discrete event scheduler Data network components tcl8.0 otcl tclcl ns-2 Event Scheduler Network Component

21 Installation Getting the code: – Installing ns-2 –

22 About extending ns-2 Implement new functionalities not covered in ns-2 –Essential for researchers –Implementing and evaluating new protocols and schemes Requires the understanding of the internal architecture –Not that hard Need more information?

23 Outline Introduction –The project, the software, the philosophy –Software architecture –Installation and getting started –About extending ns-2 tcl/otcl/ns-2 fundamentals –Programming tcl/otcl Running a ns-2 simulation –Simulation design –Example scripts

24 Hello World simple.tcl set ns [new Simulator] $ns at 1 “puts \“Hello World!\”” $ns at 1.5 “exit” $ns run % ns simple.tcl Hello World! %

25 Fundamentals tcl otcl –ftp://ftp.tns.lcs.mit.edu/pub/otcl/doc/tutorial.html ns-2 – – –

26 Basic tcl proc test {} { set a 43 set b 27 set c [expr $a + $b] set d [expr [expr $a - $b] * $c] for {set k 0} {$k < 10} {incr k} { if {$k < 5} { puts “k < 5, pow= [expr pow($d, $k)]” } else { puts “k >= 5, mod= [expr $d % $k]” } } } test k < 5, pow = 1.0 k < 5, pow = k < 5, pow = k < 5, pow = k < 5, pow = k > 5, mod = 0 k > 5, mod = 4 k > 5, mod = 0 k > 5, mod = 4

27 Basic otcl Class mom mom instproc init {age} { $self instvar age_ set age_ $age } mom instproc greet {} { $self instvar age_ puts “$age_ years old mom: How are you doing?” } Class kid -superclass mom kid instproc greet {} { $self instvar age_ puts “$age_ years old kid: What’s up, dude?” } set a [new mom 34] set b [new kid 6] $a greet $b greet 34 years old mom: How are you doing? 6 years old kid: What's up?

28 Outline Introduction –The project, the software, the philosophy –Software architecture –Installation and getting started –About extending ns-2 tcl/otcl/ns-2 fundamentals –Programming tcl/otcl Running a ns-2 simulation –Simulation design –Example scripts

29 NS input & output

30 Running a Simulation Design your simulation Build NS-2 scripts Run simulation program Analyze trace files Visualize your simulation (Animation)

31 Design your simulation Goal and expected results Network topology –Node –Link Specify Agents –Protocol Traffic Simulation Scenario

32 A simulation example

33 A TCL script example set ns [new Simulator] set n0 [$ns node] set n1 [$ns node] n0n1 set ftp [new Application/FTP] $ftp attach-agent $tcp $ns at 0.2 "$ftp start" $ns at 1.2 ”exit" $ns run $ns duplex-link $n0 $n1 1.5Mb 10ms DropTail set tcp [$ns create-connection TCP $n0 TCPSink $n1 0] Network Topology Transport Protocol Traffic Generation

34 Run simulation program Usage: ns file.tcl If the C++ source codes are modified, re-compilation is required What ns-2 does: –Read the tcl file –Run the simulation program –Create trace files –NAM (network animator) input files –Statistics (you may need to write post processing scripts)

35 Analyze trace file Use some scripts like awk or Perl, to filter the trace file Use Excel, xplot or xgraph to plot the results

36 Raw trace file tcp tcp r tcp tcp tcp r tcp ack ack r ack ack ack r ack tcp tcp

37 Open trace.out in Excel

38 Plot results in Excel

39 Outline Introduction –The project, the software, the philosophy –Software architecture –Installation and getting started –About extending ns-2 tcl/otcl/ns-2 fundamentals –Programming tcl/otcl Running a ns-2 simulation –Simulation design –Example scripts

40 A Simulation Example

41 TCL Script Step 1 #Create a simulator object set ns [new Simulator] #Open the NAM trace file set nf [open out.nam w] $ns namtrace-all $nf #Open the general trace file Set f [open out.tr w] $ns trace-all $f # has denotes a one line comment ns holds the name of the new simulation

42 TCL Script Step 2 #Create four nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] #Create links between the nodes $ns duplex-link $n0 $n2 2Mb 10ms DropTail $ns duplex-link $n1 $n2 2Mb 10ms DropTail $ns duplex-link $n2 $n3 1.7Mb 20ms DropTail

43 TCL Script Step 3 # Set Queue Size of link (n2-n3) to 10 $ns queue-limit $n2 $n3 10 #Setup a TCP connection set tcp [new Agent/TCP] $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n3 $sink $ns connect $tcp $sink #Setup a FTP over TCP connection set ftp [new Application/FTP] $ftp attach-agent $tcp

44 TCL Script Step 4 #Setup a UDP connection set udp [new Agent/UDP] $ns attach-agent $n1 $udp set null [new Agent/Null] $ns attach-agent $n3 $null $ns connect $udp $null #Setup a CBR over UDP connection set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set packet_size_ 1000 $cbr set rate_ 1mb

45 TCL Script Step 5 #Schedule events for the CBR and FTP agents $ns at 0.1 "$cbr start" $ns at 1.0 "$ftp start" $ns at 4.0 "$ftp stop" $ns at 4.5 "$cbr stop" #Call the finish procedure after 5 seconds of simulation time $ns at 5.0 "finish"

46 TCL Script Step 6 #Define a 'finish' procedure proc finish {} { global ns nf $ns flush-trace #Close the NAM trace file close $nf #Execute NAM on the trace file exec nam out.nam & exit 0 } #Run the simulation $ns run