實驗九 各種 tcp 版本之觀察 ( 二 )
DESCRIPTION
實驗九 各種 TCP 版本之觀察 ( 二 ). 指導教授:許子衡 教授 報告學生:馬敏修. ( 一 ) 實驗目的 ( 二 ) 背景知識 ( 三 ) 實驗步驟 ( 四 ) 實驗結果. 實驗目的. 暸解 TCP NewReno 與 TCP Sack 之運作方式。. 背景知識. 若同時有多個封包在網路上遺失, TCP Reno 都必須等到 timeout 才能重送遺失的封包。 因為 TCP Reno 收到 Partial ACK 就會結束 Fast-recovery ,進入 Congestion avoidance 階段 - PowerPoint PPT PresentationTRANSCRIPT
2009/10/72009/10/7 11
實驗九 各種實驗九 各種 TCPTCP 版本之觀察版本之觀察(( 二二 ))
指導教授:許子衡 教授指導教授:許子衡 教授報告學生:馬敏修報告學生:馬敏修
2009/10/72009/10/7 22
(( 一一 )) 實驗目的實驗目的
(( 二二 )) 背景知識背景知識
(( 三三 )) 實驗步驟實驗步驟
(( 四四 )) 實驗結果實驗結果
2009/10/72009/10/7 33
實驗目的實驗目的暸解暸解 TCP NewRenoTCP NewReno 與與 TCP SackTCP Sack之運作方式。之運作方式。
2009/10/72009/10/7 44
背景知識背景知識若同時有多個封包在網路上遺失,若同時有多個封包在網路上遺失, TCP TCP RenoReno 都必須等到都必須等到 timeouttimeout 才能重送遺失才能重送遺失的封包。的封包。因為因為 TCP RenoTCP Reno 收到收到 Partial ACKPartial ACK 就會就會結束結束 Fast-recoveryFast-recovery ,進入,進入Congestion avoidanceCongestion avoidance 階段階段其中其中 Partial ACKPartial ACK 的的 ACKACK 號碼較先前收號碼較先前收到的到的 ACKACK 大,但比稍早已送出的封包編號大,但比稍早已送出的封包編號小。小。
2009/10/72009/10/7 55
若遺失的封包無法使用若遺失的封包無法使用Fast-retransmit/Fast-recoveryFast-retransmit/Fast-recovery 重送,重送,就必須等待就必須等待 TimeoutTimeout 來觸發重送機制。來觸發重送機制。等待等待 TimeoutTimeout 期間期間 TCPTCP 不能送出新出的不能送出新出的資料,資料, linklink 使用率變差。使用率變差。TimeoutTimeout 之後,之後, cwndcwnd 值會被重設為值會被重設為 11 ,,降低了降低了 TCPTCP 傳輸效能。傳輸效能。
2009/10/72009/10/7 66
TCP NewRenoTCP NewRenoNewRenoNewReno 在收到在收到 Partial ACKPartial ACK 時並不會時並不會立刻結束立刻結束 Fast-recoveryFast-recovery ,反而傳送端,反而傳送端會持續重送會持續重送 Partial ACKPartial ACK 之後的封包。之後的封包。NewRenoNewReno 的傳送端在網路有大量封包遺失的傳送端在網路有大量封包遺失時不需等待時不需等待 TimeoutTimeout 就能更正此錯誤。就能更正此錯誤。NewRenoNewReno 大約每一個大約每一個 RTTRTT 時間可重送一個時間可重送一個遺失的封包。遺失的封包。
2009/10/72009/10/7 77
TCP with Selective TCP with Selective AcknowledgmentsAcknowledgments
此版本加入了一個此版本加入了一個 SACKSACK 選項允許接收端在選項允許接收端在回傳回傳 Duplicate ACKDuplicate ACK 時,將已經收到的時,將已經收到的資料區段回傳給傳送端,資料區段與資料資料區段回傳給傳送端,資料區段與資料區段之間的間隔就是接收端沒收到的資訊。區段之間的間隔就是接收端沒收到的資訊。
2009/10/72009/10/7 88
實驗步驟實驗步驟
2009/10/72009/10/7 99
實驗實驗 11 :: TCP RenoTCP Reno1.1. if {$argc !=1} {if {$argc !=1} {
2.2. puts "Usage: ns exp9.tcl TCPversion "puts "Usage: ns exp9.tcl TCPversion "
3.3. puts "Example:ns exp9.tcl Reno or ns exp9.tcl Newreno or ns exp9.tcl puts "Example:ns exp9.tcl Reno or ns exp9.tcl Newreno or ns exp9.tcl Sack"Sack"
4.4. exitexit
5.5. }}
6.6. set par1 [lindex $argv 0]set par1 [lindex $argv 0]
7.7. set ns [new Simulator]set ns [new Simulator]
8.8. set nd [open out-$par1.tr w]set nd [open out-$par1.tr w]
9.9. $ns trace-all $nd$ns trace-all $nd
10.10. set f0 [open cwnd-$par1.tr w]set f0 [open cwnd-$par1.tr w]
11.11. proc finish {} {proc finish {} {
12.12. global ns nd f0 tcp par1global ns nd f0 tcp par1
13.13. puts [format "average throughput: %.1f Kbps" \puts [format "average throughput: %.1f Kbps" \
14.14. [expr [$tcp set ack_]*([$tcp set packetSize_])*8/1000.0/10]][expr [$tcp set ack_]*([$tcp set packetSize_])*8/1000.0/10]]
15.15. $ns flush-trace$ns flush-trace
2009/10/72009/10/7 1010
1.1. close $ndclose $nd
2.2. close $f0close $f0
3.3. exec awk {exec awk {
4.4. BEGIN {BEGIN {
5.5. highest_packet_id = -1;highest_packet_id = -1;
6.6. packet_count = 0;packet_count = 0;
7.7. q_eln = 0;q_eln = 0;
8.8. }}
9.9. {{
10.10. action = $1; action = $1;
11.11. time = $2;time = $2;
12.12. src_node = $3;src_node = $3;
13.13. dst_node = $4; dst_node = $4;
14.14. type = $5; type = $5;
15.15. flow_id = $8; flow_id = $8;
16.16. seq_no = $11;seq_no = $11;
17.17. packet_id = $12;packet_id = $12;
18.18. if (src_node == "0" && dst_node == "1") {if (src_node == "0" && dst_node == "1") {
19.19. if (packet_id > highest_packet_id) {if (packet_id > highest_packet_id) {
20.20. highest_packet_id = packet_id;highest_packet_id = packet_id;
21.21. }}
2009/10/72009/10/7 1111
1.1. if (action == "+") {if (action == "+") {
2.2. q_len++;q_len++;
3.3. print time, q_len;print time, q_len;
4.4. }}
5.5. if (action == "-" || action == "d") {if (action == "-" || action == "d") {
6.6. q_eln = q_len--;q_eln = q_len--;
7.7. print time, q_len;print time, q_len;
8.8. }}
9.9. }}
10.10. }}
11.11. } out-$par1.tr > queue_length-$par1.tr} out-$par1.tr > queue_length-$par1.tr
12.12. exit 0exit 0
13.13. }}
14.14. proc record {} {proc record {} {
15.15. global ns tcp f0global ns tcp f0
16.16. set now [$ns now]set now [$ns now]
17.17. puts $f0 "$now [$tcp set cwnd_]"puts $f0 "$now [$tcp set cwnd_]"
18.18. $ns at [expr $now+0.01] "record"$ns at [expr $now+0.01] "record"
19.19. }}
2009/10/72009/10/7 1212
1.1. set r0 [$ns node]set r0 [$ns node]
2.2. set r1 [$ns node]set r1 [$ns node]
3.3. set n0 [$ns node]set n0 [$ns node]
4.4. set n1 [$ns node]set n1 [$ns node]
5.5. $ns duplex-link $n0 $r0 10Mb 1ms DropTail$ns duplex-link $n0 $r0 10Mb 1ms DropTail
6.6. $ns duplex-link $r0 $r1 1Mb 4ms DropTail$ns duplex-link $r0 $r1 1Mb 4ms DropTail
7.7. $ns duplex-link $r1 $n1 10Mb 1ms DropTail$ns duplex-link $r1 $n1 10Mb 1ms DropTail
8.8. set buffer_size 15set buffer_size 15
9.9. $ns queue-limit $r0 $r1 $buffer_size$ns queue-limit $r0 $r1 $buffer_size
10.10. if {$par1=="Reno"} {if {$par1=="Reno"} {
11.11. set tcp [new Agent/TCP/Reno]set tcp [new Agent/TCP/Reno]
12.12. set tcpsink [new Agent/TCPSink]set tcpsink [new Agent/TCPSink]
13.13. } elseif {$par1=="Newreno"} {} elseif {$par1=="Newreno"} {
14.14. set tcp [new Agent/TCP/Newreno]set tcp [new Agent/TCP/Newreno]
15.15. set tcpsink [new Agent/TCPSink]set tcpsink [new Agent/TCPSink]
16.16. } else {} else {
17.17. set tcp [new Agent/TCP/Sack1]set tcp [new Agent/TCP/Sack1]
18.18. set tcpsink [new Agent/TCPSink/Sack1]set tcpsink [new Agent/TCPSink/Sack1]
19.19. }}
2009/10/72009/10/7 1313
1.1. $ns attach-agent $n0 $tcp$ns attach-agent $n0 $tcp
2.2. $tcp set window_ 24$tcp set window_ 24
3.3. $ns attach-agent $n1 $tcpsink$ns attach-agent $n1 $tcpsink
4.4. $ns connect $tcp $tcpsink$ns connect $tcp $tcpsink
5.5. set ftp [new Application/FTP]set ftp [new Application/FTP]
6.6. $ftp attach-agent $tcp$ftp attach-agent $tcp
7.7. $ns at 0.0 "$ftp start"$ns at 0.0 "$ftp start"
8.8. $ns at 10.0 "$ftp stop"$ns at 10.0 "$ftp stop"
9.9. $ns at 0.0 "record"$ns at 0.0 "record"
10.10. $ns at 10.0 "finish"$ns at 10.0 "finish"
11.11. puts [format "on path: %.2f packets" \puts [format "on path: %.2f packets" \
12.12. [expr (1000000/(8*([$tcp set packetSize_]+40)) * ((1+4+1) * 2 * 0.001)) + [expr (1000000/(8*([$tcp set packetSize_]+40)) * ((1+4+1) * 2 * 0.001)) + $buffer_size]]$buffer_size]]
13.13. $ns run$ns run
2009/10/72009/10/7 1414
2009/10/72009/10/7 1515
2009/10/72009/10/7 1616
2009/10/72009/10/7 1717
2009/10/72009/10/7 1818
2009/10/72009/10/7 1919
2009/10/72009/10/7 2020