Network Simulator 2 Tejas Vasavada.

Slides:



Advertisements
Similar presentations
Introduction to Network Simulator NS-2 Part I
Advertisements

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 Tutorial (For CMPE 252 A) By Duy Nguyen 10/25/2012.
Network Simulator (NS) Prof. Nelson L. S. da Fonseca State University of Campinas, Brazil.
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.
報告者:黃亮維 NS2 Chapter 26 Trace Support. Outline  Trace Support ‧ OTcl Helper Functions  Library support and examples  The C++ Trace Class  Trace File.
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
Yinfei Pan SUNY Binghamton Computer Science
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.
Wireless Sensor Network for Tracking the Traffic in INTERNET Network Routers Supervisor: Mark Shifrin Students: Yuriy Kipnis Nir Bar-Or Networked Software.
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
Routing in Mobile Ad-Hoc Networks An M.Tech. Project by Srinath Perur Guide: Prof. Sridhar Iyer.
Simulators for Sensor Networks Sagnik Bhattacharya 9/12/2001.
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.
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.
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.
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.
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
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 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.
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
TNK092: Network Simulation - Nätverkssimulering Lecture #1: Course basics and a first taste of NS2 Vangelis Angelakis Ph.D.
Use of Mobility models in ns-2 Karthik Dantu Shyam Kapadia.
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.
Network Simulator with Mobile IP 2003 Huang – Yu Liu.
Lab 2, Network Simulator ns2
DMET 602: Networks and Media Lab Amr El Mougy Yasmeen EssamAlaa Tarek.
1 Network Simulator 2 Install Chao-Ying Chiu
DMET 602: Networks and Media Lab
Network Simulator Tutorial
Basics of NS-2 Training in TCL script
Mobicom ‘99 Per Johansson, Tony Larsson, Nicklas Hedman
Choe, Hyun Jung (Stella)
Introduction to ns-2: “The” Network Simulator
Planned Activities on Computer Networks for Sunday Academy
Karthik Sadasivam Banuprasad Samudrala
Introduction to ns-2 Noun Choi Oct. 11, 2007.
TexPoint fonts used in EMF.
Presentation transcript:

Network Simulator 2 Tejas Vasavada

Contents Simulation of wired networks Simulation of wireless networks Traffic and movement-pattern files Trace files Analyzing trace files using 'awk' script 'gnuplot' – utility to plot graphs

Contents (contd.) DSR – A protocol for MANETs Source code of DSR in NS2 How to change DSR (with examples) Printing packet header Configuring nodes to drop packets Adding a new function in DSR Calling previous function from Tcl Passing arguments from Tcl to DSR Use of timers

Contents How to add new package in NS Simulation of Wired-cum-Wireless Networks

Introduction Simulation comes before implementation. A newly designed protocol is simulated first to test the performance.

Simulation Tools OmNet++, NS2, Qualnet, Opnet, GlomoSim etc. NS2 - an open source tool, widely used in academics for research purpose.

How to use NS2 Front end – Tcl (Tool Command Langauage) Back end – C++ Today we will learn Tcl.

Wired Network

Tcl script set ns [new Simulator] creates an instance of ‘Simulator’ class. Output is stored in .nam files (Network AniMator) set nf [open out.nam w] $ns namtrace-all $nf

Tcl script (contd.) proc finish {} { global ns nf $ns flush-trace close $nf exec nam out.nam & exit 0 } ‘finish’ will be called at the end of simulation.

Tcl Script (contd.) $ns at 5.0 "finish“ finish() is called at 5th second. $ns run Starts simulation.

Tcl script (contd.) set n0 [$ns node] set n1 [$ns node] Creates two nodes - n0 and n1. $ns duplex-link $n0 $n1 1Mb 10ms DropTail Connects both the nodes.

Tcl script (contd.) #Create a UDP agent and attach it to node n0 set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0 # Create a CBR traffic source and attach it to udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ 0.005 $cbr0 attach-agent $udp0

Tcl script (contd.) set null0 [new Agent/Null] $ns attach-agent $n1 $null0 Creates a null agent and attaches it to n1. $ns connect $udp0 $null0 Two agents are connected togother.

Tcl script (contd.) $ns at 0.5 "$cbr0 start" $ns at 4.5 "$cbr0 stop“ Node n0 will start sending packets at time 0.5 sec and will stop at 4.5 sec.

