1 / 28

CH4 Random Number Generator

CH4 Random Number Generator. 背景知識. Seed and distribution 由 seed and distribution 決定產生的數值 產生一亂數表,當需要一亂數時,會依序選取表格中的數字,所以當所使用的 seed and dirstribution 相同時,所得的亂數會相 是 若 seed 的值為 0 ,都會產生出不同的表格,即每次的亂數都不同. 設定種子 set rng [new RNG] $rng seed 1 設定分佈 Pareto Distribution

vilmos
Download Presentation

CH4 Random Number Generator

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. CH4 Random Number Generator

  2. 背景知識 Seed and distribution 由seed and distribution決定產生的數值 產生一亂數表,當需要一亂數時,會依序選取表格中的數字,所以當所使用的seed and dirstribution相同時,所得的亂數會相是 若seed的值為0,都會產生出不同的表格,即每次的亂數都不同

  3. 設定種子 set rng [new RNG] $rng seed 1 設定分佈 Pareto Distribution 需提供expectation(avg_)與shaper parameter β(shape_) set r1 [new RandomVariable/Pareto $r1 use-rng $rng $r1 set avg_ 1.0 $r1 set shape_ 2.0

  4. Constant • 需提供平均值(avg_)參數 set r2 [new RandomVariable/Constant] $r2 use-rng $rng $r2 set avg_ 5.0 • Uniform distribution • 需提供最小值(min_)與最大值(max_) set r3 [new RandomVariable/Uniform] $r3 use-rng $rng $r3 set min_ 0.0 $r3 set max_ 10.0

  5. Exponential distribution • 需提供平均值(avg_) set r4 [new RandomVariable/Exponential] $r4 use-rng $rng $r4 set avg_ 10.0 • Hyperexponential distribution • 需提供平均值(avg_)與cov_參數 set r5 [new RandomVariable/HyperExponential] $r5 use-rng $rng $r5 set avg_ 0.001 $r5 set cov_ 1.0

  6. 網路模擬中應用亂數產生器範例

  7. R1和R2是路由,當中的Link是採用DropTail的佇列管理機制,頻寬為1Mbps,傳遞延遲為10ms,S1、S2、S3到D1、D2、D3之間有三條FTP資料流,資料流起始時間由亂數決定,但限制在0~1秒之間,且每條資料流都會傳送5秒R1和R2是路由,當中的Link是採用DropTail的佇列管理機制,頻寬為1Mbps,傳遞延遲為10ms,S1、S2、S3到D1、D2、D3之間有三條FTP資料流,資料流起始時間由亂數決定,但限制在0~1秒之間,且每條資料流都會傳送5秒 • Throughput:單位時間內,所有目的節點的平均接收資料速度 Throughput = (某段時間內,所有目的節點的平均接收資料量) ÷(統計的這段時間)

  8. 亂數的設定 • Pareto Distribution set r1 [new RandomVariable/Pareto $r1 use-rng $rng $r1 set avg_ 0.1 $r1 set shape_ 5.0 • Constant set r2 [new RandomVariable/Constant] $r2 use-rng $rng $r2 set avg_ 5.0

  9. Uniform distribution set r3 [new RandomVariable/Uniform] $r3 use-rng $rng $r3 set min_ 0.0 $r3 set max_ 1.0 • Exponential distribution set r4 [new RandomVariable/Exponential] $r4 use-rng $rng $r4 set avg_ 0.1

  10. Hyperexponential distribution set r5 [new RandomVariable/HyperExponential] $r5 use-rng $rng $r5 set avg_ 0.1 $r5 set cov_ 1.0

  11. 習題 • 換成其他的分佈 Pareto distribution Constant distribution

  12. Exponential distribution Uniform distribution

  13. Hyperexponential distribution

  14. 把FTP的資料流的數目調成5、10、15、20條 Pareto distribution Constant distribution

  15. Uniform distribution Exponential distribution

  16. Hyperexponential distribution

  17. Ch5信賴區間(Confidence interval)

  18. 背景知識 • 對於模擬真實環境時,所得的數據,去求平均值,但對此數據可有多少程度的相信?因此信任區間的觀念就可派上用場 • 信賴區間(confidence interval) 在有限個模擬數據結果中得到 一個比較接近 population mean (μ)是不可能的,因此只能去求 一個機率範圍(probability bound),使得μ有一個 很高的機率1-α,能在機率範圍的上限c1和下限 c2之間。 Probability {c1<=μ<=c2}=1-α

  19. (c1,c2)這個範圍稱為confidence interval;α稱之 significance level<以分數表示,通常接近0>;100(1-α) 稱為confidence level<一般用百分比表示,接近100%>;1-α稱為 confidence coefficient。 當α=0.1時(求90%信賴水準)時,可使用5%和95%的樣本平均值當 作上下限。例:假設有K個模擬結果,先求出樣本平均值,再由小至 大的順序作排序(sort),最後以第[1+0.05(k-1)]和第[1+0.85(k-1)]個模 擬結果(sample)當作範圍的下限和上限。

  20. 中央極限定理(Central Limit Theorem) 可以決定出平均值的分佈(distribution of the sample mean),假定所 有的結果數據{V1、V2…. VM}都是獨立的,且都來自同一 population(具有平均值μ標準差σ)的話,則從眾多的結果數據所得 到的平均直會近似常態分佈,而分佈平均值是μ,標準差: 注意的是population的標準差σ≠模擬結果平均值的標準差( ) 。而當模擬的次數越多時,即M值越大時,模擬結果平均值的標準差 也就會越小。 若是使用中央極限定理,一個100(1-α)的信賴區間可表示成:

  21. 範例 S1-d1是觀察的FTP資料流,s2-d2是干擾的資料流,s3-d3是另一條干擾 的on-off資料流。隨著不同的on-off資料流參數的設定(調整干擾的大 小),紀錄s1-d1這條FTP資料流的throughput。

  22. 把檔案增加有執行的權限。 $chomd a+x 5S.pl $./5S.pl • 執行5S.pl後,會產生result100、result200、result300、result400、result500等檔案,分別記錄了當on-off資料流速率從100到500kpbs時,s1-d1的Throughput,每個檔案都記錄了30筆實驗結果。 • 計算各result平均的Throghput<因程式設定seed=0,所以每次執行結 果不相同> • 再計算95%的信賴區間 • 結果檔案:result.txt 100 458.068 1.88651 200 410.451 2.64199 300 333.756 25.2581 400 188.320 4.86632 500 106.007 2.31282 600 78.9254 17.2354 700 60.1215 19.1635

  23. 使用gnulop把當on-off資料流速變化從100Kbps到700Kbps時的s1-d1的FTP throughput變化情形畫出來 當on-off資料流的速率越高,s1-d1的FTP throughput也會越低

  24. Ch6Queue Management

  25. 背景知識(1/2) • DropTail:當一封包到達queue,就把封包放入queue等待被傳送,但queue length有限。當資料流太大,而queue沒有空間去暫存這些新進來的封包,就會把queue尾端的封包丟棄。最大優點為實做簡單,但也使得queue有相當長的時間處於充滿的狀態,而queue management最重要的目標之一就是降低穩定狀態下queue length,因為端點對端點的延遲主要就是由於wait in queue所照成的 • 易造成TCP Global Synchronization,使網路常處於利用率很低的狀態,降低了Throughput。 • 被動式佇列管理機制:DorpTail、Random Drop、Drop Front,都在queue滿了被迫丟棄封包,仍存在”滿佇列”問題。

  26. 背景知識(2/2) • 主動式佇列管理機制會在佇列滿之前就開始把封包丟棄,就可以對具有擁塞控制的傳送端作流量速度管制,以避免滿佇列狀態所帶來的較長端點和端點延遲時間或Link利用率很低的負面效應(例:RED, Random Early Detection)。 • RED是使用average queue length來預測即將發生的網率壅塞,並採用隨機選擇的方式對封包丟棄<使得不同TCP資料流對壅塞情況的反應不會有同步化的情形發生,避免TCP Global Synchronization >在雍塞尚未發生之前就會讓具有擁塞控制的傳送端作流量控制。 • RED計算平均佇列長度是採用指數加權平均方式: Avg=(1-Wq)*avg+Wq*q • 丟棄封包依據機率公式: Pb=maxb ×(avg-minb)÷(maxth-minth)

  27. 範例 • r1與r2是路由器,當中的link是採用DropTail和RED佇列管理機制以作為校能分息之比較,頻寬56kbps,延遲時間為10ms,當中資料流數目使用者可以在模擬時決定。 • 架構圖:

More Related