Ns-2 Tutorial (1) Multimedia Networking Group, The Department of Computer Science, UVA Jianping Wang Jianping Wang, 2002 cs757 1.

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

1 The ns-2 Network Simulator H Plan: –Discuss discrete-event network simulation –Discuss ns-2 simulator in particular –Demonstration and examples: u Download,
1 NS-2 Tutorial COMP R2 University of Manitoba March 4, 2009.
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
1 ns-2 Tutorial, part 2 Dave Anderson, Xiaowei Yang (Modified from Polly Huang’s slides)
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,
LAB 3 NS2 Preliminaries. Contents TCL/OTCl Fundamentals Creating Network Setting Connections Generating Traffic Inserting Errors Configuring for multicast.
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.
Dongsoo S. Kim 1.
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.
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.
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)
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.
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.
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.
1 ns-2 Tutorial Polly Huang AT&T Labs Research 11 August, 1999.
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.
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 
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:

ns-2 Tutorial (1) Multimedia Networking Group, The Department of Computer Science, UVA Jianping Wang Jianping Wang, 2002 cs757 1

Contents: Objectives of this week What is ns-2? Working with ns-2 Tutorial exercise ns-2 internals Extending the C++ part of ns-2 Hands-on: Wireless Other ns-2 related software Jianping Wang, 2002 cs757 2 Today Partly adopted from Nicolas’ slides.

Objectives of this week Get some exposure to one of the most useful tools in networking research and development. Understand and work with a popular network simulator. Get a better understanding of the networking dynamics. “Smooth the learning curve”. Jianping Wang, 2002 cs757 3

What is ns-2? ns-2 stands for Newwork Simulator version 2. ns-2: Is a discrete event simulator for networking research Work at packet level. Provide substantial support to simulate bunch of protocols like TCP, UDP, FTP, HTTP and DSR. Simulate wired and wireless network. Is primarily Unix based. Use TCL as its scripting language. ns-2 is a standard in research community. Jianping Wang, 2002 cs757 4

tcl8.0 otcl tclcl UI Event Scheduler Network Component What is ns-2 (cont.) ? otcl: Object-oriented support tclcl: C++ and otcl linkage Discrete event scheduler Data network (the Internet) components Jianping Wang, 2002 cs757 5 C++

Other Network Simulators OPNET ( Commercial Software Support Windows and Unix Graphical Interface Not free GloMoSim ( Simulation enviroment for wireless network Scalable to support thousands of nodes Using layered approach to build different simulation layers Free for educational users Jianping Wang, 2002 cs757 6

Working with ns-2 Jianping Wang, 2002 cs757 7

Getting Started: Install ns-2 Download software package from: - Easy installation way: all at once The latest version is 2.1b9a released at July 3, It contains: - Tk release Otcl release 1.0a8 - TclCL release 1.0b12 - Tcl release Ns release 2.1b9a - Nam release 1.0a11a - Xgraph version 12 - CWeb version 3.4g - SGB version Gt-itm gt-itm and sgb2ns Zlib version Jianping Wang, 2002 cs757 8

Running ns-2 program Jianping Wang, 2002 cs757 9

Hello World - Interactive Mode jwang]$ ns % set ns [new Simulator] _o4 % $ns at 1 “puts \“Hello World!\”” 1 % $ns at 1.5 “exit” 2 % $ns run Hello World! jwang]$ Jianping Wang, 2002 cs757 10

Hello World - Batch Mode simple.tcl: set ns [new Simulator] $ns at 1 “puts \“Hello World!\”” $ns at 1.5 “exit” $ns run jwang]$ ns simple.tcl Hello World! jwang]$ Jianping Wang, 2002 cs757 11

