本文整理汇总了Java中org.eclipse.californium.core.network.config.NetworkConfig类的典型用法代码示例。如果您正苦于以下问题:Java NetworkConfig类的具体用法?Java NetworkConfig怎么用?Java NetworkConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NetworkConfig类属于org.eclipse.californium.core.network.config包,在下文中一共展示了NetworkConfig类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: dtlsPSKRequest
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
public static Response dtlsPSKRequest(String uri, String method, byte[] payload, int contentFormat, String pskIdentity, byte[] pskKey) throws Exception {
Request request = Utils.newRequest(method);
request.setURI(uri);
request.setPayload(payload);
request.getOptions().setContentFormat(contentFormat);
DtlsConnectorConfig.Builder builder = new DtlsConnectorConfig.Builder(new InetSocketAddress(0));
builder.setPskStore(new StaticPskStore(pskIdentity, pskKey));
builder.setSupportedCipherSuites(new CipherSuite[] {CipherSuite.TLS_PSK_WITH_AES_128_CCM_8});
DTLSConnector dtlsconnector = new DTLSConnector(builder.build(), null);
NetworkConfig nc = NetworkConfig.getStandard().setInt("COAP_SECURE_PORT", 15686);
dtlsEndpoint = new CoapEndpoint(dtlsconnector, nc);
dtlsEndpoint.start();
// execute request
request.send(dtlsEndpoint);
Response response = request.waitForResponse();
return response;
}
开发者ID:erwah,项目名称:acetest,代码行数:25,代码来源:DTLSUtils.java
示例2: createX509CertClient
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
public void createX509CertClient(PrivateKey privatekey, Certificate[] trustedCertificates) {
ObjectsInitializer initializer = new ObjectsInitializer();
// TODO security instance with certificate info
initializer.setInstancesForObject(LwM2mId.SECURITY, Security.noSec(
"coaps://" + server.getSecuredAddress().getHostString() + ":" + server.getSecuredAddress().getPort(),
12345));
initializer.setInstancesForObject(LwM2mId.SERVER, new Server(12345, LIFETIME, BindingMode.U, false));
initializer.setInstancesForObject(LwM2mId.DEVICE, new Device("Eclipse Leshan", MODEL_NUMBER, "12345", "U"));
List<LwM2mObjectEnabler> objects = initializer.createMandatory();
objects.add(initializer.create(2));
InetSocketAddress clientAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0);
DtlsConnectorConfig.Builder config = new DtlsConnectorConfig.Builder().setAddress(clientAddress);
// TODO we should read the config from the security object
config.setIdentity(privatekey, clientX509CertChain, false);
config.setTrustStore(trustedCertificates);
CoapServer coapServer = new CoapServer();
coapServer.addEndpoint(new CoapEndpoint(new DTLSConnector(config.build()), NetworkConfig.getStandard()));
LeshanClientBuilder builder = new LeshanClientBuilder(getCurrentEndpoint());
builder.setLocalAddress(clientAddress.getHostString(), clientAddress.getPort());
builder.setObjects(objects);
client = builder.build();
}
开发者ID:eclipse,项目名称:leshan,代码行数:26,代码来源:SecureIntegrationTestHelper.java
示例3: sweep
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
/**
* Iterate through all entries and remove the obsolete ones.
*/
private void sweep() {
int lifecycle = config.getInt(NetworkConfig.Keys.EXCHANGE_LIFETIME);
long oldestAllowed = System.currentTimeMillis() - lifecycle;
// Notice that the guarantees from the ConcurrentHashMap guarantee
// the correctness for this iteration.
for (Map.Entry<?,Exchange> entry:incommingMessages.entrySet()) {
Exchange exchange = entry.getValue();
if (exchange.getTimestamp() < oldestAllowed) {
//TODO check if exchange of observe relationship is periodically created and sweeped
LOGGER.finer("Mark-And-Sweep removes "+entry.getKey());
incommingMessages.remove(entry.getKey());
}
}
}
开发者ID:iotoasis,项目名称:SI,代码行数:19,代码来源:SweepDeduplicator.java
示例4: BlockwiseLayer
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
/**
* Constructs a new blockwise layer.
* Changes to the configuration are observed and automatically applied.
* @param config the configuration
*/
public BlockwiseLayer(NetworkConfig config) {
this.config = config;
max_message_size = config.getInt(NetworkConfig.Keys.MAX_MESSAGE_SIZE);
preferred_block_size = config.getInt(NetworkConfig.Keys.PREFERRED_BLOCK_SIZE);
block_timeout = config.getInt(NetworkConfig.Keys.BLOCKWISE_STATUS_LIFETIME);
LOGGER.config("BlockwiseLayer uses MAX_MESSAGE_SIZE="+max_message_size+", DEFAULT_BLOCK_SIZE="+preferred_block_size+", and BLOCKWISE_STATUS_LIFETIME="+block_timeout);
observer = new NetworkConfigObserverAdapter() {
@Override
public void changed(String key, int value) {
if (NetworkConfig.Keys.MAX_MESSAGE_SIZE.equals(key))
max_message_size = value;
if (NetworkConfig.Keys.PREFERRED_BLOCK_SIZE.equals(key))
preferred_block_size = value;
if (NetworkConfig.Keys.BLOCKWISE_STATUS_LIFETIME.equals(key))
block_timeout = value;
}
};
config.addConfigObserver(observer);
}
开发者ID:iotoasis,项目名称:SI,代码行数:27,代码来源:BlockwiseLayer.java
示例5: CoapStack
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
public CoapStack(NetworkConfig config, Outbox outbox) {
this.top = new StackTopAdapter();
this.outbox = outbox;
ReliabilityLayer reliabilityLayer;
if (config.getBoolean(NetworkConfig.Keys.USE_CONGESTION_CONTROL) == true) {
reliabilityLayer = CongestionControlLayer.newImplementation(config);
LOGGER.config("Enabling congestion control: " + reliabilityLayer.getClass().getSimpleName());
} else {
reliabilityLayer = new ReliabilityLayer(config);
}
this.layers =
new Layer.TopDownBuilder()
.add(top)
.add(new ObserveLayer(config))
.add(new BlockwiseLayer(config))
.add(reliabilityLayer)
.add(bottom = new StackBottomAdapter())
.create();
// make sure the endpoint sets a MessageDeliverer
}
开发者ID:iotoasis,项目名称:SI,代码行数:24,代码来源:CoapStack.java
示例6: Matcher
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
public Matcher(NetworkConfig config) {
this.started = false;
this.exchangesByMID = new ConcurrentHashMap<KeyMID, Exchange>();
this.exchangesByToken = new ConcurrentHashMap<KeyToken, Exchange>();
this.ongoingExchanges = new ConcurrentHashMap<KeyUri, Exchange>();
DeduplicatorFactory factory = DeduplicatorFactory.getDeduplicatorFactory();
this.deduplicator = factory.createDeduplicator(config);
boolean randomMID = config.getBoolean(NetworkConfig.Keys.USE_RANDOM_MID_START);
if (randomMID) {
currendMID = new AtomicInteger(new Random().nextInt(1<<16));
} else {
currendMID = new AtomicInteger(0);
}
tokenSizeLimit = config.getInt(NetworkConfig.Keys.TOKEN_SIZE_LIMIT);
LOGGER.config("Matcher uses USE_RANDOM_MID_START="+randomMID+" and TOKEN_SIZE_LIMIT="+tokenSizeLimit);
healthStatusLevel = Level.parse(config.getString(NetworkConfig.Keys.HEALTH_STATUS_PRINT_LEVEL));
healthStatusInterval = config.getInt(NetworkConfig.Keys.HEALTH_STATUS_INTERVAL);
}
开发者ID:iotoasis,项目名称:SI,代码行数:24,代码来源:Matcher.java
示例7: CoAPSAuthorizationServer
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
public CoAPSAuthorizationServer() throws Exception {
add(new TokenResource());
add(new IntrospectResource());
InMemoryPskStore pskStore = new InMemoryPskStore();
pskStore.setKey(config.getPskIdentity(), config.getPskKey().getBytes());
DtlsConnectorConfig.Builder builder = new DtlsConnectorConfig.Builder(new InetSocketAddress(config.getCoapsPort()));
builder.setClientAuthenticationRequired(true);
builder.setPskStore(pskStore);
DTLSConnector connector = new DTLSConnector(builder.build(), null);
for (InetAddress addr : EndpointManager.getEndpointManager().getNetworkInterfaces()) {
// only binds to IPv4 addresses and localhost
if (addr instanceof Inet4Address || addr.isLoopbackAddress()) {
@SuppressWarnings("static-access")
CoapEndpoint endpoint = new CoapEndpoint(connector, new NetworkConfig().getStandard());
addEndpoint(endpoint);
EndpointManager.getEndpointManager().setDefaultSecureEndpoint(endpoint);
}
}
}
开发者ID:erwah,项目名称:acetest,代码行数:25,代码来源:CoAPSAuthorizationServer.java
示例8: DtlsPSKServer
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
public DtlsPSKServer() throws Exception {
add(new TemperatureResource());
DtlsConnectorConfig.Builder builder = new DtlsConnectorConfig.Builder(new InetSocketAddress(config.getCoapsPort()));
builder.setClientAuthenticationRequired(true);
// use the global in memory psk key store thats populated using the access tokens from the global config object
builder.setPskStore(config.getPskStorage());
DTLSConnector connector = new DTLSConnector(builder.build(), null);
for (InetAddress addr : EndpointManager.getEndpointManager().getNetworkInterfaces()) {
// only binds to IPv4 addresses and localhost
if (addr instanceof Inet4Address || addr.isLoopbackAddress()) {
@SuppressWarnings("static-access")
CoapEndpoint endpoint = new CoapEndpoint(connector, new NetworkConfig().getStandard());
addEndpoint(endpoint);
EndpointManager.getEndpointManager().setDefaultSecureEndpoint(endpoint);
}
}
}
开发者ID:erwah,项目名称:acetest,代码行数:24,代码来源:DtlsPSKServer.java
示例9: init
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
public List<Stage.ConfigIssue> init(Stage.Context context) {
List<Stage.ConfigIssue> issues = new ArrayList<>();
NetworkConfig networkConfig = NetworkConfig.createStandardWithoutFile();
networkConfig.set(NetworkConfig.Keys.DEDUPLICATOR, NetworkConfig.Keys.NO_DEDUPLICATOR);
networkConfig.set(NetworkConfig.Keys.PROTOCOL_STAGE_THREAD_COUNT, coAPServerConfigs.maxConcurrentRequests);
networkConfig.set(NetworkConfig.Keys.NETWORK_STAGE_RECEIVER_THREAD_COUNT, coAPServerConfigs.maxConcurrentRequests);
if (coAPServerConfigs.networkConfigs != null) {
for (String key: coAPServerConfigs.networkConfigs.keySet()) {
networkConfig.set(key, coAPServerConfigs.networkConfigs.get(key));
}
}
coapServer = new CoapServer(networkConfig, coAPServerConfigs.port);
coapReceiverResource = new CoapReceiverResource(context, receiver, errorQueue);
coapServer.add(coapReceiverResource);
coapServer.start();
return issues;
}
开发者ID:streamsets,项目名称:datacollector,代码行数:18,代码来源:CoapReceiverServer.java
示例10: setUp
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
int port = TestHttpClientTarget.getFreePort();
coapServer = new CoapServer(NetworkConfig.createStandardWithoutFile(), port);
coapServer.add(new CoapResource("test") {
@Override
public void handlePOST(CoapExchange exchange) {
serverRequested = true;
if (returnErrorResponse) {
exchange.respond(CoAP.ResponseCode.INTERNAL_SERVER_ERROR);
return;
}
requestPayload = new String(exchange.getRequestPayload());
exchange.respond(CoAP.ResponseCode.VALID);
}
});
resourceURl = "coap://localhost:" + port + "/test";
coapServer.start();
}
开发者ID:streamsets,项目名称:datacollector,代码行数:20,代码来源:TestCoapClientTarget.java
示例11: testCoapComponent
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
@Test
public void testCoapComponent() throws Exception {
NetworkConfig.createStandardWithoutFile();
String coapConsumerUri = String.format("coap://localhost:%d/hello", AvailablePortFinder.getNextAvailable());
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
fromF(coapConsumerUri)
.convertBodyTo(String.class)
.setBody(simple("Hello ${body}"));
}
});
camelctx.start();
try {
ProducerTemplate template = camelctx.createProducerTemplate();
String result = template.requestBody(coapConsumerUri + "?coapMethod=POST", "Kermit", String.class);
Assert.assertEquals("Hello Kermit", result);
} finally {
camelctx.stop();
}
}
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:26,代码来源:CoapIntegrationTest.java
示例12: addEndpoints
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
/**
* Add individual endpoints listening on default CoAP port on all ddresses of all network interfaces.
*/
private void addEndpoints() {
int coapPort = NetworkConfig.getStandard().getInt(NetworkConfig.Keys.COAP_PORT);
for (InetAddress addr : EndpointManager.getEndpointManager().getNetworkInterfaces()) {
InetSocketAddress bindToAddress = new InetSocketAddress(addr, coapPort);
addEndpoint(new CoapEndpoint(bindToAddress));
}
}
开发者ID:beduino-project,项目名称:dcaf-java,代码行数:12,代码来源:AllInterfacesCoapServer.java
示例13: createDeduplicator
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
/**
* Creates a new deduplicator according to the specified configuration.
* @param config the configuration
* @return the deduplicator
*/
public Deduplicator createDeduplicator(NetworkConfig config) {
String type = config.getString(NetworkConfig.Keys.DEDUPLICATOR);
if (NetworkConfig.Keys.DEDUPLICATOR_MARK_AND_SWEEP.equals(type)) return new SweepDeduplicator(config);
else if (NetworkConfig.Keys.DEDUPLICATOR_CROP_ROTATION.equals(type)) return new CropRotation(config);
else if (NetworkConfig.Keys.NO_DEDUPLICATOR.equals(type)) return new NoDeduplicator();
else {
LOGGER.warning("Unknown deduplicator type: " + type);
return new NoDeduplicator();
}
}
开发者ID:iotoasis,项目名称:SI,代码行数:16,代码来源:DeduplicatorFactory.java
示例14: CropRotation
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
public CropRotation(NetworkConfig config) {
this.rotation = new Rotation();
maps = new ExchangeMap[3];
maps[0] = new ExchangeMap();
maps[1] = new ExchangeMap();
maps[2] = new ExchangeMap();
first = 0;
second = 1;
period = config.getInt(NetworkConfig.Keys.CROP_ROTATION_PERIOD);
}
开发者ID:iotoasis,项目名称:SI,代码行数:11,代码来源:CropRotation.java
示例15: ReliabilityLayer
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
/**
* Constructs a new reliability layer.
* Changes to the configuration are observed and automatically applied.
* @param config the configuration
*/
public ReliabilityLayer(NetworkConfig config) {
this.config = config;
ack_timeout = config.getInt(NetworkConfig.Keys.ACK_TIMEOUT);
ack_random_factor = config.getFloat(NetworkConfig.Keys.ACK_RANDOM_FACTOR);
ack_timeout_scale = config.getFloat(NetworkConfig.Keys.ACK_TIMEOUT_SCALE);
max_retransmit = config.getInt(NetworkConfig.Keys.MAX_RETRANSMIT);
LOGGER.config("ReliabilityLayer uses ACK_TIMEOUT="+ack_timeout+", ACK_RANDOM_FACTOR="+ack_random_factor+", and ACK_TIMEOUT_SCALE="+ack_timeout_scale);
observer = new NetworkConfigObserverAdapter() {
@Override
public void changed(String key, int value) {
if (NetworkConfig.Keys.ACK_TIMEOUT.equals(key))
ack_timeout = value;
if (NetworkConfig.Keys.MAX_RETRANSMIT.equals(key))
max_retransmit = value;
}
@Override
public void changed(String key, float value) {
if (NetworkConfig.Keys.ACK_RANDOM_FACTOR.equals(key))
ack_random_factor = value;
if (NetworkConfig.Keys.ACK_TIMEOUT_SCALE.equals(key))
ack_timeout_scale = value;
}
};
config.addConfigObserver(observer);
}
开发者ID:iotoasis,项目名称:SI,代码行数:33,代码来源:ReliabilityLayer.java
示例16: CongestionControlLayer
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
/**
* Constructs a new congestion control layer.
* @param config the configuration
*/
public CongestionControlLayer(NetworkConfig config) {
super(config);
this.config = config;
this.remoteEndpointmanager = new RemoteEndpointManager(config);
setDithering(false);
}
开发者ID:iotoasis,项目名称:SI,代码行数:11,代码来源:CongestionControlLayer.java
示例17: prepareRetransmission
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
/**
* The following method overrides the method provided by the reliability layer to include the advanced RTO calculation values
* when determining the RTO.
*/
@Override
protected void prepareRetransmission(Exchange exchange, RetransmissionTask task) {
int timeout;
//System.out.println("TXCount: " + exchange.getFailedTransmissionCount());
if (exchange.getFailedTransmissionCount() == 0) {
timeout = (int)getRemoteEndpoint(exchange).getRTO();
if(appliesDithering()){
//TODO: Workaround to force CoCoA (-Strong) not to use the same RTO after backing off several times
//System.out.println("Applying dithering, matching RTO");
getRemoteEndpoint(exchange).matchCurrentRTO();
timeout = (int)getRemoteEndpoint(exchange).getRTO();
// Apply dithering by randomly choosing RTO from [RTO, RTO * 1.5]
float ack_random_factor = config.getFloat(NetworkConfig.Keys.ACK_RANDOM_FACTOR);
timeout = getRandomTimeout(timeout, (int) (timeout*ack_random_factor));
}
//System.out.println("meanrto:" + timeout + ";" + System.currentTimeMillis());
} else {
int tempTimeout= (int)(getRemoteEndpoint(exchange).getExchangeVBF(exchange) * exchange.getCurrentTimeout());
timeout = (tempTimeout < MAX_RTO) ? tempTimeout : MAX_RTO;
getRemoteEndpoint(exchange).setCurrentRTO(timeout);
//System.out.println("RTX");
}
exchange.setCurrentTimeout(timeout);
//expectedmaxduration = calculateMaxTransactionDuration(exchange); //FIXME what was this for?
//System.out.println("Sending MSG (timeout;timestamp:" + timeout + ";" + System.currentTimeMillis() + ")");
ScheduledFuture<?> f = executor.schedule(task , timeout, TimeUnit.MILLISECONDS);
exchange.setRetransmissionHandle(f);
}
开发者ID:iotoasis,项目名称:SI,代码行数:33,代码来源:CongestionControlLayer.java
示例18: newImplementation
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
public static CongestionControlLayer newImplementation(NetworkConfig config) {
final String implementation = config.getString(NetworkConfig.Keys.CONGESTION_CONTROL_ALGORITHM);
if ("Cocoa".equals(implementation)) return new Cocoa(config);
else if ("CocoaStrong".equals(implementation)) return new CocoaStrong(config);
else if ("BasicRto".equals(implementation)) return new BasicRto(config);
else if ("LinuxRto".equals(implementation)) return new LinuxRto(config);
else if ("PeakhopperRto".equals(implementation)) return new PeakhopperRto(config);
else {
LOGGER.config("Unknown CONGESTION_CONTROL_ALGORITHM (" + implementation + "), using Cocoa");
return new Cocoa(config);
}
}
开发者ID:iotoasis,项目名称:SI,代码行数:13,代码来源:CongestionControlLayer.java
示例19: calculateVBF
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
/**
* CoCoA applies a variable backoff factor (VBF) to retransmissions, depending on the RTO value of the first transmission
* of the CoAP request.
* @param rto the initial RTO
* @return the new VBF
*/
public double calculateVBF(long rto) {
if (rto > UPPERVBFLIMIT) {
return VBFHIGH;
}
if (rto < LOWERVBFLIMIT) {
return VBFLOW;
}
return config.getFloat(NetworkConfig.Keys.ACK_TIMEOUT_SCALE);
}
开发者ID:iotoasis,项目名称:SI,代码行数:16,代码来源:Cocoa.java
示例20: RemoteEndpoint
import org.eclipse.californium.core.network.config.NetworkConfig; //导入依赖的package包/类
public RemoteEndpoint(int remotePort, InetAddress remoteAddress, NetworkConfig config){
Address = remoteAddress;
Port = remotePort;
// Fill Array with initial values
overallRTO = new long[RTOARRAYSIZE];
for(int i=0; i < RTOARRAYSIZE; i++){
overallRTO[i] = config.getInt(NetworkConfig.Keys.ACK_TIMEOUT) ;
}
currentRTO = config.getInt(NetworkConfig.Keys.ACK_TIMEOUT);
xRTO = new long[3];
xRTT = new long[3];
xRTTVAR = new long[3];
RTOupdateTimestamp = new long[3];
for(int i=0; i <= 2; i++){
setEstimatorValues(config.getInt(NetworkConfig.Keys.ACK_TIMEOUT), 0, 0, i);
setRTOtimestamp(System.currentTimeMillis(), i);
}
meanOverallRTO = config.getInt(NetworkConfig.Keys.ACK_TIMEOUT);
currentArrayElement = 0;
nonConfirmableCounter = 7;
usesBlindEstimator = true;
isBlindStrong = true;
isBlindWeak = true;
processingNON = false;
exchangeInfoMap = new ConcurrentHashMap<Exchange, exchangeInfo>();
confirmableQueue = new LinkedList<Exchange>();
nonConfirmableQueue = new LinkedList<Exchange>();
}
开发者ID:iotoasis,项目名称:SI,代码行数:37,代码来源:RemoteEndpoint.java
注:本文中的org.eclipse.californium.core.network.config.NetworkConfig类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论