[ํ’€์Šคํƒ] TCP - connection-oriented protocol

2023. 4. 12. 22:40ใ†ComputerScience/FullStackProgramming

 

 

 

Transmission Control Protocol

  • TCP is a connection-oriented protocol
  • it creates a virtual connection between two TCPs to send data.
  • In addition, TCP uses flow and error control mechanisms at the transport level.
  • ์—๋Ÿฌ ๊ฒ€์ถœ, ๋ณต๊ตฌ ๋ฐ ํ๋ฆ„ ์ œ์–ด(Layer 4)์— ์ถฉ์‹คํ•œ ํ†ต์‹  ํ”„๋กœํ† ์ฝœ TCP
  • ํด๋ผ์ด์–ธํŠธ - ์„œ๋ฒ„ ๊ฐ„ ์—ฐ๊ฒฐ ์š”์ฒญ, ์‘๋‹ต, ์ตœ์ข… ๊ฒฐ์ • 
  • ์—๋Ÿฌ ๊ฒ€์ถœ, ํ๋ฆ„ ๊ด€๋ จ ๋ฉ”์ปค๋‹ˆ์ฆ˜์ด ์žˆ๋‹ค.  

 

 

 

  • ์ผ๋ฐ˜์ ์ธ ๋™์˜์ƒ ์ŠคํŠธ๋ฆฌ๋ฐ 
    TCP(์—๋Ÿฌ ๊ฒ€์ถœ ๋ฐ ๋ณต๊ตฌ) or UDP(๋นจ๋ฆฌ ๋นจ๋ฆฌ)
    ๋‘˜ ์ค‘ ํ•˜๋‚˜๋ฅผ ์“ฐ๋“  ์ƒ๊ด€ ์—†๋‹ค.
    -> TCP๋ฅผ ์”€ 
  • ๋ฒ„ํผ๋ง - ์˜ค๋ฅ˜๊ฐ€ ์•„๋‹ˆ๋ผ, ๋ฒ„ํผ์— ์Œ“๋Š” ๊ฒƒ 
    ์—๋Ÿฌ๊ฐ€ ๋‚˜๋ฉด? ์—๋Ÿฌ ๊ฒ€์ถœ ๋ฐ ๋ณต๊ตฌ๋ฅผ ํ•ด์„œ ๊ฐ€์ ธ์˜ด
    ๊ณ„์† ๋ณต๊ตฌ ํ•˜๋ฉด์„œ ๋’ค์—๋‹ค ์Œ“์•„ ๋‘๊ณ , 15์ดˆ ๋’ค์— ๋ฟŒ๋ฆฌ๋Š” ๊ฒƒ
  • ์ž๋ณธ base์˜ ์˜์ƒ - ์‹ค์‹œ๊ฐ„์ด๋ผ๊ณ  ์ฐฉ๊ฐํ•˜๋Š”๋ฐ, ์ด๋ฏธ ๋งŒ๋“ค์–ด์ง„ ์˜์ƒ์ž„
    ๋…นํ™”๋œ ์˜ํ™” - TCP ๋ฒ ์ด์Šค
    ์คŒ, ์ŠคํŠธ๋ฆฌ๋ฐ ๋ฐฉ์†ก - live 
    ์ง€์—ฐ์ด ์ค„์–ด์•ผ ํ•œ๋‹ค๋ฉด, UDP๋ฅผ ์„ž์Œ
  • ์Œ์„ฑ - ํ—ˆ์šฉ๋˜๋Š” ์ง€์—ฐ ์‹œ๊ฐ„ 100, 150ms delay๋Š” ์ธ๊ฐ„์—๊ฒŒ ๊ฐ์ง€๋˜์ง€ ์•Š์Œ
    ๋‚ด๊ฐ€ ์ง€๊ธˆ ์ œ๊ณตํ•˜๋Š” ์ปจํ…์ธ ๊ฐ€ ์–ด๋–ค ํŠน์„ฑ์„ ๋ฐ˜์˜ํ•˜๋Š๋ƒ์— ๋”ฐ๋ผ ์ ์ ˆํ•œ ํ†ต์‹  ๊ธฐ์ˆ ์„ ์จ์•ผํ•œ๋‹ค. 

 

 

 

Stream Delivery Service

  • TCP is a stream-oriented protocol
  • TCP creates an environment in which the two processes seem to be connected by an imaginary “tube” that carries their data across the Internet.
  • TCP ๋„ IPC ! ์„œ๋กœ ๋‹ค๋ฅธ ํ”„๋กœ์„ธ์Šค ๊ฐ„ ํ†ต์‹ , ์—ฐ๊ฒฐ์„ ์˜๋ฏธํ•œ๋‹ค.
  • ๋ฐ”์ดํŠธ๊ฐ€ ์ค„์ค„ ๋“ค์–ด๊ฐ„๋‹ค - stream
    ์œ ๋‹‰์Šค - ํ†ต์‹ ๊ตํ™˜๊ธฐ / ์ด๋ฅผ ์œ„ํ•œ cpp
    ๊ธฐ๋ณธ ์ฒ ํ•™ - logicalํ•œ ๋ฌผ์ค„๊ธฐ๋ฅผ ๋งŒ๋“ค๊ณ ,
    ์†ก์‹ ๋‹จ์—์„œ ์ˆ˜์‹ ๋‹จ์œผ๋กœ ๋ฐ”์ดํŠธ ๋ฉ์–ด๋ฆฌ๋ฅผ ์ค„์ค„์ด ๋ณด๋‚ธ๋‹ค. 

 

 

 

