Class GoBackNArqHandler
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
,io.netty.channel.ChannelOutboundHandler
It also updates the writability of the associated Channel
. This update allows pending write operations to determine the writability.
This handler changes the behavior of the Promise
s returned by
ChannelOutboundInvoker.write(Object)
: The promise is not complemented
until the message's recipient has acknowledged arrival of the message.
If you abort the promise, this handler will discard the message. Aborting a promise for a message that is waiting to be acknowledged can cause the sender and receiver to no longer have the same message sequence. This occurs when the acknowledgement of a message is lost and the promise of that message was manually aborted.
This handler tries to automatically synchronize the sequence numbers.
This handler should be used together with GoBackNArqCodec
and ByteToGoBackNArqDataCodec
.
ChannelPipeline
p = ...; ... p.addLast("arq_codec", newGoBackNArqCodec
()); p.addLast("arq_handler", newGoBackNArqHandler
(150, Duration.ofMillis(100), Duration.ofMills(100).dividedBy(10))); p.addLast("buf_codec", newByteToGoBackNArqDataCodec
()); ... p.addLast("handler", new HttpRequestHandler());
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable
-
Constructor Summary
ConstructorDescriptionGoBackNArqHandler
(int windowSize, Duration retryTimeout, boolean windowShouldAffectWritability, Duration ackClock) Creates a new GoBackNArqHandler.GoBackNArqHandler
(int windowSize, Duration retryTimeout, Duration ackClock) Creates a new GoBackNArqHandler.GoBackNArqHandler
(int windowSize, Duration retryTimeout, UnsignedInteger base, UnsignedInteger nextSeqNum, UnsignedInteger nextInboundSequenceNo, boolean windowShouldAffectWritability, Duration ackClock) Creates a new GoBackNArqHandler. -
Method Summary
Modifier and TypeMethodDescriptionvoid
channelActive
(io.netty.channel.ChannelHandlerContext ctx) void
channelInactive
(io.netty.channel.ChannelHandlerContext ctx) void
channelRead
(io.netty.channel.ChannelHandlerContext ctx, Object msg) void
handlerAdded
(io.netty.channel.ChannelHandlerContext ctx) void
write
(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, read
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerRemoved, isSharable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.netty.channel.ChannelHandler
handlerRemoved
-
Constructor Details
-
GoBackNArqHandler
public GoBackNArqHandler(int windowSize, Duration retryTimeout, UnsignedInteger base, UnsignedInteger nextSeqNum, UnsignedInteger nextInboundSequenceNo, boolean windowShouldAffectWritability, Duration ackClock) Creates a new GoBackNArqHandler.When specifying the window size, you should take the MTU in bytes, the maximum link capacity (LC) in bytes, and the RTT in ms into account. For example, a good window size could be (LC * RTT) / (MTU * 2000).
The retry timeout should be at least twice as large as the time needed to transfer a single frame.
- Parameters:
windowSize
- the window sizeretryTimeout
- the retry timeoutbase
- the first unacknowledged sequence numbernextSeqNum
- the next sequence number, that was not already sendnextInboundSequenceNo
- the next expected inbound sequence numberwindowShouldAffectWritability
- if the window should be added to the channels pending bytesackClock
- the frequency of sending ACKs for received packages
-
GoBackNArqHandler
Creates a new GoBackNArqHandler.When specifying the window size, you should take the MTU, the maximum link capacity (LC), and the RTT into account. For example, a good window size could be (LC*RTT) / (1000*MTU).
The retry timeout should be at least twice as large as the time needed to transfer a single window.
- Parameters:
windowSize
- the window sizeretryTimeout
- the retry timeoutackClock
- the frequency of sending ACKs for received packages
-
GoBackNArqHandler
public GoBackNArqHandler(int windowSize, Duration retryTimeout, boolean windowShouldAffectWritability, Duration ackClock) Creates a new GoBackNArqHandler.When specifying the window size, you should take the MTU, the maximum link capacity (LC), and the RTT into account. For example, a good window size could be (LC*RTT) / (1000*MTU).
The retry timeout should be at least twice as large as the time needed to transfer a single window.
- Parameters:
windowSize
- the window sizeretryTimeout
- the retry timeoutwindowShouldAffectWritability
- if the window should be added to the channels pending bytesackClock
- the frequency of sending ACKs for received packages
-
-
Method Details
-
handlerAdded
public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
handlerAdded
in interfaceio.netty.channel.ChannelHandler
- Overrides:
handlerAdded
in classio.netty.channel.ChannelHandlerAdapter
-
channelActive
- Specified by:
channelActive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelActive
in classio.netty.channel.ChannelInboundHandlerAdapter
- Throws:
Exception
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelInactive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelInactive
in classio.netty.channel.ChannelInboundHandlerAdapter
-
channelRead
- Specified by:
channelRead
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelRead
in classio.netty.channel.ChannelInboundHandlerAdapter
-
write
public void write(io.netty.channel.ChannelHandlerContext ctx, Object msg, io.netty.channel.ChannelPromise promise) - Specified by:
write
in interfaceio.netty.channel.ChannelOutboundHandler
- Overrides:
write
in classio.netty.channel.ChannelDuplexHandler
-