pub struct Mss(/* private fields */);
Expand description
Maximum segment size, that is the maximum TCP payload one segment can carry.
Mss
also acts as a witness that the contained value is >= Mss::MIN
.
Implementations§
Source§impl Mss
impl Mss
Sourcepub const MIN: Mss
pub const MIN: Mss
The minimum MSS allowed by TCP.
Although enforcing a minimum MSS is outside the recommendations of any RFC, it is a common practice on other platforms and has multiple benefits:
- Ensures there is enough space to transmit TCP Options & IP Options. See RFC 6691 section 2, which clarifies that The TCP MSS OPTION […] SHOULD NOT be decreased to account for any possible IP or TCP options; conversely, the sender MUST reduce the TCP data length to account for any IP or TCP options that it is including in the packets that it sends.
- Protects against DOS attacks in which the attacker initiates TCP
connections with an intentionally small MSS to incur additional
packet processing overhead on the victim. See
- FreeBSD: https://www.cve.org/CVERecord?id=CVE-2004-0002
- Linux: https://www.cve.org/CVERecord?id=CVE-2019-11479
Here, the value 216 is inspired by FreeBSD. It’s large enough to satisfy points 1 & 2 from above, while remaining small enough to support all link-layer technologies on the open Internet.
Sourcepub const DEFAULT_IPV4: Mss
pub const DEFAULT_IPV4: Mss
Per RFC 9293 Section 3.7.1: If an MSS Option is not received at connection setup, TCP implementations MUST assume a default send MSS of 536 (576 - 40) for IPv4.
Sourcepub const DEFAULT_IPV6: Mss
pub const DEFAULT_IPV6: Mss
Per RFC 9293 Section 3.7.1: If an MSS Option is not received at connection setup, TCP implementations MUST assume a default send MSS of […] 1220 (1280 - 60) for IPv6 (MUST-15).
Sourcepub const fn new(mss: u16) -> Option<Self>
pub const fn new(mss: u16) -> Option<Self>
Creates Mss
, provided the given value satisfies the requirements.
Sourcepub fn from_mms(mms: Mms) -> Option<Self>
pub fn from_mms(mms: Mms) -> Option<Self>
Creates MSS from the maximum message size of the IP layer.
Trait Implementations§
Source§impl Ord for Mss
impl Ord for Mss
Source§impl PartialOrd for Mss
impl PartialOrd for Mss
impl Copy for Mss
impl Eq for Mss
impl StructuralPartialEq for Mss
Auto Trait Implementations§
impl Freeze for Mss
impl RefUnwindSafe for Mss
impl Send for Mss
impl Sync for Mss
impl Unpin for Mss
impl UnwindSafe for Mss
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