The maximum total length of an IPv4 datagram is 65,535 bytes, which is the maximum value representable by a 16-bit total length field. Since an IPv4 header is at least 20 bytes long, the maximum size of the data portion is 65,535 minus 20, which equals 65,515 bytes.