Sending and Receiving Buffers

  • Because the sending and receiving processes may not produce and consume data at the same speed, TCP needs buffers for storage.
  • One way to implement is to use a circular array

 

  • ์†ก์‹ ๋‹จ์˜ ๋ฒ„ํผ
  • ์ƒ๋Œ€๋ฐฉ์ด ๋ชป ๋ฐ›์•˜๋‹ค๋ฉด ๋‹ค์‹œ ๋ณด๋‚ด์•ผ ํ•œ๋‹ค. 
    ๋”ฐ๋ผ์„œ ๋ณด๋‚ธ ๊ฒƒ์˜ ๋ณต์‚ฌ๋ณธ์„ ๊ฐ–๊ณ  ์žˆ์–ด์•ผ ํ•จ
  • sent
    ์•„์ง ์ž˜ ๋ฐ›์•˜๋‹ค๋Š” ์ด์•ผ๊ธฐ๋ฅผ ๋ชป ๋ฐ›์Œ
    ์žฌ์ „์†ก์„ ์œ„ํ•ด ์ €์žฅํ•ด ๋‘ 
  • not sent 
    ์ƒ๋Œ€๋ฐฉ์ด ๋ชป ๋ฐ›์„๊ฑฐ ๊ฐ™์•„์„œ ์Œ“์•„๋‘๊ณ , ์•„์ง ๋ณด๋‚ด์ง€ ๋ชป ํ•จ
    ์ƒˆ๋กœ์šด ์ •๋ณด๋“ค์ด ์Œ“์—ฌ๊ฐ€๋Š” ๊ณณ

 

  • ์ˆ˜์‹ ๋‹จ์˜ ๋ฒ„ํผ
    ๋‚˜๋Š” ์ตœ์„ ์„ ๋‹คํ•ด ๋ฒ„ํผ์— ์˜ฌ๋ฆฌ๊ณ ,
    ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์—ฌ์œ ๊ฐ€ ๋  ๋•Œ, ๋ฒ„ํผ์—์„œ ์•Œ์•„์„œ ๊ฐ€์ ธ๊ฐ€๋Š” ๊ฒƒ
  • ๋ฐ›์•„์„œ ์ €์žฅํ–ˆ๋Š”๋ฐ ์•„์ง ์–ดํ”Œ์ด ์•ˆ ๊ฐ€์ ธ๊ฐ„ ์ •๋ณด
  • ์ƒˆ๋กœ์šด ์ •๋ณด ์“ฐ์ผ ๊ณณ
    -> ์ƒ๋Œ€๋ฐฉ TCP์˜ ๊ฐ€์šฉ ๊ณต๊ฐ„์„ ์ฑ„์šฐ๋Š” ๊ฒƒ 
    TCP์˜ ์ˆ˜์‹  ๋ฒ„ํผ ์‚ฌ์ด์ฆˆ๋งŒํผ ์†ก์‹ ๋‹จ์—์„œ ๋ณด๋‚ด๋Š” ๊ฒƒ 
  • ๋”ฐ๋ผ์„œ ์ˆ˜์‹ ๋‹จ์€ ๊ฐ€์šฉ ๊ณต๊ฐ„ ์‚ฌ์ด์ฆˆ๋ฅผ ์†ก์‹ ๋‹จ์œผ๋กœ ๋Š์ž„์—†์ด ์•Œ๋ฆผ
    ์ˆ˜์‹  ๋ฒ„ํผ ํด์ˆ˜๋ก ํ†ต์‹  ๋Š˜์–ด๋‚จ 
    ๋ฒ„ํผ ์‚ฌ์ด์ฆˆ - ๊ทธ๋ฆฌ ํฌ์ง€ ์•Š์Œ (4/50๋…„ ๋™์•ˆ ์“ฐ์ด๊ณ  ์žˆ๋‹ค.)
    tcp ์†Œํ”„ํŠธ์›จ์–ด - ๋ฒ„ํผ์‚ฌ์ด์ฆˆ ํ•œ๊ณ„๋กœ ๋งŽ์ด ๋ณด๋‚ผ ์ˆ˜ ์—†๋‹ค (์„ฑ๋Šฅ ์ œํ•œ) 

 

 

 

Segments

  • At the transport layer, TCP groups a number of bytes together into a packet called a segment.
  • TCP adds a header to each segment (for control purposes) and delivers the segment to the IP layer for transmission.
  • The segments are encapsulated in IP datagrams and transmitted.
  • This entire operation is transparent to the receiving process.
  • Segments received out of order, lost, or corrupted may be resent.

 

  • ์œ ๋… tcp๋งŒ segment ๋…ํŠนํ•œ ๋‹จ์–ด๋ฅผ ์”€
  • ์ฃผ๊ณ  ๋ฐ›๋Š” ์ •๋ณด์˜ ์œ ๋‹› - ๋ฐ”์ดํŠธ
  • ํ—ค๋”๊ฐ€ ์žˆ๊ณ  ํ…Œ์ผ์ด ์žˆ๋Š” ๋‹จ์œ„ - ์„ธ๊ทธ๋จผํŠธ = ์ผ์ข…์˜ ๋ฉ”์„ธ์ง€

 

 

 

