Introduction to ns-2 Noun Choi Oct. 11, 2007. Outline Background ns-2 Internals Short demo Troubleshooting Reference links Q & A.

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)
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.
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.
Introduction to Wireless simulations Shao-Cheng Wang.
Simulation of GPRS MS-BS Interface Using ns-Network Simulator Dual Degree Presentation by Richa Jain (96D07007) Department of Electrical Engineering, Indian.
15-744: Computer Networking ns-2 Tutorial Based on slides from John Heidemann, Polly Huang, and Amit Manjhi.
Network Simulator 2 Tejas Vasavada.
1 Network Simulator (NS-2). 2 講義 Network Simulator (NS2) Part 1: 下載 Part 2: 安裝與測試 Part 3: 劇本 Part 4: 數據.
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,
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.
Jump to first page NS Tutorial: mobile and wireless network simulation Ya Xu USC/ISI September 10th, 1999.
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
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.
1 Introduction to Ns-2 Zhibin WU WINLAB, ECE Dept. Rutgers U.
1 / 10 Mobile Networking in ns Speaker : Mark Yang
NS2 Tutorial for CS740 Jianming Wu *modified from Aga Zhang.
Introduction to Mobility & Network Simulator 2 (NS-2)
NS2 - Wireless Network Ming-Feng Yang. 2 2 Outline Basic wireless model Extensions wireless model Example - Ad hoc network Example – WLAN Example – Mobile.
Define options(1/2) #channel type set val(chan) Channel/WirelessChannel # radio-propagation model set val(prop) Propagation/TwoRayGround # network interface.
MOBILE IP SOMULATION IN NS2 Presenter: 吳寶緣. Outlines  Overview  Hierarchical Address Format  Hierarchical Address Format-ex  MoblieIP Demo  Additional.
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.
Chapter 15 The Addressing Structure in NS. The Default Address Format 32 lower bits for port-id, 1 higher bit for mcast and the rest 32 higher bits for.
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.
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.
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.
CDA6530: Performance Models of Computers and Networks Chapter 10: Introduction to Network Simulator (NS2) TexPoint fonts used in EMF. Read the TexPoint.
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
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 Simulator with Mobile IP 2003 Huang – Yu Liu.
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.
NS-2 Simulator 최 종 훈 Contents  About NS  Installation  Based on Linux  Based on Windows  Architecture  Using NS-2  Example  References.
1 Network Simulator 2 Install Chao-Ying Chiu
(Modified from Polly Huang’s and last year’s original)
Choe, Hyun Jung (Stella)
Introduction to ns-2: “The” Network Simulator
Karthik Sadasivam Banuprasad Samudrala
Network Performance modelling and simulation
Introduction to ns-2 Noun Choi Oct. 11, 2007.
Aga Zhang Dependable Computing Lab
TexPoint fonts used in EMF.
Presentation transcript:

Introduction to ns-2 Noun Choi Oct. 11, 2007

Outline Background ns-2 Internals Short demo Troubleshooting Reference links Q & A

History and Status UCB REAL network simulator VINT from LBL, PARC, UCB, & USC ns-1 ns-2, currently maintained by USC/ISI –100K lines of C++ –70K lines of OTcl –30K lines of test suite –20K lines of documentation

Platforms Most UNIX and UNIX-like systems -FreeBSD or *BSD -Linux -Sun Solaris -HP, SGI WINDOWS –Under Cygwin

Components of ns-2 Tcl/TK: ns-2 is an extended Tcl interpreter OTcl: Object Tcl TclCL: Tcl with classes library ns-2 nam-1: Network Animator xgraph: Plotting and Graphing And more….

Installation Latest version: 2.31 (Mar 10, 2007) Download ns-allinone – build.html#allinonehttp:// build.html#allinone./install will configure, compile, & install Problem? –

What is ns-2 Discrete-event driven network simulation Object Oriented ns-2 is an extended Tcl (OTcl) interpreter ns-2 is written in C++ and OTcl –OTcl = Tcl + OO –C++ implements the code that executed frequently –OTcl configures the system

Pros & Cons Free Almost all network components are implemented Active contributions from researchers Easy to modify and/or add new functions Unreliable Real Object Oriented? Hard to troubleshoot Unrealistic abstraction

