Class GoBackNArqSenderHandler
- 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 should be used together with GoBackNArqCodec
,
ByteToGoBackNArqDataCodec
and GoBackNArqSenderHandler
.
ChannelPipeline
p = ...; ... p.addLast("arq_codec", newGoBackNArqCodec
()); p.addLast("arq_snd_handler", newGoBackNArqSenderHandler
(150, Duration.ofMillis(100))); p.addLast("arg_rec_handler", newGoBackNArqReceiverHandler
(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
ConstructorDescriptionGoBackNArqSenderHandler
(int windowSize, Duration retryTimeout) Creates a new GoBackNArqHandler.GoBackNArqSenderHandler
(int windowSize, Duration retryTimeout, boolean windowShouldAffectWritability) Creates a new GoBackNArqHandler.GoBackNArqSenderHandler
(int windowSize, Duration retryTimeout, UnsignedInteger base, UnsignedInteger nextSeqNum, boolean windowShouldAffectWritability) Creates a new GoBackNArqHandler. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
channelActive, 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
-
GoBackNArqSenderHandler
public GoBackNArqSenderHandler(int windowSize, Duration retryTimeout, UnsignedInteger base, UnsignedInteger nextSeqNum, boolean windowShouldAffectWritability) 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 sendwindowShouldAffectWritability
- if the window should be added to the channels pending bytes
-
GoBackNArqSenderHandler
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 timeout
-
GoBackNArqSenderHandler
public GoBackNArqSenderHandler(int windowSize, Duration retryTimeout, boolean windowShouldAffectWritability) 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 bytes
-
-
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
-
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
-