[Ch3] UDP, TCP

2023. 11. 21. 15:38· CS/컴퓨터네트워크
목차
  1. UDP: connectionless transport
  2. UDP
  3. UDP checksum
  4. Reliable Data Transfer (RDT)
  5. Reliable Data Transfer Mechanism
  6. TCP
  7. TCP overview
  8. TCP Segment Structure
  9. TCP Reliable Data Transfer (RDT)
  10. TCP Flow Control
  11. Connection Management

UDP: connectionless transport

UDP

UDP: User Datagram Protocol

  • connectionless: no call setup -> no delay before data delivery
  • doesn't care errors at receiver -> just error-check
    • UDP datagram can be lost or delivered out-of-order to app
  • UDP doesn't control over what data is send & when -> App can send its data as fast as it wants
  • used in streaming multimedia apps (loss tolerant, rate sensitive), DNS, SNMP
  • reliable transfer over UDP: add reliability at application layer, application-specific error recovery

 

UDP checksum

UDP Checksum

  • sender: header field를 포함한 segment contents를 sequence of 16-bit integers로 -> sum 계산 -> one's complement sum (receiver에서의 계산을 쉽게 하기 위해) -> sender puts checksum value into UDP checksum field
  • receiver compute checksum and check if equals checksum field value (sum === 0 ? YES=no error : NO=error)

 

👉 UDP checksum과 TCP checksum의 알고리즘은 같다.

Reliable Data Transfer (RDT)

Reliable Data Transfer Mechanism

  • Checksum
    • used to detect bit errors in a transmitted packet.
  • Acknowledgement
    • used by receiver to tell the sender that packets has been received correctly.
    • Ack will typically carry the sequence number of the packets being acknowledged.
    • Ack may be individual or cumulative, depending on the protocol
  • Negative Acknowledgement
    • used by receiver to tell the sender that packet has not been received correctly.
    • Negative ack will typically carry the sequence number of the packet that was not received correctly.
  • Sequence Number
    • used for a sequential numbering of packets of data flowing from sender to receiver
    • Gaps in the sequence numbers of received packets allow the receiver to detect a loss packet.
    • Packets with duplicate sequence numbers allow the receiver to detect duplicate copies of a packet.
  • Timer
    • used to timeout/retransmit a packet, possibly because the packet or its ACK was lost within the channel.
    • premature timeout: when a packet was delayed but not lost
      • if too short timeout value => unnecessary retransmit: 네트워크 자원 낭비
    • slow reaction: when a packet was recieved by the receiver but the receiver-to-sender ACK was lost, duplicate copies of a packet may be received by a receiver
      • if too long timeout value => duplicate or long delay: 패킷 loss 감지 및 필수적인 재전송이 느려짐 = end-to-end latency가 나빠진다.
  • Pipelining & Window
    • sender may be restricted to sending only packets with sequence numbers that fall within a given range.
    • by allowing multiple packets to be transmitted but not yet acknowledged, sender utilization can be increased over a stop-and-wait mode of ooperation.
      • stop & wait: 하나씩 보내고 Ack을 기다리고 다시 보냄
    • window size W may be set on the basis of the receiver's ability to receive and buffer messages, or the level of congestion in the network
      • pipelining: inflight bytes (unacked) -> maximum # of inflight bytes = window size W
    • W = min(congestion window, receiver window)

TCP

TCP overview

  • point-to-point: one sender - one receiver
  • reliable, in-order byte stream (sequence number per byte)
  • connection-oriented: handshaking before data exchange
  • full duplex data: bi-directional data flow in same connection
    • MSS: maximum segment size
  • flow controlled: sender will not overwhelm receiver -> receiver가 알려줌 (rwnd)
  • congestion controlled: sender will not overwhelm network -> sender가 유추 (cwnd)
  • pipelined: TCP congestion and flow control set window size

- rwnd: TCP receiver의 receive buffer 잔여량을 TCP receiver가 TCP header에 넣어 TCP sender에게 알려줌으로써 sending rate 조절하게 하는 flow control을 위한 파라미터

- cwnd: TCP sender의 local parameter로 network 상황을 간접적으로 예측하여 조정하는 값

 

TCP Segment Structure

  • seuence #
    • 초기값 랜덤, 항상 유효
    • byte stream number of first byte in segment's data
  • ack #
    • ACK bit === 1: 유효
    • sequence number of next byte that a receiver expect to receive for in-order delivery
    • cumulative ACK

- receiver 는 TCP segment header의 ACK flag bit가 0인 경우에도 Ack number 필드를 처리한다? (X)

- TCP가 connection을 맺을 때마다 sequence number는 항상 초기값 0으로 시작한다? (X)

- receiver가 받은 TCP segment header의 sequence number 필드 값은 body에 실려있는 데이터의 첫번째 바이트에 붙여진 sequence number이다.

 

 

 

TCP Round Trip Time (RTT)

