Top Banner
1 Error Model 林 林 林 695430014 林林林林林 林林林林 : 林林林林林
34

1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

Dec 21, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

1

Error Model

林 玲 玉695430014通訊工程所

指導教授 : 潘仁義教授

Page 2: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

2

Outline Error model ( 有線 )

介紹 範例 ( 新增 ns2 核心模組 ) 小結

Install Wireless error model (2.28 => 2.30) Wireless error model 小考

Page 3: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

3

Introduction Their definitions can be found in

~ns/queue/errmodel.{cc, h} ~ns/tcl/lib/ns-errmodel.tcl ~ns/tcl/lib/ns-default.tcl

There are several other types of error modules not being completely documented yet.

Page 4: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

4

Introduction SRMErrorModel, PGMErrorModel ErrorModel/Trace MrouteErrorModel ErrorModel/Periodic SelectErrorModel ErrorModel/TwoState ErrorModel/TwoStateMarkov, ErrorModel/Expo,ErrorModel/Empirical ErrorModel/List

Page 5: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

5

Implementation Error model simulates link-level error or

loss Loss => Dump the packet to a drop-target. Error => Mark the packet’s error flag. ~ns2.30/common/packet.h

Page 6: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

6

Implementation The Error model class is derived from Connector ba

se class.

It inherits some methods for hooking up objects target drop-target

Page 7: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

7

Implementation In TCL

unit : Specify the unit of error time , pkt , bits

ranvar : Specify the random variable for generating errors Uniform Distribution

rate : Specify error rate error rate

IF not specify Unit : packets Random distributed from 0 to 1

Page 8: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

8

Implementation Simple example

set error_model [new ErrorModel]$ error_model set rate_ 0.01$ error_model unit pkt$ error_model ranvar [new RandomVariable/Uniform]$ error_model drop-target [new Agent/Null]

定義好 error_model ,就可以在需要的地方插入 error了。

Page 9: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

9

Implementation In C++, the Error Model contains both the mechanism

and policy for dropping packets. recv ( ) : packet dropping mechanism corrupt ( ) : packet corrupting policy

The Error Model only implements a simple policy based on a signal error rate, either in packets of bits.

Page 10: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

10

Configuration To use an error model for wired networks, at first it

has to be inserted into a SimpleLink object.

An error model can be inserted to many places.

Simulator::lossmodel <em> <src> <dst> $ns lossmodel $error_model $n0 $n1

Page 11: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

11

Example

n0 n1 n2 n3

Error Model

CBR 0.5Mbps

Page 12: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

12

Example 詳細參數設定

修改 myfifo 檔案裡 queue 的程式碼,在 enque 中去統計有多少的封包進入了佇列 。

Page 13: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

13

Example ( 新增 ns2 核心模組 )1: 把 myfifo.{cc,h} 放進 ns-allinone-2.30/ns-2.30/queue 的目錄下。

2: 修改 myfifo.h 和 myfifo.cc 先修改 myfifo.h => 把所有 DropTail & drop_tail 改成 myfifo 再修改 myfifo.cc => 把所有 DropTail & drop_tail & drop-tail 改成 myfifo

Page 14: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

14

Example ( 新增 ns2 核心模組 )3: 修改 ns-default.tcl 檔,設定初始內定值。

切到 ns-allinone-2.30/ns-2.30/tcl/lib/ 目錄下 打開 ns-default.tcl ,並利用搜尋功能找到 Queue/DropTail 把每個初始值都再設一份給 Queue/myfifo 變數初始值設定

Page 15: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

15

Example ( 新增 ns2 核心模組 )4: 修改 Makefile ,把 myfifo.o 加入 OBJ_CC 內,並重新編譯。

切到 ns-allinone-2.30/ns-2.30 目錄下的 Makefile 搜尋找到 drop-tail.o 在 drop-tail.o 後面加上 queue/myfifo.o

Page 16: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

16

Example ( 新增 ns2 核心模組 )5: 重新編譯

Make clean Make

若是沒有錯誤,會如圖所示

Page 17: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

17

Example ( 新增 ns2 核心模組 )6: 測試一下新安裝的模組是否可以正常的運作。 把剛剛的範例 DropTail 修改成 myfifo

Page 18: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

18

Example-Result

packet loss rate = (14881 - 14568) ÷ 14881 = 0.0210 ~ error rate = 0.02

Page 19: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

19

