Presentation is loading. Please wait.

Presentation is loading. Please wait.

Date : 2010/11/23 Speaker : Chia-Wen Lu 1.  Network Simulation  Introduction to NS2  Simple Simulation Example 2.

Similar presentations


Presentation on theme: "Date : 2010/11/23 Speaker : Chia-Wen Lu 1.  Network Simulation  Introduction to NS2  Simple Simulation Example 2."— Presentation transcript:

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

2  Network Simulation  Introduction to NS2  Simple Simulation Example 2

3  Network Simulation  Introduction to NS2  Simple Simulation Example 3

4 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) 4

5 advantagedisadvantage Experiment realistic expensive sometime not possible Mathematical model insight assumptions Simulationeasy (cheap) verification not much insight assumptions 5

6 Platform: - hardware, software, or hybrid Developer: - commercial or in-house Source code: - open or close Paradigm: - time-dependent/non-time-dependent; time-driven/event-driven 6

7 simulation performance - execution speed - scalability - fidelity - cost Network Layer - free: NS2, GloMoSim - commercial: Opnet, QualNet 7

8  Network Simulation  Introduction to NS2  Simple Simulation Example 8

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

10 10  有線網路 網路層: DV, LS, PIM-SM 傳輸層: TCP 、 SCTP and UDP 應用層: FTP, SIP, CBR, stochastic 排隊模型: Drop-tail, RED, FQ, SFQ QoS : MPLS 、 IntServ and Diffserv  無線網路 網路類型: MANET, Sensor Networks 路由方式: AODV, DSR, DSDV , Mobile IP 等等 鏈結層: 802.11, 802.16, 802.15.4,Smac 等

11 11 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

12 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

13 Gathering information right after every event execution Simulation finishes - at a pre-specified time - when there is no more event 13

14  Point-to-point wired communication link - a one-way communication 14

15 15 Arrival: - a packet arrival event Complete: - a successful packet transmission even t

16 PacketService time Arrival time Complete time P1303 P2225 P3146 16 P1 0 P2 2 P3 4 P1 3 P2 5 P3 6

17 17

18 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

19 19

20 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

21  Compile and create “prog.exe” - recompile for every minor changes (e.g., number of nodes, link speed) 21

22  C++ coding with input arguments - use parameters input argument - e.g., “prog ” - what if there are too many parameters? 22

23  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

24  Start from Tcl simulation script  For each line: - execution path: Tcl -> Otcl -> C++ - returning path: C++ -> OTcl -> Tcl (next line) 24

25  Network Simulation  Introduction to NS2  Simple Simulation Example 25

26 26

27  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

28 # 產生一個模擬的物件 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

29 #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

30 # 建立 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

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

32 # 設定 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

33 # 執行模擬 $ns run 33

34 34

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

36 Q & AQ & A 36


Download ppt "Date : 2010/11/23 Speaker : Chia-Wen Lu 1.  Network Simulation  Introduction to NS2  Simple Simulation Example 2."

Similar presentations


Ads by Google