Struct etherparse::TcpHeader[][src]

pub struct TcpHeader {
    pub source_port: u16,
    pub destination_port: u16,
    pub sequence_number: u32,
    pub acknowledgment_number: u32,
    pub ns: bool,
    pub fin: bool,
    pub syn: bool,
    pub rst: bool,
    pub psh: bool,
    pub ack: bool,
    pub urg: bool,
    pub ece: bool,
    pub cwr: bool,
    pub window_size: u16,
    pub checksum: u16,
    pub urgent_pointer: u16,
    // some fields omitted
}

TCP header according to rfc 793.

Field descriptions copied from RFC 793 page 15++

Fields

The source port number.

The destination port number.

The sequence number of the first data octet in this segment (except when SYN is present).

If SYN is present the sequence number is the initial sequence number (ISN) and the first data octet is ISN+1. [copied from RFC 793, page 16]

If the ACK control bit is set this field contains the value of the next sequence number the sender of the segment is expecting to receive.

Once a connection is established this is always sent.

ECN-nonce - concealment protection (experimental: see RFC 3540)

No more data from sender

Synchronize sequence numbers

Reset the connection

Push Function

Acknowledgment field significant

Urgent Pointer field significant

ECN-Echo (RFC 3168)

Congestion Window Reduced (CWR) flag

This flag is set by the sending host to indicate that it received a TCP segment with the ECE flag set and had responded in congestion control mechanism (added to header by RFC 3168).

The number of data octets beginning with the one indicated in the acknowledgment field which the sender of this segment is willing to accept.

Checksum (16 bit one's complement) of the pseudo ip header, this tcp header and the payload.

This field communicates the current value of the urgent pointer as a positive offset from the sequence number in this segment.

The urgent pointer points to the sequence number of the octet following the urgent data. This field is only be interpreted in segments with the URG control bit set.

Methods

impl TcpHeader
[src]

Creates a TcpHeader with the given values and the rest initialized with default values.

The number of 32 bit words in the TCP Header.

This indicates where the data begins. The TCP header (even one including options) is an integral number of 32 bits long.

Returns the length of the header including the options.

Returns the options size in bytes based on the currently set data_offset. Returns None if the data_offset is smaller then the minimum size or bigger then the maximum supported size.

Returns a slice containing the options of the header (size is determined via the data_offset field.

Sets the options (overwrites the current options) or returns an error when there is not enough space.

Sets the options to the data given.

Important traits for TcpOptionsIterator<'a>

Returns an iterator that allows to iterate through all known TCP header options.

Read a tcp header from the current position

Write the tcp header to a stream (does NOT calculate the checksum).

Calculates the upd header checksum based on a ipv4 header and returns the result. This does NOT set the checksum.

Calculates the checksum for the current header in ipv4 mode and returns the result. This does NOT set the checksum.

Calculates the upd header checksum based on a ipv6 header and returns the result. This does NOT set the checksum..

Calculates the checksum for the current header in ipv6 mode and returns the result. This does NOT set the checksum.

Trait Implementations

impl Clone for TcpHeader
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Default for TcpHeader
[src]

Returns the "default value" for a type. Read more

impl Debug for TcpHeader
[src]

Formats the value using the given formatter. Read more

impl PartialEq for TcpHeader
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for TcpHeader
[src]

Auto Trait Implementations

impl Send for TcpHeader

impl Sync for TcpHeader