Class ConnectionHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
org.drasyl.handler.connection.ConnectionHandler
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler, io.netty.channel.ChannelOutboundHandler

public class ConnectionHandler extends io.netty.channel.ChannelDuplexHandler
This handler provides reliable and ordered delivery of bytes between hosts. The protocol is heavily inspired by the Transmission Control Protocol (TCP), but neither implement all features nor it is compatible with it.

This handler mainly implements RFC 9293 Transmission Control Protocol (TCP), but also includes TCP Timestamps Option and RTTM Mechanism as described in RFC 7323 TCP Extensions for High Performance. Furthermore, the congestion control algorithms slow start, congestion avoidance, fast retransmit, and fast recovery as described in RFC 5681 TCP Congestion Control are implemented as well.

The Nagle algorithm is used as "Silly Window Syndrome" avoidance algorithm. To improve performance of recovering from multiple losses, the RFC 2018 TCP Selective Acknowledgment Options is used in conjunction with .

The handler can be configured to perform an active or passive OPEN process.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    ConnectionHandler(int requestedLocalPort, int remotePort)
     
    ConnectionHandler(int requestedLocalPort, int remotePort, ConnectionConfig config)
     
    ConnectionHandler(int remotePort, ConnectionConfig config)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    channelActive(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    channelInactive(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
     
    void
    channelReadComplete(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    close(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise)
     
    void
    flush(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    handlerRemoved(io.netty.channel.ChannelHandlerContext ctx)
     
    void
    read(io.netty.channel.ChannelHandlerContext ctx)
     
     
    void
    ABORT call as described in RFC 9293, Section 3.10.5.
    STATUS call as described in RFC 9293, Section 3.10.6.
    void
    write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise)
     

    Methods inherited from class io.netty.channel.ChannelDuplexHandler

    bind, connect, deregister, disconnect

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ConnectionHandler

      public ConnectionHandler(int requestedLocalPort, int remotePort, ConnectionConfig config)
    • ConnectionHandler

      public ConnectionHandler(int requestedLocalPort, int remotePort)
    • ConnectionHandler

      public ConnectionHandler(int remotePort, ConnectionConfig config)
    • ConnectionHandler

      public ConnectionHandler()
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • handlerAdded

      public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      handlerAdded in interface io.netty.channel.ChannelHandler
      Overrides:
      handlerAdded in class io.netty.channel.ChannelHandlerAdapter
    • handlerRemoved

      public void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      handlerRemoved in interface io.netty.channel.ChannelHandler
      Overrides:
      handlerRemoved in class io.netty.channel.ChannelHandlerAdapter
    • close

      public void close(io.netty.channel.ChannelHandlerContext ctx, io.netty.channel.ChannelPromise promise)
      Specified by:
      close in interface io.netty.channel.ChannelOutboundHandler
      Overrides:
      close in class io.netty.channel.ChannelDuplexHandler
    • read

      public void read(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      read in interface io.netty.channel.ChannelOutboundHandler
      Overrides:
      read in class io.netty.channel.ChannelDuplexHandler
    • write

      public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise)
      Specified by:
      write in interface io.netty.channel.ChannelOutboundHandler
      Overrides:
      write in class io.netty.channel.ChannelDuplexHandler
    • flush

      public void flush(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      flush in interface io.netty.channel.ChannelOutboundHandler
      Overrides:
      flush in class io.netty.channel.ChannelDuplexHandler
    • channelActive

      public void channelActive(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      channelActive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelActive in class io.netty.channel.ChannelInboundHandlerAdapter
    • channelInactive

      public void channelInactive(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      channelInactive in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelInactive in class io.netty.channel.ChannelInboundHandlerAdapter
    • channelRead

      public void channelRead(io.netty.channel.ChannelHandlerContext ctx, Object msg)
      Specified by:
      channelRead in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelRead in class io.netty.channel.ChannelInboundHandlerAdapter
    • channelReadComplete

      public void channelReadComplete(io.netty.channel.ChannelHandlerContext ctx)
      Specified by:
      channelReadComplete in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      channelReadComplete in class io.netty.channel.ChannelInboundHandlerAdapter
    • userCallAbort

      public void userCallAbort()
      ABORT call as described in RFC 9293, Section 3.10.5.
    • userCallStatus

      public ConnectionHandshakeStatus userCallStatus()
      STATUS call as described in RFC 9293, Section 3.10.6.