Introduction to NS. Information Main website Documentation, mailing list archive, tutorial Location of Source codes –C++ files.

Slides:



Advertisements
Similar presentations
Vacha Dave, University of Texas at Austin 1 Network Simulator Tutorial Advanced Computer Networks (CS378)
Advertisements

Network Simulator and problems in installing. Introduction Problems in installing Wired networks modified example2.tcl commands in OTcl usual problems.
Introduction to nam Tim Buchheim 21 November 2002 ns tutorial - fall 2002.
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.
1 Multicast in ns-2 報告者 : 陳沐恩. 2 Multicast 簡介 3 Multicast Routing set ns [new Simulator] $ns multicast Or set ns [new Simulator – multicast on] set mproto.
Wireless Communication : LAB 3
NS-2 (network simulator) NS by example παρουσίαση Κων/νος Τρούλος.
Ns Tutorial 成功大學電機所電腦與網路組 博士候選人 柯志亨
NS2-TCP Internet Computing KUT ( Youn-Hee Han It is licensed under a Creative Commons Attribution.
Wireless and Mobile Computing Simulations Lecture 27.
Introduction to Network Simulator NS-2 Part I
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.
Network Simulator (NS) Prof. Nelson L. S. da Fonseca State University of Campinas, Brazil.
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.
Dongsoo S. Kim 1.
NS TUTORIAL Padma Haldar USC/ISI 09/04/02.
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)
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
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.
Tutorial: The ns-2 Network Simulator Amirali Habibi Shrif Univesity Adapted from: Michael Welzl Institute of Computer Science University of Innsbruck,
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 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.
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.
Lab 2, Network Simulator ns2
1 NS-2: the network simulator 15 September 2005 Network Lab., SNU Changjee Joo.
DMET 602: Networks and Media Lab Amr El Mougy Yasmeen EssamAlaa Tarek.
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
Introduction to NS Srinath Perur.
Modeling & Analysis Mathematical Modeling: Simulation:
Karthik Sadasivam Banuprasad Samudrala
Presentation transcript:

Introduction to NS

Information Main website Documentation, mailing list archive, tutorial Location of Source codes –C++ files $NS-HOME/ns-allinone-2.28/ns-2.28 –Tcl files $NS-HOME/ns-allinone-2.28/ns-2.28/tcl/lib

NS2 – Network Simulator Event-Driven simulator –Maintain a sorted event queue –Dequeue head event Packet arrival –Assign event to its handler At TCP agent –Handler processes event Update Window –Enqueue more events in the event queue Schedule delivery of ACK

Basic Model Back-end C++ –Protocols & Framework Front-end Otcl (Object-Oriented Tcl) –Scenarios Split Object –Object created in otcl has a corresponding object in C++ This tutorial only deals with otcl

Tcl/OTcl Basics Variables –set v1 10 –set v2 $v1 Array (String indexed) –a($i) ≠ a( $i ) Printing –puts $filename “string” (default filename is stdout) Arithmetic Expressions –set value [expr $v1+($v2 * 5.2)] Control Structures –if {condition} then {…….} –for {set i 0} {$i < 10} {incr i 2} {……} Procedures –proc proc_name {arg1 arg2…} { ……}

OTcl Basics (contd.) Creating a class –Class class_name –Class class_name –superclass Base_class Defining instance procedures –class_name instproc proc_name {args} {…..} Defining instance variables –$self instvar variable_name (inside a class method) Creating an instance –set new_inst [new class_name] Using value of an instance variable –$new_inst set v1 10 or set v2 [$new_inst set v1]

NS Communication Model Nodes –Hosts, Routers Links –Queue Management –Queue Monitoring Agents –Protocol TCP TCP Sink

Node n0 Addr Classifier Port Classifier classifier_ dmux_ entry_ Node entry Unicast Node Link 1 Link 2 Slide taken from Hung-Yun Hsieh’s tutorial

Link n0n1 enqT_queue_deqT_ drophead_ drpT_ link_ttl_ n1 entry_ head_ tracing simplex link duplex link Slide taken from Hung-Yun Hsieh’s tutorial

Routing n0n1 Addr Classifier Port Classifier classifier_ dmux_ entry_ Node entry 0 1 enqT_queue_deqT_ drophead_ drpT_ link_ttl_ n1 entry_ head_ Slide taken from Hung-Yun Hsieh’s tutorial

