15-744: Computer Networking L-3 The network simulator ns-2 Slides loosely based on a tutorial by Polly Huang, ETH Zurich.

Slides:



Advertisements
Similar presentations
Wireless Communication : LAB 3
Advertisements

NS-2 (network simulator) NS by example παρουσίαση Κων/νος Τρούλος.
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,
Ns-2 tutorial Karthik Sadasivam Banuprasad Samudrala CSCI 5931 Network Security Instructor : Dr. T. Andrew Yang.
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.
1 Network Simulation and Testing Polly Huang EE NTU
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.
Day 3 Outline Multicast example (from Day 2) Wireless Misc. utilities
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.
NS2 Tutorial Aga Zhang Dependable Computing Lab. Outline Introduction Fundamental Skills - Tcl and OTcl Network Simulator - ns-2 Study Project - Mobile.
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 ns-2 Noun Choi Oct. 11, Outline Background ns-2 Internals Short demo Troubleshooting Reference links Q & A.
1 Introduction to Ns-2 Zhibin WU WINLAB, ECE Dept. Rutgers U.
NS2 Tutorial for CS740 Jianming Wu *modified from Aga Zhang.
1 Part III: Extending ns. USC INFORMATION SCIENCES INSTITUTE 2 Outline Extending ns In OTcl In C++ Debugging.
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.
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
Network Simulator ns-2. 2 Agenda Introduction Interface Tcl and OTcl TclCL Simulator Wired network Wireless network Program Assignment.
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.
Su Wen Department of Computer Science
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.
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,
NS2Work1 LAB 5 Adding New Components High level scripting in otcl Linking otcl and C++ Low level in C++
Network Simulator Tutorial Wireless Networks. Acknowledgements Material is taken from the presentations by Jim Kurose, University of Massachusetts, Amherst.
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.
1 Part II: ns Internals. USC INFORMATION SCIENCES INSTITUTE 2 Outline Fundamental concept Split object: C++/OTcl linkage Plumbing Wired Wireless Scaling.
(Tue) 1 Network Simulator 2 - Introduction for Beginners CNLAB ns - 2 seminar.
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.
Network Simulation and Simulator Internals 潘仁義
NS-2 Shahin Shayandeh December 2004 Session 1. Ns-2, the Network Simulator  A discrete event simulator Simple model  Focused on modeling network protocols.
Applications and transport agent API 許庭瑋.
Lab 2, Network Simulator ns2
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.
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.
Karthik Sadasivam Banuprasad Samudrala
Network Performance modelling and simulation
Aga Zhang Dependable Computing Lab
Presentation transcript:

15-744: Computer Networking L-3 The network simulator ns-2 Slides loosely based on a tutorial by Polly Huang, ETH Zurich.

What is ns? Network simulator VINT Project -- Virtual Internet Testbed Collaboration of many institutes AT&T UC Berkeley XEROX PARC ETH Goals

ns --- what is it good for? Evaluate performance of existing network protocols. Prototyping and evaluation of new protocols. Large-scale simulations not possible in real experiments. Used to:

ns Event-driven simulator Packet level Link layer and up How does it work:

Development Status 100K lines of C++ code 70K lines of otcl code 20K lines of documentation Otcl / Tcl tclcl C++ Current status:

otcl and C++: The Duality OTcl C++ Pure OTcl objects Pure C++ objects C++/OTcl split objects ns Your ns-script

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?” } set a [ new mom 45] $a greet instead of single class declaration multiple definitions instproc adds method instvar adds instance variable methods are always called through object ( $self) init instproc instead of constructor

Basic otcl - inheritance Class kid - superclass mom kid instproc greet {} { $ self instvar age_ puts “$age_ years old kid: What’s up, dude?” } set b [ new kid 15] $b greet

Basic structure of ns-scripts Creating the event scheduler [Tracing] Creating network topology Creating Transport Layer - Agents Creating Applications - Applications Events!

