Class QUICBabelChannel

java.lang.Object
pt.unl.fct.di.novasys.babel2.channels.quic.QUICBabelChannel
All Implemented Interfaces:
BabelChannel, IPBabelChannel

public class QUICBabelChannel extends Object implements IPBabelChannel
Babel 2 channel implementation that transports messages over QUIC streams secured with mutual TLS.

QUIC provides multiplexed, reliable, ordered delivery over a single UDP socket, combining the persistent-connection semantics of TCP with the reduced head-of-line blocking characteristic of UDP-based transports.

Connection lifecycle:

  1. A call to connect(BabelNode) resolves peer address components via NodeStore, creates an outbound QUIC channel, and opens a bidirectional stream for the handshake (QUICHandshakeHandler).
  2. After handshake completion, addConnection(BabelNode, QuicChannel) registers a QUICConnection and delivers a ConnectionUpEvent to the Babel runtime.
  3. Outbound application messages are multiplexed across unidirectional QUIC streams dedicated to each BabelProtocol and decoded by QUICBabelCodec on the receiving side.
  4. A 20-second write-idle timeout is maintained using Netty's IdleStateHandler; upon expiry a KeepAliveMessage is sent to prevent the 60-second QUIC idle timeout from closing the session.
  5. Simultaneous connections from both sides are resolved deterministically using a Comparator over BabelNode.

TLS certificates are generated using CertGenerator, embedding the node's long-term identity public key and signature into a custom X.509 extension (OID "2.25.143997576564619623049175376840488616895"). Both server and client side require mutual authentication (ClientAuth.REQUIRE).

Self-connections are short-circuited in memory without involving the network.

Use builder() to obtain a QUICBabelChannelBuilder and configure the channel before passing it to the Babel runtime.

  • Field Details

    • EXPECTED_PEER

      public static final io.netty.util.AttributeKey<BabelNode> EXPECTED_PEER
      Netty attribute key storing the target BabelNode on client channels during connection setup.
    • DEFAULT_CONNECTION_UP_DELAY

      public static final long DEFAULT_CONNECTION_UP_DELAY
      Default delay before delivering a connection up event to allow state settling.
      See Also:
    • DEFAULT_CONNECTION_UP_DELAY_UNIT

      public static final TimeUnit DEFAULT_CONNECTION_UP_DELAY_UNIT
      Default time unit for DEFAULT_CONNECTION_UP_DELAY.
  • Method Details

    • connect

      public void connect(BabelNode peer)
      Initiates a connection to the specified peer.

      If connecting to the local node (myself), loopback connection state is set and a ConnectionUpEvent is delivered directly. Otherwise, candidate addresses are resolved through the node store and attempted sequentially.

      Specified by:
      connect in interface BabelChannel
      Parameters:
      peer - the peer node to connect to
    • send

      public void send(BabelNode peer, BabelMessage message)
      Sends a message through this channel to the given peer using a persistent connection. If the connection is not currently open, the message may be queued depending on the implementation.

      Direct invocations without protocol context are not supported on this channel; messages must be sent through a QUICBabelChannelProtocolWrapper.

      Specified by:
      send in interface BabelChannel
      Parameters:
      peer - the recipient peer
      message - the message to transmit
      Throws:
      UnsupportedOperationException - always, because a protocol context is required
    • sendEphemeral

      public void sendEphemeral(BabelNode peer, BabelMessage message)
      Sends a message to peer without establishing a persistent connection. The channel implementation may use a transient transport internally, but none of the connection lifecycle events (connectionUp / connectionDown) are triggered.

      QUIC channels do not support connectionless ephemeral messaging.

      Specified by:
      sendEphemeral in interface BabelChannel
      Parameters:
      peer - the recipient peer
      message - the message to transmit
      Throws:
      UnsupportedOperationException - always, as ephemeral sends are not supported in QUIC
    • disconnect

      public void disconnect(BabelNode peer)
      Closes the connection to peer. A ConnectionDownEvent will be delivered to interested protocols after the connection has been torn down.

      Terminates the active connection to the specified peer and delivers a ConnectionDownEvent.

      Specified by:
      disconnect in interface BabelChannel
      Parameters:
      peer - the peer node to disconnect
    • isConnected

      public boolean isConnected(BabelNode peer)
      Returns true if a connection to peer is currently open on this channel.

      Returns whether an active connection to the specified peer currently exists.

      Specified by:
      isConnected in interface BabelChannel
      Parameters:
      peer - the peer node to check
      Returns:
      true if connected, false otherwise
    • shutdown

      public void shutdown()
      Releases all resources held by this channel, closing any open connections.

      Closes the server datagram channel and disconnects all active peers.

      Specified by:
      shutdown in interface BabelChannel
    • builder

      public static QUICBabelChannelBuilder builder()
      Creates a new, unconfigured QUICBabelChannelBuilder.
      Returns:
      a new builder instance
    • getBindingAddress

      public InetSocketAddress getBindingAddress()
      Description copied from interface: IPBabelChannel
      Returns the local IP socket address to which this channel is bound.
      Specified by:
      getBindingAddress in interface IPBabelChannel
      Returns:
      the local binding InetSocketAddress