Download
date 2010 11 23 speaker chia wen lu n.
Skip this Video
Loading SlideShow in 5 Seconds..
NS2 PowerPoint Presentation

NS2

2 Vues Download Presentation
Télécharger la présentation

NS2

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Date : 2010/11/23 Speaker : Chia-Wen Lu NS2

  2. Outline • Network Simulation • Introduction to NS2 • Simple Simulation Example

  3. Outline • Network Simulation • Introduction to NS2 • Simple Simulation Example

  4. Network Simulation (1) • Suppose you devise a great protocol. How do you show that it’s great? - Experiment - Mathematical model - graph theory - Simulation - programming (e.g., C++ or NS2)

  5. Network Simulation (2)

  6. Network Simulation (3) • Platform: - hardware , software, or hybrid • Developer: - commercial or in-house • Source code: - openor close • Paradigm: -time-dependent/non-time-dependent; time-driven/event-driven

  7. Network Simulation (4) • simulation performance - execution speed - scalability - fidelity - cost • Network Layer - free: NS2, GloMoSim - commercial: Opnet , QualNet

  8. Outline • Network Simulation • Introduction to NS2 • Simple Simulation Example

  9. NS2 • Network Simulator (Version 2) - widely known as NS2 - event driven simulation tool - wired / wireless network, protocols (e.g. routing algorithms, TCP, UDP)

  10. Event-Driven Simulation (1) • Events a, b, and c are executed in order • - example program • 1 initialize {system states} • 2 initialize {list of events} • 3 while {state != finalState} % or while {this.event != Null} • 4 expunge the previous event from list of events; • 5 set SimClock := time of current event; • 6 execute this.event • 7 end while

  11. Event-Driven Simulation (2) • Run by a set of events (schedule list) • Time gap between two events is not fixed • Simulation advance from one event to another • Event may induce one or more events new event is usually inserted into the list

  12. Event-Driven Simulation (3) • Gathering information right after every event execution • Simulation finishes - at a pre-specified time - when there is no more event

  13. A Simulation Example: A Single-Channel Queuing System • Point-to-point wired communication link - a one-way communication

  14. Two-event • Arrival: • - a packet arrival event • Complete: • - a successful packet transmission event

  15. Example of Two-event P1 3 P2 5 P3 6 P1 0 P2 2 P3 4

  16. NS2 Architecture (1) TCL Otcl C++

  17. NS2 Architecture (2) • two key languages • C++ - defines the internal mechanism of the simulation Objects • Otcl (Object-oriented Tool Command Language ) - sets up simulation scenarios • Linked together using TclCL

  18. NS2 Architecture (3)

  19. NS2: C++ and OTcl Composition • Two language architecture: C++ and OTcl • C++ - compiler - fast to run (run on machine codes) - slow to change (need compilation) • OTcl - interpreter - slow to run; fast to change • Why two languages? C++ coding styles

  20. Three C++ Coding Styles - Styles (1) • Compile and create “prog.exe” - recompile for every minor changes (e.g., number of nodes, link speed)

  21. Three C++ Coding Styles - Styles (2) • C++ coding with input arguments - use parameters input argument - e.g., “prog <num_node> <link_speed>” - what if there are too many parameters?

  22. Three C++ Coding Styles - Styles (3) • C++ coding with input files - put input parameters in a configuration file - no need to change C++ code - one input argument—the filename - NS2 style!! - configuration file is called “Tcl Simulation script”

  23. NS2 process • Start from Tcl simulation script • For each line: - execution path: Tcl -> Otcl -> C++ - returning path: C++ -> OTcl -> Tcl (next line)

  24. Outline • Network Simulation • Introduction to NS2 • Simple Simulation Example

  25. Simple Simulation Example

  26. (Cont.) • 4 nodes : n0, n1, n2, n3 • n0 and n2 =>2 Mbps頻寬,10 ms傳遞延遲時間 n1 and n2 =>2 Mbps頻寬,10 ms傳遞延遲時間 • n2 and n3 =>1.7 Mbps頻寬,20 ms傳遞延遲時間 • FTP session is based on TCP • CBR session is based on UDP

  27. (Cont.) # 產生一個模擬的物件 set ns [new Simulator] #產生傳輸節點(n0,n1) set n0 [$ns node] set n1 [$ns node] #產生路由器節點(n2) set n2 [$ns node] #產生資料接收節點(n3) set n3 [$ns node]

  28. (Cont.) #n0-n2 ,2Mbps 頻寬,10ms傳遞延遲時間 $ns duplex-link $n0 $n2 2Mb 10ms DropTail #n1-n2,2Mbps 頻寬,10ms傳遞延遲時間 $ns duplex-link $n1 $n2 2Mb 10ms DropTail #n2-n3,1.7Mbps 頻寬,20ms傳遞延遲時間 $ns duplex-link $n2 $n3 1.7Mb 20ms DropTail

  29. (Cont.) # 建立UDP連線(n1 到 n3) set udp [new Agent/mUDP] $ns attach-agent $n1 $udp set null [new Agent/mUdpSink] $ns attach-agent $n3 $null $ns connect $udp $null

  30. (Cont.) #在UDP連線之上建立CBR應用程式 set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set type_ CBR

  31. (Cont.) #設定FTP和CBR資料傳送開始和結束時間 $ns at 0.1 "$cbr start" $ns at 1.0 "$ftp start" $ns at 4.0 "$ftp stop" $ns at 4.5 "$cbr stop"

  32. (Cont.) #執行模擬 $ns run

  33. NS2 Demo

  34. Reference • Introduction to Network Simulator NS2 by T. Issariyakul and E. Hossain. • http://www.ns2ultimate.com/ • http://www.ece.ubc.ca/~teerawat/NS2.htm

  35. Thank you for your listening! Q&A