Creating Event Scheduler Create scheduler set ns [new Simulator] Schedule event $ns at : any legitimate ns/tcl commands Start scheduler $ns run

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

Creating Network Nodes set n0 [$ns node] set n1 [$ns node] Links & Queuing $ns duplex-link $n0 $n1

Transport Layer Class Agent Agent/UDPAgent/TCP (=Tahoe) … Other TCP flavors

The transport layer: 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

The transport layer: 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

Transport Layer Class Agent Agent/UDPAgent/TCP (=Tahoe) … Other TCP flavors Agent/TCP/FullTCP

Two-way TCP FullTcp connection set tcp1 [new Agent/TCP/FullTcp] set tcp2 [new Agent/TCP/FullTcp] $ns attach-agent $n1 $tcp1 $ns attach-agent $n2 $tcp2 $ns connect $tcp1 $tcp2 $tcp2 listen

Application Layer Class A pplication {Simulated Applications} (on top of TCP) {Traffic generators} (on top of UDP)

Creating Traffic: On Top of TCP FTP set ftp [new Application/FTP] $ftp attach-agent $tcp $ns at “$ftp start” Telnet set telnet [new Application/Telnet] $telnet attach-agent $tcp

Creating Traffic: On Top of UDP CBR set src [new Application/Traffic/CBR] Exponential or Pareto on-off set src [new Application/Traffic/Exponential] set src [new Application/Traffic/Pareto]

Attaching a traffic source set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $ns at “$cbr start”

Tracing Trace packets on all links: set f[open out.tr w] $ns trace-all $f $ns flush-trace close $f cbr cbr r cbr Is tracing all links allways the best thing to do?

More Tracing Tracing specific links $ns trace-queue $n0 $n1 $f Tracing variables set cwnd_chan_ [open all.cwnd w] $tcp trace cwnd_ $tcp attach $cwnd_chan

Putting it all together set ns [new Simulator] set n0 [$ns node] set n1 [$ns node] $ns duplex-link $n0 $n1 1.5Mb 10ms DropTail Creating Topology set tcp [$ns create-connection TCP $n0 TCPSink $n1 0] Creating Transport layer set ftp [new Application/FTP] $ftp attach-agent $tcp Creating Applications $ns trace-queue $n0 $n1 $f Schedule Events $ns at 0.2 "$ftp start“ $ns at 1.2 ”exit“ $ns run

nam – the network animator n0n1 set nf [open out.nam w] $ns namtrace-all $nf exec nam out.nam & …

Computing routes Unicast $ns rtproto : Static, Session, DV.

Network Dynamics: Link failures $ns rtmodel-at $n0 $n1 $ns rtmodel Trace $n0 $n1 $ns rtmodel $n0 $n1 : Deterministic, Exponential

Issues in Simulations Suppose you want to study the way TCP sources share a bottleneck link… Agent/FTP Which topology? When to start sources? What else affects results? Which traffic sources? Background Traffic ?

Another practical issue: Memory trace-allAvoid trace-all Use arrays for a sequence of variables n$in($i)Instead of n$i, say n($i) ~ns/tcl/ex/cmcast-150.tcl: 150 nodes, 2200 links => 53MB 2420 nodes, 2465 linkd => 800MB

Basic ns-2: Not Covered mobile IP multicasting satellite emulation

Making changes to ns – where??? OTcl C++ Pure OTcl objects Pure C++ objects C++/OTcl split objects ns Where would you implement one-time configuration variables complex procedures per packet action

ns directory structure TK8.0OTcltclclTcl8.0ns-2nam-1 ns-allinone tcl ex testlib... examples validation tests C++ code OTcl code mcast Makefile.in

New component purely in Otcl examples TK8.0OTcltclclTcl8.0ns-2nam-1 ns-allinone tcl extest lib... validation tests C++ code OTcl code mcast mysrc msg.tcl Makefile.in source msg.tcl

New component in C++ Create C++ class, fill in methods Define otcl linkage Write otcl code (if any) Build (and debug)

