-
Notifications
You must be signed in to change notification settings - Fork 22
gbn+mailbox: cleanup & prefixed logger #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package gbn | ||
|
||
import "time" | ||
|
||
// config holds the configuration values for an instance of GoBackNConn. | ||
type config struct { | ||
// n is the window size. The sender can send a maximum of n packets | ||
// before requiring an ack from the receiver for the first packet in | ||
// the window. The value of n is chosen by the client during the | ||
// GoBN handshake. | ||
n uint8 | ||
|
||
// s is the maximum sequence number used to label packets. Packets | ||
// are labelled with incrementing sequence numbers modulo s. | ||
// s must be strictly larger than the window size, n. This | ||
// is so that the receiver can tell if the sender is resending the | ||
// previous window (maybe the sender did not receive the acks) or if | ||
// they are sending the next window. If s <= n then there would be | ||
// no way to tell. | ||
s uint8 | ||
|
||
// maxChunkSize is the maximum payload size in bytes allowed per | ||
// message. If the payload to be sent is larger than maxChunkSize then | ||
// the payload will be split between multiple packets. | ||
// If maxChunkSize is zero then it is disabled and data won't be split | ||
// between packets. | ||
maxChunkSize int | ||
|
||
// resendTimeout is the duration that will be waited before resending | ||
// the packets in the current queue. | ||
resendTimeout time.Duration | ||
|
||
// recvFromStream is the function that will be used to acquire the next | ||
// available packet. | ||
recvFromStream recvBytesFunc | ||
|
||
// sendToStream is the function that will be used to send over our next | ||
// packet. | ||
sendToStream sendBytesFunc | ||
|
||
// handshakeTimeout is the time after which the server or client | ||
// will abort and restart the handshake if the expected response is | ||
// not received from the peer. | ||
handshakeTimeout time.Duration | ||
|
||
pingTime time.Duration | ||
pongTime time.Duration | ||
} | ||
|
||
// newConfig constructs a new config struct. | ||
func newConfig(sendFunc sendBytesFunc, recvFunc recvBytesFunc, | ||
n uint8) *config { | ||
|
||
return &config{ | ||
n: n, | ||
s: n + 1, | ||
recvFromStream: recvFunc, | ||
sendToStream: sendFunc, | ||
resendTimeout: defaultResendTimeout, | ||
handshakeTimeout: defaultHandshakeTimeout, | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.