- 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
This commit is contained in:
zzz
2009-05-17 11:52:49 +00:00
parent 47fc3b0d0b
commit aa2f9e34c0
4 changed files with 22 additions and 42 deletions

View File

@ -30,7 +30,7 @@ public class InboundMessageState {
/** expire after 10s */
private static final long MAX_RECEIVE_TIME = 10*1000;
private static final int MAX_FRAGMENTS = 64;
public static final int MAX_FRAGMENTS = 64;
private static final ByteCache _fragmentCache = ByteCache.getInstance(64, 2048);

View File

@ -34,8 +34,11 @@ public class OutboundMessageState {
private short _maxSends;
private int _nextSendFragment;
public static final int MAX_FRAGMENTS = 32;
private static final ByteCache _cache = ByteCache.getInstance(64, MAX_FRAGMENTS*1024);
public static final int MAX_MSG_SIZE = 32 * 1024;
/** is this enough for a high-bandwidth router? */
private static final int MAX_ENTRIES = 64;
/** would two caches, one for small and one for large messages, be better? */
private static final ByteCache _cache = ByteCache.getInstance(MAX_ENTRIES, MAX_MSG_SIZE);
public OutboundMessageState(I2PAppContext context) {
_context = context;
@ -226,7 +229,9 @@ public class OutboundMessageState {
int numFragments = totalSize / fragmentSize;
if (numFragments * fragmentSize < totalSize)
numFragments++;
// This should never happen, as 534 bytes * 64 fragments > 32KB, and we won't bid on > 32KB
if (numFragments > InboundMessageState.MAX_FRAGMENTS)
throw new IllegalArgumentException("Fragmenting a " + totalSize + " message into " + numFragments + " fragments - too many!");
if (_log.shouldLog(Log.DEBUG))
_log.debug("Fragmenting a " + totalSize + " message into " + numFragments + " fragments");

View File

@ -287,15 +287,7 @@ public class PeerState {
}
private int getDefaultMTU() {
String mtu = _context.getProperty(PROP_DEFAULT_MTU);
if (mtu != null) {
try {
return Integer.valueOf(mtu).intValue();
} catch (NumberFormatException nfe) {
// ignore
}
}
return DEFAULT_MTU;
return _context.getProperty(PROP_DEFAULT_MTU, DEFAULT_MTU);
}
/**

View File

@ -929,6 +929,10 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
}
public TransportBid bid(RouterInfo toAddress, long dataSize) {
if (dataSize > OutboundMessageState.MAX_MSG_SIZE) {
// NTCP max is lower, so msg will get dropped
return null;
}
Hash to = toAddress.getIdentity().calculateHash();
PeerState peer = getPeerState(to);
if (peer != null) {
@ -1753,7 +1757,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
buf.append(" V ");
else
buf.append(" <a href=\"").append(urlBase).append("?sort=0\">V</a> ");
buf.append("</td><td><b><a href=\"#def.idle\">idle</a></b>");
buf.append("</td><td>dir/intro</td><td><b><a href=\"#def.idle\">idle</a></b>");
appendSortLinks(buf, urlBase, sortFlags, "Sort by idle inbound", FLAG_IDLE_IN);
buf.append("/");
appendSortLinks(buf, urlBase, sortFlags, "Sort by idle outbound", FLAG_IDLE_OUT);
@ -1809,32 +1813,11 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
buf.append(name);
buf.append("\">");
buf.append(name);
/*
buf.append("@");
byte ip[] = peer.getRemoteIP();
for (int j = 0; j < ip.length; j++) {
int num = ip[j] & 0xFF;
if (num < 10)
buf.append("00");
else if (num < 100)
buf.append("0");
buf.append(num);
if (j + 1 < ip.length)
buf.append('.');
}
buf.append(':');
int port = peer.getRemotePort();
if (port < 10)
buf.append("0000");
else if (port < 100)
buf.append("000");
else if (port < 1000)
buf.append("00");
else if (port < 10000)
buf.append("0");
buf.append(port);
*/
buf.append("</a>&nbsp;");
buf.append("</a>");
//byte ip[] = peer.getRemoteIP();
//if (ip != null)
// buf.append(' ').append(_context.blocklist().toStr(ip));
buf.append("</td><td>");
if (peer.isInbound())
buf.append("in ");
else
@ -1990,8 +1973,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
numPeers++;
}
buf.append("<tr><td colspan=\"15\"><hr /></td></tr>\n");
buf.append(" <tr><td colspan=\"2\"><b>Total</b></td>");
buf.append("<tr><td colspan=\"16\"><hr /></td></tr>\n");
buf.append(" <tr><td colspan=\"3\"><b>Total</b></td>");
buf.append(" <td align=\"right\">");
buf.append(formatKBps(bpsIn)).append("/").append(formatKBps(bpsOut));
buf.append("KBps</td>");