Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/socket/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,50 @@ impl<'a> Socket<'a> {
self.nagle
}

pub fn remote_mss(&self) -> usize {
self.remote_mss
}

pub fn remote_win_len(&self) -> usize {
self.remote_win_len
}

pub fn remote_win_scale(&self) -> Option<u8> {
self.remote_win_scale
}

pub fn rtt(&self) -> u32 {
self.rtte.rtt
}

pub fn rtt_var(&self) -> u32 {
self.rtte.deviation
}

pub fn rto(&self) -> Duration {
self.rtte.retransmission_timeout()
}

pub fn retransmits(&self) -> u8 {
self.rtte.rto_count
}

pub fn cwnd(&self) -> usize {
self.congestion_controller.cwnd()
}

pub fn ssthresh(&self) -> usize {
self.congestion_controller.ssthresh()
}

pub fn local_seq_no(&self) -> TcpSeqNumber {
self.local_seq_no
}

pub fn remote_last_ack(&self) -> Option<TcpSeqNumber> {
self.remote_last_ack
}

/// Return the current window field value, including scaling according to RFC 1323.
///
/// Used in internal calculations as well as packet generation.
Expand Down
16 changes: 16 additions & 0 deletions src/socket/tcp/congestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ pub(super) trait Controller {

/// Set the maximum segment size.
fn set_mss(&mut self, mss: usize) {}

/// Returns the current congestion window size.
fn cwnd(&self) -> usize;

/// Returns the current slow start threshold.
fn ssthresh(&self) -> usize;
}

#[derive(Debug)]
Expand Down Expand Up @@ -73,6 +79,16 @@ impl AnyController {
AnyController::None(no_control::NoControl)
}

#[inline]
pub fn cwnd(&self) -> usize {
self.inner().cwnd()
}

#[inline]
pub fn ssthresh(&self) -> usize {
self.inner().ssthresh()
}

#[inline]
pub fn inner_mut(&mut self) -> &mut dyn Controller {
match self {
Expand Down
8 changes: 8 additions & 0 deletions src/socket/tcp/congestion/cubic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ impl Controller for Cubic {
self.cwnd
}

fn cwnd(&self) -> usize {
self.cwnd
}

fn ssthresh(&self) -> usize {
self.ssthresh
}

fn on_retransmit(&mut self, now: Instant) {
self.w_max = self.cwnd;
self.ssthresh = self.cwnd >> 1;
Expand Down
8 changes: 8 additions & 0 deletions src/socket/tcp/congestion/no_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@ impl Controller for NoControl {
fn window(&self) -> usize {
usize::MAX
}

fn cwnd(&self) -> usize {
0
}

fn ssthresh(&self) -> usize {
usize::MAX
}
}
8 changes: 8 additions & 0 deletions src/socket/tcp/congestion/reno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ impl Controller for Reno {
self.ssthresh = (self.cwnd >> 1).max(self.min_cwnd);
}

fn cwnd(&self) -> usize {
self.cwnd
}

fn ssthresh(&self) -> usize {
self.ssthresh
}

fn on_retransmit(&mut self, _now: Instant) {
self.cwnd = (self.cwnd >> 1).max(self.min_cwnd);
}
Expand Down
Loading