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.

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.
Network Simulator (NS) Prof. Nelson L. S. da Fonseca State University of Campinas, Brazil.
NS-2 網路模擬器介紹與使用 吳賢明國立中興大學 計算機及資訊網路中心中華民國九十三年十月二十七日.
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.
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,
Computer Networks NS. Features F Event driven simulator –developed at UC Berkeley F Network Topologies –nodes (connectivity), links (bandwidth, delay)
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)
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.
Ns Simulation of IEEE SC546 Project (Fall 2002) SOO IL KIM JISUN YOON
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
NS2 Agents Leo Bhebhe. Contents Introduction Application Composition Attaching Transport Agents to Nodes UDP Agent TCP Agents SCTP Agents Agent SRM.
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.
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.
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.
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.
The New NS2 Emulation Facility Kevin Fall NS2 is the simulation vehicle for the VINT project: –USC/ISI: Deborah Estrin, Mark Handley,
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.
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
NS2 (and possible directions for mobile routing simulation) Kevin Fall
Ns By Kulveer Singh.
Karthik Sadasivam Banuprasad Samudrala
Presentation transcript:

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 Networks Department of Computer Science and Engineering The University of Texas at Arlington

University of Texas at Arlington CSE 5346/4346 High Performance Networks 2 Outline NS-2 Overview How to Run NS-2 How to Program Simulation Examples Project Overview Q & A

University of Texas at Arlington NS-2 Overview

University of Texas at Arlington CSE 5346/4346 High Performance Networks 4 What is NS-2? VINT Project - UC Berkeley, LBL, USC/ISI, and Xerox PARC Goals - Support networking research and education - Freely distributed, open source  Share code, protocols, models, etc a Discrete Event Simulator Link layer and up Wired and Wireless

University of Texas at Arlington CSE 5346/4346 High Performance Networks 5 NS Models Wired - Routing: DV, LS, PIM-SM etc. - Transportation: TCP and UDP - Traffic sources: web, ftp, telnet, cbr, stochastic etc. - Queuing disciplines: drop-tail, RED, FQ, SFQ, DRR etc. - QoS: IntServ and Diffserv … - Emulation Wireless - Ad hoc routing, mobile IP and Satellite - Directed diffusion, sensor-MAC

University of Texas at Arlington CSE 5346/4346 High Performance Networks 6 NS Architecture Object-oriented (C++, OTcl) 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

University of Texas at Arlington CSE 5346/4346 High Performance Networks 7 OTcl and C++: The Duality C++ otcl C++/OTcl split objects Pure C++ objects Pure OTcl objects ! OTcl (object variant of Tcl) and C++ share class hierarchy !

University of Texas at Arlington CSE 5346/4346 High Performance Networks 8 NS Components - visualize ns (or other) output Pre-processing: - Traffic and topology generators Post-processing: - simple trace analysis, often in Tcl, Awk or Perl

University of Texas at Arlington Part II: How to Run NS-2

University of Texas at Arlington CSE 5346/4346 High Performance Networks 10 How to Run NS-2 ① gamma2 server - Version: Please use /tmp for your trace files (not codes) (later) - xdisplay for graphical results ② If you want to install NS2 in your own PC - Current release: ns-2.31, Mar 10, 2007)  - Platforms  Most Unix and Linux  Windows and Mac

University of Texas at Arlington CSE 5346/4346 High Performance Networks 11 How to Setup Path ls –a.cshrc setenv LD_LIBRARY_PATH /opt/ns-allinone-2.30/….bash_profile export PATH=/opt/ns-allinone-2.30/bin:$PATH export LD_LIBRARY_PATH=/opt/ns-allinone-2.30/otcl- 1.12:/opt/ns-allinone-2.30/lib:$LD_LIBRARY_PATH export TCL_LIBRARY=/opt/ns-allinone- 2.30/tcl8.4.13/library

University of Texas at Arlington CSE 5346/4346 High Performance Networks 12 gamma /tmp for Temporary Usage only - Do Not save your scripts under /tmp Use Your Own directory - mkdir /tmp/your_dir/ Example set nf [open /tmp/your_dir/out.nam w]

