1 Network Simulator (NS-2) Tutorial These slides can be downloaded from:

Slides:



Advertisements
Similar presentations
Wireless Communication : LAB 3
Advertisements

1 ns-2 Tutorial, part 2 Dave Anderson, Xiaowei Yang (Modified from Polly Huang’s slides)
1 NS Fundamentals (contd..) Padma Haldar USC/ISI.
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.
NS2 Chapter 5. Node A node is an OTcl class, but most of its components are TclObjects. All node contain at least the following components An address.
Winter 2008 Evaluation Tools1 Brief Overview of Networking Evaluation Methods and Tools.
Simulation of GPRS MS-BS Interface Using ns-Network Simulator Dual Degree Presentation by Richa Jain (96D07007) Department of Electrical Engineering, Indian.
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
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
Jump to first page NS Tutorial: mobile and wireless network simulation Ya Xu USC/ISI September 10th, 1999.
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.
Ns Simulation of IEEE SC546 Project (Fall 2002) SOO IL KIM JISUN YOON
Introduction to Network Simulator NS-2 Part II
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 - 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.
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-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.
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,
Group Management in Mobile Ad Hoc Networks Revathi Ranganathan Preeti Venkateswaran.
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.
1 Part II: ns Internals. USC INFORMATION SCIENCES INSTITUTE 2 Outline Fundamental concept Split object: C++/OTcl linkage Plumbing Wired Wireless Scaling.
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.
July 7, 2003 Building a Wireless LAN traffic test case in ns2 Radio Science Laboratory Department of Electrical and Computer Engineering The University.
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 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)
Mobicom ‘99 Per Johansson, Tony Larsson, Nicklas Hedman
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:

1 Network Simulator (NS-2) Tutorial These slides can be downloaded from:

2 Agenda  What Is NS?  Elements of Simulation  NS Architecture  NS Internals  Summary

3 What is NS  Discrete event simulator  Packet-level  Protocol stack -Link layer and up for wired networks; -Physical layer and up for wireless networks  Wired and wireless(both local and satellite) Detour

4 History and Status  Now part of VINT(Virtual InterNet Testbed) project -Columbia NEST --> UCB REAL --> NS-1 --> NS-2  Users from approximately -600 institutes -50 countries  Releases -Periodic releases (currently 2.1b9, April 2002) -Nightly snapshots (probably compiles and works, but “unstable”) -Available from: USC/ISI, UC Berkeley, UK mirror

5 Platforms  Most UNIX and UNIX-like systems FreeBSD or *BSD Linux Sun Solaris  HP, SGI  Window 95/98/NT -Some work, some does not  (Emulation only for FreeBSD for now)

6 Functionality of NS  Wired world -Point-to-point link, LAN -Unicast/multicast routing -Transport -Application layer  Wireless -Mobile IP -Ad hoc routing  Tracing, visualization, various utilities

7 Visualization Tools  nam-1 (Network AniMator Version 1) -Packet-level animation -Well supported by ns  xgraph -Conversion from ns trace to xgraph format

8 Getting Started  NS official site: -  A painless tutorial by Marc Greis: -  Another good tutorial from WPI -

9 Getting Help & Reference  Building NS -  NS user mailing list -  NS manual -

10 Agenda  What Is NS?  Elements of Simulation  NS Architecture  NS Internals  Summary

11 Elements of Simulation  Create the event scheduler  [Turn on tracing]  Create network  Setup routing  [Insert errors]  Create traffic  Start simulation  Post-process trace Detour

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

13 Tracing  Trace packets on all links -$ns trace-all [open test.out w] cbr cbr r cbr  Trace packets on all links in nam-1 format -$ns namtrace-all [open test.nam w]  Turn on tracing on specific links -$ns trace-queue $n0 $n1 -$ns namtrace-queue $n0 $n1  Must appear immediately after creating scheduler

14 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

15 Creating Network: LAN  LAN -$ns make-lan - : LL - : Queue/DropTail, - : MAC/802_3 - : Channel

16 Inserting Errors  Creating Error Module -set loss_module [new ErrorModel] -$loss_module set rate_ $loss_module unit pkt -$loss_module ranvar [new RandomVariable/Uniform] -$loss_module drop-target [new Agent/Null]  Inserting Error Module -$ns lossmodel $loss_module $n0 $n1

17 Network Dynamics  Link failures -Hooks in routing module to reflect routing changes  Four models $ns rtmodel Trace $n0 $n1 $ns rtmodel Exponential { } $n0 $n1 $ns rtmodel Deterministic { } $n0 $n1 $ns rtmodel-at up|down $n0 $n1  Parameter list [ ] [ ]

18 Setup Routing  Unicast -$ns rtproto - : Static, Session, DV, cost, multi-path  Multicast -$ns multicast (right after [new Simulator]) -$ns mrtproto - : CtrMcast, DM, ST, BST

19 Creating Connection: UDP or TCP  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  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

20 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]

21 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

22 Creating Traffic: Trace Driven  Trace driven -set tfile [new Tracefile] -$tfile filename -set src [new Application/Traffic/Trace] -$src attach-tracefile $tfile  : -Binary format (native!) -inter-packet time (msec) and packet size (byte)

