Max UDP packet size + Java: weirdness

Nerius Landys nlandys at gmail.com
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:

  http://daffy.nerius.com/temp/BigUDPPacketTestClient.java
  http://daffy.nerius.com/temp/BigUDPPacketTestServer.java

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" java.io.IOException: Message too long
        at java.net.PlainDatagramSocketImpl.send(Native Method)
        at java.net.DatagramSocket.send(DatagramSocket.java:612)
        at BigUDPPacketTestClient.main(BigUDPPacketTestClient.java:24)

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
whatnot.

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