Exercise 1 Read example1.tcl provided to you. Run it using following command ns example1.tcl Read & Run Example2.tcl

Example2.tcl $ns duplex-link-op $n0 $n2 orient right-down $ns duplex-link-op $n1 $n2 orient right-up $ns duplex-link-op $n2 $n3 orient right Creates star shape topology.

Example2.tcl (contd.)

Example2.tcl (contd.) Nodes n0 and n1 connect to n3 via n2. Bandwidth n2-n3 < (bandwidth n0-n2 + bandwidth n1-n2) Node n2 drops packets.

Example2.tcl To see what is happening at n2, different flows should be coloured differently. $udp0 set class_ 1 $udp1 set class_ 2 $ns color 1 Blue $ns color 2 Red

Example2.tcl (contd.)

Example3.tcl for {set i 0} {$i < 7} {incr i} { set n($i) [$ns node] Creates 7 nodes. $ns duplex-link $n($i) $n([expr ($i+1)%7]) 1Mb 10ms DropTail

Example3.tcl (contd.)

Example3.tcl (contd.) Node n0 is connected to n3. Packets will pass through n1 and n2 (shortest path). Break n1-n2 link using following commands. $ns rtmodel-at 1.0 down $n(1) $n(2) $ns rtmodel-at 2.0 up $n(1) $n(2)

Example3.tcl (contd.)

Example3.tcl (contd.) Use following command to use alternate path. $ns rtproto DV

Example3.tcl (contd.)

Wireless Network

Simple-wireless.tcl Components of a mobile node… Link Layer, Interface Queue between LL and Network Layer, MAC Layer Routing Layer Parameters of a mobile node Type of antenna, Radio propagation model

Simple-wireless.tcl (contd.) set val(chan) Channel/WirelessChannel ;# channel type set val(prop) Propagation/TwoRayGround ;# radio-propagation model set val(ant) Antenna/OmniAntenna ;# Antenna type set val(ll) LL ;# Link layer type set val(ifq) Queue/DropTail/PriQueue ;# Interface queue type set val(ifqlen) 50 ;# max packet in ifq set val(netif) Phy/WirelessPhy ;# network interface type set val(mac) Mac/802_11 ;# MAC type set val(rp) DSDV ;# ad-hoc routing protocol set val(nn) 2 ;# number of mobilenodes

Simple-wireless.tcl (contd.) set ns_ [new Simulator] Creates new instance of ‘Simulator’. set tracefd [open simple.tr w] $ns_ trace-all $tracefd Creates new instance of trace file.

Simple-wireless.tcl (contd.) set topo [new Topography] Creates new topology. $topo load_flatgrid 500 500 Sets resolution of topology to 500 x 500.

Simple-wireless.tcl (contd.) # Configure nodes $ns_ node-config -adhocRouting $val(rp) -llType $val(ll) \ -macType $val(mac) ifqType $val(ifq) \ -ifqLen $val(ifqlen) -antType $val(ant) \ -propType $val(prop) –phyType $val(netif) \ -topoInstance $topo \ -channelType $val(chan) \ -agentTrace ON \ -routerTrace ON \ -macTrace OFF \ -movementTrace OFF

Simple-wireless.tcl (contd.) for {set i 0} {$i < $val(nn) } {incr i} { set node_($i) [$ns_ node ] $node_($i) random-motion 0 } Random motion is disabled. We will provide initial position and movement parameters.

Simple-wireless.tcl (contd.) $node_(0) set X_ 5.0 $node_(0) set Y_ 2.0 $node_(0) set Z_ 0.0 $node_(1) set X_ 390.0 $node_(1) set Y_ 385.0 $node_(1) set Z_ 0.0

Simple-wireless.tcl (contd.) # Node_(1) starts to move towards node_(0) $ns_ at 50.0 "$node_(1) setdest 25.0 20.0 15.0" $ns_ at 10.0 "$node_(0) setdest 20.0 18.0 1.0“ # Node_(1) then starts to move away from node_(0) $ns_ at 100.0 "$node_(1) setdest 490.0 480.0 15.0"

Simple-wireless.tcl (contd.) # TCP connections between node_(0) and node_(1) set tcp [new Agent/TCP] $tcp set class_ 2 set sink [new Agent/TCPSink] $ns_ attach-agent $node_(0) $tcp $ns_ attach-agent $node_(1) $sink $ns_ connect $tcp $sink set ftp [new Application/FTP] $ftp attach-agent $tcp $ns_ at 10.0 "$ftp start"

Simple-wireless.tcl (contd.) # Tell nodes when the simulation ends for {set i 0} {$i < $val(nn) } {incr i} { $ns_ at 150.0 "$node_($i) reset"; } $ns_ at 150.0001 "stop" $ns_ at 150.0002 "puts \"NS EXITING...\" ; $ns_ halt" proc stop {} { global ns_ tracefd close $tracefd

Simple-wireless.tcl (contd.) puts "Starting Simulation..." $ns_ run Prints the message and starts simulation.

Traffic-pattern file and movement-pattern file

Wireless-1.tcl set val(cp) “/root/cbr-3-test" set val(sc) “/root/scen-3-test“ cbr-3-test is connection-pattern file. scen-3-test is movement-pattern file.

Wireless-1.tcl (contd.) set val(x) 670 set val(y) 670 set namtrace [open wireless1-out.nam w] $ns_ namtrace-all-wireless $namtrace $val(x) $val(y)

Wireless-1.tcl (contd.) puts "Loading connection pattern..." source $val(cp) Loads connection-pattern file. puts "Loading scenario file..." source $val(sc) Loads movement-pattern(scenario) file.

Wireless-1.tcl (contd.) for {set i 0} {$i < $val(nn)} {incr i} { $ns_ initial_node_pos $node_($i) 20 } Defines size of node in nam

Traffic pattern file ns cbrgen.tcl [-type cbr|tcp] [-nn nodes] [-seed seed] [-mc connections] [-rate rate] > [filenm] Generates a traffic pattern. It is saved in file ‘filenm’. -type : type of connection cbr or tcp -nn : no. of nodes -seed : seed value used by random number generator -mc : no. of connections -rate : rate at with packets are sent

Traffic pattern file (contd.) ns cbrgen.tcl -type cbr -nn 10 -seed 1.0 -mc 8 -rate 4.0 > cbr-10-test Generates traffic-pattern and saves in file cbr-10-test. Create traffice-pattern file for tcp traffic and check how it differs from cbr-10-test

Movement-pattern file ‘setdest’ utility available at: ns-x.xx/indep-utils/cmu-scen-gen/setdest /setdest –v 1 –n <nodes> -p <pause time> -M <max speed> -t <sim time> -x <maxx> -y <maxy>

Movement-pattern file (contd.) ./setdest –v 2 –n <nodes> -s <speed type> -m <min speed> -M <max speed> -t <sim time> -P <pause type> -p <pause time> -x <maxx> -y <maxy> Speed type: 1 - uniform speed 2 - normal speed

Pause type: 1 - constant 2 – uniform [ 0, 2 x pause ] For e.g. ./setdest –v 2 -n 50 -s 1 -m 1 -M 20 -t 200 -P 1 -p 0 -x 200 -y 200 > /root/Desktop/scen-3-test

Trace file format

Trace files Output of simulation is in trace format. Trace file has two formats: old and new To use new format add following line in tcl script before calling trace-all . $ns use-newtrace

Trace file format Event type s send d drop r receive f forward Time -t

Trace file format (contd.) Node property tag -Ni Node id -Nx Node’s x-coordinate -Ny Node’s y-coordinate -Nz Node’s z-coordinate -Ne Node’s energy level -Nl Trace level (AGT, RTR, MAC)

Trace file format (contd.) -Is source address.source port number -Id dest address.dest port number -It packet type -Il packet size -If flow id -Ii unique id -Iv ttl value

Trace file format (contd.) Next hop information -Hs id for this node -Hd id of next node towards destination

Awk script

Awk script ‘Awk’ is a scripting language used to process text files. Processes the file row by row. Columns are identified like $1,$2 etc. awk –f <.awk file> <.tr> file. Use the awk file provided to calculate throughput from tracefile.

Sample Script - dr.awk BEGIN { sent=0 recd=0 }

dr.awk event=$1 level=$19 if(event == “s” && level == “AGT”) sent++ if(event == “r” && level == “AGT”) recd++ }

dr.awk END { printf("sent %g, recd %g, fwd %g, del. %g\n",sent,recd,fwd,recd/sent); }

GnuPlot

'gnuplot' Syntax: gnuplot <file.gnu> Read dr.gnu file to understand use of 'gnuplot' to plot graphs.

Adding new Files in NS Find ns2_ricean_dist folder available with this presentation. Follow the procedure in “README” file.