University of Texas at Arlington CSE 5346/4346 High Performance Networks 13 How to Install NS-2 (Under Windows) m_Under_Windows_9x/2000/XP_Using_Cygwinhttp://nsnam.isi.edu/nsnam/index.php/Running_Ns_and_Na m_Under_Windows_9x/2000/XP_Using_Cygwin Cygwin or later required Select “UNIX” text type to check current mode, type “mount | grep textmode” C:\Cygwin (not C:\Program Files\Cygwin) “Install” and Categories (next page) and others (e.g., vim) in Download NS-2 under Cygwin (E.g., under /usr/local/) tar zxvf ns-allinone-2.2x.x.tar.gz cd ns-allinone-2.2x./install

University of Texas at Arlington CSE 5346/4346 High Performance Networks 14

University of Texas at Arlington CSE 5346/4346 High Performance Networks 15 Error? error near unexpected token `)'./configure: line 7624: ` OSF*)' tcl8.3.2 configuration failed! Exiting... Tcl is not part of the ns project. Please see to see if they have a fix for your platform. - Remove ‘ only if there are two ‘ at the end of relid - find. | xargs -n 1 grep -H relid\‘ Others - installing-ns-2292-allinone.htmlhttp://ns-2.blogspot.com/2006/05/problem-in- installing-ns-2292-allinone.html -

University of Texas at Arlington CSE 5346/4346 High Performance Networks 16 How to Use Cygwin-X Run /usr/X11R6/bin/startxwin.bat % sh /usr/X11R6/bin/startxwin.sh % cp /etc/X11/xinit/xinitrc ~/.xinitrc PATH=%PATH:/usr/X11R6/bin % startx &

University of Texas at Arlington CSE 5346/4346 High Performance Networks 17 NS-2 Directory Structure TK OTcltclcl Tcl ns-2nam-1.12 tcl extest lib... examples validation tests C++ code OTcl code ns-allinone mcast /opt/ns-allinone-2.30/...

University of Texas at Arlington Part III: How to Program

University of Texas at Arlington CSE 5346/4346 High Performance Networks 19 Basic Tcl Programming setb 0 - “b = 0” in C set x $b set x [expr $a + $b] sop.inria.fr/maestro/personnel/Eitan.Altman/COURS-NS/n3.pdf sop.inria.fr/maestro/personnel/Eitan.Altman/COURS-NS/n3.pdf

University of Texas at Arlington CSE 5346/4346 High Performance Networks 20 Basic Tcl # Command arg1 arg2 arg3 … set a 43 set b 27 proc test { a b } { 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]” }

University of Texas at Arlington CSE 5346/4346 High Performance Networks 21 Elements of NS-2 Create the event scheduler [Turn on tracing] Create network Setup routing Insert errors Create transport connection Create traffic Transmit application-level data

University of Texas at Arlington CSE 5346/4346 High Performance Networks 22 How to Simulate Create event scheduler - set ns [new Simulator] Schedule events - $ns at  : any legitimate ns/tcl commands - $ns at 5.0 “finish” Start scheduler - $ns run TclCL - C++ and OTcl linkage - glue library that makes it easy to share functions, variables, etc NS-2 Tcl OTcl TclCL Event Scheduler Network Components C/C++

University of Texas at Arlington CSE 5346/4346 High Performance Networks 23 Example: helloWorld.tcl set ns [new Simulator] $ns at 1 “puts \“Hello World!\”” $ns at 1.5 “exit” $ns run % ns simple.tcl Hello World! %

University of Texas at Arlington CSE 5346/4346 High Performance Networks 24 Creating Network Nodes - set n0 [$ns node] - set n1 [$ns node] Links and queuing - $ns duplex-link $n0 $n1 - : DropTail, RED, CBQ, FQ, SFQ, DRR - $ns duplex-link-op $no $n1 OPTIONS n0n1

University of Texas at Arlington CSE 5346/4346 High Performance Networks 25 Setup Routing Unicast - $ns rtproto - : Static, Session, DV, cost, multi-path Multicast - $ns multicast (right after [new Simulator]) - $ns mrtproto - : CtrMcast, DM, ST, BST

