NS Tutorial (For CMPE 252 A) By Duy Nguyen 10/25/2012.

Slides:



Advertisements
Similar presentations
Network Modeling and Simulation with Network Simulator 2 (ns2)
Advertisements

Jump to first page NS Tutorial: mobile and wireless network simulation Ya Xu USC/ISI June 18, 1999.
Vacha Dave, University of Texas at Austin 1 Network Simulator Tutorial Advanced Computer Networks (CS378)
Network Simulator and problems in installing. Introduction Problems in installing Wired networks modified example2.tcl commands in OTcl usual problems.
1 The ns-2 Network Simulator H Plan: –Discuss discrete-event network simulation –Discuss ns-2 simulator in particular –Demonstration and examples: u Download,
1 NS-2 Tutorial COMP R2 University of Manitoba March 4, 2009.
Wireless world in NS Padma Haldar USC/ISI.
Wireless Communication : LAB 3
NS-2 (network simulator) NS by example παρουσίαση Κων/νος Τρούλος.
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
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.
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,
Copyright node This presentation is a subset of the one presented by:
Day 3 Outline Multicast example (from Day 2) Wireless Misc. utilities
1 Modified Schedule Day 2 Network AniMator (nam) Examples simple.tcl mcast.tcl Day 3 Wireless (ad-hoc)
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.
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
QualNet 2014/05/ 尉遲仲涵. Outline Directory Structure QualNet Basic Message & Event QualNet simulation architecture Protocol Model Programming.
Wireless Networking and Systems CSE 590 ns2 tutorial.
1 / 10 Mobile Networking in ns Speaker : Mark Yang
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.
Ns-3 Training Computer and Communication Network Lab Department of Electrical Engineering National Sun Yat-Sen University 5/13/2013.
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.
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
Quality evaluation of MPEG4 video transmission over GPRS networks.. Presented by: Abdullah M. Rana Multimedia Communication.
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.
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.
The Creation of NS2 Simulated Environment ( 1 ) LI Chengbo
Use of Mobility models in ns-2 Karthik Dantu Shyam Kapadia.
IP-BASED MOBILITY FOR WIRELESS LANS WITH THE NETWORK SIMULATOR NS Frank Christahl, Andreas Huber, Matthias Rosenschon University of Applied Sciences Giessen-Friedberg.
NS-2 Shahin Shayandeh December 2004 Session 1. Ns-2, the Network Simulator  A discrete event simulator Simple model  Focused on modeling network protocols.
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.
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
ns-3 Training 5/08/2017 Computer and Communication Network Lab
Choe, Hyun Jung (Stella)
Introduction to ns-2: “The” Network Simulator
Karthik Sadasivam Banuprasad Samudrala
Ns-3 Tutorial Xin Li.
TexPoint fonts used in EMF.
Presentation transcript:

NS Tutorial (For CMPE 252 A) By Duy Nguyen 10/25/2012

What is NS-2? A discrete event simulator targeted at networking research Written in C++ and OTcl(OO of Tcl) OTcl usage: –Configuration and setup –Manipulating existing C++ objects C++ usage: –Anything that requires processing each packet of a flow –Change behavior of existing C++ class

Getting NS-2 Go to Download an ns-allinone package $ tar –zxf ns-allinone-2.34.tar.gz $ cd ns-allinone-2.34 &&./install Follow the instructions for setting up the environments: setenv LD_LIBRARY_PATH /cse/grads/duy/ns-allinone- 2.34/otcl-1.13:/cse/grads/duy/ns-allinone-2.34/lib setenv TCL_LIBRARY /cse/grads/duy/ns-allinone- 2.34/tcl8.4.18/library $ cd ns-2.34;./validate

NS-2 initialization # create simulator set ns [new Simulator] # Open trace file set tracefile [open out.tr w] $ns trace-all $tracefile # Open trace file $set namefile [open out.nam w] $ns nametrace-all $namefile

# define a finish procedure proc finish {} { global ns tracefile namefile $ns flush-trace close $tracefile close $namfile exec nam out.nam & exit 0 } # calling finish procedure at 125 $ns at “finish” # Run simulation $ns run

# Create nodes set n0 [$ns node] set n1 [$ns node] #available queues: RED, FQ, DRR, SFO,CBQ. $ns duplex-link $n0 $n1 10Mb 10ms DropTail #a unidirectional link $ns simplex-link $n0 $n1 10Mb 10m # Set queue size limit on the link to 50 $ns queue-limit $n0 $n2 50 NS-2 Create Nodes and Links

# Set up a TCP connection for node 0 setup tcp [new Agent/TCP] $ns attach-agent $n0 $tcp # Create a sink agent for node 1 set sink [new Agent/TCPSink] $ns attach-agent $ns1 $sink #Now connect them $ns connect $tcp $sink # Set packet size $ns set packetSize_ 512 NS-2 Agents and Applications

