private static void setBenchmarkConfiguration(int udp_sender, int udp_receiver, boolean verbose) { if (verbose) { Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).setLevel(Level.ALL); for (Handler h : Logger.getLogger("").getHandlers()) h.setLevel(Level.ALL); Logger.getLogger(UDPConnector.class.toString()).setLevel(Level.ALL); } else { Logger.getLogger(Logger.GLOBAL_LOGGER_NAME).setLevel(Level.SEVERE); Logger.getLogger("").setLevel(Level.SEVERE); } // Network configuration optimal for performance benchmarks NetworkConfig.createStandardWithoutFile() // Disable deduplication OR strongly reduce lifetime .setString(NetworkConfigDefaults.DEDUPLICATOR, NetworkConfigDefaults.NO_DEDUPLICATOR) .setInt(NetworkConfigDefaults.EXCHANGE_LIFECYCLE, 1500) .setInt(NetworkConfigDefaults.MARK_AND_SWEEP_INTERVAL, 2000) // Increase buffer for network interface to 10 MB .setInt(NetworkConfigDefaults.UDP_CONNECTOR_RECEIVE_BUFFER, 10 * 1024 * 1024) .setInt(NetworkConfigDefaults.UDP_CONNECTOR_SEND_BUFFER, 10 * 1024 * 1024) // Increase threads for receiving and sending packets through the socket .setInt(NetworkConfigDefaults.UDP_CONNECTOR_RECEIVER_THREAD_COUNT, udp_receiver) .setInt(NetworkConfigDefaults.UDP_CONNECTOR_SENDER_THREAD_COUNT, udp_sender) // Disable message logging .setBoolean(NetworkConfigDefaults.UDP_CONNECTOR_LOG_PACKETS, verbose); }
@Override public void run() { LOGGER.info("Scheduling validation of expired endpoint: " + getContext()); validationTimer = new Timer(); validationTimer.schedule( new ValidationTask(resource), NetworkConfig.getStandard().getInt("RD_VALIDATION_TIMEOUT") * 1000); }
/** * Updates the endpoint parameters from POST and PUT requests. * * @param request A POST or PUT request with a {?et,lt,con} URI Template query and a Link Format * payload. */ public boolean setParameters(Request request) { LinkAttribute attr; String newEndpointType = ""; int newLifeTime = NetworkConfig.getStandard().getInt("RD_DEFAULT_LIFETIME"); String newContext = ""; /* * get lifetime from option query - only for PUT request. */ List<String> query = request.getOptions().getURIQueries(); for (String q : query) { // FIXME Do not use Link attributes for URI template variables attr = LinkAttribute.parse(q); if (attr.getName().equals(LinkFormat.END_POINT_TYPE)) { newEndpointType = attr.getValue(); } if (attr.getName().equals(LinkFormat.LIFE_TIME)) { newLifeTime = attr.getIntValue(); if (newLifeTime < 60) { LOGGER.warning("Enforcing minimal RD lifetime of 60 seconds (was " + newLifeTime + ")"); newLifeTime = 60; } } if (attr.getName().equals(LinkFormat.CONTEXT)) { newContext = attr.getValue(); } } setEndpointType(newEndpointType); setLifeTime(newLifeTime); // TODO check with draft authors if update should be atomic if (newContext.equals("")) { context = "coap://" + request.getSource() + ":" + request.getSourcePort(); } else { Request checkRequest = Request.newGet(); try { checkRequest.setURI(context); } catch (Exception e) { LOGGER.warning(e.toString()); return false; } } return updateEndpointResources(request.getPayloadString()); }
public TokenLayer(NetworkConfig config) { if (config.getBoolean(NetworkConfigDefaults.USE_RANDOM_TOKEN_START)) counter = new AtomicInteger(new Random().nextInt()); else counter = new AtomicInteger(0); }