2
Outline Error model ( 有線 )
介紹 範例 ( 新增 ns2 核心模組 ) 小結
Install Wireless error model (2.28 => 2.30) Wireless error model 小考
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.
4
Introduction SRMErrorModel, PGMErrorModel ErrorModel/Trace MrouteErrorModel ErrorModel/Periodic SelectErrorModel ErrorModel/TwoState ErrorModel/TwoStateMarkov, ErrorModel/Expo,ErrorModel/Empirical ErrorModel/List
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
6
Implementation The Error model class is derived from Connector ba
se class.
It inherits some methods for hooking up objects target drop-target
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
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了。
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.
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
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
14
Example ( 新增 ns2 核心模組 )3: 修改 ns-default.tcl 檔,設定初始內定值。
切到 ns-allinone-2.30/ns-2.30/tcl/lib/ 目錄下 打開 ns-default.tcl ,並利用搜尋功能找到 Queue/DropTail 把每個初始值都再設一份給 Queue/myfifo 變數初始值設定
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
19
小結 新增模組到 ns2 的核心步驟 : 1. 準備好模組檔 ( 例如, a.cc 和 a.h) 。 2. 若有需要做初始設定的話,修改 ns-default.tcl 檔。 3. 修改 Makefile ( 把 a.o 加到 OBJ_CC 內 ) 4. 重新編譯 5. 測試模組
20
安裝 Wireless Error Model 環境
Linux core4 NS2-2.30
網路上 release 的模組是 2.28 版本,必須找出不同的地方並修改,才可裝進 2.30 版本。
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 檔案,在下面不同地方加入程式碼
23
安裝 Wireless Error Model3: 把 forwarder.cc, forwader.h 放到 ~ns2.30/mac 的目錄下
並修改 wireless-phy.cc & wireless-phy.h 。 先修改 wireless-phy.h 再修改 wireless-phy.cc
25
安裝 Wireless Error Model4: 再把 ns-mobilenode.tcl 放到 tcl/lib 目錄下5: 修改 Makefile.in, 在 OBJ_CC 加入 mac/forwarder.o \
6: 依序做以下指令 ./configure Make clean Make
7: 進行測試
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
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
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
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,