pub struct EffectiveMss { /* private fields */ }
Expand description
Like Mss
, but smaller to account for fixed-size TCP Options.
This corresponds to the “effective send MSS” as defined in RFC 9293 section 3.7.1: Eff.snd.MSS = min(SendMSS+20, MMS_S) - TCPhdrsize - IPoptionsize where: […] * TCPhdrsize is the size of the fixed TCP header and any options.
Both Mss
and EffectiveMss
have their place in TCP. For example,
the TCP MSS option has Mss
semantics, while the MSS used to calculate
receive windows & congestion windows has EffectiveMss
semantics. When
implementing a TCP feature, refer to the feature’s RFC to determine which
MSS semantics are appropriate to use.
Note: this implementation accounts for all fixed-sized TCP Options that are
part of SegmentOptions
. SACK blocks are ignored, because they are
variable sized. Variable sized options pose a problem when calculating the
EffectiveMss
because they vary from segment to segment, whereas the
EffectiveMss
should be stable throughout the lifetime of the connection.
While, no RFC explicitly states how to account for variable sized options,
we take inspiration from Linux’s TCP implementation and choose to ignore
them until it comes time to actually calculate payload sizes for a given
segment.
Implementations§
Source§impl EffectiveMss
impl EffectiveMss
Sourcepub const fn from_mss(mss: Mss, timestamp_option_enabled: bool) -> Self
pub const fn from_mss(mss: Mss, timestamp_option_enabled: bool) -> Self
Constructs an EffectiveMss
from an Mss
Sourcepub fn payload_size(&self, options: &SegmentOptions) -> NonZeroU16
pub fn payload_size(&self, options: &SegmentOptions) -> NonZeroU16
Computes the amount of payload data to include in a segment.
Accounts for the size of any variable-sized options present in the segment.
Sourcepub fn mss(&self) -> &Mss
pub fn mss(&self) -> &Mss
Returns the original Mss
used to compute this EffectiveMss
.
Sourcepub fn update_mss(&mut self, new: Mss)
pub fn update_mss(&mut self, new: Mss)
Replaces the held Mss
with a new value.
Trait Implementations§
Source§impl Clone for EffectiveMss
impl Clone for EffectiveMss
Source§fn clone(&self) -> EffectiveMss
fn clone(&self) -> EffectiveMss
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for EffectiveMss
impl Debug for EffectiveMss
Source§impl From<EffectiveMss> for u32
impl From<EffectiveMss> for u32
Source§fn from(mss: EffectiveMss) -> Self
fn from(mss: EffectiveMss) -> Self
Source§impl From<EffectiveMss> for usize
impl From<EffectiveMss> for usize
Source§fn from(mss: EffectiveMss) -> Self
fn from(mss: EffectiveMss) -> Self
Source§impl PartialEq for EffectiveMss
impl PartialEq for EffectiveMss
impl Copy for EffectiveMss
impl Eq for EffectiveMss
impl StructuralPartialEq for EffectiveMss
Auto Trait Implementations§
impl Freeze for EffectiveMss
impl RefUnwindSafe for EffectiveMss
impl Send for EffectiveMss
impl Sync for EffectiveMss
impl Unpin for EffectiveMss
impl UnwindSafe for EffectiveMss
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more