TNK092: Network Simulation - Nätverkssimulering Lecture #1: Course basics and a first taste of NS2 Vangelis Angelakis Ph.D.

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.
NS2 Tutorial – Part II Internet Computing KUT Youn-Hee Han.
Wireless Communication : LAB 3
NS-2 (network simulator) NS by example παρουσίαση Κων/νος Τρούλος.
NS2-TCP Internet Computing KUT ( Youn-Hee Han It is licensed under a Creative Commons Attribution.
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.
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.
Network Simulator 2 Tejas Vasavada.
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.
EECS122 - UCB1 Project 3: ns Simulation of Application-Level Routing Improve the application performance by user-level / application-level routing. Understand.
1 Modified Schedule Day 2 Network AniMator (nam) Examples simple.tcl mcast.tcl Day 3 Wireless (ad-hoc)
Submitters: Stella Pantofel Michael Halperin Igor Berman
1 Network Simulator (NS-2) Tutorial These slides can be downloaded from:
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 - Wireless Network Ming-Feng Yang. 2 2 Outline Basic wireless model Extensions wireless model Example - Ad hoc network Example – WLAN Example – Mobile.
Tutorial: The ns-2 Network Simulator Amirali Habibi Shrif Univesity Adapted from: Michael Welzl Institute of Computer Science University of Innsbruck,
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.
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.
CDA6530: Performance Models of Computers and Networks Chapter 10: Introduction to Network Simulator (NS2) TexPoint fonts used in EMF. Read the TexPoint.
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.
C++ LANGUAGE TUTORIAL LESSON 1 –WRITING YOUR FIRST PROGRAM.
The Creation of NS2 Simulated Environment ( 1 ) LI Chengbo
NS-2 Shahin Shayandeh December 2004 Session 1. Ns-2, the Network Simulator  A discrete event simulator Simple model  Focused on modeling network protocols.
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.
CS 283Computer Networks Spring 2013 Instructor: Yuan Xue.
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 
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)
Network Simulator Tutorial
Choe, Hyun Jung (Stella)
Introduction to ns-2: “The” Network Simulator
Ns By Kulveer Singh.
Karthik Sadasivam Banuprasad Samudrala
Presentation transcript:

TNK092: Network Simulation - Nätverkssimulering Lecture #1: Course basics and a first taste of NS2 Vangelis Angelakis Ph.D.

Basic Course Information Examiner: Prof. Di Yuan Seminars: Dr. Vangelis Angelakis Labs: Ms. Qing He 6 ECTS, Load distribution:  Lab assignments: 2/6  Project work: 4/6 Subscribe to the course mailing list!! Webpage at: 2

Lectures 1.Course basics and first NS2 steps. 2.Manipulating results and adding modules 3.TCP/IP in NS2 4.Routing and network Dynamics 5.Wireless Networking Simulation 6.Wired & Wireless [sept. 21] backup lecture date. 3 [ aug. 28 ] [ aug. 29 ] [ aug. 31 ] [ sept. 4 ] [ sept. 5 ] [ sept. 12 ]

Assignments & Lab sessions 1.Learning to handle NS2 2.Setting up a new module in NS2 3.TCP/IP 4.Wireless networking 4 (+1) Lab sessions: Give you assistance on given assignment The 2 first give you hints & the basic steps on  how to proceed with it  what to expect The 2 last expect you to have done most of the job by then  assistive role. At the end of a lab session you DELIVER the report on the previous lab assignment  i.e.: on the session of Tue. Sept. 11 th, you are expected to deliver a report on the lab assignment discussed in the session of Sept. the 4 th. 4 [ sept. 4 ] [ sept. 11 ] [ oct. 2] [oct. 16 ]

Lab Groups and Project Teams For the Labs you MUST:  Select a lab partner  DEADLINE: TUESDAY, Sept. 4 5 I M P O R T A N T