University of Texas at Arlington CSE 5346/4346 High Performance Networks 26 Creating Connection: UDP 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 n0n1 UDPnull

University of Texas at Arlington CSE 5346/4346 High Performance Networks 27 Creating Traffic: On Top of UDP CBR - set src [new Application/Traffic/CBR] - $src attach-agent $udp0 Exponential or Pareto on-off - set src [new Application/Traffic/Exponential] - set src [new Application/Traffic/Pareto] - $src attach-agent $udp0 n0n1 UDPnull CBR

University of Texas at Arlington CSE 5346/4346 High Performance Networks 28 Structure of a Unicast Node

University of Texas at Arlington CSE 5346/4346 High Performance Networks 29 Structure of a Simplex Link

University of Texas at Arlington CSE 5346/4346 High Performance Networks 30 Creating Connection: TCP 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 n0n1 TCP sink

University of Texas at Arlington CSE 5346/4346 High Performance Networks 31 Creating Traffic: On Top of TCP FTP - set ftp [new Application/FTP] - $ftp attach-agent $tcp Telnet - set telnet [new Application/Telnet] - $telnet attach-agent $tcp n0n1 TCP sink FTP

University of Texas at Arlington CSE 5346/4346 High Performance Networks 32 A simulation example n0 n1 n2n3 n4 n5 tcp sink ftp 5Mb, 15ms 10Mb,2ms W=32

University of Texas at Arlington CSE 5346/4346 High Performance Networks 33 TCP Agents ns has several variants of TCP available: - -- Agent/TCP/Tahoe a ``tahoe'' TCP sender - -- Agent/TCP/Reno a ``Reno'' TCP sender - -- Agent/TCP/NewReno Reno with a modification - -- Agent/TCP/Sack1 TCP with selective repeat (follows RFC2018) - -- Agent/TCP/Vegas TCP Vegas - -- Agent/TCP/Fack Reno TCP with ``forward acknowledge ment'' The oneway TCP receiving agents currently supported are: - -- Agent/TCPSink TCP sink with one ACK per packet - -- Agent/TCPSink/DelAck TCP sink with configurable delay per ACK - -- Agent/TCPSink/Sack1 selective ACK sink (follows RFC2018) - -- Agent/TCPSink/Sack1/DelAck Sack1 with DelAck The twoway experimental sender currently supports only a Reno form of TCP: - -- Agent/TCP/FullTcp

University of Texas at Arlington CSE 5346/4346 High Performance Networks 34 TCP Agent Parameters Agent/TCP set tcpTick— 0.1 ;# timer granularity in sec (.1 is NONST ANDARD) Agent/TCP set maxrto— 64 ;# bound on RTO (seconds) Agent/TCP set dupacks— 0 ;# duplicate ACK counter Agent/TCP set ack— 0 ;# highest ACK received Agent/TCP set cwnd— 0 ;# congestion window (packets) Agent/TCP set awnd— 0 ;# averaged cwnd (experimental) Agent/TCP set ssthresh— 0 ;# slowstat threshold (packets) Agent/TCP set rtt— 0 ;# rtt sample Agent/TCP set srtt— 0 ;# smoothed (averaged) rtt Agent/TCP set rttvar— 0 ;# mean deviation of rtt samples Agent/TCP set backoff— 0 ;# current RTO backoff factor Agent/TCP set maxseq— 0 ;# max (packet) seq number sent

University of Texas at Arlington CSE 5346/4346 High Performance Networks 35 Tracing and Monitoring I Trace packets on all links #Open the NAM trace file #Open the Trace file - set nf [open out.nam w] set tf [open out.tr w] - $ns namtrace-all $nf $ns trace-all $tf Must appear immediately after creating scheduler Turn on tracing on specific links - $ns trace-queue $n0 $n1 - $ns namtrace-queue $n0 $n1 Event tracing (support TCP right now) - Record “event” in trace file: $ns eventtrace-all

