Package org.drasyl.handler.arq.gobackn
Interface Window
- All Known Implementing Classes:
SimpleWindow
public interface Window
This class does model a sliding window in the Go-Back-N ARQ protocol.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(GoBackNArqData msg, io.netty.channel.ChannelPromise promise) Adds the given msg to the window, if there is enough capacity.intgetQueue()io.netty.channel.ChannelPromiseremove()Removes the oldest message from the window.voidremoveAndFailAll(Throwable cause) Clears the window and let's fail all write promises.intsize()
-
Method Details
-
add
Adds the given msg to the window, if there is enough capacity.- Parameters:
msg- the message to addpromise- the write promise- Returns:
true, if the message could be added,falseif the window has no capacity
-
remove
io.netty.channel.ChannelPromise remove()Removes the oldest message from the window.- Returns:
- the write promise of the oldest message
-
getQueue
List<Window.Frame> getQueue()- Returns:
- the original unacknowledged message queue
-
size
int size()- Returns:
- the size of the window
-
getFreeSpace
int getFreeSpace()- Returns:
- the free space of the window
-
removeAndFailAll
Clears the window and let's fail all write promises.- Parameters:
cause- the cause of the failure
-