Full-Duplex Service

  • TCP offers full-duplex service :
    After two application programs are connected to each other, they can both send and receive data.
  • Piggybacking :
    When a packet is going from A to B, it can also carry an acknowledgment of the packets received from B

 

  • ์–‘์— ์˜ํ–ฅ์„ ๋ฐ›์ง€ ์•Š์Œ, ๋ฉ”์„ธ์ง€์˜ ๊ฐœ์ˆ˜์— ์˜ํ–ฅ์„ ๋ฐ›์Œ
  • ํ†ต์‹  ํ”„๋กœ๊ทธ๋žจ - ์ฃผ๊ณ ๋ฐ›๋Š” ์–‘ ๋ณด๋‹ค, ์ดˆ๋‹น ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” ๋ฉ”์„ธ์ง€์˜ ๊ฐœ์ˆ˜์— ์˜ํ–ฅ์„ ๋ฐ›์Œ 
  • ๋‚ด๊ฐ€ ๋ฐ›์„ ๊ฒŒ ์žˆ๊ณ , ๋‹ˆ๊ฐ€ ๋ณด๋‚ผ ๊ฒŒ ์žˆ์–ด -> 2๊ฐœ๊ฐ€ ๋˜๋ฉด 
  • ๋‚ด๊ฐ€ ๋ณด๋‚ด๋Š” ๋ฉ”์„ธ์ง€ + ์ƒ๋Œ€๊ฐ€ ๋ณด๋‚ธ ๊ฒƒ์— ๋Œ€ํ•œ ๋‚˜์˜ ์ •๋ณด(์ž˜ ๋ฐ›์•˜๋‹ค ACK)๋ฅผ ํฌํ•จ
  • ๋ผ์ง€๊ฐ€ ํผ + ๊ผฌ๋ฆฌ(๋‚ด๊ฐ€ ๋ณด๋‚ด๋Š” ์ •๋ณด)๋Š” ์ž‘์Œ -> piggybacking ๐Ÿท
  • ํ•จ๊ป˜ ์„ž์–ด์„œ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋‹ค.

 

  •  Connection-Oriented Services
    • A’s TCP informs B’s TCP and gets approval from B’s TCP
    • A’s TCP and B’s TCP exchange data in both directions
    • After both processes have no data left to send and the buffers are empty, two TCPs destroy their buffers
  • Reliable Service
    • TCP uses the acknowledgment mechanism to check the safe and sound arrival of data

 

  • TCP - ์—ฐ๊ฒฐ ์„ค์ • ๊ณผ์ •์ด ์žˆ๋‹ค. 
    ํด: ๋‚˜ ๋„ˆ๋ž‘ ์—ฐ๊ฒฐํ•˜๊ณ  ์‹ถ์–ด
    ์„œ๋ฒ„: okay
    ํด: ok
  • ์„œ๋กœ ๋ฒ„ํผ ์‚ฌ์ด์ฆˆ๋ฅผ ์ฃผ๊ณ  ๋ฐ›์Œ
    ์—ฐ๊ฒฐ ์„ค์ • - ์–ด๋–ค ์ •๋ณด๋ฅผ ์ฃผ๊ณ  ๋ฐ›์•„, ํ•ด๋‹น ์ •๋ณด๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ†ต์‹ ์„ ํ•  ๋•Œ 
    -> ๋‚ด๊ฐ€ ๋ฐ›์„ ์ˆ˜ ์žˆ๋Š” ๋ฒ„ํผ ์‚ฌ์ด์ฆˆ๋ฅผ ์•Œ๋ ค์คŒ
  • UDP 
    ๊ทธ๋Ÿฐ๊ฑฐ ์—†์Œ
    ๋ณด๋‚ด๋ฉด ๋ฐ›๋Š” ๊ฑฐ๊ณ ,
    ๋ชป ๋ฐ›์œผ๋ฉด ์–ด์ฉ” ์ˆ˜ ์—†์ง€ ๋ญ  

 

 

 

Byte numbers

  • There is no field for a segment number value.
  • Instead, there are two fields called the sequence No. and the acknowledgment No.
    These two fields refer to the byte No.
  • All data bytes being transferred in each connection are numbered by TCP.
  • The numbering starts with a randomly generated number.
  • Number range for first byte : 0 ~ 2^32 -1
    (If random number is 1,057 and total number 6,000 bytes, the bytes are numbered from 1,057 to 7,056)
  • Byte numbering is used for flow and error control.

 

  • ์™œ ์ŠคํŠธ๋ฆผ์ด๋ผ๊ณ  ํ•˜๊ณ , ์„ธ๊ทธ๋จผํŠธ๋ผ๊ณ  ํ• ๊นŒ? ๋ฐ”์ดํŠธ? 
    TCP ์ œ์™ธํ•œ ๋Œ€๋ถ€๋ถ„์˜ ํ†ต์‹  ์†Œํ”„ํŠธ์›จ์–ด 
    counting -> ๋ฉ”์„ธ์ง€ ๊ธฐ๋ฐ˜
    ๋ฐ”์ดํŠธ๋ฅผ ๋ชจ์œผ๊ณ , ํ—ค๋“œ ํŠธ๋ ˆ์ผ๋Ÿฌ ๋ถ™์—ฌ์„œ, ์Ÿคํ•œํ…Œ ๋ณด๋ƒ„
    ๋ฉ”์„ธ์ง€, ํŒจํ‚ท, ํ”„๋ ˆ์ž„ ๋“ฑ๋“ฑ 
  • TCP - ๋ฐ”์ดํŠธ ๊ธฐ๋ฐ˜์œผ๋กœ 
    ๋ฒˆ์ง€์ˆ˜ 1~99๊นŒ์ง€ ์ž˜ ๋ฐ›์•„
    1000~1999 ๋ฐ”์ดํŠธ ๋ณด๋‚ด๋‹ˆ๊นŒ ์ž˜ ๋ฐ›์•„
    segment์—๋Š” 1000์ด๋ผ๊ณ  ์“ฐ์—ฌ์žˆ์Œ 
    ๋ฉ”์„ธ์ง€ ๋‹จ์œ„๋กœ ๋ฐ›์ง€ ์•Š์Œ
    ์ˆ˜๋งŽ์€ ๋ฐ์ดํ„ฐ ์ค‘, ์ผ์ผ์ด ๋ฐ”์ดํŠธ ๋‹จ์œ„๋กœ ๋ฒˆํ˜ธ๋ฅผ ๋งค๊ธฐ๊ณ 
    segment ์•ž์—, ์ฒซ๋ฒˆ์งธ ๋ฐ์ดํ„ฐ์˜ ์ˆœ์„œ๋ฅผ ์•Œ๋ ค์คŒ
  • iostream
    tcp - byte ๋ฒˆํ˜ธ
    cpp - ๋ฐฐ์—ด์˜ ์ด๋ฆ„์€ ๊ทธ ๋ฐฐ์—ด ์ฒซ๋ฒˆ์งธ element ์ฃผ์†Œ๊ฐ’
    segment ๋ฒˆํ˜ธ - ๋ฐ”์ดํŠธ๋“ค ์ค‘ ์ฒซ๋ฒˆ์งธ ๋ฐ”์ดํŠธ์˜ sequence ๋ฒˆํ˜ธ 
  • ์™œ?
    ์žฌ์ „์†ก ํ•  ๋•Œ, ๋ฉ”์„ธ์ง€ ๋ฒ ์ด์Šค๋กœ ์ „์†กํ•ด์•ผ ํ•จ
    tcp -> error ๋‚˜๋ฉด? -> ์ชผ๊ฐœ์„œ ์—๋Ÿฌ๋ฅผ ํ”ผํ•ด๋ด
    2๊ฐœ๋กœ ์ชผ๊ฐœ
    tcp : ๋ฐ”์ดํŠธ๋“ค์„ ์ŠคํŠธ๋ฆผ์œผ๋กœ ๋ณด๋‚ผ๊ฑด๋ฐ,
    ์š”๋งŒํผ ์งค๋ผ์„œ ๋ณด๋‚ผ๊ฑฐ์•ผ 

 

 

 

