๐Ÿ“˜ [Computer Network] TCP : Flow Control

๊ณ ๋ฏผ์ •ยท2023๋…„ 11์›” 8์ผ
0

Computer Network

๋ชฉ๋ก ๋ณด๊ธฐ
12/12
post-thumbnail

03_2


๐Ÿ’ก Sliding Window 1

BDP = bandwith * delay

์•ž์žฅ์—์„œ ๋งํ–ˆ๋“ฏ์ด Stop and wait ARQ ๋ผ๋Š” ๊ฒƒ์ด ์–ธ๊ธ‰๋˜์—ˆ๋‹ค.
ARQ๋Š” MSS ํฌ๊ธฐ๋งŒํผ ํ•˜๋‚˜์”ฉ ๋ณด๋‚ด๊ธฐ๋•Œ๋ฌธ์— ๋น„ํšจ์œจ์ ์ด๋‹ค.

๊ทธ๋ ‡๊ธฐ๋•Œ๋ฌธ์— ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๋‚ด๊ณ  ์•„์ง ACK์„ ๋ฐ›์ง€ ์•Š๋Š” ์ƒํƒœ(=in flight) ์—์„œ sender๊ฐ€ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋Š” ๋งŒํผ ๋ณด๋‚ด๋Š” ๊ฒƒ์ด Sliding Window ์ด๋‹ค.

ํŠนํžˆ BDP (bandwith-delay product) ์ผ๋•Œ ์ ์šฉ๋œ๋‹ค.

bandwith๊ฐ€ ๋†’์œผ๋ฉด ๋งŽ์€ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๊ณ ,
delay๊ฐ€ ๊ธธ๋ฉด ACK์ด ์˜ฌ ๋•Œ ๊นŒ์ง€ ์‹œ๊ฐ„์ด ์˜ค๋ž˜๊ฑธ๋ฆฌ๊ธฐ ๋•Œ๋ฌธ์— ๊ทธ ์‹œ๊ฐ„์— data๋ฅผ ๋” ๋งŽ์ด ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋‹ค.

์ฆ‰, bandwith โ†‘ & delay โ†‘ ์ผ ๋•Œ data packet์„ ๋” ๋งŽ์ด ๋ณด๋‚ด๋ฉด ํšจ์œจ์ ์ด๋‹ค.

Example )

1.6 Mbps link with 40 msec RTT
bandwith-delay product (BDP) is (1.6 * 40 = 64) 64 Kbits (or 8 KB)

Sender can send at most one packet per RTT (ARQ)
Assume segment size of 1 KB โ†’ 8 Kbits
(8 KB ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์„ 1KB๋งŒ ๋ณด๋ƒˆ์œผ๋‹ˆ 1/8์ธ 8 Kbits ์ด๋‹ค.)

bandwith๋Š” ์œ„ ์‹์„ ์ดํ•ญํ•ด์„œ ๊ตฌํ•˜๋ฉด 8 Kbits / 40msec = 0.2 Mpbs
๋ผ๊ณ  ํ•ด๋„ ๋˜๊ณ , ์‹ค์ œ 1.6 Mpbs ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์„ 1/8 ๋งŒ ์‚ฌ์šฉํ•˜๊ธฐ ๋•Œ๋ฌธ์— 1.6 Mbps์˜ 1/8์ธ 0.2 Mbps ๋ผ๊ณ  ํ•ด๋„ ๋œ๋‹ค.


๐Ÿ’ก Sliding Window 2

Sliding Window
sender๊ฐ€ ACK์ด ๋Œ์•„์˜ค๊ธฐ ์ „๊นŒ์ง€ Sliding Window ํฌ๊ธฐ ๋งŒํผ์˜ data๋ฅผ ๋” ๋ณด๋‚ธ๋‹ค.

์œ„์— ๋งํ–ˆ๋“ฏ์ด ARQ์ฒ˜๋Ÿผ ๋ณด๋‚ด๋Š” ๊ฒƒ์€ ๋น„ํšจ์œจ์ ์ด๊ธฐ์—
ACK์ด ๋Œ์•„์˜ค๊ธฐ ์ „์— ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋Š” ๋งŒํผ ๋ณด๋‚ด๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.

์œ„ ์‚ฌ์ง„์„ ๋ณด๋ฉด ๋‘๋ฒˆ์งธ ํŒŒ๋ž€๋ฐ•์Šค์™€ ์„ธ๋ฒˆ์งธ ๋ณด๋ผ๋ฐ•์Šค๊ฐ€ Sliding Window์˜ ํฌ๊ธฐ์ด๋‹ค.
ํ˜„์žฌ ๋‘๋ฒˆ์งธ ํŒŒ๋ž€ ๋ฐ•์Šค๊นŒ์ง€ ์ „์†กํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ์„ธ๋ฒˆ์งธ ๋ณด๋ผ๋ฐ•์Šค๋ฅผ ๋” ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•œ๋‹ค.

