Changeset 855293d6
- Timestamp:
- Oct 10, 2008 5:34:25 PM (12 years ago)
- Branches:
- master
- Children:
- f3f7537
- Parents:
- 4c2d414
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
core/java/src/net/i2p/stat/StatManager.java
r4c2d414 r855293d6 54 54 "tunnel.decryptRequestTime,tunnel.fragmentedDropped,tunnel.participatingMessageCount,"+ 55 55 "tunnel.participatingTunnels,tunnel.testFailedTime,tunnel.testSuccessTime," + 56 " udp.sendPacketSize,udp.packetsRetransmitted" ;56 "tunnel.participatingBandwidth,udp.sendPacketSize,udp.packetsRetransmitted" ; 57 57 58 58 /** -
history.txt
r4c2d414 r855293d6 1 2008-10-10 zzz 2 * Profiles: Reduce reject penalty in 3 capacity calculation to avoid a congestion collapse 4 * Throttle: Change reject to BANDWIDTH from CRIT on shutdown 5 for improved anonymity 6 * Tunnels: Implement random discard to enforce share limit 7 * Tunnel Tests: Add time for outbound delay, to avoid 8 congestion collapse 9 * UDPPacketReader: Adjust logging 10 * build files: Change to source=1.5, target=1.5 11 * configpeer.jsp: Table cleanup 12 * i2psnark: Change default tunnel length from 1+1 to 2+0 13 * peers.jsp: Change <,> to in,out for UDP 14 1 15 2008-10-09 sponge 2 16 * Update version to -3 -
router/java/src/net/i2p/router/RouterVersion.java
r4c2d414 r855293d6 18 18 public final static String ID = "$Revision: 1.548 $ $Date: 2008-06-07 23:00:00 $"; 19 19 public final static String VERSION = "0.6.4"; 20 public final static long BUILD = 3;20 public final static long BUILD = 4; 21 21 public static void main(String args[]) { 22 22 System.out.println("I2P Router version: " + VERSION + "-" + BUILD); -
router/java/src/net/i2p/router/tunnel/HopConfig.java
r4c2d414 r855293d6 29 29 private long _messagesProcessed; 30 30 private long _oldMessagesProcessed; 31 private long _messagesSent; 32 private long _oldMessagesSent; 31 33 32 34 /** IV length for {@link #getReplyIV} */ … … 45 47 _messagesProcessed = 0; 46 48 _oldMessagesProcessed = 0; 49 _messagesSent = 0; 50 _oldMessagesSent = 0; 47 51 } 48 52 … … 116 120 117 121 /** take note of a message being pumped through this tunnel */ 122 /** "processed" is for incoming and "sent" is for outgoing (could be dropped in between) */ 118 123 public void incrementProcessedMessages() { _messagesProcessed++; } 119 124 public long getProcessedMessagesCount() { return _messagesProcessed; } … … 121 126 long rv = _messagesProcessed - _oldMessagesProcessed; 122 127 _oldMessagesProcessed = _messagesProcessed; 128 return rv; 129 } 130 public void incrementSentMessages() { _messagesSent++; } 131 public long getSentMessagesCount() { return _messagesSent; } 132 public long getRecentSentMessagesCount() { 133 long rv = _messagesSent - _oldMessagesSent; 134 _oldMessagesSent = _messagesSent; 123 135 return rv; 124 136 } -
router/java/src/net/i2p/router/tunnel/InboundGatewayReceiver.java
r4c2d414 r855293d6 23 23 } 24 24 public long receiveEncrypted(byte[] encrypted, boolean alreadySearched) { 25 if (!alreadySearched) 26 _config.incrementProcessedMessages(); 25 27 if (_target == null) { 26 28 _target = _context.netDb().lookupRouterInfoLocally(_config.getSendTo()); … … 34 36 } 35 37 36 _config.incrementProcessedMessages(); 38 if (_context.tunnelDispatcher().shouldDropParticipatingMessage()) 39 return -1; 40 _config.incrementSentMessages(); 37 41 TunnelDataMessage msg = new TunnelDataMessage(_context); 38 42 msg.setData(encrypted); -
router/java/src/net/i2p/router/tunnel/OutboundTunnelEndpoint.java
r4c2d414 r855293d6 42 42 + (toRouter != null ? toRouter.toBase64().substring(0,4) : "") 43 43 + (toTunnel != null ? toTunnel.getTunnelId() + "" : "")); 44 // don't drop it if we are the target 45 if ((!_context.routerHash().equals(toRouter)) && 46 _context.tunnelDispatcher().shouldDropParticipatingMessage()) 47 return; 48 _config.incrementSentMessages(); 44 49 _outDistributor.distribute(msg, toRouter, toTunnel); 45 50 } -
router/java/src/net/i2p/router/tunnel/TunnelDispatcher.java
r4c2d414 r855293d6 19 19 import net.i2p.router.Service; 20 20 import net.i2p.router.peermanager.PeerProfile; 21 import net.i2p.stat.Rate; 22 import net.i2p.stat.RateStat; 21 23 import net.i2p.util.Log; 22 24 … … 111 113 "Participating traffic", "Tunnels", 112 114 new long[] { 60*1000l, 60*10*1000l }); 115 ctx.statManager().createRateStat("tunnel.participatingBandwidthOut", 116 "Participating traffic", "Tunnels", 117 new long[] { 60*1000l, 60*10*1000l }); 118 ctx.statManager().createRateStat("tunnel.participatingMessageDropped", 119 "Dropped for exceeding share limit", "Tunnels", 120 new long[] { 60*1000l, 60*10*1000l }); 113 121 ctx.statManager().createRateStat("tunnel.participatingMessageCount", 114 122 "How many messages are sent through a participating tunnel?", "Tunnels", … … 551 559 long count = 0; 552 560 long bw = 0; 561 long bwOut = 0; 553 562 long tcount = 0; 554 563 long tooYoung = _context.clock().now() - 60*1000; … … 558 567 long c = cfg.getRecentMessagesCount(); 559 568 bw += c; 569 bwOut += cfg.getRecentSentMessagesCount(); 560 570 long created = cfg.getCreation(); 561 571 if (created > tooYoung || created < tooOld) … … 568 578 _context.statManager().addRateData("tunnel.participatingMessageCount", count, 20*1000); 569 579 _context.statManager().addRateData("tunnel.participatingBandwidth", bw*1024/20, 20*1000); 580 _context.statManager().addRateData("tunnel.participatingBandwidthOut", bwOut*1024/20, 20*1000); 570 581 _context.statManager().addRateData("tunnel.participatingTunnels", size, 0); 582 } 583 584 /** 585 * Implement random early discard (RED) to enforce the share bandwidth limit. 586 * For now, this does not enforce the available bandwidth, 587 * we leave that to Throttle. 588 * This is similar to the code in ../RouterThrottleImpl.java 589 * We drop in proportion to how far over the limit we are. 590 * Perhaps an exponential function would be better? 591 */ 592 public boolean shouldDropParticipatingMessage() { 593 RateStat rs = _context.statManager().getRate("tunnel.participatingBandwidth"); 594 if (rs == null) 595 return false; 596 Rate r = rs.getRate(60*1000); 597 if (r == null) 598 return false; 599 // weight current period higher 600 long count = r.getLastEventCount() + (3 * r.getCurrentEventCount()); 601 int bw = 0; 602 if (count > 0) 603 bw = (int) ((r.getLastTotalValue() + (3 * r.getCurrentTotalValue())) / count); 604 else 605 bw = (int) r.getLifetimeAverageValue(); 606 607 int usedIn = Math.min(_context.router().get1sRateIn(), _context.router().get15sRateIn()); 608 usedIn = Math.min(usedIn, bw); 609 if (usedIn <= 0) 610 return false; 611 int usedOut = Math.min(_context.router().get1sRate(true), _context.router().get15sRate(true)); 612 usedOut = Math.min(usedOut, bw); 613 if (usedOut <= 0) 614 return false; 615 int used = Math.min(usedIn, usedOut); 616 int maxKBps = Math.min(_context.bandwidthLimiter().getInboundKBytesPerSecond(), 617 _context.bandwidthLimiter().getOutboundKBytesPerSecond()); 618 float share = (float) _context.router().getSharePercentage(); 619 620 // start dropping at 95% of the limit 621 float maxBps = maxKBps * share * 1024f * 0.95f; 622 float pctDrop = (used - maxBps) / used; 623 if (pctDrop <= 0) 624 return false; 625 float rand = _context.random().nextFloat(); 626 boolean reject = rand <= pctDrop; 627 if (reject) { 628 if (_log.shouldLog(Log.WARN)) { 629 int availBps = (int) (((maxKBps*1024)*share) - used); 630 _log.warn("Drop part. msg. avail/max/used " + availBps + "/" + (int) maxBps + "/" 631 + used + " %Drop = " + pctDrop); 632 } 633 _context.statManager().addRateData("tunnel.participatingMessageDropped", 1, 0); 634 } 635 return reject; 571 636 } 572 637 … … 686 751 } 687 752 } 688 if (_log.shouldLog(Log. INFO)) {753 if (_log.shouldLog(Log.DEBUG)) { 689 754 long now = getContext().clock().now(); 690 _log. info("Scheduling leave in " + DataHelper.formatDuration(dropTime.longValue()-now) +": " + cfg);755 _log.debug("Scheduling leave in " + DataHelper.formatDuration(dropTime.longValue()-now) +": " + cfg); 691 756 } 692 757 } -
router/java/src/net/i2p/router/tunnel/TunnelParticipant.java
r4c2d414 r855293d6 76 76 77 77 if ( (_config != null) && (_config.getSendTo() != null) ) { 78 _config.incrementProcessedMessages(); 78 79 RouterInfo ri = _nextHopCache; 79 80 if (ri == null) … … 83 84 _log.debug("Send off to nextHop directly (" + _config.getSendTo().toBase64().substring(0,4) 84 85 + " for " + msg); 85 _config.incrementProcessedMessages();86 86 send(_config, msg, ri); 87 if (_config != null) 88 incrementThroughput(_config.getReceiveFrom()); 87 // see comments below 88 //if (_config != null) 89 // incrementThroughput(_config.getReceiveFrom()); 89 90 } else { 90 91 if (_log.shouldLog(Log.WARN)) … … 110 111 * now. 111 112 */ 113 /**** 112 114 private void incrementThroughput(Hash prev) { 113 115 if (true) return; … … 124 126 } 125 127 } 128 ****/ 126 129 127 130 public int getCompleteCount() { … … 148 151 149 152 private void send(HopConfig config, TunnelDataMessage msg, RouterInfo ri) { 153 if (_context.tunnelDispatcher().shouldDropParticipatingMessage()) 154 return; 155 _config.incrementSentMessages(); 150 156 long oldId = msg.getUniqueId(); 151 157 long newId = _context.random().nextLong(I2NPMessage.MAX_ID_VALUE);
Note: See TracChangeset
for help on using the changeset viewer.