Class UdpChannel

java.lang.Object
io.aeron.driver.media.UdpChannel

public final class UdpChannel extends Object
The media configuration for Aeron UDP channels as an instantiation of the socket addresses for a ChannelUri.
See Also:
  • Field Details

    • RESERVED_VALUE_MESSAGE_OFFSET

      public static final int RESERVED_VALUE_MESSAGE_OFFSET
      The offset from the beginning of a payload where the reserved value begins.
      See Also:
  • Method Details

    • parse

      public static UdpChannel parse(String channelUriString)
      Parse channel URI and create a UdpChannel using the default name resolver.
      Parameters:
      channelUriString - to parse.
      Returns:
      a new UdpChannel as the result of parsing.
      Throws:
      InvalidChannelException - if an error occurs.
    • parse

      public static UdpChannel parse(String channelUriString, NameResolver nameResolver)
      Parse channel URI and create a UdpChannel.
      Parameters:
      channelUriString - to parse.
      nameResolver - to use for resolving names.
      Returns:
      a new UdpChannel as the result of parsing.
      Throws:
      InvalidChannelException - if an error occurs.
    • parse

      public static UdpChannel parse(String channelUriString, NameResolver nameResolver, boolean isDestination)
      Parse channel URI and create a UdpChannel.
      Parameters:
      channelUriString - to parse.
      nameResolver - to use for resolving names.
      isDestination - to identify if it is a destination within a channel.
      Returns:
      a new UdpChannel as the result of parsing.
      Throws:
      InvalidChannelException - if an error occurs.
    • parseBufferLength

      public static int parseBufferLength(ChannelUri channelUri, String paramName)
      Parse a buffer length for a given URI paramName with a format specified by SystemUtil.parseSize(String, String), clamping the range to 0 <= x <= Integer.MAX_VALUE.
      Parameters:
      channelUri - to get the value from.
      paramName - key for the parameter.
      Returns:
      value as an integer.
      See Also:
    • parseControlMode

      public static ControlMode parseControlMode(ChannelUri channelUri)
      Parse the control mode from the channel URI. If the value is null or unknown then ControlMode.NONE will be used.
      Parameters:
      channelUri - to parse the control mode from.
      Returns:
      an enum value representing the control mode.
    • parseOptionalDurationNs

      public static Long parseOptionalDurationNs(ChannelUri channelUri, String paramName)
      Parses out a duration from a channel URI and caters for unit suffix information.
      Parameters:
      channelUri - to read the value from
      paramName - specific field to access in the URI
      Returns:
      duration in nanoseconds, null if not present
    • canonicalise

      public static String canonicalise(String localParamValue, InetSocketAddress localData, String remoteParamValue, InetSocketAddress remoteData)
      Return a string which is a canonical form of the channel suitable for use as a file or directory name and also as a method of hashing, etc.

      The general format is: UDP-interface:localPort-remoteAddress:remotePort

      Parameters:
      localParamValue - interface or MDC control param value or null for not set.
      localData - address/interface for the channel.
      remoteParamValue - endpoint param value or null if not set.
      remoteData - address for the channel.
      Returns:
      canonical representation as a string.
    • remoteData

      public InetSocketAddress remoteData()
      Remote data address and port.
      Returns:
      remote data address and port.
    • localData

      public InetSocketAddress localData()
      Local data address and port.
      Returns:
      local data address port.
    • remoteControl

      public InetSocketAddress remoteControl()
      Remote control address information.
      Returns:
      remote control address information.
    • localControl

      public InetSocketAddress localControl()
      Local control address and port.
      Returns:
      local control address and port.
    • channelUri

      public ChannelUri channelUri()
      Get the ChannelUri for this channel.
      Returns:
      the ChannelUri for this channel.
    • hasMulticastTtl

      public boolean hasMulticastTtl()
      Has this channel got a multicast TTL value set so that multicastTtl() is valid.
      Returns:
      true if this channel is a multicast TTL set otherwise false.
    • multicastTtl

      public int multicastTtl()
      Multicast TTL value.
      Returns:
      multicast TTL value.
    • canonicalForm

      public String canonicalForm()
      The canonical form for the channel.
      Returns:
      canonical form for channel.
      See Also:
    • toString

      public String toString()
      The canonicalForm() for the channel.
      Overrides:
      toString in class Object
      Returns:
      the canonicalForm() for the channel.
    • isMulticast

      public boolean isMulticast()
      Is the channel UDP multicast.
      Returns:
      true if the channel is UDP multicast.
    • localInterface

      public NetworkInterface localInterface()
      Local interface to be used by the channel.
      Returns:
      NetworkInterface for the local interface used by the channel.
    • originalUriString

      public String originalUriString()
      Original URI of the channel URI.
      Returns:
      the original uri string from the client.
    • protocolFamily

      public ProtocolFamily protocolFamily()
      Get the ProtocolFamily for this channel.
      Returns:
      the ProtocolFamily for this channel.
    • tag

      public long tag()
      Get the tag value on the channel which is only valid if hasTag() is true.
      Returns:
      the tag value on the channel.
    • controlMode

      public ControlMode controlMode()
      The channel's control mode.
      Returns:
      the control mode for the channel.
    • isManualControlMode

      public boolean isManualControlMode()
      Does the channel have manual control mode specified.
      Returns:
      does channel have manual control mode specified.
    • isDynamicControlMode

      public boolean isDynamicControlMode()
      Does the channel have dynamic control mode specified.
      Returns:
      does channel have dynamic control mode specified.
    • isResponseControlMode

      public boolean isResponseControlMode()
      Does the channel have response control mode specified.
      Returns:
      does the channel have response control mode specified.
    • hasExplicitEndpoint

      public boolean hasExplicitEndpoint()
      Does the channel have an explicit endpoint address?
      Returns:
      does channel have an explicit endpoint address or not?
    • hasExplicitControl

      public boolean hasExplicitControl()
      Does the channel have an explicit control address as used with multi-destination-cast or not?
      Returns:
      does channel have an explicit control address or not?
    • hasTag

      public boolean hasTag()
      Has the URI a tag to indicate entity relationships and if tag() is valid.
      Returns:
      true if the channel has a tag.
    • isMultiDestination

      public boolean isMultiDestination()
      Is the channel configured as multi-destination.
      Returns:
      true if the channel configured as multi-destination.
    • hasGroupSemantics

      public boolean hasGroupSemantics()
      Does the channel have group semantics (multicast or MDC).
      Returns:
      true if the channel has group semantics.
    • socketRcvbufLength

      public int socketRcvbufLength()
      Get the socket receive buffer length.
      Returns:
      socket receive buffer length or 0 if not specified.
    • socketRcvbufLengthOrDefault

      public int socketRcvbufLengthOrDefault(int defaultValue)
      Get the socket receive buffer length.
      Parameters:
      defaultValue - to be used if the UdpChannel's value is 0 (unspecified).
      Returns:
      socket receive buffer length or 0 if not specified.
    • socketSndbufLength

      public int socketSndbufLength()
      Get the socket send buffer length.
      Returns:
      socket send buffer length or 0 if not specified.
    • socketSndbufLengthOrDefault

      public int socketSndbufLengthOrDefault(int defaultValue)
      Get the socket send buffer length.
      Parameters:
      defaultValue - to be used if the UdpChannel's value is 0 (unspecified).
      Returns:
      socket send buffer length or defaultValue if not specified.
    • receiverWindowLength

      public int receiverWindowLength()
      Get the receiver window length used as the initial window length for congestion control.
      Returns:
      receiver window length or 0 if not specified.
    • receiverWindowLengthOrDefault

      public int receiverWindowLengthOrDefault(int defaultValue)
      Get the receiver window length used as the initial window length for congestion control.
      Parameters:
      defaultValue - to be used if the UdpChannel's value is 0 (unspecified).
      Returns:
      receiver window length or defaultValue if not specified.
    • nakDelayNs

      public Long nakDelayNs()
      The length of the initial nak delay to be used by the LossDetector on this channel.
      Returns:
      delay in nanoseconds or null if the value is not set.
    • matchesTag

      public boolean matchesTag(UdpChannel udpChannel, InetSocketAddress localAddress, InetSocketAddress remoteAddress)
      Does this channel have a tag match to another channel having INADDR_ANY endpoints.
      Parameters:
      udpChannel - to match against.
      localAddress - local address override to use for this channel.
      remoteAddress - remote address override to use for this channel.
      Returns:
      true if there is a match otherwise false.
    • description

      public String description()
      Used for debugging to get a human-readable description of the channel.
      Returns:
      a human-readable description of the channel.
    • equals

      public boolean equals(Object o)
      Channels are considered equal if the canonicalForm() is equal.
      Overrides:
      equals in class Object
      Parameters:
      o - object to be compared with.
      Returns:
      true if the canonicalForm() is equal, otherwise false.
    • hashCode

      public int hashCode()
      The hash code for the canonicalForm().
      Overrides:
      hashCode in class Object
      Returns:
      the hash code for the canonicalForm().
    • destinationAddress

      public static InetSocketAddress destinationAddress(ChannelUri uri, NameResolver nameResolver)
      Get the endpoint destination address from the URI.
      Parameters:
      uri - to check.
      nameResolver - to use for resolution.
      Returns:
      endpoint address for URI.
    • isMulticastDestinationAddress

      public static boolean isMulticastDestinationAddress(ChannelUri uri)
      Check if the address pointed to by the endpoint is multicast.
      Parameters:
      uri - to check.
      Returns:
      true if the destination uses multicast address.
      Since:
      1.44.0
    • isMulticastEndpoint

      public static boolean isMulticastEndpoint(String endpoint)
      Check if the endpoint is multicast.
      Parameters:
      endpoint - to check.
      Returns:
      true if the destination uses multicast address.
      Since:
      1.47.0
    • resolve

      public static InetSocketAddress resolve(String endpoint, String uriParamName, boolean isReResolution, NameResolver nameResolver)
      Resolve and endpoint into a InetSocketAddress.
      Parameters:
      endpoint - to resolve.
      uriParamName - for the resolution.
      isReResolution - for the resolution.
      nameResolver - to be used for hostname.
      Returns:
      address for endpoint.
    • channelReceiveTimestampOffset

      public int channelReceiveTimestampOffset()
      Offset to store the channel receive timestamp in a user message.
      Returns:
      offset of channel receive timestamps.
    • isChannelReceiveTimestampEnabled

      public boolean isChannelReceiveTimestampEnabled()
      Check if channel receive timestamps should be recorded.
      Returns:
      true if channel receive timestamps should be collected false otherwise.
    • isChannelSendTimestampEnabled

      public boolean isChannelSendTimestampEnabled()
      Check if channel send timestamps should be recorded.
      Returns:
      true if channel send timestamps should be collected false otherwise.
    • channelSendTimestampOffset

      public int channelSendTimestampOffset()
      Offset to store the channel send timestamp in a user message.
      Returns:
      offset of channel send timestamps.
    • groupTag

      public Long groupTag()
      Group tag specified for this channel or null if not specified.
      Returns:
      group tag for the channel