1 / 25

實驗 ( 五 ) 網路效能量測

實驗 ( 五 ) 網路效能量測. 計算機網路 COMPUTER NETWORK. 實驗步 驟. 學習 TCL 語言 分析 out.tr 分析相關數值 學習 AWK 語言 利用 NSG2 所提供的範例檔,並產生 TCL 檔 再利用 Out.tr 去計算出有關網路效能的數值. TCL. TCL(Tool Command Language) 用途 : 描述腳本 描述要模擬的網路環境和參數設定. TCL 基本介紹 ( 變數宣告及使用 ). set $ Example 執行方法 執行 結果. variable.tcl. s et name “jim”

sadah
Download Presentation

實驗 ( 五 ) 網路效能量測

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 實驗(五)網路效能量測 計算機網路 COMPUTERNETWORK

  2. 實驗步驟 • 學習TCL語言 • 分析out.tr • 分析相關數值 • 學習AWK語言 • 利用NSG2所提供的範例檔,並產生TCL檔 • 再利用Out.tr去計算出有關網路效能的數值

  3. TCL • TCL(Tool Command Language) • 用途:描述腳本 • 描述要模擬的網路環境和參數設定

  4. TCL基本介紹(變數宣告及使用) • set • $ • Example 執行方法 執行結果 variable.tcl set name “jim” Puts “my name is $name” $ns variable.tcl my name is jim

  5. TCL基本介紹(表示式) • expr • 判斷真假 • example • 數學表示式 • Example expr2.tcl expr1.tcl set value [expr 0==1] puts $value set value [expr 2+3] puts $value $ns expr2.tcl 5 $ns expr1.tcl 0

  6. TCL基本介紹(指令替換) • example CommandSubstitution.tcl puts “I am [expr 10*2] years old” $ns CommandSubsitution.tcl I am 20 years old

  7. TCL基本介紹(流程控制) • if-else、switch、while、for、foreach • example ControlFlow.tcl set my_planet “earth” If {$my_planet == “earth”}{ puts “I feel right at home.” } else if {$my_planet == “mars”}{ puts “This is not my home.” } else { puts “I am neither from earth,nor from mars.” } set temp 25 If {$temp < 20 }{ puts “It’s a little chilly.” } else{ puts “Warm enough for me” } $ns ControlFlow.tcl I feel right at home. Warm enough for me. 空格要注意,一定要空,不然不能跑

  8. TCL基本介紹(程序) • TCL中也允許使用者自定程序 • example procedure.tcl 空格注意 procsum_proc{a b}{ return[expr $a =$b] } set num1 5 set num2 6 set sum [sum_proc $num1 $num2] puts “the sum is $sum” $ns procedure.tcl the sum is 11

  9. TCL基本介紹(陣列) • example array.tcl set myarray(0) “Zero” set myarray(1) “One” set myarray(2) “Two” for { set i 0} {$i <3} {incri 1} { puts $myarray($i) } $ns array.tcl Zero One Two 空格要注意,一定要空,不然不能跑

  10. Out.tr Analysis • 欄位一:封包事件 (r:receive,+:enpueue, -:dequeue,d:drop) • 欄位二:事件發生時間 • 欄位三、欄位四: fromnode到tonode • 欄位五:封包型態 • 欄位六:封包大小 • 欄位七:旗標 • 欄位八:表示封包屬於的資料流 • 欄位九、欄位十:封包來源端和目的端 x.y->x:節點編號,y:portnumber • 欄位十一:封包序號 • 欄位十二:封包id 1 2 3 4 5 6 7 8 9 10 11 12

  11. Analysis • End-to-End Delay 端點到端點的延遲 = receiver time – sender time • Jitter 抖動率(延遲時間變化量) = (receiver time(j) – sender time(j)) – (receiver time(i) – sender time(i)), j > i • Throughput 吞吐量 • packet loss 封包遺失率 Ex:from node=1 to node=2 且event=“+”從n1送到n2封包 Flowid=2 & event=“d” 封包遺失 所以封包遺失率= 封包遺失數/(封包送達數+封包遺失數)

  12. AWK • 一種程式語言 • 變數無形別之分 • 擅長處理資料列、欄位型態的資料。

  13. AWK $1 $2$3$4$5$6$7$8$9$10$11$12 $0 • 當awk讀入資料列後,會把每個欄位的值存入欄位變數

  14. AWK • 程式主要結構 • 一般常用”關係判斷式來當Pattern” • 提供C語言常見的關係運算元,如>、<、>=、<=、==、!=…等 • I/O指令:print、printf()……等 • 流程控制指令:if(…){…}else{…}、while(…){…}…… • AWK語言與C語言類似,在空格不會像TCL一樣,有一定要空格的問題 Pattern1 { Action1} Pattern2 { Action2} …………………………………. Pattern3 { Action3}

  15. AWK • 工作流程 • 從指定的資料檔中讀取一筆資料列 • 更新相關的內建變數之值 • 逐次執行程式所有的Pattern{Actions} • 當所有的Pattern{Action}接執行完時,若資料檔中還有位讀取的資料則反覆執行步驟1步驟4 *awk會自動執行上述迴圈步驟,使用者不需再寫迴圈

  16. AWK學習 • 網站一血落閣 • Linux相關技術學習 http://blog.xuite.net/mb1016.flying/linux/28111008-linux+shell+awk+%E8%AA%9E%E6%B3%95 此網站是翻譯成繁中版 • 來源出處(weekly123的专栏 • http://blog.csdn.net/weekly123/article/details/1465675) • 網站二 http://lalakiwe.myweb.hinet.net/Documents/awk/awk_1.html

  17. 作業 • 本實驗將利用NSG2實作範例圖(圖同實驗三)所產生的tcl檔和out.tr檔 • 再撰寫一程式,計算每個封包之delaytime,jitter 及PackageLossRate

  18. PacketLoss.awk • BEGIN {#程式初始化,設定一變數記錄packet被drop的數目 • fsDrops = 0; • numFs = 0; } • { action = $1; • time = $2; • from = $3; • to = $4; • type = $5; • pktsize = $6; • flow_id = $8; • src = $9; • dst= $10; • seq_no = $11; • packet_id = $12; • #統計從n1送出多少packets • #統計flow_id為2,且被drop的封包 • } • END { • printf • }

  19. Delay.awk(1) • BEGIN { • #程式初始化,設定一變數以記錄目前最高處理封包的ID。 • highest_packet_id = 0; • } • { action = $1; • time = $2; • from = $3; • to = $4; • type = $5; • pktsize = $6; • flow_id = $8; • src = $9; • dst = $10; • seq_no = $11; • packet_id = $12; • #記錄目前最高的packet ID • if ( packet_id > highest_packet_id ) • #記錄封包的傳送時間 • if ( start_time[packet_id] == 0 ) • start_time[packet_id] = time;

  20. Delay.awk(2) • #記錄CBR (flow_id=2) 的接收時間 • if ( flow_id == 2 && action != "d" ) { • if ( action == "r" ) { • } • } else { • #把不是flow_id=2的封包或者是flow_id=2但此封包被drop的時間設為-1 • } • } • END { • #當資料列全部讀取完後,開始計算有效封包的端點到端點延遲時間 • for ( packet_id = 0; packet_id <= highest_packet_id; packet_id++ ) { • start = • end = • packet_duration = end - start; • #只把接收時間大於傳送時間的記錄列出來 • if ( start < end ) printf("%f %f\n", start, packet_duration); • } • }

  21. Jitter.awk(1) • BEGIN {#程式初始化,設定一變數以記錄目前最高處理封包的ID。 • highest_packet_id = 0;} • { action = $1; • time = $2; • from = $3; • to = $4; • type = $5; • pktsize = $6; • flow_id = $8; • src = $9; • dst = $10; • seq_no = $11; • packet_id = $12; • #記錄目前最高的packet ID • if ( packet_id > highest_packet_id ) • #記錄封包的傳送時間 • if ( start_time[packet_id] == 0 ) { • # 記錄下包的seq_no • pkt_seqno[packet_id] = seq_no; • start_time[packet_id] = time; } • }

  22. Jitter.awk(2) • #記錄CBR (flow_id=2) 的接收時間 • if ( flow_id == 2 && action != "d" ) { • if ( action == "r" ) { • } • } else { • #把不是flow_id=2的封包或者是flow_id=2但此封包被丟棄的時間設為-1 • } • END { • # 初始化jitter計算所需變量 • last_seqno = 0; • last_delay = 0; • seqno_diff = 0; • #當資料列全部讀取完後,開始計算有效封包的端點到端點延遲時間 • for ( packet_id = 0; packet_id <= highest_packet_id; packet_id++ ) { • start = • end = • packet_duration= end - start;

  23. Jitter.awk(3) • #只把接收時間大於傳送時間的記錄列出來 • if ( start < end ) { • # 得到了delay值(packet_duration)後計算jitter • seqno_diff = • delay_diff= • if (seqno_diff == 0) { • jitter =0; • } else { • jitter = delay_diff/seqno_diff; • } • printf("%f %f\n", start, jitter); • last_seqno = pkt_seqno[packet_id]; • last_delay = packet_duration; • } • } • }

  24. HINT • 根據上列(P17~P22投影片)提示,來完成橘色空格,並完成AWK檔,搭配out.tr來計算出相關數值 • 如果真的不熟悉AEK語言 ,也可以由(P17~P22投影片) 提示,自行做出C、C++程式語言版本,來計算出相關數值

  25. 作業 • Doc檔上,須說明: • 封面(班級、學號、姓名) 檔名範例:Hw3_498410561_張建雄 • 相關程式碼 • Terminal在執行$awk結果之截圖(如有三個awk檔,則截三個圖) • 如果是用其他語言的也須附上截圖 • 心得 若有問題請e-mail給助教

More Related