Sequence number

  •  After the bytes have been numbered, TCP assigns a sequence number to each segment that is being sent.
  • Segment number for each segment is number of the first byte carried in that segment.
  • ๋ฐ”์ดํŠธ ๋ฒˆํ˜ธ๋ฅผ ์จ์•ผํ•œ๋‹ค -> ์„ธ๊ทธ๋จผํŠธ 1.2.3 ์ด๋Ÿฐ ๊ฐœ๋… X 

 

 

 

Acknowledgment number

  • The value of the acknowledgment field in a segment defines the number of the next byte a party expects to receive.
  • The acknowledgment number is cumulative. (๋ˆ„์ ๋œ๋‹ค)
  • ACK๊ฐ€ ์ค‘์š” โœจ
    ์ˆ˜์‹  ์ธก์—์„œ ์ •๋ณด๋ฅผ ์ž˜ ๋ฐ›์•˜๋‹ค๊ณ  ๋งํ•  ๋•Œ
    1, 2๋ฅผ ๋ณด๋‚ด๋ฉด -> 3๋ฒˆ์„ ์ค˜! (์ด๊ฒŒ ack)
  • ๋Œ€๋ถ€๋ถ„์˜ ํ†ต์‹  ํ”„๋กœํ† ์ฝœ์€ ์ด๋ ‡๊ฒŒ ๋งํ•จ

 

 

 

TCP format

 

 

 

Control field

  • Enabling flow control, connection establishment and termination, and mode of data transfer in TCP
  • ์—ฐ๊ฒฐ ์„ค์ • ๋ฐ ํ•ด์ œ๋ฅผ ๋‹ด๋‹นํ•˜๋Š” 6๋น„ํŠธ ๋ถ€๋ถ„์„ ๋งํ•œ๋‹ค. 
  • ์ด SYN ๋ฒˆํ˜ธ๋ฅผ ๋งž์ถ”๋ฉด -> 1๋น„ํŠธ ์„ธํŒ… - ์—ฐ๊ฒฐ ์š”์ฒญ
  • ์ด์— ๋Œ€ํ•œ ์‘๋‹ต์€ ack ๋น„ํŠธ
  • fin ์—ฐ๊ฒฐ ํ•ด์ œ - ํ”ผ๋‚ ๋ž˜ 
    ์ด ๋น„ํŠธ๊ฐ€ ์„ธํŒ…๋˜์–ด ์žˆ์œผ๋ฉด ์—ฐ๊ฒฐ ํ•ด์ œ ์š”์ฒญ

 

 

 

TCP is connection-oriented

  •  A connection-oriented transport protocol establishes a virtual path between the source and destination.
  • All the segments belonging to a message are then sent over this virtual path.
  • Using a single virtual pathway for the entire message facilitates the acknowledgment process as well as retransmission of damaged or lost frames.
  • You may wonder how TCP, which uses the services of IP, a connectionless protocol, can be connection-oriented. The point is that a TCP connection is virtual, not physical. TCP uses the services of IP to deliver individual segments to the receiver, but it controls the connection itself.

 

  •  TCP transmits data in full-duplex mode. (์ด์ค‘ ํ†ต์‹ )
  • When two TCPs in two machines are connected, they are able to send segments to each other simultaneously.
  • This implies that each party must initialize communication and get approval from the other party before any data are transferred.

 

 

 

