Wireless Communication : LAB 3

Slides:



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

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.
Katz, Stoica F04 EECS 122 Introduction to Computer Networks (Fall 2004) Network simulator 2 (ns-2) Department of Electrical Engineering and Computer Sciences.
NS-2 (network simulator) NS by example παρουσίαση Κων/νος Τρούλος.
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,
LAB 3 NS2 Preliminaries. Contents TCL/OTCl Fundamentals Creating Network Setting Connections Generating Traffic Inserting Errors Configuring for multicast.
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 網路模擬器介紹與使用 吳賢明國立中興大學 計算機及資訊網路中心中華民國九十三年十月二十七日.
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.
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)
1 Ns Tutorial Alhussein A. Abouzeid Elect. Eng. Dept./U. of Washington Parts of this educational presentation use examples available.
SANS A Simple Ad hoc Network Simulator Nicolas Burri Roger Wattenhofer Yves Weber Aaron Zollinger.
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)
P2P Over MANET An Introduction to Mobile Resource Sharing.
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
Network Simulation Internet Technologies and Applications.
 A network simulator is a piece of software or hardware that predicts the behavior of a network, without an actual network being present.
Network Simulator (NS2) 1 Tutorial on Network Simulator (NS2) Hemant Kumar Rath Infonet Lab, Dept of Electrical Engineering IIT Bombay, Mumbai
CS 299 – Web Programming and Design CS299: Web Programming and Design Instructor: Dr. Fang (Daisy) Tang.
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.
Redes Inalámbricas Máster Ingeniería de Computadores 2008/2009 Tema 7.- CASTADIVA PROJECT Performance Evaluation of a MANET architecture.
Introduction to NS2 -Network Simulator- -Prepared by Changyong Jung.
NS2 - Appendix Ming-Feng Yang. 2 2 Outline NS2 Models NS2 Directory Structure Extending NS2 in OTcl Extending NS2 in C++ NS2 related links.
Ns-3 tutorial Katto lab Tadashi Yamazaki 8 November 2012.
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
Background of Wireless Communication Student Presentations and Projects Wireless Communication Technology Wireless Networking and Mobile IP Wireless Local.
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.
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.
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 
A Model-Driven Multi-Paradigm Integrated Simulation Framework For Analysis of Communication Networks Amogh Kavimandan 1, Marina Thottan 2, Wonsuck Lee.
The Creation of NS2 Simulated Environment ( 1 ) LI Chengbo
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.
TCP/IP Protocol Suite ©Richard L. Goldman September 25, 2002.
DMET 602: Networks and Media Lab Amr El Mougy Yasmeen EssamAlaa Tarek.
DMET 602: Networks and Media Lab
(Modified from Polly Huang’s and last year’s original)
Simulators for Sensor Networks
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
Introduction to NS Srinath Perur.
Karthik Sadasivam Banuprasad Samudrala
ns-2 simulation of TCP + CBR traffic
Ns-3 Tutorial Xin Li.
Presentation transcript:

Wireless Communication : LAB 3 Background of Wireless Communication Wireless Communication Technology Wireless Networking and Mobile IP Wireless Local Area Networks Student Presentations and Projects Introduction to NS2 Programming

