Class QUICBabelChannel
- All Implemented Interfaces:
BabelChannel, IPBabelChannel
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:
- A call to
connect(BabelNode)resolves peer address components viaNodeStore, creates an outbound QUIC channel, and opens a bidirectional stream for the handshake (QUICHandshakeHandler). - After handshake completion,
addConnection(BabelNode, QuicChannel)registers aQUICConnectionand delivers aConnectionUpEventto the Babel runtime. - Outbound application messages are multiplexed across unidirectional QUIC
streams
dedicated to each
BabelProtocoland decoded byQUICBabelCodecon the receiving side. - A 20-second write-idle timeout is maintained using Netty's
IdleStateHandler; upon expiry aKeepAliveMessageis sent to prevent the 60-second QUIC idle timeout from closing the session. - Simultaneous connections from both sides are resolved deterministically
using a
ComparatoroverBabelNode.
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final longDefault delay before delivering a connection up event to allow state settling.static final TimeUnitDefault time unit forDEFAULT_CONNECTION_UP_DELAY.static final io.netty.util.AttributeKey<BabelNode> Netty attribute key storing the targetBabelNodeon client channels during connection setup. -
Method Summary
Modifier and TypeMethodDescriptionstatic QUICBabelChannelBuilderbuilder()Creates a new, unconfiguredQUICBabelChannelBuilder.voidInitiates a connection to the specified peer.voiddisconnect(BabelNode peer) Closes the connection topeer.Returns the local IP socket address to which this channel is bound.booleanisConnected(BabelNode peer) Returnstrueif a connection topeeris currently open on this channel.voidsend(BabelNode peer, BabelMessage message) Sends a message through this channel to the given peer using a persistent connection.voidsendEphemeral(BabelNode peer, BabelMessage message) Sends a message topeerwithout establishing a persistent connection.voidshutdown()Releases all resources held by this channel, closing any open connections.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BabelChannel
getInnerModifier and TypeMethodDescriptiondefault BabelChannelgetInner()Gets this channel or returns the inner channel if this instance is a wrapper.
-
Field Details
-
EXPECTED_PEER
-
DEFAULT_CONNECTION_UP_DELAY
public static final long DEFAULT_CONNECTION_UP_DELAYDefault delay before delivering a connection up event to allow state settling.- See Also:
-
DEFAULT_CONNECTION_UP_DELAY_UNIT
Default time unit forDEFAULT_CONNECTION_UP_DELAY.
-
-
Method Details
-
connect
Initiates a connection to the specified peer.If connecting to the local node (
myself), loopback connection state is set and aConnectionUpEventis delivered directly. Otherwise, candidate addresses are resolved through the node store and attempted sequentially.- Specified by:
connectin interfaceBabelChannel- Parameters:
peer- the peer node to connect to
-
send
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:
sendin interfaceBabelChannel- Parameters:
peer- the recipient peermessage- the message to transmit- Throws:
UnsupportedOperationException- always, because a protocol context is required
-
sendEphemeral
Sends a message topeerwithout 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:
sendEphemeralin interfaceBabelChannel- Parameters:
peer- the recipient peermessage- the message to transmit- Throws:
UnsupportedOperationException- always, as ephemeral sends are not supported in QUIC
-
disconnect
Closes the connection topeer. AConnectionDownEventwill 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:
disconnectin interfaceBabelChannel- Parameters:
peer- the peer node to disconnect
-
isConnected
Returnstrueif a connection topeeris currently open on this channel.Returns whether an active connection to the specified peer currently exists.
- Specified by:
isConnectedin interfaceBabelChannel- Parameters:
peer- the peer node to check- Returns:
trueif connected,falseotherwise
-
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:
shutdownin interfaceBabelChannel
-
builder
Creates a new, unconfiguredQUICBabelChannelBuilder.- Returns:
- a new builder instance
-
getBindingAddress
Description copied from interface:IPBabelChannelReturns the local IP socket address to which this channel is bound.- Specified by:
getBindingAddressin interfaceIPBabelChannel- Returns:
- the local binding
InetSocketAddress
-