220 likes | 533 Views
TCP Agent. 指導 老師 : 潘仁義 學生 : 曹琴雅. Introduction Agent Introduction Agent State Protocol Agent TCP Agent. Outline. Agents represent endpoints where network-layer packets are constructed or consumed. Agents are used in the implementation of protocols at various layers .
E N D
TCP Agent 指導老師: 潘仁義 學生:曹琴雅
Introduction • Agent Introduction • Agent State • Protocol Agent • TCP Agent Outline
Agents represent endpoints where network-layer packets are constructed or consumed. • Agents are used in the implementation of protocols at various layers. • The class Agent has an implementation partly in OTcl and partly in C++. • C++ implementation is in agent.cc and agent.h • the OTcl support is in ns-agent.tcl Introduction
addr_ (source add.) dst_ (des. add.) size_ packet size(bytes) type_ type of packet (see packet.h) fid_ the IP flow identifier prio_ the IP priority field flags_ packet flags defttl_(TTL defaults to 32) Agent state
TCP a “Tahoe” TCP sender (cwnd = 1 on any loss) TCP/Reno a “Reno” TCP sender (with fast recovery) TCP/Newreno a modified Reno TCP sender (changes fast recovery) TCP/Sack1 a SACK TCP sender TCP/Fack a “forward” SACK sender TCP TCP/FullTcp a more full-functioned TCP with 2-way traffic TCP/Vegas a “Vegas” TCP sender TCP/Vegas/RBP a Vegas TCP with “rate based pacing” TCP/Vegas/RBP a Reno TCP with “rate based pacing” TCP/Asym an experimental Tahoe TCP for asymmetric links TCP/Reno/Asym an experimental Reno TCP for asymmetric links TCP/Newreno/Asyman experimental Newreno TCP for asymmetric links TCPSink a Reno or Tahoe TCP receiver (not used for FullTcp) TCPSink/DelAck a TCP delayed-ACK receiver TCPSink/Asym an experimental TCP sink for asymmetric links TCPSink/Sack1 a SACK TCP receiver TCPSink/Sack1/DelAcka delayed-ACK SACK TCP receiver Protocol Agents
TCP SACK RFC2018 Tahoe RFC793 Reno RFC2001 newReno RFC2582 Vegas
TCP Agents • There are two major types of TCP agents: • one-way agents : sender & receiver • two-way agent
One-way TCP agents • The one-way TCP sending agents currently supported are: • Agent/TCP - a “tahoe” TCP sender • Agent/TCP/Reno - a “Reno” TCP sender • Agent/TCP/Newreno- Reno with a modification • Agent/TCP/Sack1 - TCP with selective repeat (RFC2018) • Agent/TCP/Vegas - TCP Vegas • Agent/TCP/Fack- Reno TCP with “forward ack.” • The one-way TCP receiving agents currently supported are: • Agent/TCPSink - TCP sink with one ACK per packet • Agent/TCPSink/DelAck - TCP sink with configurable delay per ACK • Agent/TCPSink/Sack1 - selective ACK sink (RFC2018) • Agent/TCPSink/Sack1/DelAck - Sack1 with DelAck
set tcp[new Agent/TCP] ;# tcpagent $ns attach-agent$n0 $tcp;# bind agent to node set sink [new Agent/TCPSink] ;#tcpsinkagent $ns attach-agent $n1 $sink ;# bind sink to node set ftp [new Application/FTP] ;# ftp traffic $ftp attach-agent $tcp;# bind ftp traffic to tcpagent $ns connect$tcp$sink ;# active connection 範例(抽考)
Agent/TCP/FullTcp • 相異處 • connections may be establised and town down (SYN/FIN packets are exchanged) • bidirectionaldata transfer is supported • sequence numbers are in bytes rather than packets two-way TCP agent
TCP Reno 除了包含了Tahoe 的三個機制(SS,CA,FS),Reno 多了另外一個機制稱為: Fast Recovery(FR);FR 機制:當Reno 收到三個重複的ack或是超過了RTO 且尚未收到某個封包的ack,Reno 會認為有封包遺失了,並且認定網路發生雍塞,Reno 會把ssthresh設為目前congestion window 的一半,但並不會回到SS 的狀態而是設定congestion window 為ssthresh,之後congestion window 則維持線性成長。以Fig.1 為說明,在round 8 的時候發生了封包遺失,因此Reno 把ssthresh設為目前congestion window 的一半亦即是6,Reno congestion window 並且從6 開始線性成長(Fig.1 黑線部分)。 補充:Reno(1/2)
Two-Way TCP Agents (FullTcp) • set src [new Agent/TCP/FullTcp] • set sink [new Agent/TCP/FullTcp] • $ns attach-agent $n0$src • $ns attach-agent $n1$sink • $ns connect $src $sink • $sink listen • $src set window_ 100 • set ftp1 [new Application/FTP] • $ftp1 attach-agent $src • $ns_ at 0.0 "$ftp1 start"
The end Thank you!
TCP Tahoe 主要有三個機制去控制flow 和congestion window: slow start (SS),congestion avoidance (CA), and fast retransmit(FS)。 SS 機制:當connection 建立時,把congestion window 的size 初始化,並設為一個MSS(maximum segment size),同時把ssthresh (slow start threshold)設為 64 (assuming 1KB packet)。 CA 機制: 為了在發生雍塞的情形下控制流量TCP Tahoe 使用Additive Increase Multiplicative Decrease(AIMD)此機制。 補充:Tahoe(1/2)
AIMD:只要有一個packet loss 就認為網路發生雍塞,Tahoe 會把ssthrsh設為目前的congestion window 的一半。並且回到SS 的狀態,之後congestion window 繼續以指數成長;當到達ssthresh時congestion window 會以線性成長來避免雍塞。 FS 機制:當收到三個重複的ack而不必等到Retransmit Timeout(RTO),會認為packet loss 並且馬上重傳。 補充:Tahoe(2/2)
New Reno 跟Reno 在只有一個封包遺失的情況下,其機制是一樣的。當同時有多個packet 遺失時,Reno 會重新傳遞一個發現遺失之封包,並且跳離Fast Recovery 的階段,當Reno 發現仍舊有其它的封包遺失時,Reno 才會進入Fast Recovery;當多個封包遺失時Reno 必須等待一個RTO 才能重傳一個遺失的封包,因此在同一個congestion window 中有多個封包遺失時,Reno 必須等待多個RTO,才能回到Fast Recovery。New Reno 遇到上述的問題並不跳出Fast Recovery,當重新重送第一個遺失的封包之後,會收到ack要求下一個遺失的封包(所謂的partial ack)此時New Reno 會重傳第二遺失的封包並且預測後面的封包皆已經遺失並且馬上重傳,因此不用等待更多的RTO。 補充:New Reno
Sack 會在ack header 的TCP option field 中清楚告知哪些區段的封包以經被正確收到,亦即指出已經正確接收區段的第一包封的序號以及最後一封包的序號;當多個封包遺失時,ack header 的TCP option field 會有多個區段指出哪些區段已經正確收到。因此可以明確判斷出那些遺失封包的序號,並且重傳。不同於New Reno 的預測方式,New Reno 會有已經正確接收的封包再被重新重送;而Sack 能明確指出哪些封包是遺失的,因此不會有上述的情狀發生。 補充:Sack
使用RTT(Round trip time)測量網路狀況的壅塞控制演算法,藉由比較預期的效能和實際的效能以決定是否增加或減少壅塞視窗的值。 Vegas 修改了fast retransmit(FS),fast retransmit(FS),congestion avoidance (CA)。Modified Fast Retransmit:當收到一個重覆ACK 時,便會特別去檢查RTT 是否有大於Timeout,若有,則不用等待有3 個重覆的ACK,就直接重送。Modified slow start : cwnd的值大約在經過兩個RTT 時間後才會增加一倍。vegas將佇列長度維持在α 與β 之間,若佇列長度超過此區間,則將由slow-start進入congestion avoidance。Modified congestion avoidance: 補充:Vegas(1/2)
補充:Vegas(2/2) Diff 的值即是連線路徑bottleneck 的佇列長度,該版本的tcp主要希望將佇列長度維持在α 與β 之間,並依據Diff 來調整slow start threshold