Connection Establishment

  • TCP ์„œ๋ฒ„๊ฐ€ ๋จผ์ € ์‚ด์•„์žˆ๋‹ค๋Š” ๊ฐ€์ •
  • ํด - TCP ํ”„๋ ˆ์ž„ ๋ณด๋ƒ„
    syn ๋น„ํŠธ 1๋กœ ํ‚ด
    ์ฒซ๋ฒˆ์งธ seq ๋ฒˆํ˜ธ - ๋‚œ์ˆ˜๋กœ ๋„์›€
  • ๋™์˜์˜ ์˜๋ฏธ๋กœ ack ํ‚ด
    + syn ๋น„ํŠธ 1๋กœ ํ‚ด
    8000 ์ž˜ ๋ฐ›์•˜์œผ๋‹ˆ๊นŒ, 8001์„ ์ค˜
    ๋‚˜์˜ seq ์ฒซ๋ฒˆ์งธ ๋ฐ”์ดํŠธ์ธ 15000์„ ์คŒ
  • ์—ฌ๊ธฐ์„œ syn ๊ฑฐ์ ˆํ•˜๋ฉด -> 1๋ฐฉํ–ฅ ํ†ต์‹ ์ด ๋จ
    ์—ฐ๊ฒฐ ํ•ด์ œํ• ๊ฒŒ -> ๋™์˜ํ• ๊ฒŒ 
    ํ•˜์ง€๋งŒ ๋‚˜๋Š” ์•„์ง ๋„ˆ์—๊ฒŒ ํ•  ๋ง์ด ์žˆ์–ด
    ์ด๋Ÿฐ ๊ฒƒ๋„ ๊ฐ€๋Šฅ 
  • ํด - 15001 ์ค˜ -> ์ด ๊ณผ์ •์„ ํ†ตํ•ด ๋‘ TCP ์—ฐ๊ฒฐ ์™„๋ฃŒ 
    ํ๋ฆ„ ์ œ์–ด๋ฅผ ์œ„ํ•œ ์ค€๋น„๊ฐ€ ์™„๋ฃŒ๋จ

 

  •  Simultaneous Open
    • Simultaneous Open may occur when both processes issue an active open.
    • In this case, both TCPs transmit a SYN+ACK segment to each other, and one single-connection is established between them.
  • SYN Flooding Attack
    • SYN Flooding Attack happens when a malicious attacker sends a large number of SYN segments to a server, pretending that each of them is coming from a different client by faking the source IP addresses in the data-grams.
    • The SYN flooding attack belongs to a type of security attack known as a denial-of-service attack, in which an attacker monopolizes a system with so many service requests that the system collapses and denies service to every request.
    • syn ๊ฑฐ๋ถ€ ํ•  ์ˆœ ์—†์Œ -> ์ด๊ฑด ํ†ต์‹  ์•ˆํ•˜๊ฒ ๋‹ค๋Š” ์˜๋ฏธ 
      syn ์—„์ฒญ ๋งŽ์ด ๋ณด๋‚ด๋ฉด, tcp ์„œ๋ฒ„๊ฐ€ ์ฃฝ์Œ -> ์ด๊ฒŒ ํ•ดํ‚น
      but, tcp ์—ฐ๊ฒฐ ์š”์ฒญ์„ ๊ฑฐ์ ˆํ•  ์ˆ˜ ์—†์ž–์•„ 
      -> ip ์ฃผ์†Œ๋ฅผ ์—ฐ๊ฒฐํ•จ: ๋˜ ๊ณ„์† ์˜ค๋ฉด - ์ˆ˜์ƒํ•จ -> ๋ธ”๋ž™๋ฆฌ์ŠคํŠธ์— ์˜ฌ๋ฆผ
      ๊ฐ„ํ—์ ์œผ๋กœ ๋–จ๊ตผ (์ •์ƒ์ผ ์ˆ˜ ์žˆ์œผ๋‹ˆ๊น)
      ์˜๋„๊ฐ€ ์‚ฌ์•…ํ•œ๊ฑฐ ๊ฐ™์•„ -> ์™„์ „ ์ฐจ๋‹จ
      * ์ด๊ฑด tcp ์„œ๋ฒ„๊ฐ€ ํ•  ์ˆ˜ ์žˆ๋Š”๊ฒŒ ์•„๋‹ˆ์•ผ (ํŒŒ์ด์–ด์›”)

 

 

 

Data transfer

  • Pushing Data
    • The application program at the sending site can request a push operation that the sending TCP must not wait for the window to be filled.
    • It must create a segment and send it immediately.
  • Urgent Data
    • When the sending application program wants a piece of data to be read out of order by the receiving application program.
    • Sender can send a segment with the URG bit set.
    • When the receiving TCP receives a segment with the URG bit set, it extracts the urgent data from the segment, using the value of the pointer, and delivers them, out of order, to the receiving application program.
    • ๋น„ํŠธ ์†์— SYN FIN ACK ๋ง๊ณ ,
      PUSH / URG ๋น„ํŠธ๊ฐ€ ์žˆ๋‹ค.
      ํ‘ธ์‰ฌ ๋น„ํŠธ - ๊ฐ€์žฅ ๋จผ์ € ๋ณด๋‚ธ๋‹ค.
      ์–ด์ „ํŠธ - ๊ธด๊ธ‰ํ•œ ๋ฉ”์„ธ์ง€์ด๋‹ˆ๊นŒ, ๋ฐ›์ž ๋งˆ์ž ์œ„๋กœ ์˜ฌ๋ ค๋ผ

 

 

 

Connection termination

  • ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๋ณด๋‚ผ ๋ฐ์ดํ„ฐ๋Š” ๋‹ค ๋ณด๋ƒˆ๊ณ , ์„œ๋ฒ„ ์ž…์žฅ์—์„œ๋Š” ๋” ๋ณด๋‚ผ ๋ฐ์ดํ„ฐ๊ฐ€ ์žˆ์—ˆ์Œ 
  • ์„œ๋กœ ์•ˆ ๋ณด๋‚ด๋ ค๊ณ  ์—ฐ๊ฒฐ ํ•ด์ œ ํ•จ -> ack๊ฐ€ ์•ˆ์˜ค๋Š”๊ฑด ์•„๋‹ˆ๋‹ค.
  • ๋ฐ์ดํ„ฐ๋ฅผ ์•ˆ ๋ณด๋‚ด๋Š”๊ฒŒ ์—ฐ๊ฒฐ ํ•ด์ œ, ํ•˜๋‚˜๋กœ ํ•ฉ์น˜๋Š” ๊ฒŒ ๋ˆˆ์†์ž„ 

 

 