University of Texas at Arlington CSE 5346/4346 High Performance Networks 36 Tracing and Monitoring II

University of Texas at Arlington CSE 5346/4346 High Performance Networks 37 Tracing and Monitoring III Queue monitor set qmon [$ns monitor-queue $n0 $n1 $q_f $sample_interval] - Get statistics for a queue $qmon set pdrops_ - Record to trace file as an optional Flow monitor set fmon [$ns_ makeflowmon Fid] $ns_ attach-fmon $slink $fmon $fmon set pdrops_

University of Texas at Arlington CSE 5346/4346 High Performance Networks 38 Tracing and Monitoring IV Variable tracing in nam Agent/TCP set nam_tracevar_ true $tcp tracevar srtt_ $tcp tracevar cwnd_ Monitor agent variables in nam $ns add-agent-trace $tcp $tcp $ns monitor-agent-trace $tcp $srm0 tracevar cwnd_ …… $ns delete-agent-trace $tcp

University of Texas at Arlington CSE 5346/4346 High Performance Networks 39 Visualization Tools nam-1 (Network AniMator Version 1) - Packet-level animation - Well supported by ns xgraph - Conversion from ns trace to xgraph format

University of Texas at Arlington CSE 5346/4346 High Performance Networks 40 xgraph The xgraph program draws a graph on an X display given data read from either data files. - To run it: xgraph dataFileName You can save the hardcopy of the graph as a postscript file. Xgraph is available on gamma : - /opt/ns-allinone-2.30/xgraph-12.1

University of Texas at Arlington CSE 5346/4346 High Performance Networks 41 nam Basic visualization - Topology layout - Animation control - Synchronous replay Fine-tune layout TCP/SRM visualization Editor: generate ns simulation scripts

University of Texas at Arlington CSE 5346/4346 High Performance Networks 42 ns  nam Interface Color Node manipulation Link manipulation Topology layout Protocol state Misc

University of Texas at Arlington CSE 5346/4346 High Performance Networks 43 nam Interface: Color Color mapping $ns color 1 red $ns color 2 blue $ns color 3 chocolate Color  flow id association $tcp0 set fid_ 1;# red packets $tcp1 set fid_ 2;# blue packets

University of Texas at Arlington CSE 5346/4346 High Performance Networks 44 nam Interface: Nodes Color $node color red Shape (can’t be changed after sim starts) $node shape box;# circle, box, hexagon Marks (concentric “shapes”) $ns at 1.0 “$n0 add-mark m0 blue box” $ns at 2.0 “$n0 delete-mark m0” Label (single string) $ns at 1.1 “$n0 label \”web cache 0\””

University of Texas at Arlington CSE 5346/4346 High Performance Networks 45 nam Interfaces: Links Color $ns duplex-link-op $n0 $n1 color "green" Label $ns duplex-link-op $n0 $n1 label "abced" Dynamics (automatically handled) $ns rtmodel Deterministic { } $n0 $n1 Asymmetric links not allowed

University of Texas at Arlington CSE 5346/4346 High Performance Networks 46 nam Interface: Topo 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

University of Texas at Arlington CSE 5346/4346 High Performance Networks 47 nam Interface: Protocol State Monitor values of agent variables $ns add-agent-trace $srm0 srm_agent0 $ns monitor-agent-trace $srm0 $srm0 tracevar C1_ $srm0 tracevar C2_ # … … $ns delete-agent-trace $tcp1

University of Texas at Arlington CSE 5346/4346 High Performance Networks 48 nam Interface: Misc Annotation - Add textual explaination to your sim $ns at 3.5 "$ns trace-annotate \“packet drop\"“ Set animation rate $ns at 0.0 "$ns set-animation-rate 0.1ms"

University of Texas at Arlington CSE 5346/4346 High Performance Networks 49

University of Texas at Arlington CSE 5346/4346 High Performance Networks 50 Summary: Generic Script Structure set ns [new Simulator] # [Turn on tracing] # Create topology # Setup packet loss, link dynamics # Create routing agents # Create: # - multicast groups # - protocol agents # - application and/or setup traffic sources # Post-processing procs # Start simulation