Project 6 Implementation of (recent) research papers, with simulatory results Available on the course webpage from Tuesday, Sept. 11 th By Tuesday SEP :59 the course list (+ me) stating:  The names of TWO (2) students forming a project group  A list of 2-3 papers that the group is interested in IN ORDER OF PREFERENCE  Assignment of papers will be done in a first-come-first served manner, BUT:  Some groups may be assigned the same paper Such groups MUST work separately Reports and codes of these groups will be compared to identify integrity issues.

Project Deliverables 7 1.Project PROPOSAL By TUESDAY SEP. 30: NO extensions a brief summary identifying the paper’s KEY IDEA and the MAIN RESULT a list of the key points to implement that will illustrate them a list of the key system parameters, as the ones contained in the paper along with potential added assumptions 2.FINAL Report By SUNDAY OCT. 21: NO extensions  NS2 Implementation  Written 5-page (double-column) report  If FAIL deadlines for project resubmission (retake): Jan. 20, 2013 Aug. 25, Details on the course website

Other timeslots 1.lab time exceeding the assignments: One extra session [ Oct. 16] 2.Project tutorial sessions on a project group need-to-do basis i.e. BY APPOINTMENT! Sept 21: 8:15-10:15 Oct. 3: 17:15-19:15 Oct. 9: 13:15-17:15 Further tutorial may be arranged (upon availability only) by further arrangements 8

Some resources NS simulator for beginners: NS by example: The ns-2 wiki, user information: Getting started with ns-2: 9

