[CS] Computer Networking - Transport layer(5): TCP congestion control
๐์ปดํจํฐ ๋คํธ์ํฌ ์ ๊ณต ์์ ์ ๋ฆฌ
TCP Congestion Control
Congestion: โtoo many sources sending too much data too fast for network to handleโ
โ flow control vs Congestion control
- flow control: ํ sender๊ฐ ํ receiver์๊ฒ ๋๋ฌด ๋น ๋ฅด๊ฒ ๋ฐ์ดํฐ๋ฅผ ๋ณด๋ด๋ ๋ฌธ์ ํด๊ฒฐ(end-to-end)
- Congestion control: ๋๋ฌด ๋ง์ sender๊ฐ ๋คํธ์ํฌ์ ๋๋ฌด ๋ง์ ๋ฐ์ดํฐ๋ฅผ ๋ณด๋ด๋ ๋ฌธ์ ํด๊ฒฐ(๋คํธ์ํฌ ์ฐจ์)
Congestion Control scenario 1
๊ฐ์ฅ ๋จ์ํ ์ด์์ ์๋๋ฆฌ์ค(๋ฌดํํ ๋ฒํผ, ํจํท loss x)
no retransmissions = no packet loss
- ๋ ์ฐ๊ฒฐ์ ์ต๋ throuput์ R/2์ด๋ค.
- ๋์ฐฉ ์๋(arrival rate)๊ฐ R/2์ ์ ๊ทผํ ์๋ก ์ฒ๋ฆฌ๋์ด ์ ํ์ ์ผ๋ก ์ฆ๊ฐํจ
- ๋์์ delay๋ ๊ธ๊ฒฉํ๊ฒ ์ฆ๊ฐํจ โ ํจํท์ด buffer์์ ๋๊ธฐํ๋ ์๊ฐ์ด ๊ธธ์ด์ง๊ธฐ ๋๋ฌธ
Congestion Control scenario 2
- ์ด์์ ์ํฉ
sender๊ฐ buffer์ ์ฉ๋๋งํผ๋ง ๋ฐ์ดํฐ๋ฅผ ์ ์ก
์ฒ๋ฆฌ๋์ด ์ต๋ R/2๊น์ง ์ฆ๊ฐ
- ์กฐ๊ธ ํ์ค์ ์ผ๋ก ์ ํํ ๋ฒํผ๋ฅผ ๊ฐ์ง ๋ผ์ฐํฐ์ ๊ฒฝ์ฐ
packet loss
๊ฐ๋ฅretransmission
์์
๋ผ์ฐํฐ ๋ฒํผ๊ฐ ๊ฐ๋ ์ฐจ์ ํจํท์ด ์์ค
sender๊ฐ ์ฌ์ ์ก โ โ๋ญ๋น๋ ์ฉ๋โ์ด ๋ฐ์(์ฌ์ ์ก์ผ๋ก ์ธํด ์๋ก์ด ๋ฐ์ดํฐ ์ ์ก ๊ฐ๋ฅ ์ฉ๋์ด ์ค์ด๋ฆ)
- ํ์ค์ ์ธ ์๋๋ฆฌ์ค: ๋ถํ์ํ duplication
Timeout์ ์ผ์ฐ ๊ฐ์งํด์ ๋ถํ์ํ duplication์ด ๋ฐ์ ์ด๋ก ์ธํด ์ฒ๋ฆฌ๋์ด ๋ ๊ฐ์ํ๊ณ , โ๋ญ๋น๋ ์ฉ๋โ์ด ์ฆ๊ฐ
Congestion Control scenario 3
- A, B, C, D๊ฐ ์๋ก ๋ฐ์ดํฐ๋ฅผ ์ฃผ๊ณ ๋ฐ๋๋ค
- ๋ฐ์ดํฐ๊ฐ 2๊ฐ์ ๋ผ์ฐํฐ๋ฅผ ๊ฑฐ์ณ ๋ชฉ์ ์ง์ ๋๋ฌํ๋ค
- packet loss ์ ํ์์์ ํ ์ฌ์ ์ก
Q: ๋นจ๊ฐ์ ๋ผ์ธ์ ๋ฐ์ดํฐ ์ธํ์ด ์ฆ๊ฐํ๋ฉด? A: ๋งจ์ ๋ผ์ฐํฐ์ ๋นจ๊ฐ์์ ํจํท์ผ๋ก ๊ฐ๋์ฐจ๊ณ , ๋ผ์ฐํฐ๋ฅผ ๊ณต์ ํ๋ ํ๋์ ๋ผ์ธ์ ํจํท๋ค์ด ๋ชจ๋ ๋ฒ๋ ค์ง๋ค
๋์ฐฉ ์๊ฐ์ด ๊ธธ์ด์ง์ ๋ฐ๋ผ ์ฒ๋ฆฌ๋์ด ์ปค์ง๋ค๊ฐ 0์ ์๋ ด
๋คํธ์ํฌ์์ ํจํท์ด ์ฌ๋ฌ ๋ผ์ฐํฐ๋ฅผ ํต๊ณผํ ํ ๋ง์ง๋ง ๋ผ์ฐํฐ์์ ๋ฒ๋ ค์ง๋ค๋ฉด, ๊ทธ ํจํท์ด ์ด๋ฏธ ์๋นํ ๋ชจ๋ ๋คํธ์ํฌ ๋ฆฌ์์ค(๋ฒํผ ๊ณต๊ฐ, ์ฒ๋ฆฌ ์๊ฐ)๋ ์์ ํ ๋ญ๋น๋๋ค!!
flow control์์ sender์ window size๋ receiver window์ ๋ฐ๋ผ์ ์ ๋์ ์ผ๋ก ๋ณํ๋ค๊ณ ํ์ง๋ง, ์ฌ์ค ๋คํธ์ํฌ ์ํฉ๋ ํจ๊ป ๊ณ ๋ คํด์ผํ๋ค
sender๋ RWND
์ ๋คํธ์ํฌ ์ํฉ์ ๊ณ ๋ คํ CWND(Congestion Window)์ค์์ ์์ ๊ฐ์ ํํ๋ค
- congestion control ๋ฐฉ์์ ์์๋ณด๊ธฐ ์ ์
CWND
,ssthresh
์ ๊ฐ๋ ์ ์ก๊ณ ๊ฐ์ - CWND: ํ ๋ฒ์ ๋คํธ์ํฌ์ ์ ์กํ ์ ์๋ ๋ฐ์ดํฐ์ ์(
LastByteSent - LastByteAcked โค cwnd
)- TCP ์๋ โ cwnd / RTT (bytes/sec)
- ssthresh: slow start threshold(์๊ณ์ )
- ์ฌ๊ธฐ๊น์ง๋ง slow start๋ฅผ ์ฌ์ฉํ๊ฒ ๋ค๋ ์๋ฏธ
- ํน์ ํ ์๊ณ์ ์ ์ ํด๋๊ณ ์๋์ฐ ์ฌ์ด์ฆ๊ฐ ์๊ณ์ ์ ๋์ด๊ฐ๋ฉด ์ดํ๋ถํฐ๋ AIMD ๋ฐฉ์์ ์ฌ์ฉํ์ฌ ์๋์ฐ๋ฅผ ์ฆ๊ฐ์ํด
๊ทธ๋ผ congestion control์๋ ์ด๋ค ๋ฐฉ์์ด ์์๊น?
AIMD (Addictive Increase Multiplicative Decrease)
ํฉ ์ฆ๊ฐ - ๊ณฑ ๊ฐ์ ์๊ณ ๋ฆฌ์ฆ์ด๋ค.
Addictive Increase: network congestion์ด ๊ฐ์ง๋์ง ์๋ ๋์ ๋งค RTT๋ง๋ค MSS(Maximum segment size)๋งํผ ์ ์ก์๋๋ฅผ ์ฆ๊ฐ
Multiplicate Decrease: ํจํท ์์ค์ด ๊ฐ์ง๋๋ฉด ๊ทธ๋๋ง๋ค ์ ์ก ์๋๋ฅผ ์ ๋ฐ์ผ๋ก ์ค์
- TCP Reno: 3-ACK duplication์ด ๊ฐ์ง๋๋ฉด ์ ์ก ์๋๋ฅผ ์ ๋ฐ์ผ๋ก ์ค์ด๋ ๋ฐฉ์
- TCP Tahoe: ํ์์์์ผ๋ก ์์ค์ด ๊ฐ์ง๋๋ฉด
cwnd
๋ฅผ 1 MSS๋ก ์ค์
Slow start
- ์ด๊ธฐ์๋
cwnd=1 MSS
๋ก ์ค์ - ๋งค RTT๋ง๋ค cwnd๋ฅผ 2๋ฐฐ ์ฆ๊ฐ โ ๊ฐ ACK๋ฅผ ์์ ํ ๋๋ง๋ค cwnd ์ฆ๊ฐ
TCP Reno์ Tahoe๋ AIMD + Slow start
๋ฅผ ํผํฉํด์ congestion control์ ํ๋ ์ ์ฑ
์ด๋ค.
TCP Tahoe
๐ Tahoe์ ํผ์ก ์ ์ด์ ์ด๊ธฐ ์ ์ฑ ์ด๊ณ ๋น ๋ฅธ ์ฌ์ ์ก์ด ์ฒ์์ผ๋ก ๋์ ๋ ์ ์ฑ
- ์ฒ์์๋ ๋์ผํ๊ฒ Slow Start ๋ฐฉ์์ผ๋ก ์๋์ฐ๋ฅผ ์ฆ๊ฐ์ํค๋ค๊ฐ ssthresh ์์ ์ดํ๋ถํฐ๋ AIMD ๋ฐฉ์์ ์ฌ์ฉ
TimeOut
์ด๋3 ACK Duplicated
์ํฉ์ด ๋ฐ์ ์ ๋คํธ์ํฌ๊ฐ ํผ์กํ๋ค๋ ๊ฒ์ ์ธ์ง- โ
ssthresh
๋ wnd size์ ์ ๋ฐ์ผ๋ก,window size
๋ 1๋ก ์์
โTahoe์ ๋จ์ ์ ์ด๋ฐ์ Slow Start ๊ตฌ๊ฐ์์ ์๋์ฐ ํฌ๊ธฐ๋ฅผ ํค์ธ๋ ๋๋ฌด ์ค๋ ๊ฑธ๋ฆฐ๋ค
๊ทธ๋์ ๋์จ Fast Recovery ๋ฐฉ์์ ํ์ฉํ TCP Reno
TCP Reno
๐ Tahoe์ ๋ง์ฐฌ๊ฐ์ง๋ก Slow Start๋ก ์์ํ์ฌ ์๊ณ์ ์ ๋์ด์๋ฉด ํฉ ์ฆ๊ฐ๋ก ๋ณ๊ฒฝํ๋ ๋ฐฉ๋ฒ
- Tahoe๋ ๋ช
ํํ ์ฐจ์ด๊ฐ ์๋๋ฐ, ๋ฐ๋ก
3 ACK Duplicated
์Timeout
์ ๊ตฌ๋ถํ๋ค๋ ๊ฒ
- Reno๋
3 ACK Duplicated
๊ฐ ๋ฐ์ํ์ ๋, ์๋์ฐ ํฌ๊ธฐ๋ฅผ 1๋ก ์ค์ด๋ ๊ฒ์ด ์๋๋ผ AIMD์ฒ๋ผ ๋ฐ์ผ๋ก๋ง ์ค์ด๊ณ sshthresh๋ฅผ ์ค์ด๋ ์๋์ฐ ๊ฐ์ผ๋ก ์ ํ๊ฒ ๋๋ค. - ์ด๋ Tahoe์ ๋นํด ๋น ๋ฅด๊ฒ ์๋ window size์ ๋๋ฌํ๊ธฐ ๋๋ฌธ์ Fast Recovery๋ผ๊ณ ๋ถ๋ฆผ
Timeout
์ ๊ฒฝ์ฐ์๋ Tahoe์ ๋ง์น๊ฐ์ง๋ก window size๋ฅผ 1๋ก ์ค์ธ๋ค slow start๋ฅผ ์งํ- ์ด๋ ssthresh๋ ๋ณ๊ฒฝํ์ง ์์
Tahoe์ Reno ๋น๊ต ๊ทธ๋ํ
Reno์ FSM
โ FSM ๋ฉ์ปค๋์ฆ:
1. Slow Start
- ์ด๊ธฐ๊ฐ:
cwnd = 1 MSS
,ssthresh = 64 KB
,dupACKcount = 0
- ๋คํธ์ํฌ์ ๊ธ์์ค๋ฌ์ด ๋ถํ๋ฅผ ์ฃผ์ง ์๊ธฐ ์ํ ์์ ๋จ๊ณ
- new ACK ์์ :
cwnd = cwnd + MSS
(๋งค ACK๋ง๋ค ์๋์ฐ ํฌ๊ธฐ ์ฆ๊ฐ)dupACKcount = 0
(์ค๋ณต ACK ์นด์ดํฐ ์ด๊ธฐํ)- ์ ์ธ๊ทธ๋จผํธ ์ ์ก ํ์ฉ 2. Timeout ๋ฐ์ ์:
ssthresh = cwnd/2
(์๊ณ๊ฐ์ ํ์ฌ ์๋์ฐ์ ์ ๋ฐ์ผ๋ก ์ค์ )cwnd = 1 MSS
(์๋์ฐ ํฌ๊ธฐ ์ต์๋ก ์ฌ์ค์ )dupACKcount = 0
- ๋๋ฝ๋ ์ธ๊ทธ๋จผํธ ์ฌ์ ์ก
2. Congestion Avoidance
- Congestion Avoidance๋ก ์ ์ดํ๋ ์กฐ๊ฑด:
cwnd โฅ ssthresh
- ๋คํธ์ํฌ ์ฉ๋์ ๊ฐ๊น์์ก๋ค๊ณ ํ๋จํ์ฌ ๋ณด๋ค ์ ์คํ๊ฒ ์๋์ฐ ํฌ๊ธฐ ์ฆ๊ฐ
- new ACK ์์ :
cwnd = cwnd + MSSร(MSS/cwnd)
(์ฝ 1 MSS๋ฅผ ํ RTT๋น ์ฆ๊ฐ, ์ฆ ์ ํ์ ์ฆ๊ฐ)dupACKcount = 0
- ์ ์ธ๊ทธ๋จผํธ ์ ์ก ํ์ฉ 2. duplicated ACK ์์ :
dupACKcount++
3. Fast Recovery
- Fast Recovery๋ก ์ ์ดํ๋ ์กฐ๊ฑด:
dupACKcount = 3
- ์ด๋:
ssthresh = cwnd/2
cwnd = ssthresh + 3
(์๋์ฐ ํฌ๊ธฐ ์กฐ์ )- ๋๋ฝ๋ ์ธ๊ทธ๋จผํธ ์ฌ์ ์ก
- duplicated ACK ์์ ์:
cwnd = cwnd + MSS
(๊ฐ ์ค๋ณต ACK๋ง๋ค ์๋์ฐ ์ฆ๊ฐ)- ์ ์ธ๊ทธ๋จผํธ ์ ์ก ํ์ฉ 2. new ACK ์์ ์(๋๋ฝ๋ ์ธ๊ทธ๋จผํธ์ ๋ํ ACK):
cwnd = ssthresh
(์๋์ฐ ์ ์ํ)dupACKcount = 0
- Congestion Avoidance๋ก ์ ํ 3. Timeout ๋ฐ์ ์:
ssthresh = cwnd/2
cwnd = 1 MSS
dupACKcount = 0
- Slow start๋ก ์ ํ(์ฌ๊ฐํ ๋คํธ์ํฌ ํผ์ก ์ํฉ)