23 Application-Level Simulation  Features -Build on top of existing transport protocol -Transmit user data, e.g., HTTP header  Two different solutions -TCP: Application/TcpApp -UDP: Agent/Message

24 Agenda Detour ends.  What Is NS?  Elements of Simulation  NS Architecture  NS Internals  Summary

25 NS Architecture  Object-oriented (C++, OTcl)  Scalability + Extensibility -Control/”data” separation -Split C++/OTcl object  Modular approach -Fine-grained object composition Detour ends.

26 C++/OTcl Split Objects C++ OTcl Pure C++ objects Pure OTcl objects C++/OTcl split objects NS 100K 70K

27 C++/OTcl Linkage

28 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

29 The Merit of OTcl Program size, complexity C/C++ OTcl  Smoothly adjust the granularity of scripting to balance extensibility and performance  With complete compatibility with existing simulation scripts high low split objects

30 Scalability vs Flexibility  It’s tempting to write all-OTcl simulation -Benefit: quick prototyping -Cost: memory + runtime  Solution -Control the granularity of your split object by migrating methods from OTcl to C++

31 Object Granularity Tips  Functionality -Per-packet processing  C++ -Hooks, frequently changing code  OTcl  Data management -Complex/large data structure  C++ -One-time configuration variables  OTcl

32 Agenda  What Is NS?  Elements of Simulation  NS Architecture  NS Internals  Summary

33 NS Internals  Discrete event scheduler  Network topology  Routing  Transport  Packet flow  Packet format  Application

34 Discrete Event Scheduler time_, uid_, next_, handler_ head_ ->  Three types of schedulers -List: simple linked list, order-preserving, O(N) -Heap: O(logN) -Calendar: hash-based, fastest, O(1) handler_ -> handle() time_, uid_, next_, handler_ reschedule insert

35 Network Topology: Node n0n1 Addr Classifier Port Classifier classifier_ dmux_ entry_ Node entry Unicast Node Multicast Classifier classifier_ dmux_ entry_ Node entry Multicast Node multiclassifier_

36 Network Topology: Link n0n1 enqT_queue_deqT_ drophead_ drpT_ link_ttl_ n1 entry_ head_ tracing simplex link duplex link

37 Routing n0n1 Addr Classifier Port Classifier classifier_ dmux_ entry_ Node entry 0 1 enqT_queue_deqT_ drophead_drpT_ link_ttl_ n1 entry _ head_

38 Routing (con’t) n0n1 Addr Classifier Port Classifier classifier_ dmux_ entry_ 0 1 Addr Classifier Port Classifier classifier_ dmux_ entry_ 1 0 Link n0-n1 Link n1-n0

39 Transport 0 1 n0n1 Addr Classifier Port Classifier classifier_ dmux_ entry_ 0 Agent/TCP agents_ Addr Classifier Port Classifier classifier_ dmux_ entry_ 1 0 Link n0-n1 Link n1-n0 0 Agent/TCPSink agents_ dst_=1.0 dst_=0.0

40 Application: Traffic Generator 0 1 n0n1 Addr Classifier Port Classifier classifier_ dmux_ entry_ 0 Agent/TCP agents_ Addr Classifier Port Classifier classifier_ dmux_ entry_ 1 0 Link n0-n1 Link n1-n0 0 Agent/TCPSink agents_ dst_=1.0 dst_=0.0 Application/FTP

41 Plumbing: Packet Flow 0 1 n0n1 Addr Classifier Port Classifier entry_ 0 Agent/TCP Addr Classifier Port Classifier entry_ 1 0 Link n0-n1 Link n1-n0 0 Agent/TCPSink dst_=1.0 dst_=0.0 Application/FTP

42 Packet Format header data ip header tcp header rtp header trace header cmn header... ts_ ptype_ uid_ size_ iface_

43 Abstract the Real Wireless World  Packet headers  Mobile node  Wireless channel  Forwarding and routing  Visualization

44 Wireless Packet Format header data ts_ ptype_ uid_ size_ iface_ IP header cmn header LL MAC 802_ ARP Wireless headers

45 Mobile Node Abstraction  Location -Coordinates (x,y,z)  Movement -Speed, direction, starting/ending location, time...

46 Portrait of A Mobile Node Node ARP Propagation and antenna models MobileNode LL MAC PHY LL CHANNEL LL MAC PHY Classifier: Forwarding Agent: Protocol Entity Node Entry LL: Link layer object IFQ: Interface queue MAC: Mac object PHY: Net interface protocol agent routing agent addr classifier port classifier 255 IFQ defaulttarget_

47 Wireless Channel  Duplicate packets to all mobile nodes attached to the channel except the sender  It is the receiver’s responsibility to decide if it will accept the packet -Collision is handled at individual receiver -O(N 2 ) messages  grid keeper

48 Agenda  What Is NS?  Elements of Simulation  NS Architecture  NS Internals  Summary

49 Summary  What can we do with NS?  Architectural overview of NS -split C++/OTcl Object  Inside NS -node, link, routing, tcp, app, wireless extension -how it works

50 References  