Lab 2, Network Simulator ns2

Slides:



Advertisements
Similar presentations
Network Simulator and problems in installing. Introduction Problems in installing Wired networks modified example2.tcl commands in OTcl usual problems.
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.
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.
Dongsoo S. Kim 1.
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.
Assignment #2 Due Sunday Sept 17, 11:55pm. Objectives  Getting to know ns-2  Manipulate ns-2 as a black box.  Configure/Script.
Katz, Stoica F04 EECS 122 Introduction to Computer Networks (Fall 2003) Network simulator 2 (ns-2) Department of Electrical Engineering and Computer Sciences.
CprE 543x – ns-2 Tutorial Zak Abichar, Dept of Electrical and Computer Engineering Iowa State University Ames,
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.
Submitters: Stella Pantofel Michael Halperin Igor Berman
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.
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.
Date : 2010/11/23 Speaker : Chia-Wen Lu 1.  Network Simulation  Introduction to NS2  Simple Simulation Example 2.
Bridging the Gap: Turning a Network Simulation into an Emulation Mac Newbold.
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 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 
University of Texas at Arlington CSE 5346/4346 High Performance Networks 1 NS-2 Tutorial Choe, Hyun Jung (Stella) Spring 2008 Spring 2008 High Performance.
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.
NS-2 Shahin Shayandeh December 2004 Session 1. Ns-2, the Network Simulator  A discrete event simulator Simple model  Focused on modeling network protocols.
1 NS-2: the network simulator 15 September 2005 Network Lab., SNU Changjee Joo.
© 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 Simulator 최 종 훈 Contents  About NS  Installation  Based on Linux  Based on Windows  Architecture  Using NS-2  Example  References.
Overview of VANET Project(2011) on NS2 Perspective Part 1 of 2 Jae-Myeong Lee Human-centric Mobile Computing Lab.
ECE 6610 Sandeep Kakumanu GNAN research Lab
DMET 602: Networks and Media Lab
(Modified from Polly Huang’s and last year’s original)
Network Simulator Tutorial
Choe, Hyun Jung (Stella)
Introduction to ns-2: “The” Network Simulator
Introduction to NS Srinath Perur.
Ns By Kulveer Singh.
Karthik Sadasivam Banuprasad Samudrala
Network Performance modelling and simulation
Presentation transcript:

Lab 2, Network Simulator ns2 Experimental Networking Lab 2, Network Simulator ns2 Shiv Kalyanaraman Yong Xia (TA) Satish Raghunath shivkuma@ecse.rpi.edu http://www.ecse.rpi.edu/Homepages/shivkuma GOOGLE: “Shiv RPI” 1

How ns2 works 2

Ns2 Tutorial Languages Ns2 Nam Assignment #2 3

Nam View 4

Languages System language: C, C++, Java Build data structures and algorithms from scratch Strongly typed to manage complexity Compiled, high efficiency, 10~20x faster Scripting language: Perl, Tcl(OTcl), Unix shell Rapid high level programming: to “glue” applicatons Typeless to simplify connections btwn components Interpreted, less efficient Sacrifice execution speed for development speed (5~10x faster than system language for gluing dev) 5

Ns2 NS is a “Network Simulator” NS is needed because: Can setup network topologies Generate packet traffic similar to Internet and measure various parameters NS is needed because: Need to verify utility / feasibility of new algorithms / architectures Actual topologies Expensive / Error prone / Time consuming to setup 6

Ns2 status Source code Platforms C++ for packet processing, Otcl for control 100K lines of C++; 70K lines of OTcl; 50K+ lines of test suite, examples, docs http://www.isi.edu/nsnam/ns/ Current version 2.26, (v2.1-b5 installed) Platforms Most UNIX systems (FreeBSD, Linux, Solaris) Window 9x/NT/2000 7

Ns2 Most of the NS2 source code is in C++ http://www.cplusplus.com/doc/tutorial/ http://www.isi.edu/nsnam/ns http://www.isi.edu/nsnam/ns/ns-documentation.html Tcl is a simple scripting language used in conjunction with Otcl to setup simulation topologies and scenarios. http://dev.scriptics.com/man/tcl8.2.3/ OTcl adds Object orientation to Tcl http://bmrc.berkeley.edu/research/cmt/cmtdoc/otcl/tutorial.html NAM – Network Animator is used to visualize simulations http://www.isi.edu/nsnam/nam 8

C++ and OTcl Separation “data” / control separation C++ for “data”: per packet processing, core of ns fast to run, detailed, complete control OTcl for control: Simulation scenario configurations Periodic or triggered action Manipulating existing C++ objects fast to write and change running vs. writing speed Learning and debugging (two languages) Shivkuma@ecse.rpi.edu