TCP Timeout Value

  • longer than RTT -> 실제 네트워크의 RTT값 이용해서 계산
    • if too short -> premature timeout, unnecessary retransmissions
    • if too long -> slow reaction to segment loss
    • 👉 Goal: reducing unneeded retransmission & avoiding unnecessary delay
  • How to estimate RTT?
    • Sample RTT: measured time from segment transmission until ACK receipt
      • Ignore retransmission

EstimatedRTT = (1 - a) * EstimatedRTT + a * SampleRTT

  • influence of past sample decreases exponentially fast
  • typical value: a = 0.125
  • 오래된 값이 weight를 적게 받는다

TCP sender가 timeout 값을 조정하지 않고 network router의 buffer 크기를 증가시키면?

  • TCP sender가 delayed pkt을 loss로 오인 -> 불필요한 retransmission 증가
  • RTT 증가 -> throughput 감소
  • 중간 라우터의 buffer에 TCP receiver가 이미 받은 pkt들이 차지하는 비율 증가

 

 

Timeout Interval = EstimatedRTT + 4 * DevRTT

  • 4 * DevRTT = safety margin

 

TCP Reliable Data Transfer (RDT)

  • pipelined segments, cumulative acks => 3 duplicate acks (fast retransmission before timeout)
  • single retransmission timer per connection -> timer for oldest unacked segment == SendBase

3 Duplicate Acks

  • if sender receives 3 duplicate Acks for same data, then t he sender resend unacked segment with smallest sequence # without wating for timeout
  • 네트워크에서 drop 되지는 않았지만 늦게 도착한 패킷 (delayed not lost pkt)을 loss로 오판하여 불필요한 retx을 보내는 것을 막기 위해

👉 fast retransmit

👉 TCP는 timeout 값은 넉넉히 설정하고 pipelining과 cumulative Ack 을 이용해서 timeout 전에 loss를 유추하는 방법 사용

 

TCP Flow Control

Flow Control

  • receiver controls sender (sending rate), so sender won't overflow receiver's buffer by transmitting too much, too fast.
  • rwnd value in TCP header of receiver-to-sender segments
    • rwnd == free buffer space
  • sender limits amount of unacked (in-flight) data to receiver's rwnd value

👉 guarantees receive buffer will not overflow

 

Connection Management

TCP 3-way handshake

 

TCP: Closing a connection

  • client, sender each close their side of connection
  • send TCP segment with FIN bit = 1
  • respond to received FIN with ACK
    • on receiving FIN, ACK can be combined with own FIN (FINACK)
저작자표시 (새창열림)

'CS > 컴퓨터네트워크' 카테고리의 다른 글

[Ch4 Network Layer] Network Layer, Router  (0) 2023.12.02
[Ch3] TCP congestion control  (2) 2023.11.27
[Ch2 & Ch3] CDN, UDP & TCP, Mux & Demux  (1) 2023.11.14
[Ch2 Application Layer] Electronic Mail, DNS, P2P applications  (1) 2023.11.02
[Ch2 Application Layer] Principles of Network Applications, Web and HTTP  (0) 2023.10.30
  1. UDP: connectionless transport
  2. UDP
  3. UDP checksum
  4. Reliable Data Transfer (RDT)
  5. Reliable Data Transfer Mechanism
  6. TCP
  7. TCP overview
  8. TCP Segment Structure
  9. TCP Reliable Data Transfer (RDT)
  10. TCP Flow Control
  11. Connection Management
'CS/컴퓨터네트워크' 카테고리의 다른 글
  • [Ch4 Network Layer] Network Layer, Router
  • [Ch3] TCP congestion control
  • [Ch2 & Ch3] CDN, UDP & TCP, Mux & Demux
  • [Ch2 Application Layer] Electronic Mail, DNS, P2P applications
호프
호프
호프
Untitled
호프
전체
오늘
어제
  • 분류 전체보기 (341)
    • 오류😬 (4)
    • 스터디📖 (96)
      • 웹 개발 기초 (8)
      • Spring (20)
      • ML, DL (30)
      • Node.js (22)
      • React (0)
      • 블록체인 (12)
      • Go (3)
      • Javascript (1)
    • 알고리즘💻 (153)
      • 그리디 (23)
      • Bruteforce&Backtracking (16)
      • DP (17)
      • 이분탐색&정렬&분할정복 (17)
      • 누적합&투포인터 (6)
      • 스택&큐&덱 (19)
      • 그래프(DFS&BFS) (19)
      • 트리 (7)
      • 우선순위큐&다익스트라 (11)
      • 벨만포드&플로이드와샬 (8)
      • map&set&number theory (5)
      • 기타 (5)
    • 프로젝트 (3)
      • 캡스톤 디자인 프로젝트 (3)
    • 블록체인🔗 (3)
      • Solana (2)
      • 개발 (0)
      • Harmony (1)
    • ASC (6)
    • CS (73)
      • 데이터베이스 (12)
      • 클라우드컴퓨팅 (21)
      • 운영체제 (11)
      • 컴퓨터네트워크 (14)
      • 블록체인응용 (15)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • 복습

최근 댓글

최근 글

hELLO · Designed By 정상우.v4.2.1
호프
[Ch3] UDP, TCP
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.