TCP

Transmission Layer

TCP (Transmission Control Protocol)

UDP (User Datagram Protocol)

Untitled

TCP

Transport services and protocols

Transport Layer vs Network Layer

Transport Layer

Network Layer

TCP segment Structure

Untitled

src, dest port

sequence number, acknowledgement number

head length(data offset), not used(reserved)

U(URG)

A(ACK)

P(PSH)

R(RST)

S(SYN)

F(FIN)

TCP Establishment, Termination and retransmission scenarios

TCP Establishment

Untitled

TCP Termination

Untitled

TCP retransmission scenarios

Untitled

Untitled

Untitled

TCP State Diagram

출처 : https://ssup2.github.io/theory_analysis/TCP_Connection_State/ TCP State Diagram

TCP Client lifecycle

Untitled

TCP Server lifecycle

Untitled

Untitled

TCP connection terminating

  1. Active Closer
    • ESTABLISHED → FIN_WAIT→ FIN_WAIT_2 → TIME_WAIT → CLOSED
      1. Active Closer가 FIN을 전송하고 FIN_WAIT_1로 전이한다.
      2. Passive Closer로부터 ACK를 수신하고 FIN_WAIT_2로 전이한다.
      3. Passive Closer로부터 FIN을 수신하고 TIME_WAIT로 전이한다.
      4. 2MSL(Maximum Segment Lifetime)만큼 TIME_WAIT가 유지된 후 CLOSED로 전이한다.
  2. Passive Closer
    • ESTABLISHED → CLOSE_WAIT → LAST_ACK → CLOSED
      1. CLOSE_WAIT 상태는 Passive Closer가 Active Closer로부터 FIN을 수신하고 전이하는 상태이다.
      2. Passive Closer가 close() System Call을 호출하거나 Passive Closer의 Process가 종료되면 Passive Closer는 FIN을 전송하고 LAST_ACK상태가 된다.
      3. CLOSE_WAIT상태의 Passive Closer가 FIN을 전송한 후 이에 대한 ACK를 전송받기 전까지의 상태이다.
      4. ACK를 수신하고 CLOSED로 전이한다.
  3. 동시에 close하는 경우(둘다 Active Closer)
    • ESTABLISHED → FIN_WAIT_1 → CLOSING → TIME_WAIT → CLOSED
      1. simultaneous closes가 발생하여 FIN_WAIT_1상태의 두 Active Closer가 FIN을 수신한다.
      2. 이 경우 두 Active Closer들은 FIN_WAIT_1에서 CLOSING 상태로 전이한다.
      3. 다른 Host로부터 ACK를 전송받고 TIME_WAIT로 전이한다.
      4. TIME_WAIT에서 2MSL만큼 대기한 후 CLOSED로 전이한다.

Why TIME_WAIT?

Untitled

TCP Error Control

Stop-and-Wait ARQ

Go - Back - N ARQ

Untitled

Selective Repeat ARQ

Untitled

TCP Flow Control

reference

[TCP/UDP] TCP와 UDP의 특징과 차이

TCP Connection State

TCP connection status

[네트워크프로토콜] 흐름제어, 에러제어

Window Size란?