How does linkage work? C++ OTcl Pure C++ objects Pure OTcl objects C++/OTcl split objects ns how to access Tcl variables from C++ how is C++ object created from interpreter ……

TclObject: Hierarchy and Shadowing TclObject Agent Agent/TCP Agent/TCP otcl shadow object _o123 Agent/TCP C++ object *tcp TclObject Agent TcpAgent otcl class hierarchy C++ class hierarchy

TclObject Example set tcp [new Agent/TCP] => how is corresponding C++ object created? => how is corresponding C++ object created? $tcp set window_ 500 => how is corresponding C++ variable set? => how is corresponding C++ variable set? $tcp advance 5000 => how is C++ procedure called? => how is C++ procedure called?

TclObject: Hierarchy and Shadowing TclObject Agent Agent/TCP Agent/TCP otcl shadow object _o123 Agent/TCP C++ object *tcp TclObject Agent TcpAgent otcl class hierarchy C++ class hierarchy

TclObject::bind() Link C++ member variables to otcl object variables C++ TcpAgent::TcpAgent() { bind(“window_”, &wnd_); … } bind_time(), bind_bool(), bind_bw() otcl $tcp set window_ 200

TclObject::command() Implement otcl methods in C++ Trap point: otcl method cmd{} Send all arguments after cmd{} call to TclObject::command()

TclObject::command() $tcp advance TclObject::unknown{}$tcp cmd advance no such procedure TcpAgent::command() match “advance”? Invoke parent: return Agent::command() process and return Yes No OTcl space C++ space

TclObject::command() otcl set tcp [new Agent/TCP] $tcp advance 10 C++ int TcpAgent::command(int argc, const char*const* argv) { if (argc == 3) { if (strcmp(argv[1], “advance”) == 0) { int newseq = atoi(argv[2]); …… return(TCL_OK); } return (Agent::command(argc, argv); }

TclObject Example set tcp [new Agent/TCP] => how is corresponding C++ object created? => how is corresponding C++ object created? $tcp set window_ 500 => how is corresponding C++ variable set? => how is corresponding C++ variable set? $tcp advance 5000 => how is C++ procedure called? => how is C++ procedure called? ?

C++ OTcl TclObject: Creation and Deletion invoke parent constructor Agent/TCP constructor parent constructor invoke parent constructor TclObject constructor create C++ object AgentTCP constructor invoke parent constructor invoke parent constructor parent (Agent) constructor do nothing, return TclObject (C++) constructor bind variables and return bind variables and return create OTcl shadow object complete initialization complete initialization which C++ object to create? – TclClass

TclClass Static class TcpClass : public TclClass { public: TcpClass() : TclClass(“Agent/TCP”) {} TclObject* create(int, const char*const*) { return (new TcpAgent()); } } class_tcp; Static class TcpClass : public TclClass { public: TcpClass() : TclClass(“Agent/TCP”) {} TclObject* create(int, const char*const*) { return (new TcpAgent()); } } class_tcp;

Class Tcl Singleton class with a handle to Tcl interpreter Usage Invoke otcl procedure Obtain otcl evaluation results Pass a result string to otcl Return success/failure code to otcl

Class Tcl Tcl& tcl = Tcl::instance(); if (strcmp(argv[1], “now”) == 0) { tcl.resultf(“%g”, clock()); return TCL_OK; } if (strcmp(argv[1], “helloworld”) { tcl.evalc(“puts stdout Hello World”); return TCL_OK; } Passing results to the interpreter: Executing Otcl commands from C++

Class TclCommand C++ implementation of global otcl commands class RandomCommand : public TclCommand { public: RandomCommand() : TclCommand("ns-random") {} virtual int command(int argc, const char*const* argv); }; int RandomCommand::command(int argc, const char*const* argv) { Tcl& tcl = Tcl::instance(); if (argc == 1) { sprintf(tcl.buffer(), "%u", Random::random()); tcl.result(tcl.buffer()); }

Summary