Otcl and C++: The Duality C++/OTcl split objects otcl OTcl (object variant of Tcl) and C++ share class hierarchy TclCL is glue library that makes it easy to share functions, variables, etc Shivkuma@ecse.rpi.edu

Tcl expr 20 + 10 set x 32 set cmd expr; set x 11; $cmd $x*$x set a 44; set b [expr $a*4] set x 24; set y 18; set z "$x + $y is [expr $x + $y]" set x 24; set y 18; set z {$x + $y is [expr $x + $y]} proc power {base p} { set result 1 while {$p > 0} { set result [expr $result * $base] set p [expr $p - 1] } return $result Further: http://www.beedub.com/book/2nd/tclintro.doc.html 11

Anatomy of a simple Tcl Script Examine “simple.tcl” # This is a simple Tcl script to illustrate # basic operations puts “Executing simple tcl script” # Open a file for writing set f1 [open “try” “w”] # Write something into the file and close it puts $f1 “Writing a sentence into file” close $f1 # Read the sentence set f1 [open “try” “r”] set l1 [gets $f1] puts “Read line: $l1” Shivkuma@ecse.rpi.edu

A Simple Tcl Script (contd.) You can run the Tcl script using the program “tclsh” as: ~> tclsh simple.tcl Executing simple tcl script Read line: Writing a sentence into file ~> Let us observe the syntax: Lines beginning with “#” are treated as comments The symbol “$” is used to obtain the contents of a variable The “set” method is used to assign values to variables. Note that the “$” does not appear when something is being assigned to the variable The effect of parentheses in math is obtained by using [] – e.g., [open …] indicates that the code in the brackets is evaluated first and then assigned to f1 “puts”, “gets”, “open” are all Tcl commands. “puts $f1 …” indicates that we are passing contents of f1 as a parameter to puts Simple.tcl thus opens a file called “try”, writes a sentence and reads from it Shivkuma@ecse.rpi.edu

Exercise 1- Loops and Lists This exercise will introduce you to loops and lists in Tcl. A file contains information about path in a network. The path is specified as a list of numbers: 1 15 7 25 3 25 2 10 5 … to indicate that node 1 is connected to node 7 with a link of 15Mbps, node 7 to node 3 with 25Mbps and so on. Write a tcl script to read this file and interpret its contents. Your output should look like: Link 1: Node 1 to Node 7; Bandwidth: 15M Link 2: Node 7 to Node 3; Bandwidth: 25M You might want to use the following functions: # Create an empty list in l1 set l1 [list] # Concatenate a list/string with another and assign to l2 set l2 [concat $l1 $s1] # Access an element i from the list l2 set el1 [lindex $l2 $i] # Execute a statement n times for {set i 0} { $i < n } {incr i} { ... } Shivkuma@ecse.rpi.edu

Tcl Stop here, let students do Tcl program 15

Otcl Examples A “class” is like a struct with facilities for private and public variables, member functions and inheritance Lets examine the topology class: Class Topology Topology instproc init { } { $self instvar nodes ns set ns [Simulator instance] set nodes(1) [$ns node] set nodes(2) [$ns node] $ns duplex-link $nodes(1) $nodes(2) 10M 10ms DropTail } Topology instproc get-node { node-id } { return $nodes($node-id) Shivkuma@ecse.rpi.edu

Otcl Examples (contd.) To understand all aspects in the above example you have to know the basics of Object oriented programming. I will assume that you know at least the meaning of these terms: member functions, static functions/variables, instances, constructors The first line is the declaration of “Topology” as a class The function “init” is the equivalent of constructor in C++ - it is the first function called when an instance of this class is created by “new” operator. $self is equivalent to the “this” pointer in C++. It refers to the present instance within which the function is executing – that is it refers to “itself” “instvar” is used to declare a member variable and similarly “instproc” is used to declare a member function. The syntax of a procedure is similar to that in Tcl except that the class name has to come first and the “proc” keyword is replaced by instproc. The empty braces (“{}”) indicate that the procedure takes no parameters. Shivkuma@ecse.rpi.edu

Otcl Examples (contd.) Note that the variable ns is being assigned “[Simulator instance]”. “Simulator” is the name of a class. “instance” is a static function in the class which returns the instance of the Simulator class (already in memory) The general syntax to access member functions is $obj member-func parameters This can be observed where the duplex-link function is called to create a link between nodes(1) and nodes(2). nodes() is an array. As noted in the example no special declaration is needed to use arrays. To use this class, we may write this code: set ns [new Simulator] set t1 [new Topology] set n1 [$t1 get-node 1] Shivkuma@ecse.rpi.edu

OTcl Stop here, let students do OTcl program 19

How ns2 works 20

An example: skeleton A ns-2 simulation script generally includes Create the event scheduler Turn on tracing, if needed Create network topology Setup routing Create transport agent Create traffic source/sink Transmit application-level data 21

An example: how to start Create a event scheduler set ns [new Simulator] Open a file for trace data set nf [open out.nam w] $ns namtrace-all $nf 22

An example: how to start A procedure to close file and start NAM proc finish {} { global ns nf $ns flush-trace close $nf exec nam out.nam & exit 0 } Schedule the procedure $ns at 5.0 "finish" Start simulation $ns run 23

An example: topology Node Link set n0 [$ns node] set n1 [$ns node] $ns duplex-link $n0 $n1 1Mb 5ms DropTail $ns duplex-link $n1 $n2 400Kb 10ms DropTail 24

An example: agent / applicaiton Create a UDP agent and attach it to node n0 set udp [new Agent/UDP] $ns attach-agent $n0 $udp Create a CBR traffic source and attach it to udp0 set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp Create a null agent to be traffic sink set null [new Agent/Null] $ns attach-agent $n2 $null 25

An example: agent / applicaiton Connect them $ns connect $udp $null Schedule the event $ns at 0.5 "$cbr start" $ns at 4.5 "$cbr stop" 26

An example: agent / applicaiton Stop here, let students do UDP transmission simulation 27

An example: agent / applicaiton Create a TCP agent and attach it to node n0 set tcp [new Agent/TCP] $ns attach-agent $n0 $tcp Create a FTP traffic source and attach it to udp0 set ftp [new Application/FTP] $ftp attach-agent $tcp Create a TCPSink agent to be traffic sink set sink [new Agent/TCPSink] $ns attach-agent $n2 $sink 28

An example: agent / applicaiton Connect them $ns connect $tcp $sink Schedule the event $ns at 0.5 "$ftp start" $ns at 4.5 "$ftp stop" 29

Traces Traces in NS format $ns trace-all [open tr.out w] <event> <time> <from> <to> <pkt> <size> -- <fid> <src> <dst> <seq> <attr> + 1 0 2 cbr 210 ------- 0 0.0 3.1 0 0 - 1 0 2 cbr 210 ------- 0 0.0 3.1 0 0 r 1.00234 0 2 cbr 210 ------- 0 0.0 3.1 0 0 d 1.04218 1 2 cbr 210 ------- 0 0.0 3.1 0 0 Traces in NAM format $ns namtrace-all [open tr.nam w] Turn on tracing on specific links $ns trace-queue $n0 $n1 $ns namtrace-queue $n0 $n1 30

An example: agent / applicaiton Stop here, let students do TCP transmission simulation 31

More settings: event and queuing Schedule events $ns at <time> <event> <event>: any legitimate ns/tcl commands Links and queuing $ns duplex-link $n0 $n1 <bandwidth> <delay> <queue_type> <queue_type>: DropTail, RED, CBQ, FQ, SFQ, DRR Shivkuma@ecse.rpi.edu

More settings: Routing Unicast $ns rtproto <type> <type>: Static, Session, DV, cost, multi-path Multicast $ns multicast (right after [new Simulator]) or set ns [new Simulator –multicast on] $ns mrtproto <type> <type>: CtrMcast, DM, ST, BST (centralized,dense mode, shared tree Shivkuma@ecse.rpi.edu

More settings: Traffic on Top of UDP set udp [new Agent/UDP] set null [new Agent/Null] $ns attach-agent $n0 $udp $ns attach-agent $n1 $null $ns connect $udp $null CBR set src [new Application/Traffic/CBR] Exponential or Pareto set src [new Application/Traffic/Exponential] set src [new Application/Traffic/Pareto] Shivkuma@ecse.rpi.edu

More settings: Traffic on Top of TCP set tcp [new Agent/TCP] set tcpsink [new Agent/TCPSink] $ns attach-agent $n0 $tcp $ns attach-agent $n1 $tcpsink $ns connect $tcp $tcpsink FTP set ftp [new Application/FTP] $ftp attach-agent $tcp Telnet set telnet [new Application/Telnet] $telnet attach-agent $tcp Shivkuma@ecse.rpi.edu

Exploring further The slides till now have provided the basics of what is needed to run simulations in NS. To explore further, you can exploit the following sources: The NS manual: http://www.isi.edu/nsnam/ns/doc/index.html Example code in tcl/test directory of your NS distribution NS Mailing lists: http://www.isi.edu/nsnam/ns/ns-lists.html Shivkuma@ecse.rpi.edu

Assignment #2 See assignment page Shivkuma@ecse.rpi.edu