Basic tcl proc test {} { set a 43 ; a = 43 set b 27 ; b = 27 set c [expr $a + $b] ; c = a + b set d [expr [expr $a - $b] * $c] ; d = (a – b) * c for {set k 0} {$k < 10} {incr k} { ; for (k=0; k<10; k++) puts “k = $k” } Jianping Wang, 2002 cs757 12

Basic otcl Class mom 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] $a set age_ 45 set b [new kid] $b set age_ 15 $a greet $b greet Jianping Wang, 2002 cs757 13

Basic ns-2 Create a new simulator object [Turn on tracing] –[Open your own trace files] Create network (physical layer) Create link and queue (data-link layer) Define routing protocol Create transport connection (transport layer) Create traffic (application layer) Insert errors Jianping Wang, 2002 cs757 14

Creating Simulator Instance Create simulator instance set ns [new Simulator] -Usually the first non-comment statement in ns- 2 script -Initialize the packet format -Create a scheduler (default is a calendar scheduler) -Create a “null agent” Jianping Wang, 2002 cs757 15

Turning on a Tracefile Open file for NS tracing set f [open out.tr w] $ns trace-all $f Open file for nam tracing set nf [open out.nam w] $ns namtrace-all $nf Open your own trace file set my_f [open my_out.tr w] puts $my_f “[$ns now] [expr $x(1) + $y(1)]” Jianping Wang, 2002 cs757 16

Creating a Network(1) Jianping Wang, 2002 cs Network topology

Creating a Network (2) Creating nodes set node_(h1) [$ns node] set node_(h2) [$ns node] set node_(r1) [$ns node] set node_(r2) [$ns node] set node_(h3) [$ns node] set node_(h4) [$ns node] Jianping Wang, 2002 cs757 18

Creating a Network(3) Creating Link and Queue $ns duplex-link $node_(h1) $node_(r1) 10Mb 2ms DropTail $ns duplex-link $node_(h2) $node_(r2) 10Mb 3ms DropTail $ns duplex-link $node_(r1) $node_(r2) 1.5Mb 20ms DropTail $ns queue-limit $node_(r1) $node_(r2) 50 …… Jianping Wang, 2002 cs757 19

Creating a TCP connection set tcp0 [$ns create-connection TCP/Reno $node_(s1) TCPSink/DelAck $node_(s4) 0] Jianping Wang, 2002 cs757 20

Creating traffic Attaching FTP traffic on the top of TCP set ftp0 [$tcp0 attach-app FTP] Jianping Wang, 2002 cs757 21

Insert Errors set loss_module [new ErrorModel] $loss_module set rate_ 0.01 $loss_module unit pkt $loss_module ranvar [new RandomVariable/Uniform] $loss_module drop-target [new Agent/Null] $ns lossmodel $loss_module $n0 $n1 Jianping Wang, 2002 cs757 22

Summary Jianping Wang, 2002 cs757 23

Start/Stop ns Schedule an event to start traffic at time 1.0 $ns at 1.0 "$ftp0 start“ Schedule an event to stop ns at time 17.0 $ns at 17.0 "$ftp0 stop“ Start ns $ns run - last statement Stop ns exit 0 Jianping Wang, 2002 cs757 24

Visualization Tool: nam Replay events from a nam trace file The nam trace file can be huge when simulation time is long or events happen intensively. Be careful! Run nam: –$nam nam_trace_file.nam –In ns-2 script: Proc finish{} { …… exec nam nam_trace_file.nam & exit } Jianping Wang, 2002 cs757 25

Jianping Wang, 2002 cs757 26

Draw Plots Using Xgraph Create your own output files Collect statistical data synchronized. Run xgraph: –$xgraph out0.tr, out1.tr –geometry 800x400 –In ns-2 script: Proc finish{} { …… exec xgraph out0.tr, out1.tr –geometry 800x400 & exit } Jianping Wang, 2002 cs757 27

Useful URLs - the official ns homepage - ns manual /tcl/tcl_tut.html - Tcl tutorial - oTcl tutorial Jianping Wang, 2002 cs757 28