if(log.isInfoEnabled()) log.info("frag_size=" + lower);
if(log.isDebugEnabled()) log.debug("frag_size=" + lower);
    public int senseMaxFragSize() {        int max_send=32000;        int upper=8192;        int lower=0;        int highest_failed=-1;        DatagramSocket sock;        byte[] buf;        DatagramPacket packet;        InetAddress local_addr;        try {            sock=new DatagramSocket();            local_addr=InetAddress.getLocalHost();        }        catch(Exception ex) {            if(log.isWarnEnabled()) log.warn("failed creating DatagramSocket: " + ex);            return 0;        }        upper=max_send;        for(int i=0; i < num_iterations && lower < upper; i++) { // iterations to approximate frag_size            try {                buf=new byte[upper];                // System.out.println("** upper=" + upper + " (lower=" + lower + ")");                packet=new DatagramPacket(buf, buf.length, local_addr, 9);                sock.send(packet);                lower=Math.max(lower, upper);                upper=upper * 2;                if(highest_failed > -1)                    upper=Math.min(highest_failed, upper);            }            catch(IOException io_ex) {                if(highest_failed > -1)                    highest_failed=Math.min(highest_failed, upper); // never exceed max_upper                else                    highest_failed=upper;                upper=(upper + lower) / 2;            }            catch(Throwable ex) {                if(log.isWarnEnabled()) log.warn("exception=" + ex);                break;            }        }        /** Reduce the frag_size a bit to prevent packets that are too large (see bug #854887) */        lower-=frag_overhead;         if(log.isInfoEnabled()) log.info("frag_size=" + lower);        return lower;    }