Outline NS overview NS structure and basics Steps to create a typical NS script Summary: Generic Script Structure Vis Tools Useful pointers NS by Example (http://nile.wpi.edu/NS/) Where is documentation and Tutorials: http://www.isi.edu/nsnam/ns/ns-documentation.html http://www.isi.edu/nsnam/ns/tutorial/

What is NS Discrete event simulator targeted for networking research Discrete event simulation: representing a system by a collection of states and a set of events that describe state changes. Discrete-Event/Continuous-Time An event in NS a packet ID that is unique for a packet with scheduled time and the pointer to an network object that handles the packet

What can ns simulate? Topology: wired, wireless Queue Scheduling Algorithms: RED, DropTail, … Transport Protocols: TCP (all flavors), UDP, … Routing: Static and dynamic routing, MPLS, … Application: FTP, HTTP, Telnet, Traffic generators, … Multicast Various error models for link failures Open source

NS Structure NS is written in oTcl and C++; Efficiency and simplicity oTcl is an extension to oTcl (object Tcl): Have to deal with objects NS uses C++ for per-packet action e.g. scheduler, TCP implementation oTcl for control Topology Network objects "Tool Control Language," a flexible interpreter designed primarily by John Ousterhout at UC Berkeley. Extensible and powerful, it is a viable competitor of the perl language. Tk is the X11 toolkit extension to Tcl.

User interface-Interactive Mode adeel@laptop#> ./ns #> set ns [new Simulator] _o4 #> $ns at 1 "puts \"Hello World!\"" 1 #> $ns at 1.5 "exit" 2 #> $ns run Hello World!

User interface-Batch Mode simple.tcl set ns [new Simulator] $ns at 1 "puts \"Hello World!\"" $ns at 1.5 "exit" $ns run adeel@laptop#> ns simple.tcl Hello World!

Basic Tcl proc test{ } { set a 43 set b 27 set c [expr $a+$b] set d [expr [expr $a - $b] * $c] for {set k 0} {$k<10} {incr k} if {$k<5} puts "k<5, pow=[expr pow($d, $k)]" } else puts "k>=5, mod=[expr $d % $k]" test

Basic oTcl Class vehicle vehicle instproc characterize{} { $self instvar NumberOfWheels_ puts "$NumberOfWheels_ -wheel vehicle is a vehicle“ } Class car -superclass vehicle car instproc characterize{} $self instvar NumberOfWheels_ puts "$NumberOfWheels_ -wheel vehicle is a car" set a [new vehicle] set b [new car] $a set NumberOfWheels_ 3 $b set NumberOfWheels_ 4 $a characterize $b characterize

Tcl/oTcl Common Problem Generally useless debugging information: no object (_o24 cmd line 1) invoked from within “_o24 cmd drop-target { }” “catch “$self cmd $args” ret” (procedure “_o24” line 2) Fortunately, you do NOT need to be a Tcl expert for using NS

Structure of a typical ns script Creating event scheduler Opening trace files Creating topology Creating the transport layer “connection” Creating application to generate traffic Start and stop the traffic flows

Structure of a typical ns script Creating event scheduler Opening trace files Creating topology Creating the transport layer “connection” Creating application to generate traffic Start and stop the traffic flows

Create Event Scheduler Create scheduler set ns [new Simulator] Schedule event $ns at <time> <event> <event> is any legitimate ns/tcl commands Start scheduler $ns run

Structure of a typical ns script Creating event scheduler Opening trace files Creating topology Creating the transport layer “connection” Creating application to generate traffic Start and stop the traffic flows

Open trace files Ex.1 Trace packets on all links set fp [open test.out w] $ns trace-all $fp trace format: <event> <time> <from> <to> <pkt_type> <size> <flag><flow_id><src> <dst><seq_no> <ack_seq_no> r 1 0 2 tcp 1000 - - - - - - - - - - - - - - - - - 0 0.0 3.1 29 199 + 1 0 2 tcp 1000 - - - - - - - - - - - - - - - - - 0 0.0 3.1 29 199 - 1 0 2 tcp 1000 - - - - - - - - - - - - - - - - - 0 0.0 3.1 29 199 d 1.00234 0 2 tcp 1000 - - - - - - - - - - - - 0 0.0 3.1 29 199

Open trace files Ex.2 #Open the Trace file set tf [open out.tr w] $ns trace-all $tf

Create Topology Create nodes Create links and queues set n0 [$ns node] $ns <link-type> $n0de1 $node2 <bandwidth> <delay> <queue-type> <queue-type>: DropTail, RED, WFQ, SFQ, … <link-type>: duplex-link, simplex-link $ns duplex-link $n0 $n1 1Mb 10ms DropTail

Create Flow: UDP UDP Create agents - set udp [new Agent/UDP] - set null [new Agent/NULL] Attach to the nodes - $ns attach-agent $n0 $udp - $ns attach-agent $n1 $null Establish the “connection” - $ns connect $udp $null

Create Connection: TCP Create agents - set tcp [new Agent/TCP] - set tcpsink [new Agent/TCPSink] Attach to the nodes - $ns attach-agent $n0 $tcp - $ns attach-agent $n1 $tcpsink Establish the “connection” - $ns connect $tcp $tcpsink

Create Application On Top of UDP: CBR On Top of TCP: FTP set cbr0 [new Application/Traffic/CBR] $cbr0 attach-agent $udp On Top of TCP: FTP set ftp [new Application/FTP] $ftp attach-agent $tcp

Start & Stop the traffic Schedule to start the traffic $ns at 0.0 “$cbr0 start” Schedule to stop the traffic $ns at 5.0 “$cbr0 stop” $ns at 5.0 “finish” proc finish { } { global ns fp $ns flush-trace; close $fp exec …. & }

Summary: Generic Script Structure set ns [new Simulator] # [Turn on tracing] # Create topology # Setup packet loss, link dynamics # Create routing agents # Create: # - multicast groups # - protocol agents # - application and/or setup traffic sources # Post-processing procs # Start simulation

Example 1 - TCP Simple scenario with TCP and UDP connections n0 TCP n5 recvr 5Mb 2ms n1 n2 1.5Mb 10ms 5Mb 2ms n4 UDP n3 TCPSink

TCP : Step 1 Scheduler & tracing #Create scheduler Set ns [new Simulator] #Turn on tracing set f [open out.tr w] $ns trace-all $f Set nf [open out.nam w] $ns namtrace-all $nf

TCP : Step 2 Create topology #create nodes set n0 [$ns node]

TCP : Step 3 #create links $ns duplex-link $n0 $n1 5Mb 2ms DropTail $ns queue-limit $n1 $n2 25 $ns queue-limit $n2 $n1 25

TCP : Step 4 Create TCP agents set tcp [new Agent/TCP] set sink [new Agent/TCPSink] $ns attach-agent $n0 $tcp $ns attach-agent $n3 $sink $ns connect $tcp $sink

TCP : Step 5 #start application traffic $ns at 1.1 “$ftp start” Attach traffic set ftp [new Application/FTP] $ftp attach-agent $tcp #start application traffic $ns at 1.1 “$ftp start”

TCP : Step 6 End of simulation wrapper (as usual) $ns at 2.0 “finish” Proc finish {} { global ns f nf close $f close $nf puts “Running nam…” exec nam out.nam & exit 0 } $ns run

Example 2

Example 2 #Create a simulator object set ns [new Simulator] #Define different colors for data flows (for NAM) $ns color 1 Blue $ns color 2 Red #Open the NAM trace file set nf [open out.nam w] $ns namtrace-all $nf

Example 2 #Define a 'finish' procedure proc finish {} { global ns nf $ns flush-trace #Close the NAM trace file close $nf #Execute NAM on the trace file exec nam out.nam & exit 0 }

Example 2 #Create four nodes set n0 [$ns node] set n1 [$ns node] #Create links between the nodes $ns duplex-link $n0 $n2 2Mb 10ms DropTail $ns duplex-link $n1 $n2 2Mb 10ms DropTail $ns duplex-link $n2 $n3 1.7Mb 20ms DropTail #Set Queue Size of link (n2-n3) to 10 $ns queue-limit $n2 $n3 10

Example 2 #Give node position (for NAM) $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 #Monitor the queue for link (n2-n3). (for NAM) $ns duplex-link-op $n2 $n3 queuePos 0.5 #Setup a TCP connection set tcp [new Agent/TCP] $tcp set class_ 2 $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n3 $sink $ns connect $tcp $sink $tcp set fid_ 1

Example 2 #Setup a FTP over TCP connection set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP #Setup a UDP connection set udp [new Agent/UDP] $ns attach-agent $n1 $udp set null [new Agent/Null] $ns attach-agent $n3 $null $ns connect $udp $null $udp set fid_ 2

Example 2 #Setup a CBR over UDP connection set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set type_ CBR $cbr set packet_size_ 1000 $cbr set rate_ 1mb $cbr set random_ false #Schedule events for the CBR and FTP agents $ns at 0.1 "$cbr start" $ns at 1.0 "$ftp start" $ns at 4.0 "$ftp stop" $ns at 4.5 "$cbr stop"

Example 2 #Detach tcp and sink agents (not really necessary) $ns at 4.5 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n3 $sink" #Call the finish procedure after 5 seconds of simulation time $ns at 5.0 "finish" #Print CBR packet size and interval puts "CBR packet size = [$cbr set packet_size_]" puts "CBR interval = [$cbr set interval_]" #Run the simulation $ns run

Tracing cat out.tr | grep " 2 3 cbr " | grep ^r | column 1 10 | awk '{dif = $2 - old2; if(dif==0) dif = 1; if(dif > 0) {printf("%d\t%f\n", $2, ($1 - old1) / dif); old1 = $1; old2 = $2}}' > jitter.txt Give a .tr file the user must be able to extract the useful information. A Simple unix shell script using text filters like grep and awk can extract and write to a file the required information. This can later used by Xgraph orGNUPlot etc. This shell command selects the "CBR packet receive" event at n3, selects time (column 1) and sequence number (column 10), and calculates the difference from last packet receive time divided by difference in sequence number (for loss packets) for each sequence number. The following is the corresponding jitter graph that is generated using gnuplot. The X axis show the packet sequence number and the Y axis shows simulation time in seconds.

Viz Tools Nam-1 (Network AniMator Version 1) Packet-level animation Well-supported by ns Xgraph Convert trace output into xgraph format

NAM NAM has a nice graphical user interface similar to that of a CD player (play, fast forward, rewind, pause and so on), and also has a display speed controller.It can graphically present information such as throughput and number of packet drops at each link, although the graphical information cannot be used for accurate simulation analysis. For wireless simuations, however, only node movements can currently be seen in nam . Dumping of traffic data and thus visualization of data pkt movements in nam for wireless scenarios is still not supported (future work).

Ns-nam Interface Color Node manipulation Link manipulation Topology layout Protocol state Misc

Nam Interface: Color Color mapping Color  flow id association $ns color 40 red $ns color 41 blue $ns color 42 chocolate Color  flow id association $tcp0 set fid_ 40 ;# red packets $tcp1 set fid_ 41 ;# blue packets

Nam Interface: Nodes Color Shape (can’t be changed after sim starts) $node color red Shape (can’t be changed after sim starts) $node shape box ;# circle, box, hexagon Marks (concentric “shapes”) $ns at 1.0 “$n0 add-mark m0 blue box” $ns at 2.0 “$n0 delete-mark m0” Label (single string) $ns at 1.1 “$n0 label \”web cache 0\””

Nam Interface: Links Color Label Dynamics (automatically handled) $ns duplex-link-op $n0 $n1 color "green" Label $ns duplex-link-op $n0 $n1 label "abced" Dynamics (automatically handled) $ns rtmodel Deterministic {2.0 0.9 0.1} $n0 $n1 Asymmetric links not allowed

Nam Interface: Topo Layout “Manual” layout: specify everything $ns duplex-link-op $n(0) $n(1) orient right $ns duplex-link-op $n(1) $n(2) orient right-up $ns duplex-link-op $n(2) $n(3) orient down $ns duplex-link-op $n(3) $n(4) orient 60deg If anything missing  automatic layout

Nam Interface: Protocol State Monitor values of agent variables $ns add-agent-trace $srm0 srm_agent0 $ns monitor-agent-trace $srm0 $srm0 tracevar C1_ $srm0 tracevar C2_ # … … $ns delete-agent-trace $tcp1

Nam Interface: Misc Annotation Set animation rate Add textual explanation to your sim $ns at 3.5 "$ns trace-annotate \“packet drop\"“ Set animation rate $ns at 0.0 "$ns set-animation-rate 0.1ms"

Useful Pointers Directory structure: /ns-2.../ contains C++ code /ns-2.../tcl/lib/ contains oTcl source code /ns-2.../tcl/ex/ examples simulation scripts /ns-2.../tcl/test/ validation test scripts RED Queue Monitor Example http://nile.wpi.edu/NS

Xgraph

Other Utilities in Ns Nam editor Tcl debugger Topology generator Available as part of nam-1 Tcl debugger For source and documentation, see http://www.isi.edu/nsnam/ns/ns-debugging.html Topology generator http://www.isi.edu/nsnam/ns/ns-topogen.html Scenario generator http://www.isi.edu/nsnam/ns/ns-scengeneration.html

Resources Ns distribution download Installation problems and bug-fix http://www.isi.edu/nsnam/ns/ns-build.html Installation problems and bug-fix http://www.isi.edu/nsnam/ns/ns-problems.html Ns-users mailing list Ns-users@isi.edu See http://www.isi.edu/nsnam/ns/ns-lists.html Archives from above URL

Resources (contd..) Marc Greis’ tutorial Ns-users archive Ns-manual http://www.isi.edu/nsnam/ns/tutorial Ns-users archive Ns-manual http://www.isi.edu/nsnam/ns/ns-documentation.html Tcl (Tool Command Language) http://dev.scriptics.com/scripting Practical programming in Tcl and Tk, Brent Welch Otcl (MIT Object Tcl) ~otcl/doc/tutorial.html (in distribution)

Resources (contd..) NS Frequently Asked Questions: http://www.isi.edu/nsnam/ns/ns-faq.html Lloyd Wood - introducing ns: http://www.ee.surrey.ac.uk/Personal/L.Wood/ns/

QUESTIONS ???