flow control

  • ์ˆ˜์‹  ๋ฒ„ํผ ์‚ฌ์ด์ฆˆ์˜ ๋ณ€ํ™”๋ฅผ ์•Œ๋ ค์ฃผ๋Š” ๊ฒƒ 
  • ๋ฆฌ์‹œ๋ธŒ์œˆ๋„์šฐ: rwnd -> ์ˆ˜์‹  ๋ฒ„ํผ ์‚ฌ์ด์ฆˆ ๋ณด๋‚ด์ค€๋‹ค
    r window : ํ•œ๋ฒˆ์— ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋Š” ์ตœ๋Œ€ ๋ฐ”์ดํŠธ๋Š” 800์ด์•ผ
    ๋ณธ์ธ์ด ๋ณด๋‚ธ ์‹œํ€€์Šค ๋„˜๋ฒ„ - ์ค‘์š”ํ•˜์ง€ ์•Š์•„.
  • ์ž˜ ๋ฐ›์•˜์œผ๋‹ˆ 200 ์ง€์› ๋‹ค.
    ํ•˜์ง€๋งŒ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋Š”๊ฑด 600์ด๋‹ˆ๊น, ๊ธธ์ด๋ฅผ 600์œผ๋กœ ์œ ์ง€
    ์–˜๋„ค๊ฐ€ ๊ธธ์ด ์กฐ์ ˆ ํ•จ
  • ํ๋ฆ„ ์ œ์–ด - flow control
    ์ด๋ ‡๊ฒŒ ์ˆซ์ž์™€ ๋ฒ„ํผ ๊ฐ–๊ณ  ํ•˜๋Š” ๊ฒƒ

 

 

 

Normal operation

โฐ ํƒ€์ด๋จธ๊ฐ€ ํ„ฐ์ง
์ƒ๋Œ€๋ฐฉ์ด ๋ณด๋‚ด๋Š” ๋ฐ์ดํ„ฐ ์กฑ์กฑ ์• ํฌ๋ฅผ ๋„˜๊ธฐ๋ฉด
๋ถ€ํ•˜๋ฅผ ๊ทธ๋Œ€๋กœ ๋„˜๊ธฐ๊ธฐ ๋•Œ๋ฌธ์—, ๋‘˜ ๋‹ค ์ฃฝ์„ ์ˆ˜ ์žˆ๋‹ค.
์ ์ • ์‹œ๊ฐ„์ด ์ง€๋‚ฌ์„ ๋•Œ ACK๋ฅผ ๋ณด๋‚ด๋Š” ๊ฒƒ
-> ์ƒ๋Œ€๋ฐฉ์ด ์ฒ˜๋ฆฌํ•  ACK์˜ ๋ถ€ํ•˜๋ฅผ ์ค„์ด๋Š” ๊ฒƒ 

 

ํ†ต์‹ ์€ 
์ดˆ๋‹น ๋ฉ”์„ธ์ง€ ์ฒ˜๋ฆฌ ๊ฐœ์ˆ˜ packet / sec 
๋ฐ์ดํ„ฐ๊ฐ€ ์•„๋‹ˆ๋ผ!

 

 

 

Lost segment

  • ๋ฐ”๋กœ ์žฌ์ „์†ก ํ•˜์ง€ ์•Š์Œ
  • ํƒ€์ด๋จธ๊ฐ€ ํ„ฐ์ง€๊ณ  ์žฌ์ „์†ก
  • ์—๋Ÿฌ๊ฐ€ ๋‚œ ์ƒํ™ฉ์—์„œ ์˜จ๊ฑด์ง€, ๋‚ด๊ฐ€ ๋ณด๋‚ด๊ธฐ ์ „์— ๋ณด๋‚ธ๊ฒŒ ์ด์ œ ์˜จ๊ฑด์ง€ ์•Œ ์ˆ˜ ์—†๋‹ค.
  • ๋”ฐ๋ผ์„œ ์• ํฌ๊ฐ€ ๋‚ด๊ฐ€ ๋ณด๋‚ธ๊ฑฐ ๋’ค์— ๋„์ฐฉํ–ˆ๋‹ค๋Š” ์ด์œ  ๋งŒ์œผ๋กœ
    ์—๋Ÿฌ์‚ฌํ•ญ์ด๋ผ๊ณ  ํŒ๋‹จํ•  ์ˆ˜๋Š” ์—†๋‹ค
  • ๊ทธ๋ž˜์„œ ํƒ€์ด๋จธ๋กœ ๊ณ„์† ๊ธฐ๋‹ค๋ ค์ฃผ๋Š” ๊ฒƒ 

 

