Changeset aa2f9e3


Ignore:
Timestamp:
May 17, 2009 11:52:49 AM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
b59a38ff
Parents:
47fc3b0
Message:
  • Rework UDP peers.jsp table a little
  • Don't let UDP bid on messages that are too long
  • Clean up the max fragments code in UDP
Location:
router/java/src/net/i2p/router/transport/udp
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/transport/udp/InboundMessageState.java

    r47fc3b0 raa2f9e3  
    3131    /** expire after 10s */
    3232    private static final long MAX_RECEIVE_TIME = 10*1000;
    33     private static final int MAX_FRAGMENTS = 64;
     33    public static final int MAX_FRAGMENTS = 64;
    3434   
    3535    private static final ByteCache _fragmentCache = ByteCache.getInstance(64, 2048);
  • router/java/src/net/i2p/router/transport/udp/OutboundMessageState.java

    r47fc3b0 raa2f9e3  
    3535    private int _nextSendFragment;
    3636   
    37     public static final int MAX_FRAGMENTS = 32;
    38     private static final ByteCache _cache = ByteCache.getInstance(64, MAX_FRAGMENTS*1024);
     37    public static final int MAX_MSG_SIZE = 32 * 1024;
     38    /** is this enough for a high-bandwidth router? */
     39    private static final int MAX_ENTRIES = 64;
     40    /** would two caches, one for small and one for large messages, be better? */
     41    private static final ByteCache _cache = ByteCache.getInstance(MAX_ENTRIES, MAX_MSG_SIZE);
    3942   
    4043    public OutboundMessageState(I2PAppContext context) {
     
    227230        if (numFragments * fragmentSize < totalSize)
    228231            numFragments++;
    229        
     232        // This should never happen, as 534 bytes * 64 fragments > 32KB, and we won't bid on > 32KB
     233        if (numFragments > InboundMessageState.MAX_FRAGMENTS)
     234            throw new IllegalArgumentException("Fragmenting a " + totalSize + " message into " + numFragments + " fragments - too many!");
    230235        if (_log.shouldLog(Log.DEBUG))
    231236            _log.debug("Fragmenting a " + totalSize + " message into " + numFragments + " fragments");
  • router/java/src/net/i2p/router/transport/udp/PeerState.java

    r47fc3b0 raa2f9e3  
    288288   
    289289    private int getDefaultMTU() {
    290         String mtu = _context.getProperty(PROP_DEFAULT_MTU);
    291         if (mtu != null) {
    292             try {
    293                 return Integer.valueOf(mtu).intValue();
    294             } catch (NumberFormatException nfe) {
    295                 // ignore
    296             }
    297         }
    298         return DEFAULT_MTU;
     290        return _context.getProperty(PROP_DEFAULT_MTU, DEFAULT_MTU);
    299291    }
    300292   
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    r47fc3b0 raa2f9e3  
    930930   
    931931    public TransportBid bid(RouterInfo toAddress, long dataSize) {
     932        if (dataSize > OutboundMessageState.MAX_MSG_SIZE) {
     933            // NTCP max is lower, so msg will get dropped
     934            return null;
     935        }
    932936        Hash to = toAddress.getIdentity().calculateHash();
    933937        PeerState peer = getPeerState(to);
     
    17541758        else
    17551759            buf.append(" <a href=\"").append(urlBase).append("?sort=0\">V</a> ");
    1756         buf.append("</td><td><b><a href=\"#def.idle\">idle</a></b>");
     1760        buf.append("</td><td>dir/intro</td><td><b><a href=\"#def.idle\">idle</a></b>");
    17571761        appendSortLinks(buf, urlBase, sortFlags, "Sort by idle inbound", FLAG_IDLE_IN);
    17581762        buf.append("/");
     
    18101814            buf.append("\">");
    18111815            buf.append(name);
    1812 /*
    1813             buf.append("@");
    1814             byte ip[] = peer.getRemoteIP();
    1815             for (int j = 0; j < ip.length; j++) {
    1816                 int num = ip[j] & 0xFF;
    1817                 if (num < 10)
    1818                     buf.append("00");
    1819                 else if (num < 100)
    1820                     buf.append("0");
    1821                 buf.append(num);
    1822                 if (j + 1 < ip.length)
    1823                     buf.append('.');
    1824             }
    1825             buf.append(':');
    1826             int port = peer.getRemotePort();
    1827             if (port < 10)
    1828                 buf.append("0000");
    1829             else if (port < 100)
    1830                 buf.append("000");
    1831             else if (port < 1000)
    1832                 buf.append("00");
    1833             else if (port < 10000)
    1834                 buf.append("0");
    1835             buf.append(port);
    1836 */
    1837             buf.append("</a>&nbsp;");
     1816            buf.append("</a>");
     1817            //byte ip[] = peer.getRemoteIP();
     1818            //if (ip != null)
     1819            //    buf.append(' ').append(_context.blocklist().toStr(ip));
     1820            buf.append("</td><td>");
    18381821            if (peer.isInbound())
    18391822                buf.append("in ");
     
    19911974        }
    19921975       
    1993         buf.append("<tr><td colspan=\"15\"><hr /></td></tr>\n");
    1994         buf.append(" <tr><td colspan=\"2\"><b>Total</b></td>");
     1976        buf.append("<tr><td colspan=\"16\"><hr /></td></tr>\n");
     1977        buf.append(" <tr><td colspan=\"3\"><b>Total</b></td>");
    19951978        buf.append("     <td align=\"right\">");
    19961979        buf.append(formatKBps(bpsIn)).append("/").append(formatKBps(bpsOut));
Note: See TracChangeset for help on using the changeset viewer.