Installation For Linux (Redhat, Ubuntu), FreeBSD, or other,  gcc needed  download ns-allinone software package, unzip (tar)  building ns from the sources (./install)  remember the enviromental variables (.bashrc in your own directory) For Windows  using Vmware Player (Free) will be the one used later on for the Lab download the ubuntu image for vmware, and install ns on your linux system: DETAILED INSTRUCTIONS ON THE COURSE WEB-PAGE  using Cygwin (Free) install Cygwin ( install all the packages if you don’t know which one you need instead of the defaut one download nsallinonesoftware package, unzip (tar) to one directory build ns source (./install) remember the enviromental variable (.bashrc) See Lab instructions or NS2 homepage for detailed information 10

NS2 Hello World! (hello.tcl) set ns [new Simulator] $ns at 1 “puts \“Hello World!\”” $ns at 1.5 “exit” $ns run $ $ ns hello.tcl Hello World! $ | 11

Tcl programming fundamentals 1/4 # This is a comment,the tcl interpreter will not “see” it set b 0 assigns to b the value 0 set x $a assigns to variable ‘ x ’ the value of variable ‘ a ’  To use the value assigned to a variable, we use the $ sign before the variable. set x [expr $a + $b]  A mathematical operation is done using the expr (ession) command. set myFilePtr [open my_filename w] opens my_filename for writing and gives you the pointer myFilePtr 12

Tcl programming fundamentals 2/4 puts $myFilePtr "text"  each time the puts command is used, a new line is started.  To avoid new line, one has to add -nonewline after puts  Tabulating is done by inserting \t puts "[expr 1/60]" will print ‘0’ on the screen  In Tcl the variables have no specific type, so a variable can be a string or an integer depending on the value you assign to it. puts "[expr 1.0/60.0]" to get the correct result exec xgraph data & Executes the unix program xgraph with input the file data. the & is used for background running 13

Tcl programming fundamentals 3/4 if { expression } { } else { }  The “ if ” command can be nested with other “ if ”s and with “ else ”s that can appear in the ” ” part  To test for equality, we use ==  For inequality, we use != for {set i 0} {$i < 5} {incr i} { } 14

Tcl programming fundamentals 4/4 proc blue { par1 par2... } { global var1 var2 return $something } This procedure is called by typing: blue x y in our tcl script  The values of x and y will be used by the procedure for par1 and par2. If par1 and par2 are changed within the procedure, this will not affect the values of x and y at the caller level (…“by value” argument passing)  On the other hand, if we wish the procedure to be able to affect directly variables external to it, we have to declare these variables as " global ". In the above example these are var1 and var2 15

TCL basic #1 16

TCL basic #2 17 fmod : Return the remainder after dividing expression x by expression y. break : could be used here... Notice there is a TCL commands wiki at:

Basic scripting: initialization & termination 1. Create a Simulator object set ns [new Simulator] The finish procedure: Flushing & closing the traces proc finish{} { global ns trc_file nam_file $ns flush-trace close trc_file close nam_file exec nam out.nam & exit 0 } 2. Output Traces: set file1 [open out.tr w] $ns trace-all $trc_file Data trace for all links set file2 [open out.nam w] $ns nametrace-all $nam_file Visual trace using the nam file format

Definition of nodes & links Create nodes set n0 [$ns node] set n1 [$ns node] Link the nodes Format follows: duplex-link $n0 $n1 e.g.: $ns duplex-link $n0 $n1 1Mb 10ms 19

Definition of nodes & links: a simplex link 20

An example Create nodes 21 Check: ns-default.tcl Find there default value

Basic networking scripts An ”automated” topology example for {set i 0} {$i < 7} {incr i} { set n($i) [$ns node] } for {set i 0} {$i < 7} {incr i} { $ns duplex-link $n($i) $n([expr($i+1)%7]) 1Mb 10ms RED } 22

Agents and applications Creating Data Connections  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  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 23 n1 n0 tcp/udp sink

Basic Scripts Generating Traffic  FTP set ftp [new Application/FTP] $ftp attach-agent $tcp  Telnet set telnet [new Application/Telnet] $telnet attach-agent $tcp  CBR set src [new Application/Traffic/CBR]  Exponential, or Pareto on-off set src [new Application/Traffic/Exponential] set src [new Application/Traffic/Pareto] n1 n0 tcp ftp sink

Basic Scripts Insert Link dynamics Creating Error Module set loss_module[new ErrorModel] $loss_moduleset rate_ 0.01 $loss_moduleunit pkt $loss_module ranvar[new RandomVariable/Uniform] $loss_moduledrop-target [new Agent/Null] Inserting an Error Module $ns lossmodel $loss_module$n0 $n1 25

Basic Scripts Schedule Events and Run Simulation  Schedule Events $ns at  : any legitimate ns/tcl command $ns at 0.5 “$cbr start” $ns at 4.5 “$cbr stop”  Call ‘finish’ $ns at 5.0 “finish”  Run the simulation $ns run 26

Visualizing NAM 27 Remember this:

Visualizing NAM 28

Visualizing NAM Nodes  Color $node color red  Shape (can’t be changed after simulation starts) $node shape box (circle, box, hexagon)  Label (single string) $ns at 1.1 “$n0 label \”web cache 0\”” 29

Visualizing NAM Links  Color $ns duplex-link-op $n0 $n1 color "green”  Label $ns duplex-link-op $n0 $n1 label “backbone" 30

Visualizing NAM Layout  “Manual” layout: specify everything $ns duplex-link-op $n(0) $n(1) orient right $ns duplex-link-op $n(1) $n(2) orient right $ns duplex-link-op $n(2) $n(3) orient right $ns duplex-link-op $n(3) $n(4) orient 60deg  If anything missing  automatic layout 31

Example 1 32

Example 1 33

Example 2 #Create a simulator object set ns [new Simulator] #Open the nam trace file set nf [open out.nam w] $ns namtrace-all $nf #Define a 'finish' procedure proc finish {} { global ns nf $ns flush-trace #Close the trace file close $nf #Execute nam on the trace file exec nam out.nam & exit 0 } #Create two nodes set n0 [$ns node] set n1 [$ns node] #Create a duplex link between the nodes $ns duplex-link $n0 $n1 1Mb 10ms DropTail 34 # #Create a UDP agent and attach it to node n0 set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0 # Create a CBR traffic source and attach it to udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ $cbr0 attach-agent $udp0 #Create a Null agent (a traffic sink) and attach it to node n1 set null0 [new Agent/Null] $ns attach-agent $n1 $null0 #Connect the traffic source with the traffic sink $ns connect $udp0 $null0 #Schedule events for the CBR agent $ns at 0.5 "$cbr0 start" $ns at 4.5 "$cbr0 stop" #Call the finish procedure after 5 seconds of simulation time $ns at 5.0 "finish" #Run the simulation $ns run

Visualizing NAM 35

Example 3 #Create a simulator object set ns [new Simulator] #Define different colors for data flows $ns color 1 Blue $ns color 2 Red #Open the nam trace file set nf [open out.nam w] $ns namtrace-all $nf #Define a 'finish' procedure proc finish {} { global ns nf $ns flush-trace #Close the trace file close $nf #Execute nam on the trace file exec nam out.nam & exit 0 } #Create four nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] 36 #Create links between the nodes $ns duplex-link $n0 $n2 1Mb 10ms DropTail $ns duplex-link $n1 $n2 1Mb 10ms DropTail $ns duplex-link $n3 $n2 1Mb 10ms SFQ $ns duplex-link-op $n0 $n2 orient right-down $ns duplex-link-op $n1 $n2 orient right-up $ns duplex-link-op $n2 $n3 orient right #Monitor the queue for the link between node 2 and node 3 $ns duplex-link-op $n2 $n3 queuePos 0.5 #Create a UDP agent and attach it to node n0 set udp0 [new Agent/UDP] $udp0 set class_ 1 $ns attach-agent $n0 $udp0 # Create a CBR traffic source and attach it to udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ $cbr0 attach-agent $udp0

Example 3 #Create a UDP agent and attach it to node n1 set udp1 [new Agent/UDP] $udp1 set class_ 2 $ns attach-agent $n1 $udp1 # Create a CBR traffic source and attach it to udp1 set cbr1 [new Application/Traffic/CBR] $cbr1 set packetSize_ 500 $cbr1 set interval_ $cbr1 attach-agent $udp1 #Create a Null agent (a traffic sink) and attach it to node n3 set null0 [new Agent/Null] $ns attach-agent $n3 $null0 #Connect the traffic sources with the traffic sink $ns connect $udp0 $null0 $ns connect $udp1 $null0 #Schedule events for the CBR agents $ns at 0.5 "$cbr0 start" $ns at 1.0 "$cbr1 start" $ns at 4.0 "$cbr1 stop" $ns at 4.5 "$cbr0 stop" #Call the finish procedure after 5 seconds of simulation time $ns at 5.0 "finish" #Run the simulation $ns run 37

38

Example 4 #Create a simulator object set ns [new Simulator] #Tell the simulator to use dynamic routing $ns rtproto DV #Open the nam trace file set nf [open out.nam w] $ns namtrace-all $nf #Define a 'finish' procedure proc finish {} { global ns nf $ns flush-trace #Close the trace file close $nf #Execute nam on the trace file exec nam out.nam & exit 0 } #Create seven nodes for {set i 0} {$i < 7} {incr i} { set n($i) [$ns node] } #Create links between the nodes for {set i 0} {$i < 7} {incr i} { $ns duplex-link $n($i) $n([expr ($i+1)%7]) 1Mb 10ms DropTail } 39 #Create links between the nodes for {set i 0} {$i < 7} {incr i} { $ns duplex-link $n($i) $n([expr($i+1)%7]) 1Mb 10ms DropTail } #Create a UDP agent and attach it to node n(0) set udp0 [new Agent/UDP] $ns attach-agent $n(0) $udp0 # Create a CBR traffic source and attach it to udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ $cbr0 attach-agent $udp0 #Create a Null agent (a traffic sink) #and attach it to node n(3) set null0 [new Agent/Null] $ns attach-agent $n(3) $null0 #Connect the traffic source with the traffic sink $ns connect $udp0 $null0 #Schedule events for the CBR agent # and the network dynamics $ns at 0.5 "$cbr0 start" $ns rtmodel-at 1.0 down $n(1) $n(2) $ns rtmodel-at 2.0 up $n(1) $n(2) $ns at 4.5 "$cbr0 stop" #Call the finish procedure after 5 seconds #of simulation time $ns at 5.0 "finish" #Run the simulation $ns run

40