본문 바로가기
DSP, MCU/펌웨어

Fragmentation을 피하기 위한(안전한) UDP payload size

by eteo 2023. 3. 20.

 

 

 

 

왜 UDP는 단편화를 피해야 할까?

 

TCP는 누락된 패킷 재전송과 패킷 재정렬 메커니즘이 있는 연결지향(stream-oriented) 프로토콜이기 때문에 단편화가 발생하는 경우 성능 저하가 발생할 순 있지만 단편화로 인한 직접적인 패킷 손실은 발생하지 않는다.

 

반면 UDP는 연결성이 없고(message-oriented) 안정성을 추구하지 않는 프로토콜로 재전송이나 재정렬 메커니즘이 없기 때문에 패킷이 손실되지 않도록 하려면 단편화를 피해야 한다.

 

 

 

 

 

 

 

Maximum safe UDP payload

 

RFC 1122 문서 상 IPv4에서 reassemble 가능한 최소 MTU 권고값을 576 byte로 명시하고 있다.

 

실제로 네트워크상에 최소 규격만을 만족하는 장비가 있을 가능성을 배제할 수는 없고, 하나의 fragment가 누락되면 전체 패킷이 drop되므로 단편화를 피하기 위한 안전한 IPv4 packet(데이터그램)은 576 byte이며,

 

따라서 Maximum safe UDP payload는 508 byte 이다.

 

508 = 57 - 60 (Maximum IPv4 header) - 8 (UDP header)

 

단, 일반적인 경우 IPv4 header는 20 byte이므로 이보다 좀 커도 상관 없다.

일반적으로 2의 거듭제곱으로 떨어지는 512 byte를 채택하는 듯 하다. DNS도 512 byte의 제한을 두고 있다.

 

 

 
 
 
 
 

MTU와의 차이

 
 
 
Framentation의 3계층인 네트워크 계층(IPv4/IPv6)에서 일어나는데, 
 
576 byte는 IPv4에서 모든 호스트가 수신할 수 있어야하는 미니멈 데이터그램 사이즈이고, 
 
MTU는 주어진 매체에서 fragmentation 없이 송신할 수 있는 IP Packet에 맥시멈 사이즈이다. (Ethernet의 경우 MTU가 1500 byte)
 

 

 

 

Reference : https://stackoverflow.com/questions/1098897/what-is-the-largest-safe-udp-packet-size-on-the-internet%EF%BB%BF

 

What is the largest Safe UDP Packet Size on the Internet

I've read a number of articles about UDP packet sizes but have been unable to come to a conclusion on whats correct. A number of services restrict the largest UDP packet to 512 bytes (like dns) G...

stackoverflow.com

https://goziro.com/udp-fragmentation-why-should-you-avoid-it/

 

UDP fragmentation. Why should you avoid it?

UDP fragmentation is avoidable when certain unusual network problems occur. Here are some tips on how to diagnose and address the issues.

goziro.com

https://en.wikipedia.org/wiki/Maximum_transmission_unit

 

Maximum transmission unit - Wikipedia

From Wikipedia, the free encyclopedia Size of largest allowed packet on a network segment In computer networking, the maximum transmission unit (MTU) is the size of the largest protocol data unit (PDU) that can be communicated in a single network layer tra

en.wikipedia.org