MTU

Message bundling accumulates messages in the transport until m bytes have been accumulated, or n milliseconds have elapsed, whichever comes first.

In UDP, message bundling can be enabled with the following properties:

 

 

<UDP enable_bundling="true"        max_bundle_size="64000"        max_bundle_timeout="30"/>

 

max_bundle_size defines how many bytes to accumulate until a message is sent and max_bundle_timeout defines the max number of milliseconds to wait until a message is sent.

 

When either condition becomes true, all accumulated messages are bundled into a larger message and sent.

 

 

However, this may be counter-productive. The MTU (max transmission unit) causes the IP layer to fragment IP packets if the MTU is exceeded. A typical MTU for ethernet is 1500 bytes. Let's look at an example.

 

 

JGroups assigns sequence numbers to each message (org.jgroups.Message). Let's say we multicast 100 1K messages. Let's assume (for this example) that UDP bundling creates 4 messages, assigning sequence numbers 1,2,3 and 4 to them. Let's say message 1 is contains 40 bundled messages (40K), message 2 35, message 3 20 and message 4 5 (total of 100 messages, each of 1K).

 

 

The IP layer now receives messages 1,2,3 and 4. It will fragment message 1 into 27 IP packets (26 of 1500 bytes, and 1 for the remainder), message 2 into 24, message 3 into 14 and message 4 into 4 IP packets.

Each IP packet for the same UDP datagram will have the same IP sequence number and the DF (Dont Fragment) bit set. At the receiver, those IP packets are reassembled and delivered to the receiver as a UDP datagram.

 

 

 

However, if one of the IP fragment is lost, the entire datagram will not be delivered. Because the message is therefore not received, JGroups (NAKACK) will run into a timeout and request retransmission, say of message 2. Message 2 will be resent, which causes all 24 IP packets to be sent again.

 

 

 

 

Conclusion: if your transport is lossy, or you are sending a lot of messages, it may be better to turn UDP bundling off, set the max fragmentation size to less than the max MTU (including the headers !) and send messages that don't need to be fragmented at the IP layer. For example, if we sent 24 JGroups messages instead of the old message 2, and the IP layer would drop one of them, JGroups would request retransmission of 1 JGroups message, resulting in re-sending of 1 IP packet, instead of 24