Search in sources :

Example 1 with DebugConnectionStore

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);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) DebugConnectionStore(org.eclipse.californium.scandium.dtls.DebugConnectionStore) CoapEndpoint(org.eclipse.californium.core.network.CoapEndpoint)

Example 2 with DebugConnectionStore

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;
}
Also used : AdvancedSinglePskStore(org.eclipse.californium.scandium.dtls.pskstore.AdvancedSinglePskStore) DtlsHealthLogger(org.eclipse.californium.scandium.DtlsHealthLogger) HealthStatisticLogger(org.eclipse.californium.core.network.interceptors.HealthStatisticLogger) Endpoint(org.eclipse.californium.core.network.Endpoint) CoapEndpoint(org.eclipse.californium.core.network.CoapEndpoint) DtlsConnectorConfig(org.eclipse.californium.scandium.config.DtlsConnectorConfig) DTLSConnector(org.eclipse.californium.scandium.DTLSConnector) DebugConnectionStore(org.eclipse.californium.scandium.dtls.DebugConnectionStore) CoapEndpoint(org.eclipse.californium.core.network.CoapEndpoint)

Example 3 with DebugConnectionStore

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;
    }
}
Also used : DebugConnectionStore(org.eclipse.californium.scandium.dtls.DebugConnectionStore) Endpoint(org.eclipse.californium.core.network.Endpoint) CoapEndpoint(org.eclipse.californium.core.network.CoapEndpoint)

Example 4 with DebugConnectionStore

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);
}
Also used : DtlsManagedClusterConnector(org.eclipse.californium.scandium.DtlsManagedClusterConnector) CoapServer(org.eclipse.californium.core.CoapServer) DtlsClusterHealthLogger(org.eclipse.californium.scandium.DtlsClusterHealthLogger) HealthStatisticLogger(org.eclipse.californium.core.network.interceptors.HealthStatisticLogger) Endpoint(org.eclipse.californium.core.network.Endpoint) CoapEndpoint(org.eclipse.californium.core.network.CoapEndpoint) DtlsConnectorConfig(org.eclipse.californium.scandium.config.DtlsConnectorConfig) DTLSConnector(org.eclipse.californium.scandium.DTLSConnector) NodeConnectionIdGenerator(org.eclipse.californium.scandium.dtls.NodeConnectionIdGenerator) SingleNodeConnectionIdGenerator(org.eclipse.californium.scandium.dtls.SingleNodeConnectionIdGenerator) NodeConnectionIdGenerator(org.eclipse.californium.scandium.dtls.NodeConnectionIdGenerator) ConnectionIdGenerator(org.eclipse.californium.scandium.dtls.ConnectionIdGenerator) SingleNodeConnectionIdGenerator(org.eclipse.californium.scandium.dtls.SingleNodeConnectionIdGenerator) DebugConnectionStore(org.eclipse.californium.scandium.dtls.DebugConnectionStore) CoapEndpoint(org.eclipse.californium.core.network.CoapEndpoint) DtlsClusterConnectorConfig(org.eclipse.californium.scandium.config.DtlsClusterConnectorConfig)

Example 5 with DebugConnectionStore

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;
}
Also used : DebugConnectionStore(org.eclipse.californium.scandium.dtls.DebugConnectionStore)

Aggregations

DebugConnectionStore (org.eclipse.californium.scandium.dtls.DebugConnectionStore)6 CoapEndpoint (org.eclipse.californium.core.network.CoapEndpoint)4 Endpoint (org.eclipse.californium.core.network.Endpoint)3 HealthStatisticLogger (org.eclipse.californium.core.network.interceptors.HealthStatisticLogger)2 DTLSConnector (org.eclipse.californium.scandium.DTLSConnector)2 DtlsConnectorConfig (org.eclipse.californium.scandium.config.DtlsConnectorConfig)2 InetSocketAddress (java.net.InetSocketAddress)1 CoapServer (org.eclipse.californium.core.CoapServer)1 DtlsClusterHealthLogger (org.eclipse.californium.scandium.DtlsClusterHealthLogger)1 DtlsHealthLogger (org.eclipse.californium.scandium.DtlsHealthLogger)1 DtlsManagedClusterConnector (org.eclipse.californium.scandium.DtlsManagedClusterConnector)1 DtlsClusterConnectorConfig (org.eclipse.californium.scandium.config.DtlsClusterConnectorConfig)1 ConnectionIdGenerator (org.eclipse.californium.scandium.dtls.ConnectionIdGenerator)1 NodeConnectionIdGenerator (org.eclipse.californium.scandium.dtls.NodeConnectionIdGenerator)1 SingleNodeConnectionIdGenerator (org.eclipse.californium.scandium.dtls.SingleNodeConnectionIdGenerator)1 TestInMemorySessionStore (org.eclipse.californium.scandium.dtls.TestInMemorySessionStore)1 AdvancedSinglePskStore (org.eclipse.californium.scandium.dtls.pskstore.AdvancedSinglePskStore)1