Routing n0n1 Port Classifier entry_ Addr Classifier classifier_ dmux_ 1 0 Addr Classifier Port Classifier classifier_ dmux_ entry_ 0 1 Link n0-n1 Link n1-n0 Slide taken from Hung-Yun Hsieh’s tutorial

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 Slide taken from Hung-Yun Hsieh’s tutorial

Application 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 Slide taken from Hung-Yun Hsieh’s tutorial

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 Slide taken from Hung-Yun Hsieh’s tutorial

Starting off … Things common to all simulation scripts: Create a new simulator object set ns [new Simulator] Finish procedure proc finish { } { …….. exit 0 } Last line $ns run

Basic Script set ns [new Simulator] proc finish { } { exit 0 } Topology set n1 [$ns node] set n2 [$ns node] $ns duplex-link $n1 $n2 1Mb 10ms DropTail Agents set a1 [new Agent/TCP] set a2 [new Agent/TCPSink] Attach and Connect Agents $ns attach-agent $n1 $a1 $ns attach-agent $n2 $a2 $ns connect $a1 $a2 Start and Finish Time $ns at 0.5 “$a1 advance 10” $ns at 1.5 “finish” $ns run

A more useful script set ns [new Simulator] set nam_file [open out.nam w] $ns namtrace-all $nam_file proc finish {} { global ns nam_file $ns flush-trace close $nam_file exec nam out.nam & exit 0 } set n1 [$ns node] set n2 [$ns node] $ns duplex-link $n1 $n2 1Mb 10ms DropTail set a1 [new Agent/TCP] set a2 [new Agent/TCPSink] $ns attach-agent $n1 $a1 $ns attach-agent $n2 $a2 $ns connect $a1 $a2 $ns at 0.5 “$a1 advance 10” $ns at 1.5 “finish” $ns run

Recording Data Add a new procedure proc record-data { duration } { global datafile a1 ns # data format -- time bytes-received puts $datafile “[$ns now] [$a1 set ndatabytes_]” $ns after $duration “record-data $duration” } set datafile [open “datafile.dat” w] $ns at 0.5 “record-data 0.1”

More Complex Case Bottleneck Link

Topology for {set i 0} {$i < 4} {incr i} { set border($i) [$ns node] } for {set i 0} {$i < 2} {incr i} { set core($i) [$ns node] } $ns duplex-link $border(0) $core(0) 10Mb 5ms DropTail $ns duplex-link $border(1) $core(0) 10Mb 5ms DropTail $ns duplex-link $border(2) $core(1) 10Mb 5ms DropTail $ns duplex-link $border(3) $core(1) 10Mb 5ms DropTail $ns duplex-link $core(0) $core(1) 1Mb 5ms DropTail $ns queue-limit $core(0) $core(1) 20 set qmon [$ns monitor-queue $core(0) $core(1) “”]

Agents set tcp [new Agent/TCP] $ns attach-agent $border(0) $tcp set tcpsink [new Agent/TCPSink] $ns attach-agent $border(3) $tcpsink set udp [new Agent/UDP] $ns attach-agent $border(1) $udp set lm [new Agent/LossMonitor] $ns attach-agent $border(2) $lm $tcp set fid_ 0 $udp set fid_ 1 $ns color 0 Red $ns color 1 Blue

Sources Attach traffic source to agents and connect set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set rate_ 2Mb set ftp [$tcp attach-app FTP] $tcp set packetSize_ 100 $ns connect $tcp $tcpsink $ns connect $udp $lm

Data Collection proc record-data { duration } { global ns tcp tcp_file lm udp_file queue_file qmon puts $tcp_file “[$ns now] [expr [$tcp set ndatabytes_]/$duration]” $tcp set ndatabytes_ 0 puts $udp_file “[$ns now] [expr [$lm set bytes_]/$duration]” $lm set bytes_ 0 puts $queue_file “[$ns now] [$qmon set pkts_]” $ns after $duration “record-data $duration” }

Other details set ns [new Simulator] # Nam, TCP-data, UDP-data, Queue-data files # Finish method # Topology # Agents # Sources # Data Collection $ns at 0.1 “$ftp start” $ns at 4.0 “$ftp stop” $ns at 1.0 “$cbr start” $ns at 2.0 “$cbr stop” $ns at 0.1 “record-data 0.1” $ns at 4.1 “finish” $ns run

Things to Remember Topology, agents, sources, start Connect the agents –Slot not found error Start/Stop the sources In procedures, declare global variables before use “ $ns run ” – last line