ThroughPut์„ ๋†’์ด๋ ค๋ฉด Window ์‚ฌ์ด์ฆˆ๊ฐ€ ํฐ ๊ฒƒ์ด ์ข‹๋‹ค.
๋ฌธ์ œ์ 

  • receiver ๊ฐ€ ๋„ˆ๋ฌด ๋งŽ์€ data๋ฅผ ๋ณด๋‚ด๋ฉด ๋ฐ›์ง€ ๋ชปํ• ์ˆ˜๋„ ์žˆ๋‹ค.
  • ๋„ˆ๋ฌด ๋งŽ์€ ์–‘์˜ data๋ฅผ ๋ณธ๋ฉด router overflow๊ฐ€ ์ผ์–ด๋‚˜์„œ congestion, loss๊ฐ€ ์ผ์–ด๋‚  ์ˆ˜ ์žˆ๋‹ค.

๐Ÿ“Œ ๊ทธ๋ ‡๋‹ค๋ฉด ์–ผ๋งŒํผ ์–ด๋–ป๊ฒŒ ๋ณด๋‚ด์•ผํ• ๊นŒ?
๋‹ต์€ flow control ์— ์žˆ๋‹ค.


๐Ÿ’ก Flow Control

Folw Control
Sender์—๊ฒŒ receiver๊ฐ€ ์–ผ๋งˆ๋‚˜ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‚˜ ์•Œ๋ ค์ค€๋‹ค.

๋งŒ์•ฝ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์„ผํ„ฐ๊ฐ™์€ powerful sender์˜ receiver๊ฐ€ 2G phone ์ด๋ผ๊ณ  ํ•ด๋ณด์ž.

powerful sender ๊ฐ€ sliding window ๋งŒํผ์˜ ๋ฐ์ดํ„ฐ๋ฅผ receiver๋ฅผ ๊ณ ๋ คํ•˜์ง€ ์•Š๊ณ  ๊ณ„์† ๋ณด๋‚ด๊ฒŒ๋˜๋ฉด receiver๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ๋ชจ๋‘ ๋ฐ›์„ ์ˆ˜ ์—†์„๊ฒƒ์ด๋‹ค.
๊ทธ๋Ÿผ loss๊ฐ€ ๋ฐœ์ƒํ•  ํ™•๋ฅ ์ด ๋†’๋‹ค.

๊ทธ๋ž˜์„œ flow control์„ ์‚ฌ์šฉํ•˜์—ฌ receiver์˜ buffer๋ฅผ ํ™•์ธํ•ด์ค€๋‹ค.

rwnd
์ด๋ฏธ ์ฐจ ์žˆ๋Š” buffer๋ฅผ ์ œ์™ธํ•œ ๋‚จ๋Š” buffer (= free buffer space)

์œ„ ์‚ฌ์ง„์€ receiver์˜ buffer๋ฅผ ๋ณด์—ฌ์ค€๋‹ค.
receiver ๋Š” ์ง€์†์ ์œผ๋กœ ์ž์‹ ์˜ rwnd๋ฅผ ํ™•์ธํ•˜์—ฌ TCP header์— ์ ์–ด ACK์„ ๋ณด๋‚ธ๋‹ค.

์œ„์™€ ๊ฐ™์ด receive window์— rwnd๋ฅผ ์ ์–ด์„œ ๋ณด๋‚ธ๋‹ค.

๊ทธ๋Ÿผ sender๋Š” limits amount of unacked ("in-flight") data to receiver's rwnd value
receiver ์˜ rwnd์— ๋งž์ถฐ์„œ ์ œํ•œ์„ ๋‘ฌ์„œ overflow๊ฐ€ ์ผ์–ด๋‚˜์ง€ ์•Š๊ฒŒ ํ•œ๋‹ค.

๐Ÿ“Œ ๊ทธ๋Ÿผ ๋ฐ์ดํ„ฐ๋ฅผ ์ฒ˜์Œ ๋ณด๋‚ผ๋•Œ๋Š” ACK์„ ๋ฐ›์€ ์ ์ด ์—†๋Š” ์ƒํƒœ์ธ๋ฐ ์–ด๋–ป๊ฒŒ ์กฐ์ ˆํ• ๊นŒ?
์ดˆ๊ธฐ๊ฐ’์ด ์žˆ๋‹ค. ์ดˆ๊ธฐ๊ฐ’๋งŒํผ ๋ณด๋‚ด๊ณ  ACK์„ ๋ฐ›๋Š”๋‹ค. (overflow๊ฐ€ ์ผ์–ด๋‚  ์ˆ˜ ๋„ ์žˆ๋‹ค.)

0๊ฐœ์˜ ๋Œ“๊ธ€