-
Notifications
You must be signed in to change notification settings - Fork 71
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
Syncing documentation #260
Changes from all commits
6a86f50
58630ed
3cd0310
d8f8bd1
68bdf8f
c1675ac
1280d6f
74a2d4b
ce03a18
d93fc01
edf29f1
d583916
a7baf72
1d8917d
5e2add0
118ae6a
a67ddbd
67dac59
1868937
8e74dec
b0a14ab
ca89ee3
328e2a1
5f7de27
2050ac5
5c63a4e
98c0747
fce428b
78a5563
b0121dc
8acde72
364400e
7585201
3175608
f8a970e
c042b18
34df82a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,15 +8,15 @@ const DEFAULT_SEND_PACKETS_SIZE: usize = 256; | |
|
||
/// Responsible for handling the acknowledgment of packets. | ||
pub struct AcknowledgmentHandler { | ||
// Local sequence number which we'll bump each time we send a new packet over the network | ||
// Local sequence number which we'll bump each time we send a new packet over the network. | ||
sequence_number: SequenceNumber, | ||
// The last acked sequence number of the packets we've sent to the remote host. | ||
remote_ack_sequence_num: SequenceNumber, | ||
// Using a Hashmap to track every packet we send out so we can ensure that we can resend when | ||
// Using a `Hashmap` to track every packet we send out so we can ensure that we can resend when | ||
// dropped. | ||
sent_packets: HashMap<u16, SentPacket>, | ||
// However, we can only reasonably ack up to REDUNDANT_PACKET_ACKS_SIZE + 1 packets on each | ||
// message we send so this should be that large | ||
// However, we can only reasonably ack up to `REDUNDANT_PACKET_ACKS_SIZE + 1` packets on each | ||
// message we send so this should be that large. | ||
received_packets: SequenceBuffer<ReceivedPacket>, | ||
} | ||
|
||
|
@@ -31,7 +31,7 @@ impl AcknowledgmentHandler { | |
} | ||
} | ||
|
||
/// Get the current number of not yet acknowledged packets | ||
/// Returns the current number of not yet acknowledged packets | ||
pub fn packets_in_flight(&self) -> u16 { | ||
self.sent_packets.len() as u16 | ||
} | ||
|
@@ -46,14 +46,14 @@ impl AcknowledgmentHandler { | |
self.received_packets.sequence_num().wrapping_sub(1) | ||
} | ||
|
||
/// Returns the ack_bitfield corresponding to which of the past 32 packets we've | ||
/// Returns the `ack_bitfield` corresponding to which of the past 32 packets we've | ||
/// successfully received. | ||
pub fn ack_bitfield(&self) -> u32 { | ||
let most_recent_remote_seq_num: u16 = self.remote_sequence_num(); | ||
let mut ack_bitfield: u32 = 0; | ||
let mut mask: u32 = 1; | ||
|
||
// Iterate the past REDUNDANT_PACKET_ACKS_SIZE received packets and set the corresponding | ||
// iterate the past `REDUNDANT_PACKET_ACKS_SIZE` received packets and set the corresponding | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious why would wouldn't capitalize these as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because there are also very small '//' comments, and those are often not a complete sentence. I do think that either way we should do everything capitalized or with a lowercase. This PR has everything lower case. It is a matter of preference. |
||
// bit for each packet which exists in the buffer. | ||
for i in 1..=REDUNDANT_PACKET_ACKS_SIZE { | ||
let sequence = most_recent_remote_seq_num.wrapping_sub(i); | ||
|
@@ -76,18 +76,18 @@ impl AcknowledgmentHandler { | |
remote_ack_seq: u16, | ||
mut remote_ack_field: u32, | ||
) { | ||
// We must ensure that self.remote_ack_sequence_num is always increasing (with wrapping) | ||
// ensure that `self.remote_ack_sequence_num` is always increasing (with wrapping) | ||
if sequence_greater_than(remote_ack_seq, self.remote_ack_sequence_num) { | ||
self.remote_ack_sequence_num = remote_ack_seq; | ||
} | ||
|
||
self.received_packets | ||
.insert(remote_seq_num, ReceivedPacket {}); | ||
|
||
// The current remote_ack_seq was (clearly) received so we should remove it. | ||
// the current `remote_ack_seq` was (clearly) received so we should remove it | ||
self.sent_packets.remove(&remote_ack_seq); | ||
|
||
// The remote_ack_field is going to include whether or not the past 32 packets have been | ||
// The `remote_ack_field` is going to include whether or not the past 32 packets have been | ||
// received successfully. If so, we have no need to resend old packets. | ||
for i in 1..=REDUNDANT_PACKET_ACKS_SIZE { | ||
let ack_sequence = remote_ack_seq.wrapping_sub(i); | ||
|
@@ -98,7 +98,7 @@ impl AcknowledgmentHandler { | |
} | ||
} | ||
|
||
/// Enqueue the outgoing packet for acknowledgment. | ||
/// Enqueues the outgoing packet for acknowledgment. | ||
pub fn process_outgoing( | ||
&mut self, | ||
packet_type: PacketType, | ||
|
@@ -116,7 +116,7 @@ impl AcknowledgmentHandler { | |
}, | ||
); | ||
|
||
// Bump the local sequence number for the next outgoing packet. | ||
// bump the local sequence number for the next outgoing packet | ||
self.sequence_number = self.sequence_number.wrapping_add(1); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a way to enforce this? It seems awfully pedantic if we don't have a programmatic way of both performing the transform and validating it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe so. However, as noted the IntelIJ rust plugin is able to do this. So once in a while, we can run that to validate everything is ordered correctly. I have no idea how to enforce it in some way.