-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented the ordering module for laminar. (#150)
Some changes were done to accomplish that: - Refactoring Headers. - Removing Channels. - Introducing some types for processing of packets. - Added unit tests. - Refactoring Packet processing.
- Loading branch information
Showing
39 changed files
with
2,042 additions
and
1,050 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
mod channels; | ||
mod delivery_method; | ||
mod acknowlegement; | ||
mod congestion; | ||
mod fragmenter; | ||
|
||
pub use self::channels::Channel; | ||
pub use self::channels::{ReliableChannel, SequencedChannel, UnreliableChannel}; | ||
pub use self::delivery_method::DeliveryMethod; | ||
pub mod arranging; | ||
|
||
pub use self::acknowlegement::AcknowledgementHandler; | ||
pub use self::congestion::CongestionHandler; | ||
pub use self::fragmenter::Fragmentation; |
This file contains 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,50 @@ | ||
use crate::net::{ExternalAcks, LocalAckRecord}; | ||
|
||
/// Type responsible for handling the acknowledgement of packets. | ||
pub struct AcknowledgementHandler { | ||
waiting_packets: LocalAckRecord, | ||
their_acks: ExternalAcks, | ||
pub seq_num: u16, | ||
pub dropped_packets: Vec<Box<[u8]>>, | ||
} | ||
|
||
impl AcknowledgementHandler { | ||
/// Constructs a new `AcknowledgementHandler` with which you can perform acknowledgement operations. | ||
pub fn new() -> AcknowledgementHandler { | ||
AcknowledgementHandler { | ||
seq_num: 0, | ||
waiting_packets: Default::default(), | ||
their_acks: Default::default(), | ||
dropped_packets: Vec::new(), | ||
} | ||
} | ||
} | ||
|
||
impl AcknowledgementHandler { | ||
/// Returns the bit mask that contains the packets who are acknowledged. | ||
pub fn bit_mask(&self) -> u32 { | ||
self.their_acks.field | ||
} | ||
|
||
/// Returns the last acknowledged sequence number by the other endpoint. | ||
pub fn last_seq(&self) -> u16 { | ||
self.their_acks.last_seq | ||
} | ||
|
||
/// Process the incoming sequence number. | ||
/// | ||
/// - Acknowledge the incoming sequence number | ||
/// - Update dropped packets | ||
pub fn process_incoming(&mut self, incoming_seq: u16) { | ||
self.their_acks.ack(incoming_seq); | ||
|
||
let dropped_packets = self.waiting_packets.ack(incoming_seq, self.bit_mask()); | ||
|
||
self.dropped_packets = dropped_packets.into_iter().map(|(_, p)| p).collect(); | ||
} | ||
|
||
/// Enqueue the outgoing packet for acknowledgement. | ||
pub fn process_outgoing(&mut self, payload: &[u8]) { | ||
self.waiting_packets.enqueue(self.seq_num, &payload); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.