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
- Sample RTT: measured time from segment transmission until ACK receipt
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 |