use of org.eclipse.californium.scandium.dtls.DebugConnectionStore in project californium by eclipse.
the class NatTestHelper method dumpClientConnections.
boolean dumpClientConnections(int id) throws InterruptedException {
DebugConnectionStore connections = clientConnections.get(id);
connections.dump();
clientStatistics.get(id).dump();
clientCoapStatistics.get(id).dump();
CoapEndpoint endpoint = clientEndpoints.get(id);
InetSocketAddress address = endpoint.getAddress();
InetSocketAddress via = nat.getLocalAddressForAddress(address);
if (via.getAddress().isAnyLocalAddress()) {
via = new InetSocketAddress(InetAddress.getLoopbackAddress(), via.getPort());
}
return dumpServerConnections(via);
}
use of org.eclipse.californium.scandium.dtls.DebugConnectionStore in project californium by eclipse.
the class NatTestHelper method createClientEndpoint.
CoapEndpoint createClientEndpoint(Integer cidLength) throws IOException {
String tag = "client";
int size = clientEndpoints.size();
if (size > 0) {
tag += "." + size;
}
DtlsHealthLogger health = new DtlsHealthLogger(tag);
this.clientStatistics.add(health);
// prepare secure client endpoint
DtlsConnectorConfig clientDtlsConfig = DtlsConnectorConfig.builder(config).set(DtlsConfig.DTLS_MAX_CONNECTIONS, 20).set(DtlsConfig.DTLS_RECEIVER_THREAD_COUNT, 2).set(DtlsConfig.DTLS_CONNECTOR_THREAD_COUNT, 2).set(DtlsConfig.DTLS_CONNECTION_ID_LENGTH, cidLength).setAddress(TestTools.LOCALHOST_EPHEMERAL).setLoggingTag(tag).setHealthHandler(health).setAsList(DtlsConfig.DTLS_CIPHER_SUITES, CipherSuite.TLS_PSK_WITH_AES_128_CCM_8).setAdvancedPskStore(new AdvancedSinglePskStore(IDENITITY + "." + size, KEY.getBytes())).build();
DebugConnectionStore clientConnectionStore = ConnectorHelper.createDebugConnectionStore(clientDtlsConfig);
DTLSConnector clientConnector = new MyDtlsConnector(clientDtlsConfig, clientConnectionStore);
clientConnector.setAlertHandler(new MyAlertHandler(clientDtlsConfig.getLoggingTag()));
CoapEndpoint.Builder builder = new CoapEndpoint.Builder();
builder.setConnector(clientConnector);
builder.setConfiguration(config);
CoapEndpoint clientEndpoint = builder.build();
HealthStatisticLogger healthLogger = new HealthStatisticLogger(tag, true);
clientCoapStatistics.add(healthLogger);
clientEndpoint.addPostProcessInterceptor(healthLogger);
clientEndpoint.start();
clientConnections.add(clientConnectionStore);
clientEndpoints.add(clientEndpoint);
return clientEndpoint;
}
use of org.eclipse.californium.scandium.dtls.DebugConnectionStore in project californium by eclipse.
the class NatTestHelper method dumpServerConnections.
boolean dumpServerConnections(InetSocketAddress address) {
int count = 0;
int index = 0;
int last = 0;
for (DebugConnectionStore store : serverConnections) {
if (store.get(address) != null) {
last = index;
++count;
}
++index;
}
if (count == 1) {
serverConnections.get(last).dump(address);
serverStatistics.get(last).dump();
serverCoapStatistics.get(last).dump();
serverConnections.get(last).dump();
return true;
} else {
for (DebugConnectionStore store : serverConnections) {
store.dump(address);
}
return false;
}
}
use of org.eclipse.californium.scandium.dtls.DebugConnectionStore in project californium by eclipse.
the class NatTestHelper method createSecureServer.
void createSecureServer(ConnectionIdGenerator... cidGenerators) throws IOException {
MyClusterNodesProvider provider = new MyClusterNodesProvider();
int count = 1;
for (ConnectionIdGenerator generator : cidGenerators) {
String tag = "server" + count;
DtlsClusterHealthLogger health = new DtlsClusterHealthLogger(tag);
this.serverStatistics.add(health);
TestUtilPskStore pskStore = new TestUtilPskStore();
pskStore.set(IDENITITY, KEY.getBytes());
pskStore.setCatchAll(true);
DtlsConnectorConfig dtlsConfig = DtlsConnectorConfig.builder(config).set(DtlsConfig.DTLS_ROLE, DtlsRole.SERVER_ONLY).set(DtlsConfig.DTLS_MAX_CONNECTIONS, 10000).set(DtlsConfig.DTLS_STALE_CONNECTION_THRESHOLD, 20, TimeUnit.SECONDS).set(DtlsConfig.DTLS_RECEIVER_THREAD_COUNT, 2).set(DtlsConfig.DTLS_CONNECTOR_THREAD_COUNT, 4).set(DtlsConfig.DTLS_VERIFY_PEERS_ON_RESUMPTION_THRESHOLD, 100).setAddress(TestTools.LOCALHOST_EPHEMERAL).setLoggingTag(tag).setHealthHandler(health).setConnectionIdGenerator(generator).setAdvancedPskStore(pskStore).build();
DebugConnectionStore serverConnectionStore = ConnectorHelper.createDebugConnectionStore(dtlsConfig);
this.serverConnections.add(serverConnectionStore);
CoapEndpoint.Builder builder = new CoapEndpoint.Builder();
if (generator instanceof NodeConnectionIdGenerator) {
DtlsClusterConnectorConfig.Builder clusterConfigBuilder = DtlsClusterConnectorConfig.builder();
clusterConfigBuilder.setAddress(TestTools.LOCALHOST_EPHEMERAL);
DtlsManagedClusterConnector serverConnector = new MyDtlsClusterConnector(dtlsConfig, clusterConfigBuilder.build(), serverConnectionStore);
serverConnector.setClusterNodesProvider(provider);
provider.add(serverConnector);
serverConnector.setAlertHandler(new MyAlertHandler(dtlsConfig.getLoggingTag()));
builder.setConnector(serverConnector);
} else {
DTLSConnector serverConnector = new MyDtlsConnector(dtlsConfig, serverConnectionStore);
serverConnector.setAlertHandler(new MyAlertHandler(dtlsConfig.getLoggingTag()));
builder.setConnector(serverConnector);
}
builder.setConfiguration(config);
CoapEndpoint serverEndpoint = builder.build();
HealthStatisticLogger healthLogger = new HealthStatisticLogger(tag, true);
serverCoapStatistics.add(healthLogger);
serverEndpoint.addPostProcessInterceptor(healthLogger);
serverEndpoints.add(serverEndpoint);
CoapServer server = new CoapServer();
server.addEndpoint(serverEndpoint);
resource = new MyResource(TARGET);
server.add(resource);
server.start();
servers.add(server);
++count;
}
createLoadBalancer();
System.out.println("coap-server " + uri);
}
use of org.eclipse.californium.scandium.dtls.DebugConnectionStore in project californium by eclipse.
the class ConnectorHelper method createDebugConnectionStore.
public static DebugConnectionStore createDebugConnectionStore(DtlsConnectorConfig configuration) {
DebugConnectionStore store = createDebugConnectionStore(configuration.getConfiguration(), configuration.getSessionStore());
store.setTag(configuration.getLoggingTag());
return store;
}
Aggregations