Max UDP packet size + Java: weirdness

Nerius Landys nlandys at
Tue Feb 9 20:41:08 UTC 2010

I'm trying to send large UDP packets between 2 programs written in the
Java programming language.  These 2 programs will be running on 2
different hosts which are far apart.  The "test" code for these
programs is only a few lines and is here:

First, I noticed that I was able to send data that is 9216 in length
between 2 FreeBSD 7.1 hosts ("far apart" in network distance) running
Sun JDK 1.5.0_16-p9 (compiled myself from /usr/ports/java/jdk15).
Any packet greater than this in length would not be sent, with the
following error:

Exception in thread "main" Message too long
        at Method)
        at BigUDPPacketTestClient.main(

I then repeated these tests between 2 Linux hosts ("far apart" in
network distance).  One Linux host (the "server") was running OpenJDK
1.6.0-b09, and the other (the "client") was running Sun JDK
1.6.0_14-b08.  This time, I was able to send 35512 bytes in a UDP
packet before it crapped out.

For my particular application, I would really benefit from being able
to send large UDP packets.  Does anyone know how to increase the max
allowed size of UDP packets in a Java program?  I assume it's
something outside of the Java program, in the system or kernel or

Any help from network gurus would be appreciated.  Should I post this
in the freebsd-net mailing list instead?

- Nerius

More information about the freebsd-questions mailing list