byte[] buffer = new byte[8192];
DatagramPacket dp = new DatagramPacket(buffer, buffer. length);
For this constructor, it doesn't care how big the buffer can be and will happily let you create a DatagramPacket several megabytes in size.
However, then the underlying native networking software is less forgiving, and the most primitive implementations of UDP don't support more than 8,192 byte/datagram. The theoretical datagram limit for IPv4 is 65,507 bytes, and a DatagramPacket object with a 65,507 byte size cache can receive any possible IPv4 datagram losslessly. many UDP-based protocols such as DNS and TFTP will use 512 bytes per datagram or less. The maximum datagram size for common use with NFS is 8,192 bytes. Almost all of the UDP datagrams you're likely to encounter are 8K or less. In fact, many operating systems do not support UDP datagrams with more than 8K of data, or truncate, or split, or discard them. If a datagram is truncated or discarded by the network because it is too large, your java program is not notified of the problem (UDP is, after all, an unreliable protocol). Therefore, you should not create DatagramPacket objects larger than 8,192 bytes.