小結 新增模組到 ns2 的核心步驟 : 1. 準備好模組檔 ( 例如, a.cc 和 a.h) 。 2. 若有需要做初始設定的話,修改 ns-default.tcl 檔。 3. 修改 Makefile ( 把 a.o 加到 OBJ_CC 內 ) 4. 重新編譯 5. 測試模組

Page 20: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

20

安裝 Wireless Error Model 環境

Linux core4 NS2-2.30

網路上 release 的模組是 2.28 版本,必須找出不同的地方並修改,才可裝進 2.30 版本。

Page 21: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

21

安裝 Wireless Error Model1: 安裝 noah

a. 修改 Makefile.in ,在以下的地方,加入下列指令 在 OBJ_CC 加入 noah/noah.o \ 在 NS_TCL_LIB 加入 tcl/mobility/noah.tcl \

b. 在 ns-2.30 目錄下新建一個 noah 資料夾,並將 noah.h 與 noah.cc

檔案放入其中 c. 再把 noah.tcl 放到 tcl/mobility 內d. 用 vim 編輯 tcl/lib/ns-lib.tcl 檔案,在下面不同地方加入程式碼

Page 22: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

22

安裝 Wireless Error Model2: 編輯完成後,回到 ns-2.30 目錄下,依序做以下指令 :

./configure Make clean Make 編譯完無錯誤即可

Page 23: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

23

安裝 Wireless Error Model3: 把 forwarder.cc, forwader.h 放到 ~ns2.30/mac 的目錄下

並修改 wireless-phy.cc & wireless-phy.h 。 先修改 wireless-phy.h 再修改 wireless-phy.cc

Page 24: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

24

安裝 Wireless Error Model

Page 25: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

25

安裝 Wireless Error Model4: 再把 ns-mobilenode.tcl 放到 tcl/lib 目錄下5: 修改 Makefile.in, 在 OBJ_CC 加入 mac/forwarder.o \

6: 依序做以下指令 ./configure Make clean Make

7: 進行測試

Page 26: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

26

Wireless Error Model 分散型遺失

Random uniform model 連續型遺失

Gilbert-Elliot (GE) model

Uniform Random Error model

Gilbert-Elliot Error model

PI PBPP

I BBP

PIPIPIPI PPPP PB

PI PBPPPIPIPIPI PPPP PB

PB PB

PB PB

MPEG Video Frame

Error packet

Page 27: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

27

Wireless Error Model In NS2 修改 mac/wireless-phy.cc

Transport

IP

MAC

Phy

Transport

IP

MAC

Phy

Sender(BS/MH)Receiver(BS/MH)

Add Error modelAdd Error model

Page 28: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

28

Gilbert-Elliot (GE) model

In the “good” state (G) losses occur with low probability Iin the “bad” state (B) they happen with high probability The steady state probabilities of being in states G and B are and

The average packet loss rate produced by the Gilbert channel is

G B

GBp

BGp

BBpGGp

0

1

0

1

Gp1

Gp1

Gp

Gp

G

0

1

0

1

B

a.

b. c.

Bp1

Bp1

Bp

Bp

Gp

Bp

GBBG

BGG pp

p

GBBG

GBB pp

p

G G B Bp p p

Page 29: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

29

Simulation Topology (example)

W(0)HA

(base station)MH

10Mbps, 10ms802.11

Page 30: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

30

執行方法 ( 以 run_ge_error 為例 ) $./run_ge_error

Page 31: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

31

Result – GE model

Simulated p (%)0.4 0.1660

0.5 0.2060

0.6 0.2460

0.7 0.2860

Bp G G B Bp p p

Page 32: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

32

Reason G B

1

1GG GB GB GB

BG BB BG BG

p p p pP

p p p p

P

1

1GB GB

G B G BBG BG

p p

p p

(1 ) (1 )G B GB G BG B GB G BG Bp p p p

(1 )G GB G BG Bp p

G G GB G BG Bp p

GB G BG Bp p

: :G B BG GBp p

1G B BG

GBG GB

p

p p

GB

BBG GB

p

p p

IN steady state,

The state probability in steady state,

Page 33: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

33

抽考 error_ 設定為 0.1

n0 n1 n2 n3

Error Model

CBR 0.5Mbps

Page 34: 1 Error Model 林 玲 玉 695430014 通訊工程所 指導教授 : 潘仁義教授.

34

Reference The ns Manual ( Chapter 13 Error Model)

NS2 教學手冊 ( NS2 Learning Guide) Error Model