Fast retransmission

  • ์ค‘๊ฐ„์— ํ•˜๋‚˜ ๋‚ ๋ผ๊ฐ
    ๋˜‘๊ฐ™์€ ACK๊ฐ€ 3๋ฒˆ ์—ฐ์† ์™”๋‹ค.
  • ๊ต‰์žฅํžˆ ๋งŽ์€ ๋ฐ์ดํ„ฐ๋ฅผ ๋Š์ž„์—†์ด ๋ณด๋‚ด๋Š” ์ƒํ™ฉ
    ์ƒ๋Œ€๊ฐ€ ๋ฐ›์•˜๋Š”๋ฐ, ์—๋Ÿฌ -> ๊ฐ™์€ seq num ACK 3๊ฐœ๊ฐ€ ์—ฐ๋‹ฌ์•„ ๋„์ฐฉ
  • ๋ฐ”๋กœ ์žฌ์ „์†ก์„ ์ด๋ฒ„๋ฆผ (์‹œ๊ฐ„์„ ๋น„์šด๋‹ค๋Š” ๊ฑฐ - ์•„๋ฌด ๊ฒƒ๋„ ์•ˆ ํ•œ๋‹ค๋Š” ๊ฒƒ)
    ๋Œ€๋Ÿ‰์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋ณด๋‚ด๊ณ , ๋„คํŠธ์›Œํฌ๊ฐ€ ์•ˆ์ •ํ™”๋˜์—ˆ๋‹ค๋Š” ๊ฐ€์ • ํ•˜์—,
    ์žฌ์ „์†ก ํŒ๋‹จํ•˜๊ณ  ๋ฐ”๋กœ ์œ๋‹ค. 

 

 

 

Slow start, exponential increase

  • TCP๋ฅผ ๋ฒ„๋ฆฌ๊ฒŒ ๋œ ๊ทผ๋ณธ์ ์ธ ์›์ธ
  • ์ˆ˜์‹  ์œˆ๋„์šฐ 16๋น„ํŠธ ๋Š˜๋ฆด ์ˆ˜ ์—†๋‹ค 
    ์ˆ˜์‹  ๋ฒ„ํผ ์‚ฌ์ด์ฆˆ๊ฐ€ ์ ๋‹ค
    ์ด๊ฒƒ์ด tcp์˜ ์ฒซ๋ฒˆ์งธ ํ•œ๊ณ„
  • ์ˆ˜์‹  ๋ฒ„ํผ ์‚ฌ์ด์ฆˆ๋ฅผ ์•Ž์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ , 
    ์ „์†ก๊ณผ ๊ด€๋ จ๋œ ํ•„ํ„ฐ๊ฐ€ ๋” ์žˆ๋‹ค.
    ์ฒœ์ฒœํžˆ ์‹œ์ž‘ํ•˜๊ณ , ์ง€์ˆ˜์ ์œผ๋กœ ์ฆ๊ฐ€ํ•œ๋‹ค. 

 

  • ํ•œ ๋ฒˆ์— ๋ฒ„ํผ๋ฅผ ๋‹ค ์ฑ„์šธ ์ˆ˜ ์—†๋‹ค. 
    Cwindow -> congestion ์œˆ๋„์šฐ
    ์ดˆ๊ธฐ ์—ฐ๊ฒฐ ์„ค์ • ๋๋‚œ ์ดํ›„,
    1 = ์ตœ๋Œ€ ์„ธ๊ทธ๋จผํŠธ์‚ฌ์ด์ฆˆ ํ•˜๋‚˜๋ฅผ ๋ณด๋‚ผ ์ˆ˜ ์žˆ์Œ 
  • ์™œ? 
    ์ˆ˜์‹  ๋ฒ„ํผ ์‚ฌ์ด์ฆˆ? -> ์ƒ๋Œ€๋ฐฉ ์ปดํ“จํ„ฐ์˜ ํ”„๋กœ์„ธ์Šค๋ฅผ ์œ„ํ•œ ๋ฒ„ํผ
    ์ค‘๊ฐ„์˜ ๋„คํŠธ์›Œํฌ๊ฐ€ ์–ด๋–ป๊ฒŒ ๋  ์ง€ ๋ชจ๋ฅด๊ธฐ ๋•Œ๋ฌธ์— 
    ํ•œ๊บผ๋ฒˆ์— ์ด ๋ฒ„๋ฆฌ๋ฉด -> ๋‚˜๊ฐ™์€ ์• ๋“ค์ด ๋งŽ์ด ์žˆ์„ ๋•Œ, ์ธํ„ฐ๋„ท์ด ๋ง๊ฐ€์งˆ ์ˆ˜ ์žˆ๋‹ค.
    ๋”ฐ๋ผ์„œ ์ตœ์ดˆ ์—ฐ๊ฒฐ ์„ค์ • ์‹œ, cwnd 1๋กœ ์„ค์ •๋˜์–ด ์žˆ์œผ๋ฉด, ์ƒ๋Œ€๋ฐฉ ๋ฒ„ํผ๋ฅผ ๋ฌด์‹œํ•จ 
  • ์ดํ›„ ๊ทธ ๊ฐ’์ด ๋Š˜์–ด๋‚จ
    cwnd - max segmentsize ์˜๋ฏธ -> ์ฆ‰ ์ด์ œ๋Š” 2๊ฐœ๋ฅผ ๋ณด๋‚ผ ์ˆ˜ ์žˆ๊ฒŒ ๋œ๋‹ค. 
    ๊พธ์ค€ํ•˜๊ฒŒ ACK๋ฅผ ์ฃผ๊ณ  ๋ฐ›์œผ๋ฉฐ, 2๋ฐฐ์”ฉ ์ง€์ˆ˜์ ์œผ๋กœ ์ฆ๊ฐ€ํ•ด์„œ 64 KB๊นŒ์ง€ ๊ฐ„๋‹ค. 
  •  Congestion avoidance, additive increase
    • ๋ฆฌ๋‹ˆ์–ดํ•˜๊ฒŒ ์ฆ๊ฐ€ํ•  ์ˆ˜๋„ ์žˆ๋‹ค: 4->5->6

 

 

 