# Set FTP over TCP connection # FTP uses TCP/IP set ftp [new Application/FTP] $ftp attach-agent $tcp # Setting up UDP connection set udp [new Agent/UDP] $ns attach-agent $n0 $udp set null [new Agent/Null] $ns attach-agent $n1 $null $ns connect $udp $null # Set up CBR over UDP connection Set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set rate_.01Mb

# introduce noise $cbr set random_ true # interval between transmission of packets $cbr interval_.005 # set packet Size $cbr set packetSize_ 512

# Format $ns at # Examples $ns at 1.0 “$cbr start” $ns at 3.0 “$ftp start” $ns at 95.0 “$cbr stop” $ns at “$ftp stop” #a unidirectional link $ns simplex-link $n0 $n1 10Mb 10m Scheduling Events

# Format #Please see Trace File

cbr cbr r cbr cbr cbr cbr cbr tcp tcp r cbr r cbr cbr r tcp tcp cbr cbr r cbr cbr cbr cbr r cbr cbr cbr cbr

Comments on the tracefile There are current old and new trace format, select one which is most suitable. Need to write your own script for processing data from the trace file i.e. throughput, delay etc Awk, perl, grep are some of the tools Need to specify how the throughput and delay are obtained. For example: –Throughput is the number of successful packets received multiply by the packet length and divided by the total simulation time –Delay is difference between the time a packet arrives at the queue and the time a packet gets transmitted successfully

Plotting graphs Matlab, Xgraph, and many other tools I personally use an awk script to extract throughput, delay, etc information and use Microsoft Excel to graph them.

set opt(chan) Channel/WirelessChannel; set opt(prop) Propagation/TwoRayGround; set opt(netif) Phy/WirelessPhy; set opt(mac) Mac/802_11; set opt(ifq) Queue/DropTail/PriQueue; set opt(ll) LL ;#link layer set opt(ant) Antenna/OmniAntenna; set opt(ifqlen) 50 ;# queue length set opt(nn) 36 ;# number of nodes set opt(flow) 3 set opt(row) 6 ;#for grid set opt(column) 6 #set opt(adhocRouting) DSDV ;# routing protocol set opt(adhocRouting) DumbAgent ;# disable routing set opt(cp) "" ;# connection pattern set opt(sc) "" ;# node movement set opt(x) 400 ;# x coordinate of topology set opt(y) 400 ;# y coordinate of topology set opt(seed) 0 ;# seed for random number gen set opt(stop) 50 ;# time to stop simulation Wireless Simulation

# Create topography object set topo [new Topography] # define topology $topo load_flatgrid $opt(x) $opt(y) # 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 -agentTrace ON -routerTrace OFF -macTrace ON -movementTrace OFF

# create God for monitoring all nodes create-god [expr $opt(nn)] # Creating mobile nodes for {set j 0} {$j < $opt(nn)} {incr j} { set node_($j) [$ns_ node] } # define node’s fixed position for {set j 0} {$j < $opt(row)} {incr j} { for {set i 0} {$i < $opt(column)} {incr i} { $node_([expr $j * $opt(column) + $i]) set X_ [expr $i * 10] $node_([expr $j * $opt(column) + $i]) set Y_ [expr $j * 10] $node_([expr $j * $opt(column) + $i]) set Z_ 0 }

# setting up connection for {set k 1} {$k <= $opt(flow)} {incr k} { set udp_($k) [new Agent/UDP] $ns_ attach-agent $node_([expr $l + 0]) $udp_($k) set null_($k) [new Agent/Null] $ns_ attach-agent $node_([expr $l + 1]) $null_($k) set cbr_($k) [new Application/Traffic/CBR] $cbr_($k) set packetSize_ $pktsize $cbr_($k) set interval_ $inter $cbr_($k) set random_ 1 $cbr_($k) attach-agent $udp_($k) $ns_ connect $udp_($k) $null_($k) $ns_ at 9.8 "$cbr_($k) start" $ns_ at 30.0 "$cbr_($k) stop" set l [expr $l + 2] }

# Tell all nodes when the simulation ends for {set i 0} {$i < $opt(nn) } {incr i} { $ns_ at $opt(stop).0 "$node_($i) reset"; } $ns_ at $opt(stop).0004 "stop" $ns_ at $opt(stop).0005 "puts \"NS EXITING...\" ; $ns_ halt"

# Available in ~ns/indep-utils/cmu-scen-gen # Format ns cbrgen.tcl [-type cbr|tcp] [-nn nodes] [-seed seed] [-mc connections] [-rate rate] # CBR 20 nodes, max 8 connections, seed value 1.0 and a rate of 4.0, output to cbr-20-test ns cbrgen.tcl -type cbr -nn 20 -seed 1.0 -mc 8 -rate 4.0 > cbr-20-test Generating traffic-connection