OTcl and C++: The Duality C++ otcl

OTcl Linkage set tcp [new Agent/TCP] init Agent/TCP init Agent Create Otcl shadow object TclObject Create C++ object constructor TclObject (C++) constructor parent constructor TcpAgent OTcl C++ static class TcpClass : public TclClass { public: TcpClass() : TclClass( "Agent/TCP" ) {} TclObject* create(int, const char*const*) { return (new TcpAgent );} } class_tcp;

OTcl Linkage (II) Command() Otcl $tcp advance 10 C++ int Agent::command(int argc, const char*const* argv) { if (argc == 3) { if (strcmp(argv[1], “advance") == 0) { int newswq = atoi(argv[2]); return (TCL_OK); } return (Agent::command(argc, argv); }

OTcl Linkage (III) 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 You must setting the initial values of variants in ~ns/tcl/lib/ns- default.tcl

OTcl Linkage (IV) Invoking Otcl procedure and obtaining its results Tcl::instance().evalf("%s Lookup_CIP_RT %d", name(), iph- >dst().addr_); nextHop = Tcl::instance().result(); Classifier/Addr/Cip instproc Lookup_CIP_RT { m_addr } { return … } Passing a results string to Otcl Tcl::instance().result(“………”) Buffer

How ns-2 works Scheduler Event Queue Target object Event (Packet) Time Object BObject A Deque Dispatch Register Event

Source code in Scheduler.cc void Scheduler::schedule(Handler* h, Event* e, double delay) { e->uid_ = uid_++; e->handler_ = h; double t = clock_ + delay; e->time_ = t; insert(e); } void Scheduler::run() { instance_ = this; Event *p; while (!halted_ && (p = deque())) { dispatch(p, p->time_); } void Scheduler::dispatch(Event* p, double t) { clock_ = t; p->uid_ = -p->uid_;// being dispatched p->handler_->handle(p);// dispatch }

An Example AB CBR Transport Network LL IFQ MAC NetIF CBR Sink Transport Network LL IFQ MAC NetIF Scheduler Wireless Channel

Demonstration BaseStation MobileNode Wireless Wired

Demonstration (Contd.) set opt(chan) Channel/WirelessChannel ;# channel type set opt(prop) Propagation/TwoRayGround ;# radio-propagation model set opt(netif) Phy/WirelessPhy ;# network interface type set opt(mac) Mac/802_11 ;# MAC type set opt(ifq)Queue/DropTail/PriQueue;# interface queue type set opt(ll) LL ;# link layer type set opt(ant) Antenna/OmniAntenna ;# antenna model set opt(ifqlen) 50 ;# max packet in ifq set opt(adhocRouting) DSDV;# routing protocol set opt(cp) "" ;# connection pattern file set opt(sc) "./scen/scen-3-test" ;# node movement file. set opt(x) 670 ;# x coordinate of topology set opt(y) 670 ;# y coordinate of topology set opt(seed) 0.0 ;# seed for random number gen. set opt(stop) 250 ;# time to stop simulation set opt(ftp1-start) 100 set opt(ftp2-start) 150 set num_wired_nodes 2 set num_bs_nodes 1

Demonstration (Contd.) # ================================================================ # accpet input parameter set opt(nn)[lindex $argv 0] set outfile_ [lindex $argv 1] # ================================================================ # check for boundary parameters and random seed if { $opt(x) == 0 || $opt(y) == 0 } { puts "No X-Y boundary values given for wireless topology\n" } if {$opt(seed) > 0} { puts "Seeding Random number generator with $opt(seed)\n" ns-random $opt(seed) }

Demonstration (Contd.) # create simulator instance set ns_ [new Simulator] # set up for hierarchical routing $ns_ node-config -addressType hierarchical AddrParams set domain_num_ 2 ;# number of domains lappend cluster_num 2 1 ;# number of clusters in each domain AddrParams set cluster_num_ $cluster_num lappend eilastlevel ;# number of nodes in each cluster AddrParams set nodes_num_ $eilastlevel ;# of each domain set tracefd [open $outfile_.tr w] set namtrace [open $outfile_.nam w] $ns_ trace-all $tracefd $ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y)

Demonstration (Contd.) # Create topography object set topo [new Topography] # define topology $topo load_flatgrid $opt(x) $opt(y) # create God create-god [expr $opt(nn) + $num_bs_nodes] #create wired nodes set temp { } ;# hierarchical addresses for wired domain for {set i 0} {$i < $num_wired_nodes} {incr i} { set W($i) [$ns_ node [lindex $temp $i]] }

Demonstration (Contd.) # configure for base-station node $ns_ node-config -adhocRouting $opt(adhocRouting) \ -llType $opt(ll) \ -macType $opt(mac) \ -ifqType $opt(ifq) \ -ifqLen $opt(ifqlen) \ -antType $opt(ant) \ -propType $opt(prop) \ -phyType $opt(netif) \ -channelType $opt(chan) \ -topoInstance $topo \ -wiredRouting ON \ -agentTrace OFF \ -routerTrace OFF \ -macTrace OFF #create base-station node set temp { } ;# hier address to be used for wireless ;# domain set BS(0) [$ns_ node [lindex $temp 0]] $BS(0) random-motion 0 ;# disable random motion #provide some co-ord (fixed) to base station node $BS(0) set X_ 1.0 $BS(0) set Y_ 2.0 $BS(0) set Z_ 0.0

Demonstration (Contd.) #configure for mobilenodes $ns_ node-config -wiredRouting OFF for {set j 0} {$j < $opt(nn)} {incr j} { set node_($j) [ $ns_ node [lindex $temp \ [expr $j+1]] ] $node_($j) base-station [AddrParams addr2id \ [$BS(0) node-addr]] } #create links between wired and BS nodes $ns_ duplex-link $W(0) $W(1) 5Mb 2ms DropTail $ns_ duplex-link $W(1) $BS(0) 5Mb 2ms DropTail $ns_ duplex-link-op $W(0) $W(1) orient down $ns_ duplex-link-op $W(1) $BS(0) orient left-down

Demonstration (Contd.) # setup TCP connections set tcp1 [new Agent/TCP] $tcp1 set class_ 2 set sink1 [new Agent/TCPSink] $ns_ attach-agent $node_(0) $tcp1 $ns_ attach-agent $W(0) $sink1 $ns_ connect $tcp1 $sink1 set ftp1 [new Application/FTP] $ftp1 attach-agent $tcp1 $ns_ at $opt(ftp1-start) "$ftp1 start" set tcp2 [new Agent/TCP] $tcp2 set class_ 2 set sink2 [new Agent/TCPSink] $ns_ attach-agent $W(1) $tcp2 $ns_ attach-agent $node_(2) $sink2 $ns_ connect $tcp2 $sink2 set ftp2 [new Application/FTP] $ftp2 attach-agent $tcp2 $ns_ at $opt(ftp2-start) "$ftp2 start"

Demonstration (Contd.) # Tell all nodes when the simulation ends for {set i } {$i < $opt(nn) } {incr i} { $ns_ at $opt(stop).0 "$node_($i) reset"; } $ns_ at $opt(stop).0 "$BS(0) reset"; $ns_ at $opt(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt" $ns_ at $opt(stop).0001 "stop" proc stop {} { global ns_ tracefd namtrace # $ns_ flush-trace close $tracefd close $namtrace } puts "Starting Simulation..." $ns_ run

Trace File Format EventAbbreviationTypeValue Normal Event r: Receive d: Drop e: Error +: Enque -: Deque %g %d %d %s %d %s %d %d.%d %d.%d %d %d doubleTime IntSource Node intDestination Node stringPacket Name intPacket Size stringFlags IntFlow ID IntSource Address IntDestination Address IntSequence Number IntUnique Packet ID

Troubleshooting Problem while installing –Compiler may complain – Program crashes –Use gdb Unexpected results Hidden problem –Slice & dice the trace log

Reference Links Manual & Tutorial – – – NS/n3.pdfhttp://www-sop.inria.fr/maestro/personnel/Eitan.Altman/COURS- NS/n3.pdf Mailing List – Tcl – OTcl – tclCL –