use of io.aeron.driver.media.UdpChannel in project Aeron by real-logic.
the class UdpChannelTest method shouldParseWithNameResolver.
@ParameterizedTest
@CsvSource({ "NAME_ENDPOINT,192.168.1.1,,,UDP-127.0.0.1:0-NAME_ENDPOINT", "localhost:41024,127.0.0.1,,,UDP-127.0.0.1:0-localhost:41024", "[fe80::5246:5dff:fe73:df06]:40456,[fe80::5246:5dff:fe73:df06],,," + "UDP-127.0.0.1:0-[fe80::5246:5dff:fe73:df06]:40456", "NAME_ENDPOINT,224.0.1.1,,,UDP-127.0.0.1:0-224.0.1.1:40124", "NAME_ENDPOINT,192.168.1.1,NAME_CONTROL,192.168.1.2,UDP-NAME_CONTROL-NAME_ENDPOINT", "NAME_ENDPOINT,224.0.1.1,NAME_CONTROL,127.0.0.1,UDP-127.0.0.1:0-224.0.1.1:40124", "192.168.1.1:40124,192.168.1.1,NAME_CONTROL,192.168.1.2,UDP-NAME_CONTROL-192.168.1.1:40124", "192.168.1.1:40124,192.168.1.1,192.168.1.2:40192,192.168.1.2,UDP-192.168.1.2:40192-192.168.1.1:40124" })
void shouldParseWithNameResolver(final String endpointName, final String endpointAddress, final String controlName, final String controlAddress, final String canonicalForm) {
final int port = 40124;
final NameResolver resolver = new NameResolver() {
public InetAddress resolve(final String name, final String uriParamName, final boolean isReResolution) {
return DefaultNameResolver.INSTANCE.resolve(name, uriParamName, isReResolution);
}
public String lookup(final String name, final String uriParamName, final boolean isReLookup) {
if (endpointName.equals(name)) {
return endpointAddress + ":" + port;
} else if (controlName.equals(name)) {
return controlAddress + ":" + port;
}
return name;
}
};
final ChannelUriStringBuilder uriBuilder = new ChannelUriStringBuilder().media("udp").networkInterface("localhost");
if (!Strings.isEmpty(endpointName)) {
uriBuilder.endpoint(endpointName);
}
if (!Strings.isEmpty(controlName)) {
uriBuilder.controlEndpoint(controlName);
}
final UdpChannel udpChannel = UdpChannel.parse(uriBuilder.build(), resolver);
assertThat(udpChannel.canonicalForm(), is(canonicalForm));
}
use of io.aeron.driver.media.UdpChannel in project Aeron by real-logic.
the class UdpChannelTest method shouldHandleImpliedLocalPortFormat.
@Test
public void shouldHandleImpliedLocalPortFormat() {
final UdpChannel udpChannel = UdpChannel.parse("aeron:udp?interface=localhost|endpoint=localhost:40124");
assertThat(udpChannel.localData(), is(new InetSocketAddress("localhost", 0)));
assertThat(udpChannel.localControl(), is(new InetSocketAddress("localhost", 0)));
assertThat(udpChannel.remoteData(), is(new InetSocketAddress("localhost", 40124)));
assertThat(udpChannel.remoteControl(), is(new InetSocketAddress("localhost", 40124)));
}
use of io.aeron.driver.media.UdpChannel in project Aeron by real-logic.
the class UdpChannelTest method shouldParseSocketRcvAndSndBufSizes.
@Test
void shouldParseSocketRcvAndSndBufSizes() {
final UdpChannel udpChannelWithBufferSizes = UdpChannel.parse("aeron:udp?endpoint=127.0.0.1:9999|so-sndbuf=4096|so-rcvbuf=8192");
assertEquals(4096, udpChannelWithBufferSizes.socketSndbufLength());
assertEquals(8192, udpChannelWithBufferSizes.socketRcvbufLength());
final UdpChannel udpChannelWithoutBufferSizes = UdpChannel.parse("aeron:udp?endpoint=127.0.0.1:9999");
assertEquals(0, udpChannelWithoutBufferSizes.socketRcvbufLength());
assertEquals(0, udpChannelWithoutBufferSizes.socketSndbufLength());
}
use of io.aeron.driver.media.UdpChannel in project Aeron by real-logic.
the class UdpChannelTest method shouldHandleCanonicalFormForMulticastCorrectlyWithAeronUri.
@ParameterizedTest
@CsvSource("endpoint,interface")
public void shouldHandleCanonicalFormForMulticastCorrectlyWithAeronUri(final String endpointKey, final String interfaceKey) {
final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "localhost"));
final UdpChannel udpChannelLocal = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "127.0.0.1"));
final UdpChannel udpChannelAllSystems = UdpChannel.parse(uri(endpointKey, "224.0.0.1:40456", interfaceKey, "127.0.0.1"));
final UdpChannel udpChannelDefault = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456"));
final UdpChannel udpChannelSubnet = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "localhost/24"));
final UdpChannel udpChannelSubnetLocal = UdpChannel.parse(uri(endpointKey, "224.0.1.1:40456", interfaceKey, "127.0.0.0/24"));
assertThat(udpChannel.canonicalForm(), is("UDP-127.0.0.1:0-224.0.1.1:40456"));
assertThat(udpChannelLocal.canonicalForm(), is("UDP-127.0.0.1:0-224.0.1.1:40456"));
assertThat(udpChannelAllSystems.canonicalForm(), is("UDP-127.0.0.1:0-224.0.0.1:40456"));
final Pattern canonicalFormPattern = Pattern.compile("UDP-127\\.0\\.0\\.[1-7]:0-224\\.0\\.1\\.1:40456");
assertThat(udpChannelSubnet.canonicalForm(), matchesPattern(canonicalFormPattern));
assertThat(udpChannelSubnetLocal.canonicalForm(), matchesPattern(canonicalFormPattern));
assertThat(udpChannelDefault.localInterface(), supportsMulticastOrIsLoopback());
}
use of io.aeron.driver.media.UdpChannel in project Aeron by real-logic.
the class UdpChannelTest method shouldHandleIPv6AnyAddressAsInterfaceAddressForUnicast.
@ParameterizedTest
@CsvSource("endpoint,interface")
public void shouldHandleIPv6AnyAddressAsInterfaceAddressForUnicast(final String endpointKey, final String interfaceKey) {
final UdpChannel udpChannel = UdpChannel.parse(uri(endpointKey, "[::1]:40124", interfaceKey, "[::]"));
assertThat(udpChannel.localData(), is(new InetSocketAddress("::", 0)));
assertThat(udpChannel.localControl(), is(new InetSocketAddress("::", 0)));
assertThat(udpChannel.remoteData(), is(new InetSocketAddress("::1", 40124)));
assertThat(udpChannel.remoteControl(), is(new InetSocketAddress("::1", 40124)));
}
Aggregations