/** * Return an unused DH key builder * to be put back onto the queue for reuse. */ public void returnUnused(KeyPair kp) { _context.statManager().addRateData("crypto.XDHReused", 1); _keys.offer(kp); }
/** * @param name for stats */ public CoDelPriorityBlockingQueue(I2PAppContext ctx, String name, int initialCapacity) { super(ctx, name, initialCapacity); STAT_DROP = ("codel." + name + ".drop.").intern(); STAT_DELAY = ("codel." + name + ".delay").intern(); for (int i = 0; i < PRIORITIES.length; i++) { ctx.statManager().createRateStat(STAT_DROP + PRIORITIES[i], "queue delay of dropped items by priority", "Router", RATES); } ctx.statManager().createRateStat(STAT_DELAY, "average queue delay", "Router", RATES); _id = __id.incrementAndGet(); }
protected I2PSessionImpl2(I2PSessionImpl primary, InputStream destKeyStream, Properties options) throws I2PSessionException { super(primary, destKeyStream, options); _sendingStates = new ConcurrentHashMap<Long, MessageState>(32); _sendMessageNonce = new AtomicLong(); _noEffort = "none".equals(getOptions().getProperty(I2PClient.PROP_RELIABILITY, "").toLowerCase(Locale.US)); _context.statManager().createRateStat("i2cp.receiveStatusTime.1", "How long it took to get status=1 back", "i2cp", new long[] { 10*60*1000 }); _context.statManager().createRateStat("i2cp.receiveStatusTime.4", "How long it took to get status=4 back", "i2cp", new long[] { 10*60*1000 }); _context.statManager().createRateStat("i2cp.receiveStatusTime.5", "How long it took to get status=5 back", "i2cp", new long[] { 10*60*1000 }); _context.statManager().createRateStat("i2cp.tx.msgCompressed", "compressed size transferred", "i2cp", new long[] { 30*60*1000 }); _context.statManager().createRateStat("i2cp.tx.msgExpanded", "size before compression", "i2cp", new long[] { 30*60*1000 }); }
public ConnectionPacketHandler(I2PAppContext context) { _context = context; _log = context.logManager().getLog(ConnectionPacketHandler.class); _context.statManager().createRateStat("stream.con.receiveMessageSize", "Size of a message received on a connection", "Stream", new long[] { 60*1000, 10*60*1000, 60*60*1000 }); _context.statManager().createRateStat("stream.con.receiveDuplicateSize", "Size of a duplicate message received on a connection", "Stream", new long[] { 60*1000, 10*60*1000, 60*60*1000 }); _context.statManager().createRateStat("stream.con.packetsAckedPerMessageReceived", "Avg number of acks in a message", "Stream", new long[] { 60*1000, 10*60*1000, 60*60*1000 }); _context.statManager().createRateStat("stream.sendsBeforeAck", "How many times a message was sent before it was ACKed?", "Stream", new long[] { 10*60*1000, 60*60*1000 }); _context.statManager().createRateStat("stream.resetReceived", "How many messages had we sent successfully before receiving a RESET?", "Stream", new long[] { 60*60*1000, 24*60*60*1000 }); _context.statManager().createRateStat("stream.trend", "What direction the RTT is trending in (with period = windowsize)", "Stream", new long[] { 60*1000, 60*60*1000 }); _context.statManager().createRateStat("stream.con.initialRTT.in", "What is the actual RTT for the first packet of an inbound conn?", "Stream", new long[] { 10*60*1000, 60*60*1000 }); _context.statManager().createRateStat("stream.con.initialRTT.out", "What is the actual RTT for the first packet of an outbound conn?", "Stream", new long[] { 10*60*1000, 60*60*1000 }); _context.statManager().createFrequencyStat("stream.ack.dup.immediate","How often duplicate packets get acked immediately","Stream",new long[] { 10*60*1000, 60*60*1000 }); _context.statManager().createRateStat("stream.ack.dup.sent","Whether the ack for a duplicate packet was sent as scheduled","Stream",new long[] { 10*60*1000, 60*60*1000 }); }
/** @return rv[0] = Y; rv[1] = K */ public BigInteger[] getNextYK() { ctx.statManager().addRateData("crypto.YKUsed", 1); BigInteger[] rv = _values.poll(); if (rv != null) return rv; ctx.statManager().addRateData("crypto.YKEmpty", 1); return generateYK(); }
private void requestOutbound(SimpleRequest req, int bytesOut, String purpose) { // don't init twice - uncomment if we make public again? //req.init(0, bytesOut, purpose); int pending; synchronized (_pendingOutboundRequests) { pending = _pendingOutboundRequests.size(); _pendingOutboundRequests.add(req); } satisfyOutboundRequests(req.satisfiedBuffer); req.satisfiedBuffer.clear(); if (pending > 0) _context.statManager().addRateData("bwLimiter.pendingOutboundRequests", pending); }
public I2CPMessageProducer(I2PAppContext context) { _context = context; _log = context.logManager().getLog(I2CPMessageProducer.class); _lock = new ReentrantLock(true); context.statManager().createRateStat("client.sendThrottled", "Times waited for bandwidth", "ClientMessages", new long[] { 60*1000 }); context.statManager().createRateStat("client.sendDropped", "Length of msg dropped waiting for bandwidth", "ClientMessages", new long[] { 60*1000 }); }
private void setupI2PTunnelHTTPServer(String spoofHost) { _spoofHost = (spoofHost != null && spoofHost.trim().length() > 0) ? spoofHost.trim() : null; getTunnel().getContext().statManager().createRateStat("i2ptunnel.httpserver.blockingHandleTime", "how long the blocking handle takes to complete", "I2PTunnel.HTTPServer", new long[] { 60*1000, 10*60*1000, 3*60*60*1000 }); readTimeout = DEFAULT_HTTP_READ_TIMEOUT; }
/** * @param name for stats */ public CoDelBlockingQueue(I2PAppContext ctx, String name, int capacity) { super(capacity); _context = ctx; _log = ctx.logManager().getLog(CoDelBlockingQueue.class); _name = name; _capacity = capacity; STAT_DROP = ("codel." + name + ".drop").intern(); STAT_DELAY = ("codel." + name + ".delay").intern(); ctx.statManager().createRateStat(STAT_DROP, "queue delay of dropped items", "Router", RATES); ctx.statManager().createRateStat(STAT_DELAY, "average queue delay", "Router", RATES); _id = __id.incrementAndGet(); }
public AsyncFortunaStandalone(I2PAppContext context) { super(); _bufferCount = Math.max(context.getProperty("prng.buffers", DEFAULT_BUFFERS), 2); _bufferSize = Math.max(context.getProperty("prng.bufferSize", DEFAULT_BUFSIZE), 16*1024); _emptyBuffers = new LinkedBlockingQueue<AsyncBuffer>(_bufferCount); _fullBuffers = new LinkedBlockingQueue<AsyncBuffer>(_bufferCount); _context = context; context.statManager().createRequiredRateStat("prng.bufferWaitTime", "Delay for random number buffer (ms)", "Encryption", new long[] { 60*1000, 10*60*1000, 60*60*1000 } ); context.statManager().createRequiredRateStat("prng.bufferFillTime", "Time to fill random number buffer (ms)", "Encryption", new long[] { 60*1000, 10*60*1000, 60*60*1000 } ); _log = context.logManager().getLog(AsyncFortunaStandalone.class); }
public MessageHandler(I2PAppContext ctx, ConnectionManager mgr) { _manager = mgr; _context = ctx; _listeners = new CopyOnWriteArraySet<DisconnectListener>(); _log = ctx.logManager().getLog(MessageHandler.class); _context.statManager().createRateStat("stream.packetReceiveFailure", "When do we fail to decrypt or otherwise receive a packet sent to us?", "Stream", new long[] { 60*60*1000, 24*60*60*1000 }); }
public void closed() { if (_closed) return; _closed = true; long lifetime = _context.clock().now() - _started; _context.statManager().addRateData("send." + _connectionId + ".lifetime", lifetime, lifetime); try { _in.close(); } catch (IOException ioe) {} }
/** * Bounded queue with a hardcoded failsafe max size, * except when using put(), which is unbounded. */ public PriBlockingQueue(I2PAppContext ctx, String name, int initialCapacity) { super(initialCapacity, new PriorityComparator<E>()); _context = ctx; _log = ctx.logManager().getLog(PriorityBlockingQueue.class); _name = name; STAT_FULL = ("pbq." + name + ".full").intern(); ctx.statManager().createRateStat(STAT_FULL, "queue full", "Router", RATES); }
public void closed() { if (_closed) return; _closed = true; long lifetime = _context.clock().now() - _started; _context.statManager().addRateData("sink." + _connectionId + ".lifetime", lifetime, lifetime); try { _out.close(); } catch (IOException ioe) { _log.info("Error closing", ioe); } } public void received(byte data[], int offset, int len) {
public Flooder(int conId, String remDest) { _connectionId = conId; _remoteDestination = remDest; _closed = false; _outOfSync = false; _lastReceived = -1; _lastReceivedOn = _context.clock().now(); _context.statManager().createRateStat("swarm." + conId + ".totalReceived", "Data size received", "swarm", new long[] { 30*1000, 60*1000, 5*60*1000 }); _context.statManager().createRateStat("swarm." + conId + ".totalSent", "Data size sent", "swarm", new long[] { 30*1000, 60*1000, 5*60*1000 }); _context.statManager().createRateStat("swarm." + conId + ".started", "When we start", "swarm", new long[] { 5*60*1000 }); _context.statManager().createRateStat("swarm." + conId + ".lifetime", "How long we talk to a peer", "swarm", new long[] { 5*60*1000 }); }
/** * Returns false if full */ @Override public boolean offer(E o) { timestamp(o); if (size() >= MAX_SIZE) { _context.statManager().addRateData(STAT_FULL, 1); return false; } return super.offer(o); }
public void timeReached() { if (!_alive) return; long beforeExpire = _context.clock().now(); int expired = aggressiveExpire(); int overage = _inboundTagSets.size() - MAX_INBOUND_SESSION_TAGS; if (overage > 0) clearExcess(overage); long expireTime = _context.clock().now() - beforeExpire; _context.statManager().addRateData("crypto.sessionTagsExpired", expired, expireTime); _context.simpleTimer2().addEvent(this, 60*1000); } }
private ByteCache(int maxCachedEntries, int entrySize) { super(new ByteArrayFactory(entrySize), maxCachedEntries); _entrySize = entrySize; int stagger = SystemVersion.isAndroid() ? 0 : (entrySize % 777); SimpleTimer2.getInstance().addPeriodicEvent(new Cleanup(), CLEANUP_FREQUENCY + stagger); I2PAppContext.getGlobalContext().statManager().createRateStat("byteCache.memory." + entrySize, "Memory usage (B)", "Router", new long[] { 10*60*1000 }); }
public void closed() { _closed = true; long lifetime = _context.clock().now() - _started; _context.statManager().addRateData("swarm." + _connectionId + ".lifetime", lifetime, lifetime); } public void run() {
private void drop(E entry) { long delay = _context.clock().now() - entry.getEnqueueTime(); _context.statManager().addRateData(STAT_DROP, delay); if (_log.shouldLog(Log.WARN)) _log.warn("CDQ #" + _id + ' ' + _name + " dropped item with delay " + delay + ", " + DataHelper.formatDuration(_context.clock().now() - _first_above_time) + " since first above, " + DataHelper.formatDuration(_context.clock().now() - _drop_next) + " since drop next, " + (_count+1) + " dropped in this phase, " + size() + " remaining in queue: " + entry); entry.drop(); }