# Available in ~ns/indep-utils/cmu-scen-gen/setdest and consists of setdest{.cc,.h} and Makefile # Format./setdest [-n num_of_nodes] [-p pausetime] [-s maxspeed] [-t simtime] [-x maxx] [-y maxy] > [outdir/movement- file] # 20 nodes, maximum speed of 10.0m/s, an average pause between movement being 2s../setdest -n 20 -p 2.0 -s t 200 -x 500 -y 500 > scen-20-test #Specify traffic-connection and node-movement in script set opt(cp) "tcl/mobility/scene/cbr-20-test" set opt(sc) "tcl/mobility/scene/scen-20-test" Generating node-movement file

New protocols See Chapter of NS Manual for better understanding of C++ and Otcl Linkage between the C++ code and Tcl code(if you modify an already existing protocol, no need) Add new protocols Make changes to makefile(.cc) or ~ns/tcl/lib/ns- lib.tcl(.tcl) $make clean &&./configure --enable-debug && make

Other features Emulation (nice complement with your simulation) NS-Click (Modular router) Sensor-nets Satellite …

More Help Use Nam visual tool to aid in visualizing the networks (not really essential) Check out other tutorials in reference section Sign up for NS user mailing list – Documentation(most comprehensive source): – Very detailed tutorial: k/ k/

References NS-2 page-- Detailed NS-2 tutorial-- sop.inria.fr/members/Eitan.Altman/COURS -NS/n3.pdfhttp://www- sop.inria.fr/members/Eitan.Altman/COURS -NS/n3.pdf Marc Greis’ tutorial html NS-2 by examples--

NS-3 An open source project building a new network simulator to replace ns-2

ns-3 is a new simulator, without backward compatibility Similarities to ns-2: C++ software core GNU GPLv2 licensing ported ns-2 models: random variables, error models, OLSR, Calendar Queue scheduler, (more planned) Differences: Python scripting (or C++ programs) replaces OTcl most of the core rewritten also based on the yans and GTNetS simulators new animators, configuration tools, etc. are in work

ns-3 follows a Linux architecture class NetDevice class Ipv4Protocol Linux corollaries –each NetDevice is modelled like struct net_device –each layer-3 protocol has a struct in_device component for each NetDevice –this interface (transmit side) is aligned with Linux dev_queue_xmit() –on receive side, demux is modelled after Linux protocol handlers

Software Integration Do not reimplement models and tools for which open-source implementations abound ns-3 conforms to standard input/output formats so that other tools can be reused. –e.g., pcap trace output, ns-2 mobility scripts ns-3 is adding support for running implementation code –Network Simulation Cradle integration has met with success: Linux TCP code –ns-3 “process” API

Instructions Go to and download current ns-3http:// $ wget allinone-3.15.tar.bz2https:// allinone-3.15.tar.bz2./build.py --enable-examples --enable-tests –This script will build everything Also:./waf clean;./waf -d optimized --enable- examples --enable-tests configure;./waf –Replace ‘optimized’ with ‘debug’ for enabling debug messages

Sample Browse examples for sample scenarios. Try simple- global-routing // n0 // \ 5 Mb/s, 2ms // \ 1.5Mb/s, 10ms // n n3 // / // / 5 Mb/s, 2ms // n1 CBR/UDP flows from n0 to n3, and from n3 to n1 FTP/TCP flow from n0 to n3, starting at time 1.2 to time 1.35 sec. UDP packet size of 210 bytes, with per-packet interval sec.

Sample To run:./waf --run simple-global-routing Output: pcap files and trace.tr files To view pcap files: –tcpdump -nn -tt -r filename.pcap

Sample tcpdump -nn -tt -r simple- global-routing-1-1.pcap reading from file simple-global-routing-1-1.pcap, link-type PPP (PPP) IP > : UDP, length IP > : UDP, length IP > : UDP, length IP > : UDP, length IP > : UDP, length IP > : UDP, length IP > : UDP, length IP > : UDP, length IP > : UDP, length 512

Final comments Since ns-3 is a new network simulator, it does not have as many network models as ns-2. For wireless simulations: use ns-3 –Wireless Routing, Rate Adaptation For wired simulations: use ns-2 –Distance Vector (RIP): routing/rtProtoDV.cc –Link State: linkstate/

References NS-3 page-- Detailed NS-2 tutorial-- sop.inria.fr/members/Eitan.Altman/COURS- NS/n3.pdfhttp://www- sop.inria.fr/members/Eitan.Altman/COURS- NS/n3.pdf Slides from Tom Henderson’s talk UW-EE Documentationhttp:// tion/ tion/ Tutorial: singlehtml/index.html singlehtml/index.html Contact: Duy Nguyen duy att soe.ucsc.edu

Qualnet RIP Tutorials links