Changeset d9b4406


Ignore:
Timestamp:
Sep 11, 2005 3:22:51 AM (15 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
172ffd04
Parents:
8ac0e85
git-author:
jrandom <jrandom> (09/11/05 03:22:51)
git-committer:
zzz <zzz@…> (09/11/05 03:22:51)
Message:

2005-09-10 jrandom

  • Test the router's reachability earlier and more aggressively
  • Use the low level bandwidth limiter's rates for the router console, and if the router has net.i2p.router.transport.FIFOBandwidthLimiter=INFO in the logger config, keep track of the 1 second transfer rates as the stat 'bw.sendBps1s' and 'bw.recvBps1s', allowing closer monitoring of burst behavior.
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/SummaryHelper.java

    r8ac0e85 rd9b4406  
    207207            return "0.0";
    208208       
    209         RateStat receiveRate = _context.statManager().getRate("transport.receiveMessageSize");
     209        RateStat receiveRate = _context.statManager().getRate("bw.recvRate");
    210210        if (receiveRate == null) return "0.0";
    211211        Rate rate = receiveRate.getRate(60*1000);
    212         double bytes = rate.getLastTotalValue();
    213         double bps = (bytes*1000.0d)/(rate.getPeriod()*1024.0d);
    214 
    215         DecimalFormat fmt = new DecimalFormat("##0.00");
    216         return fmt.format(bps);
     212        double kbps = rate.getAverageValue()/1024;
     213        DecimalFormat fmt = new DecimalFormat("##0.00");
     214        return fmt.format(kbps);
    217215    }
    218216    /**
     
    225223            return "0.0";
    226224       
    227         RateStat receiveRate = _context.statManager().getRate("transport.sendMessageSize");
     225        RateStat receiveRate = _context.statManager().getRate("bw.sendRate");
    228226        if (receiveRate == null) return "0.0";
    229227        Rate rate = receiveRate.getRate(60*1000);
    230         double bytes = rate.getLastTotalValue();
    231         double bps = (bytes*1000.0d)/(rate.getPeriod()*1024.0d);
    232 
    233         DecimalFormat fmt = new DecimalFormat("##0.00");
    234         return fmt.format(bps);
     228        double kbps = rate.getAverageValue()/1024;
     229        DecimalFormat fmt = new DecimalFormat("##0.00");
     230        return fmt.format(kbps);
    235231    }
    236232   
     
    244240            return "0.0";
    245241       
    246         RateStat receiveRate = _context.statManager().getRate("transport.receiveMessageSize");
     242        RateStat receiveRate = _context.statManager().getRate("bw.recvBps");
    247243        if (receiveRate == null) return "0.0";
    248244        Rate rate = receiveRate.getRate(5*60*1000);
    249         double bytes = rate.getLastTotalValue();
    250         double bps = (bytes*1000.0d)/(rate.getPeriod()*1024.0d);
    251 
    252         DecimalFormat fmt = new DecimalFormat("##0.00");
    253         return fmt.format(bps);
     245        double kbps = rate.getAverageValue()/1024;
     246        DecimalFormat fmt = new DecimalFormat("##0.00");
     247        return fmt.format(kbps);
    254248    }
    255249   
     
    263257            return "0.0";
    264258       
    265         RateStat receiveRate = _context.statManager().getRate("transport.sendMessageSize");
     259        RateStat receiveRate = _context.statManager().getRate("bw.sendBps");
    266260        if (receiveRate == null) return "0.0";
    267261        Rate rate = receiveRate.getRate(5*60*1000);
    268         double bytes = rate.getLastTotalValue();
    269         double bps = (bytes*1000.0d)/(rate.getPeriod()*1024.0d);
    270 
    271         DecimalFormat fmt = new DecimalFormat("##0.00");
    272         return fmt.format(bps);
     262        double kbps = rate.getAverageValue()/1024;
     263        DecimalFormat fmt = new DecimalFormat("##0.00");
     264        return fmt.format(kbps);
    273265    }
    274266   
     
    282274            return "0.0";
    283275       
    284         long received = _context.bandwidthLimiter().getTotalAllocatedInboundBytes();
    285 
    286         DecimalFormat fmt = new DecimalFormat("##0.00");
    287 
    288         // we use the unadjusted time, since thats what getWhenStarted is based off
    289         long lifetime = _context.clock().now()-_context.clock().getOffset()
    290                         - _context.router().getWhenStarted();
    291         lifetime /= 1000;
    292         if (received > 0) {
    293             double receivedKBps = received / (lifetime*1024.0);
    294             return fmt.format(receivedKBps);
    295         } else {
    296             return "0.0";
    297         }
     276        RateStat receiveRate = _context.statManager().getRate("bw.recvBps");
     277        if (receiveRate == null) return "0.0";
     278        double kbps = receiveRate.getLifetimeAverageValue()/1024;
     279        DecimalFormat fmt = new DecimalFormat("##0.00");
     280        return fmt.format(kbps);
    298281    }
    299282   
     
    307290            return "0.0";
    308291       
    309         long sent = _context.bandwidthLimiter().getTotalAllocatedOutboundBytes();
    310 
    311         DecimalFormat fmt = new DecimalFormat("##0.00");
    312 
    313         // we use the unadjusted time, since thats what getWhenStarted is based off
    314         long lifetime = _context.clock().now()-_context.clock().getOffset()
    315                         - _context.router().getWhenStarted();
    316         lifetime /= 1000;
    317         if (sent > 0) {
    318             double sendKBps = sent / (lifetime*1024.0);
    319             return fmt.format(sendKBps);
    320         } else {
    321             return "0.0";
    322         }
     292        RateStat sendRate = _context.statManager().getRate("bw.sendBps");
     293        if (sendRate == null) return "0.0";
     294        double kbps = sendRate.getLifetimeAverageValue()/1024;
     295        DecimalFormat fmt = new DecimalFormat("##0.00");
     296        return fmt.format(kbps);
    323297    }
    324298   
  • history.txt

    r8ac0e85 rd9b4406  
    1 $Id: history.txt,v 1.242 2005/09/09 20:13:50 cervantes Exp $
     1$Id: history.txt,v 1.243 2005/09/09 23:30:37 jrandom Exp $
     2
     32005-09-10  jrandom
     4    * Test the router's reachability earlier and more aggressively
     5    * Use the low level bandwidth limiter's rates for the router console, and
     6      if the router has net.i2p.router.transport.FIFOBandwidthLimiter=INFO in
     7      the logger config, keep track of the 1 second transfer rates as the stat
     8      'bw.sendBps1s' and 'bw.recvBps1s', allowing closer monitoring of burst
     9      behavior.
    210
    3112005-09-09  jrandom
  • router/doc/udp.html

    r8ac0e85 rd9b4406  
    1 <code>$Id: udp.html,v 1.16 2005/08/17 15:05:02 jrandom Exp $</code>
     1<code>$Id: udp.html,v 1.17 2005/09/09 23:30:37 jrandom Exp $</code>
    22
    33<h1>Secure Semireliable UDP (SSU)</h1>
     
    744744
    745745<dl>
    746  <dt>A</dt>
    747  <dd>If the peer address contains the 'A' capability, that means
     746 <dt>B</dt>
     747 <dd>If the peer address contains the 'B' capability, that means
    748748     they are willing and able to participate in peer tests as
    749749     a 'Bob' or 'Charlie'.</dd>
    750  <dt>B</dt>
    751  <dd>If the peer address contains the 'B' capability, that means
     750 <dt>C</dt>
     751 <dd>If the peer address contains the 'C' capability, that means
    752752     they are willing and able to serve as an introducer - serving
    753753     as a Bob for an otherwise unreachable Alice.</dd>
  • router/java/src/net/i2p/router/RouterVersion.java

    r8ac0e85 rd9b4406  
    1616 */
    1717public class RouterVersion {
    18     public final static String ID = "$Revision: 1.229 $ $Date: 2005/09/09 20:13:49 $";
     18    public final static String ID = "$Revision: 1.230 $ $Date: 2005/09/09 23:30:36 $";
    1919    public final static String VERSION = "0.6.0.5";
    20     public final static long BUILD = 4;
     20    public final static long BUILD = 5;
    2121    public static void main(String args[]) {
    2222        System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
  • router/java/src/net/i2p/router/transport/FIFOBandwidthLimiter.java

    r8ac0e85 rd9b4406  
    2727    private FIFOBandwidthRefiller _refiller;
    2828   
     29    private long _lastTotalSent;
     30    private long _lastTotalReceived;
     31    private long _lastStatsUpdated;
     32    private long _lastRateUpdated;
     33    private float _sendBps;
     34    private float _recvBps;
     35   
    2936    private static int __id = 0;
    3037   
     
    3643        _context.statManager().createRateStat("bwLimiter.outboundDelayedTime", "How long it takes to honor an outbound request (ignoring ones with that go instantly)?", "BandwidthLimiter", new long[] { 60*1000l, 5*60*1000l, 10*60*1000l, 60*60*1000l });
    3744        _context.statManager().createRateStat("bwLimiter.inboundDelayedTime", "How long it takes to honor an inbound request (ignoring ones with that go instantly)?", "BandwidthLimiter", new long[] { 60*1000l, 5*60*1000l, 10*60*1000l, 60*60*1000l });
     45        _context.statManager().createRateStat("bw.sendRate", "Low level bandwidth send rate, averaged every minute", "BandwidthLimiter", new long[] { 60*1000l, 5*60*1000l, 10*60*1000l, 60*60*1000l });
     46        _context.statManager().createRateStat("bw.recvRate", "Low level bandwidth receive rate, averaged every minute", "BandwidthLimiter", new long[] { 60*1000l, 5*60*1000l, 10*60*1000l, 60*60*1000l });
    3847        _pendingInboundRequests = new ArrayList(16);
    3948        _pendingOutboundRequests = new ArrayList(16);
     49        _lastTotalSent = _totalAllocatedOutboundBytes;
     50        _lastTotalReceived = _totalAllocatedInboundBytes;
     51        _sendBps = 0;
     52        _recvBps = 0;
     53        _lastStatsUpdated = _context.clock().now();
     54        _lastRateUpdated = _lastStatsUpdated;
    4055        _refiller = new FIFOBandwidthRefiller(_context, this);
    4156        I2PThread t = new I2PThread(_refiller);
     
    134149        }
    135150        satisfyRequests();
     151        updateStats();
     152    }
     153   
     154    private void updateStats() {
     155        long now = _context.clock().now();
     156        long time = now - _lastStatsUpdated;
     157        if (time >= 1000) {
     158            long totS = _totalAllocatedOutboundBytes;
     159            long totR = _totalAllocatedInboundBytes;
     160            long sent = totS - _lastTotalSent;
     161            long recv = totR - _lastTotalReceived;
     162            _lastTotalSent = totS;
     163            _lastTotalReceived = totR;
     164            _lastStatsUpdated = now;
     165            if (_sendBps <= 0)
     166                _sendBps = ((float)sent*time)/1000f;
     167            else
     168                _sendBps = (0.9f)*_sendBps + (0.1f)*((float)sent*time)/1000f;
     169            if (_recvBps <= 0)
     170                _recvBps = ((float)recv*time)/1000f;
     171            else
     172                _recvBps = (0.9f)*_recvBps + (0.1f)*((float)recv*time)/1000f;
     173            if (_log.shouldLog(Log.INFO)) {
     174                _log.info("BW: time = " + time + " sent: " + sent + " recv: " + recv);
     175                _context.statManager().getStatLog().addData("bw", "bw.sendBps1s", (long)_sendBps, sent);
     176                _context.statManager().getStatLog().addData("bw", "bw.recvBps1s", (long)_recvBps, recv);
     177            }
     178        }
     179        if (60*1000 + _lastRateUpdated <= now) {
     180            _lastRateUpdated = now;
     181            _context.statManager().addRateData("bw.sendRate", (long)_sendBps, 0);
     182            _context.statManager().addRateData("bw.recvRate", (long)_recvBps, 0);
     183        }
    136184    }
    137185   
     
    155203                } else {
    156204                    // no bandwidth available
    157                     if (_log.shouldLog(Log.WARN))
    158                         _log.warn("Still denying the " + _pendingInboundRequests.size()
     205                    if (_log.shouldLog(Log.DEBUG))
     206                        _log.debug("Still denying the " + _pendingInboundRequests.size()
    159207                                  + " pending inbound requests (available "
    160208                                  + _availableInboundBytes + "/" + _availableOutboundBytes
     
    214262            satisfied.add(req);
    215263            long waited = _context.clock().now() - req.getRequestTime();
    216             if (_log.shouldLog(Log.INFO))
    217                  _log.info("Granting inbound request " + req.getRequestName() + " fully for "
     264            if (_log.shouldLog(Log.DEBUG))
     265                 _log.debug("Granting inbound request " + req.getRequestName() + " fully for "
    218266                            + req.getTotalInboundRequested() + " bytes (waited "
    219267                            + waited
     
    241289            if (req.getAborted()) {
    242290                // connection decided they dont want the data anymore
    243                 if (_log.shouldLog(Log.INFO))
    244                      _log.info("Aborting inbound request to "
     291                if (_log.shouldLog(Log.DEBUG))
     292                     _log.debug("Aborting inbound request to "
    245293                                + req.getRequestName() + " (total "
    246294                                + req.getTotalInboundRequested() + " bytes, waited "
     
    271319            satisfied.add(req);
    272320            if (req.getPendingInboundRequested() > 0) {
    273                 if (_log.shouldLog(Log.INFO))
    274                      _log.info("Allocating " + allocated + " bytes inbound as a partial grant to "
     321                if (_log.shouldLog(Log.DEBUG))
     322                     _log.debug("Allocating " + allocated + " bytes inbound as a partial grant to "
    275323                                + req.getRequestName() + " (wanted "
    276324                                + req.getTotalInboundRequested() + " bytes, waited "
     
    279327                                + ", longest waited " + locked_getLongestInboundWait() + " in");
    280328            } else {
    281                 if (_log.shouldLog(Log.INFO))
    282                      _log.info("Allocating " + allocated + " bytes inbound to finish the partial grant to "
     329                if (_log.shouldLog(Log.DEBUG))
     330                     _log.debug("Allocating " + allocated + " bytes inbound to finish the partial grant to "
    283331                                + req.getRequestName() + " (total "
    284332                                + req.getTotalInboundRequested() + " bytes, waited "
     
    305353                } else {
    306354                    // no bandwidth available
    307                     if (_log.shouldLog(Log.WARN))
    308                         _log.warn("Still denying the " + _pendingOutboundRequests.size()
     355                    if (_log.shouldLog(Log.DEBUG))
     356                        _log.debug("Still denying the " + _pendingOutboundRequests.size()
    309357                                  + " pending outbound requests (available "
    310358                                  + _availableInboundBytes + "/" + _availableOutboundBytes + " in/out, "
     
    338386            satisfied.add(req);
    339387            long waited = _context.clock().now() - req.getRequestTime();
    340             if (_log.shouldLog(Log.INFO))
    341                  _log.info("Granting outbound request " + req.getRequestName() + " fully for "
     388            if (_log.shouldLog(Log.DEBUG))
     389                 _log.debug("Granting outbound request " + req.getRequestName() + " fully for "
    342390                            + req.getTotalOutboundRequested() + " bytes (waited "
    343391                            + waited
     
    366414            if (req.getAborted()) {
    367415                // connection decided they dont want the data anymore
    368                 if (_log.shouldLog(Log.INFO))
    369                      _log.info("Aborting outbound request to "
     416                if (_log.shouldLog(Log.DEBUG))
     417                     _log.debug("Aborting outbound request to "
    370418                                + req.getRequestName() + " (total "
    371419                                + req.getTotalOutboundRequested() + " bytes, waited "
     
    396444            satisfied.add(req);
    397445            if (req.getPendingOutboundRequested() > 0) {
    398                 if (_log.shouldLog(Log.INFO))
    399                      _log.info("Allocating " + allocated + " bytes outbound as a partial grant to "
     446                if (_log.shouldLog(Log.DEBUG))
     447                     _log.debug("Allocating " + allocated + " bytes outbound as a partial grant to "
    400448                                + req.getRequestName() + " (wanted "
    401449                                + req.getTotalOutboundRequested() + " bytes, waited "
     
    404452                                + ", longest waited " + locked_getLongestOutboundWait() + " out");
    405453            } else {
    406                 if (_log.shouldLog(Log.INFO))
    407                      _log.info("Allocating " + allocated + " bytes outbound to finish the partial grant to "
     454                if (_log.shouldLog(Log.DEBUG))
     455                     _log.debug("Allocating " + allocated + " bytes outbound to finish the partial grant to "
    408456                                + req.getRequestName() + " (total "
    409457                                + req.getTotalOutboundRequested() + " bytes, waited "
  • router/java/src/net/i2p/router/transport/udp/RemoteHostId.java

    r8ac0e85 rd9b4406  
    3939    public String toString() { return toString(true); }
    4040    public String toString(boolean includePort) {
    41         StringBuffer buf = new StringBuffer(_ip.length + 5);
    42         for (int i = 0; i < _ip.length; i++) {
    43             buf.append(_ip[i]&0xFF);
    44             if (i + 1 < _ip.length)
     41        if (includePort)
     42            return toString(_ip) + ':' + _port;
     43        else
     44            return toString(_ip);
     45    }
     46    public static String toString(byte ip[]) {
     47        StringBuffer buf = new StringBuffer(ip.length+5);
     48        for (int i = 0; i < ip.length; i++) {
     49            buf.append(ip[i]&0xFF);
     50            if (i + 1 < ip.length)
    4551                buf.append('.');
    4652        }
    47         if (includePort)
    48             buf.append(':').append(_port);
    4953        return buf.toString();
    5054    }
  • router/java/src/net/i2p/router/transport/udp/UDPTransport.java

    r8ac0e85 rd9b4406  
    283283     */
    284284    void externalAddressReceived(byte ourIP[], int ourPort) {
    285         if (_log.shouldLog(Log.DEBUG))
    286             _log.debug("External address received: " + Base64.encode(ourIP) + ":" + ourPort);
     285        if (_log.shouldLog(Log.INFO))
     286            _log.info("External address received: " + RemoteHostId.toString(ourIP) + ":" + ourPort);
    287287       
    288288        if (explicitAddressSpecified())
     
    295295            if ( (_externalListenHost == null) ||
    296296                 (!eq(_externalListenHost.getAddress(), _externalListenPort, ourIP, ourPort)) ) {
    297                 if ( (_reachabilityStatus != CommSystemFacade.STATUS_OK) ||
     297                if ( (_reachabilityStatus == CommSystemFacade.STATUS_UNKNOWN) ||
    298298                     (_context.clock().now() - _reachabilityStatusLastUpdated > 2*TEST_FREQUENCY) ) {
    299299                    // they told us something different and our tests are either old or failing
     
    516516        if (introducersRequired() && (_introducersSelectedOn < _context.clock().now() - 10*60*1000))
    517517            rebuildExternalAddress();
     518       
     519        if (getReachabilityStatus() != CommSystemFacade.STATUS_OK) {
     520            _testEvent.forceRun();
     521            SimpleTimer.getInstance().addEvent(_testEvent, 0);
     522        }
    518523        return true;
    519524    }
     
    12411246            }
    12421247            _lastTested = _context.clock().now();
    1243         }
    1244        
    1245         private void forceRun() { _forceRun = true; }
     1248            _forceRun = false;
     1249        }
     1250       
     1251        void forceRun() { _forceRun = true; }
    12461252       
    12471253        public void setIsAlive(boolean isAlive) {
Note: See TracChangeset for help on using the changeset viewer.