Linear vs Exponential increase

  • ์–ธ์ œ๋Š” ์ง€์ˆ˜์ , ์–ธ์ œ๋Š” ๋ฆฌ๋‹ˆ์–ด? 
    ๋‚ด๊ฐ€ ์ƒ๋Œ€๋ฐฉ์—๊ฒŒ ACK ์—†์ด ๋ณด๋‚ผ ์ˆ˜ ์žˆ๋Š”๊ฑด ์„ธ๊ทธ๋จผํŠธ ํ•˜๋‚˜
    ACK ์ œ๋Œ€๋กœ ์˜ด -> 2 -> ACK -> 4 -> ACK -> 8
  • ํƒ€์ž„ ์•„์›ƒ ๋ฐœ์ƒ : ACK ์•ˆ ์˜ค๊ฑฐ๋‚˜, ์ •๋ณด๊ฐ€ ๋ชป ๊ฐ”๊ฑฐ๋‚˜, ACK ๋Šฆ๊ฒŒ ์˜ค๊ฑฐ๋‚˜ ์…‹ ์ค‘ ํ•˜๋‚˜
    ์–ด์จ‹๋“  ์„ผ๋”๋Š” ํƒ€์ด๋จธ๊ฐ€ ํ„ฐ์กŒ๊ณ , ์—๋Ÿฌ๋กœ ๊ฐ์ง€
    -> ๋‹ค์‹œ ์ดˆ๊ธฐ ๊ฐ’์ธ 1๋กœ, ๋š ๋–จ์–ด์ง
  • error: ์ธํ„ฐ๋„ท์ด ๋ถ๋น„๊ณ  ์žˆ๋‹ค๋Š” ๊ฒƒ
    ์ƒ๋Œ€๋ฐฉ ์ปดํ“จํ„ฐ๋กœ ๊ฐ€๊ธฐ ์œ„ํ•œ ๋„คํŠธ์›Œํฌ ์ค„ or ๊ทธ ๊ฒฝ๋กœ๋“ค ์ค‘ ํ•˜๋‚˜ ๋“ฑ๋“ฑ ๋ถ๋นˆ๋‹ค๋Š” ๊ฒƒ
    ๋ถ๋น„์ง€ ์•Š๋„๋ก ์ค„์ด๋Š” ๊ฒƒ 
  • ์ˆ˜์‹  ๋ฒ„ํผ์™€ ์ƒ๊ด€ ์—†์ด ๋‹ค์‹œ 1๋กœ ๋–จ๊ตฐ๋‹ค. 
    ํ„ฐ์ง„ 8 / 2 -> 4 (ํƒ€์ž„ ์•„์›ƒ์„ 2๋กœ ๋‚˜๋ˆˆ ๊ฐ’ -> ๊ฒฝ๊ณ„๊ฐ€ ๋œ๋‹ค.)
    1 -> ACK -> 2 -> ACK -> 4 
    ์ด ์ƒํ•œ์„  4 ์— ๋„๋‹ฌ -> ์ง€์ˆ˜์ ์ด ์•„๋‹ˆ๋ผ, ์„ ํ˜•์ ์œผ๋กœ ๋ฆฌ๋‹ˆ์–ดํ•˜๊ฒŒ ์ฆ๊ฐ€ 
    ๋˜ ์—๋Ÿฌ ๋‚˜๋ฉด ๋‹ค์‹œ 1 
    -> ์ด๋ฒˆ์—๋Š” 12๋‹ˆ๊นŒ 6์ด ๊ฒฝ๊ณ„ (๊ทธ ์ดํ›„๋Š” ๋ฆฌ๋‹ˆ์–ด)

 

 

 

Additive increase, multiplicative decrease

  • TCP์˜ ํ†ฑ๋‹ˆ ๋ฐ”ํ€ด๊ฐ€ ์„ฑ๋Šฅ ์ €ํ•˜์˜ ๊ฐ€์žฅ ํฐ ์›์ธ
  • ๋„คํŠธ์›Œํฌ์˜ ์ƒํ™ฉ๊ณผ ์ƒ๊ด€ ์—†์ด, ์ตœ์ดˆ ์—ฐ๊ฒฐ์‹œ์—๋Š” TCP๋Š” ์ผ๋‹จ ๋ฌด์กฐ๊ฑด ๋Š๋ฆฌ๋‹ค.
  • CWND๊ฐ€ 1์—์„œ ์‹œ์ž‘ํ•˜๋‹ˆ๊นŒ, ๋ฌด์กฐ๊ฑด ๋Š๋ฆผ
  • ๋„คํŠธ์›Œํฌ ์ƒํ™ฉ์— ๋”ฐ๋ผ ๋ฐœ์ƒํ•˜๋Š” ์—๋Ÿฌ -> ๋‚ด ์†์œผ๋กœ ์–ด๋–ป๊ฒŒ ํ•  ์ˆ˜ ์—†๋Š” ์ƒํ™ฉ
  • ์ด๋ ‡๊ฒŒ ๋˜๋ฉด TCP๋Š” ์ตœ์ € ์ƒํ™ฉ์œผ๋กœ ๋Œ์•„๊ฐ

 

  • ์• ์ดˆ์— TCP ์ง€์›ํ•˜๋Š” ๋„คํŠธ์›Œํฌ 
  • ์ตœ์ € ์ธํ„ฐ๋„ท ์†๋„ ์ง€์› ์ž์ฒด๊ฐ€ ๋ถˆ๊ฐ€๋Šฅํ•œ ๋„คํŠธ์›Œํฌ 
  • ์ธํ„ฐ๋„ท์„ ๊ฐ€๋กœ์ง€๋ฅด๋Š” ๊ฒฝ์šฐ์—๋Š”, ์–ด๋– ํ•œ ํ€„๋ฆฌํ‹ฐ๋„ ๋ณด์žฅํ•  ์ˆ˜ ์—†๋‹ค.