NS2模拟工具实作.ppt
文本预览下载声明
NS2模擬工具實作 Reporter:m9456002 林濟斌 m9456004 吳啟鴻Present Date:04/12/2005 Outline TCL 語言簡介 TCP與UDP模擬實驗 動態路由 亂數產生器 信賴區間 佇列管理機制 TCL語言簡介 TCL(Tool Command Language) 安裝文書編輯軟體PSPad 變數和變數替換 1. set foo “john” puts “my name is $foo” 2 set foo puts hi eval $foo 表示式及指令替換 1. set value [expr 0==1] puts $value 2. set value [expr 2+3] puts $value 流程控制 set num_legs 4 switch $num_legs { 2 {puts It could be a human.} 4 {puts It could be a cow.} 6 {puts It could be an ant.} 8 {puts It could be a spider.} default {puts It could be anything.} } 流程控制cont. set i 0 while {$i 5} { puts In the while loop, and i == $i incr i 1 } 程序 proc sum_proc {a b} { return [expr $a + $b] } proc magnitude {num} { if {$num 0} { return $num } set num [expr $num * (-1)] return $num } set num1 12 set num2 14 set sum [sum_proc $num1 $num2] puts The sum is $sum puts The magnitude of 3 is [magnitude 3] puts The magnitude of -2 is [magnitude -2] 程序cont. proc dumb_proc {} { set myvar 4 puts The value of the local variable is $myvar global myglobalvar puts The value of the global variable is $myglobalvar“ } set myglobalvar 79 dumb_proc 陣列 set myarray(0) Zero set myarray(1) One set myarray(2) Two for {set i 0} {$i 3} {incr i 1} { puts $myarray($i) } 輸出 set f [open /tmp/myfile w] puts $f We live in Texas. Its already 110 degrees out here.“ puts $f 456“ close $f TCP與UDP模擬實驗 背景知識 使用一些工具來分析和呈現模擬結果,這包含了如何去量測End-to-End Delay、Jitter、Packet Loss、和Throughput 分析的方法 分析traffic trace file 優:簡單且不需要去修改到ns2核心的部份 缺:模擬資料若是太多,traffic trace的檔案會太大,會增 加分析所需要的時間 TCL Script 架構 Set ns [new simulator] Proc finish {} { #定義一個結束的程序 exit 0 } #在適當的時間去呼叫程序,以結束模擬 $ ns at 5.0 “finish” $ ns run 模擬環境介紹 模擬過程記錄檔與格式 out.nam:把模擬的過程用視覺化的方式呈現 出來 out.tr: 這個檔案記錄了模擬過程中封包傳送 中所有的事件 Awk語言 特點 使用直譯器(Interpreter)不需先行編譯 變數無型別之分(Typeless) 使用文字當陣列的註標(Associative Array) 功能 擅於處
显示全部