Queue management
Q g
y DropTail: 當一個封包到達佇列時因佇列已滿 ,而將佇 列最尾端的封包丟棄。
列最尾端的封包丟棄。
y 此方法易造成TCP Global Synchronization problem
R d D 當一個封包到達佇列時因佇列已滿
y Random Drop : 當一個封包到達佇列時因佇列已滿 , 而將佇列中隨機找出一個封包丟棄。
D F t 當一個封包到達佇列時因佇列已滿 而將
y Drop Front : 當一個封包到達佇列時因佇列已滿 ,而將 佇列最前端的封包丟棄。
上述方法均是在佇列滿時被迫丟棄封包 稱為被動式
y 上述方法均是在佇列滿時被迫丟棄封包,稱為被動式
佇列管理
y 主動式式佇列管理:在佇列滿之前就開始把封包丟棄 R d E l D i (RED) 使用平均佇列長度來 y Random Early Detection (RED):使用平均佇列長度來 預測即將發生的網路擁塞,並採用隨機選擇的方式丟 棄封包 (解決TCP Global Synchronization problem ) 棄封包。(解決TCP Global Synchronization problem )
q w
avg w
avg = (1−w )× avg + w × q avg = (1 q )× + q ×
) i
( ) i
(
Pb max p (avg minth ) (maxth minth)
P = × − ÷ −
) 1
/( count P P
Pa Pb /(1 count × )Pb
P = − ×
y 修改DropTail佇列管理機制(myfifo.cc, myfifo.h) 放入 queue目錄下( /ns allinone 2 30/ns 2 30/queue)
queue目錄下(~/ns-allinone-2-30/ns-2.30/queue) y 修改tcl/lib/ns-default.tcl
新增一行Q / fif 0
y 新增一行Queue/myfifo set curq_ 0
y 修改Makefile,把queue/myfifo.o加入OBJ_CC內
#開啟一個trace file,用來記錄封包傳送的過程
d [ $ 1 $ 2 ]
set nd [open out-$par1-$par2.tr w]
$ns trace-all $nd
…
…
$ns duplex-link $r1 $r2 56k 10ms $par1
#設定r1到r2之間的Queue Size為50個封包大小
$ns queue limit $r1 $r2 50
$ns queue-limit $r1 $r2 50
#把佇列長度記錄下來
#把佇列長度記錄下來
set q_ [[$ns link $r1 $r2] queue]
set queuechan [open q-$par1-$par2.tr w]
$q_ trace curq_q_ q_
$q_ attach $queuechan
for {set i 0} {$i < $par2} {incr i} {
set tcp($i) [$ns create connection TCP/Reno $src($i) set tcp($i) [$ns create-connection TCP/Reno $src($i) TCPSink $dst($i) 0]
$tcp($i) set fid $i
$tcp($i) set fid_ $i }
y 10 條TCP資料流,採用DropTail
$ l fif 10
$ns queue.tcl myfifo 10
y 10 條TCP資料流,採用RED
$ns queue.tcl RED 10
Dynamic routingy g
y 路由(routing)就是IP封包用來決定路徑的方法
靜態路由(St ti t ) 是由網管人員以手動方式一筆一
y 靜態路由(Static route): 是由網管人員以手動方式一筆一 筆鍵入路由表中。
y 動態路由(Dynamic route):根據路由協定或演算法來動態
y 動態路由(Dynamic route):根據路由協定或演算法來動態 維護路由表中的內容,路徑的建立是透過與鄰近的路由器 交換資料所得到的。
交換資料所得到的
y 預設路由(Default route):當路由器無法判斷封包轉送的路 徑時,就會將封包送至一個預設的閘道器(default (
gateway)。
Routing table using DVg g
n0 n1 n2
n3 n4
n0 n1 n2 n3 n4
n0 0 1 2 2 3
n1 1 0 1 1 2
n1 1 0 1 1 2
n2 2 1 0 1 2
n3 2 1 1 0 1
n4 3 2 2 1 0
set ns [new Simulator]
#若是使用者有指定使用距離相量(distance vector)演算法 的動態路由方式
#則設定路由的方式為DV if {$argc==1} {
if {$argc 1} {
set par [lindex $argv 0]
if {$par=="DV"} { if {$par== DV } {
$ns rtproto DV }
} }