views:

68

answers:

2

Hello!

I want to send broadcast message to all peers in my local network. Message is a 32 bit integer. I can be sure, that message will not me fragmented, right? There will be two options: - peer will receive whole message at once - peer will not receive message at all

Going further, 4 bytes is maximum size of data, that can be sent in one UDP datagram? I use Ethernet based network in 99%.

+3  A: 

Ethernet packets can be up to around 1500 bytes (and that's not counting jumbo frames). If you send broadcast messages with a payload of only 4 bytes, they shouldn't get fragmented at all. Fragmentation should only occur when the packet is larger than the Maximum Transmission Unit (so about 1500 bytes over Ethernet).

Mathiasdm
I have often set MTU much smaller than 1500. Especially on modem or ISDN/IDSL links combined with QoS, smaller packets help responsiveness. So don't *assume* 1500 is valid everywhere.
Zan Lynx
+6  A: 

IPv4 specifies a minimum supported MTU of 576 bytes, including the IP header. Your 4 byte UDP payload will result in an IP packet far smaller than this, so you need not fear fragmentation.

Furthermore, your desired outcome - "peer will receive whole message at once or peer will not receive message at all" is always how UDP works, even in the presence of fragmentation. If a fragment doesn't arrive, your app won't recieve the packet at all.

The rules for UDP are "The packet may arrive out-of-order, duplicated, or not at all. If the packet does arrive, it will be the whole packet and error-free.". ("Error-free" is obviously only true within the modest limits of the IP checksum).

caf
+1 for fragmentation not an application issue. Fragmentation is what the "IP" part of UDP/IP is dealing with. It is handled in the lower part of the network stack and not something you don't have to bother with in your application.
Martin Wickman