iPXE
|
TCP protocol. More...
#include <ipxe/tcpip.h>
Go to the source code of this file.
Data Structures | |
struct | tcp_header |
A TCP header. More... | |
struct | tcp_option |
Generic TCP option. More... | |
struct | tcp_mss_option |
TCP MSS option. More... | |
struct | tcp_window_scale_option |
TCP window scale option. More... | |
struct | tcp_window_scale_padded_option |
Padded TCP window scale option (used for sending) More... | |
struct | tcp_sack_permitted_option |
TCP selective acknowledgement permitted option. More... | |
struct | tcp_sack_permitted_padded_option |
Padded TCP selective acknowledgement permitted option (used for sending) More... | |
struct | tcp_sack_option |
TCP selective acknowledgement option. More... | |
struct | tcp_sack_block |
TCP selective acknowledgement block. More... | |
struct | tcp_sack_padded_option |
Padded TCP selective acknowledgement option (used for sending) More... | |
struct | tcp_timestamp_option |
TCP timestamp option. More... | |
struct | tcp_timestamp_padded_option |
Padded TCP timestamp option (used for sending) More... | |
struct | tcp_options |
Parsed TCP options. More... | |
Macros | |
#define | TCP_OPTION_END 0 |
End of TCP options list. More... | |
#define | TCP_OPTION_NOP 1 |
TCP option pad. More... | |
#define | TCP_OPTION_MSS 2 |
Code for the TCP MSS option. More... | |
#define | TCP_OPTION_WS 3 |
Code for the TCP window scale option. More... | |
#define | TCP_RX_WINDOW_SCALE 9 |
Advertised TCP window scale. More... | |
#define | TCP_OPTION_SACK_PERMITTED 4 |
Code for the TCP selective acknowledgement permitted option. More... | |
#define | TCP_SACK_MAX 3 |
Maximum number of selective acknowledgement blocks. More... | |
#define | TCP_OPTION_SACK 5 |
Code for the TCP selective acknowledgement option. More... | |
#define | TCP_OPTION_TS 8 |
Code for the TCP timestamp option. More... | |
#define | TCP_CWR 0x80 |
#define | TCP_ECE 0x40 |
#define | TCP_URG 0x20 |
#define | TCP_ACK 0x10 |
#define | TCP_PSH 0x08 |
#define | TCP_RST 0x04 |
#define | TCP_SYN 0x02 |
#define | TCP_FIN 0x01 |
#define | TCP_STATE_SENT(flags) ( (flags) << 0 ) |
TCP flags that have been sent in outgoing packets. More... | |
#define | TCP_FLAGS_SENT(state) ( ( (state) >> 0 ) & 0xff ) |
#define | TCP_STATE_ACKED(flags) ( (flags) << 8 ) |
TCP flags that have been acknowledged by the peer. More... | |
#define | TCP_FLAGS_ACKED(state) ( ( (state) >> 8 ) & 0xff ) |
#define | TCP_STATE_RCVD(flags) ( (flags) << 16 ) |
TCP flags that have been received from the peer. More... | |
#define | TCP_FLAGS_RCVD(state) ( ( (state) >> 16 ) & 0xff ) |
#define | TCP_FLAGS_SENDING(state) ( TCP_FLAGS_SENT ( state ) & ~TCP_FLAGS_ACKED ( state ) ) |
TCP flags that are currently being sent in outgoing packets. More... | |
#define | TCP_CLOSED TCP_RST |
CLOSED. More... | |
#define | TCP_LISTEN 0 |
LISTEN. More... | |
#define | TCP_SYN_SENT ( TCP_STATE_SENT ( TCP_SYN ) ) |
SYN_SENT. More... | |
#define | TCP_SYN_RCVD |
SYN_RCVD. More... | |
#define | TCP_ESTABLISHED |
ESTABLISHED. More... | |
#define | TCP_FIN_WAIT_1 |
FIN_WAIT_1. More... | |
#define | TCP_FIN_WAIT_2 |
FIN_WAIT_2. More... | |
#define | TCP_CLOSING_OR_LAST_ACK |
CLOSING / LAST_ACK. More... | |
#define | TCP_TIME_WAIT |
TIME_WAIT. More... | |
#define | TCP_CLOSE_WAIT |
CLOSE_WAIT. More... | |
#define | TCP_CAN_SEND_DATA(state) |
Can send data in current state. More... | |
#define | TCP_HAS_BEEN_ESTABLISHED(state) |
Have ever been fully established. More... | |
#define | TCP_CLOSED_GRACEFULLY(state) |
Have closed gracefully. More... | |
#define | TCP_MASK_HLEN 0xf0 |
Mask for TCP header length field. More... | |
#define | TCP_MIN_PORT 1 |
Smallest port number on which a TCP connection can listen. More... | |
#define | TCP_MAX_WINDOW_SIZE ( 2048 * 1024 ) |
Maxmimum advertised TCP window size. More... | |
#define | TCP_PATH_MTU ( 1280 - 40 /* IPv6 */ - 20 /* TCP */ - 12 /* TCP timestamp */ ) |
Path MTU. More... | |
#define | TCP_MSL ( 2 * 60 * TICKS_PER_SEC ) |
TCP maximum segment lifetime. More... | |
#define | TCP_KEEPALIVE_DELAY ( 15 * TICKS_PER_SEC ) |
TCP keepalive period. More... | |
#define | TCP_MAX_HEADER_LEN |
TCP maximum header length. More... | |
#define | TCP_FINISH_TIMEOUT ( 1 * TICKS_PER_SEC ) |
TCP finish wait time. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER_OR_UBDL) | |
struct tcp_window_scale_padded_option | __attribute ((packed)) |
static int32_t | tcp_cmp (uint32_t seq1, uint32_t seq2) |
Compare TCP sequence numbers. More... | |
static int | tcp_in_window (uint32_t seq, uint32_t start, uint32_t len) |
Check if TCP sequence number lies within window. More... | |
Variables | |
struct tcp_header | __attribute__ |
uint8_t | nop |
struct tcp_window_scale_option | wsopt |
struct tcp_sack_permitted_option | __attribute |
struct tcpip_protocol tcp_protocol | __tcpip_protocol |
ICMPv4 TCP/IP protocol. More... | |
#define TCP_MIN_PORT 1 |
#define TCP_MAX_WINDOW_SIZE ( 2048 * 1024 ) |
Maxmimum advertised TCP window size.
The maximum bandwidth on any link is limited by
max_bandwidth * round_trip_time = tcp_window
Some rough expectations for achievable bandwidths over various links are:
a) Gigabit LAN: expected bandwidth 125MB/s, typical RTT 0.5ms, minimum required window 64kB
b) 10-Gigabit LAN: expected bandwidth 1250MB/s, typical RTT 0.5ms, minimum required window 640kB
c) Home Internet connection: expected bandwidth 50MB/s, typical RTT 25ms, minimum required window 1280kB
d) International WAN: expected bandwidth 50MB/s, typical RTT 25ms, minimum required window 1280kB
e) Intercontinental WAN: expected bandwidth 5MB/s, typical RTT 250ms, minimum required window 1280kB.
The maximum possible value for the TCP window size is 1GB (using the maximum window scale of 2**14). However, it is advisable to keep the window size as small as possible (without limiting bandwidth), since in the event of a lost packet the window size represents the maximum amount that will need to be retransmitted.
We therefore choose a (rounded up) maximum window size of 2048kB.
#define TCP_PATH_MTU ( 1280 - 40 /* IPv6 */ - 20 /* TCP */ - 12 /* TCP timestamp */ ) |
Path MTU.
IPv6 requires all data link layers to support a datagram size of 1280 bytes. We choose to use this as our maximum transmitted datagram size, on the assumption that any practical link layer we encounter will allow this size. This is a very conservative assumption in practice, but the impact of making such a conservative assumption is insignificant since the amount of data that we transmit (rather than receive) is negligible.
We allow space within this 1280 bytes for an IPv6 header, a TCP header, and a (padded) TCP timestamp option.
#define TCP_MSL ( 2 * 60 * TICKS_PER_SEC ) |
#define TCP_KEEPALIVE_DELAY ( 15 * TICKS_PER_SEC ) |
#define TCP_MAX_HEADER_LEN |
TCP maximum header length.
#define TCP_FINISH_TIMEOUT ( 1 * TICKS_PER_SEC ) |
TCP finish wait time.
Currently set to one second, since we should not allow a slowly responding server to substantially delay a call to shutdown().
FILE_LICENCE | ( | GPL2_OR_LATER_OR_UBDL | ) |
Compare TCP sequence numbers.
seq1 | Sequence number 1 |
seq2 | Sequence number 2 |
diff | Sequence difference |
Analogous to memcmp(), returns an integer less than, equal to, or greater than zero if seq1
is found, respectively, to be before, equal to, or after seq2
.
Definition at line 418 of file tcp.h.
Referenced by tcp_process_rx_queue(), tcp_rx_enqueue(), tcp_rx_seq(), and tcp_sack_block().
struct tcp_header __attribute__ |
uint8_t nop |
Definition at line 13 of file tcp.h.
Referenced by xhci_nop().
struct tcp_window_scale_option wsopt |
Definition at line 14 of file tcp.h.
Referenced by tcp_xmit_sack().
struct tcpip_protocol tcp_protocol __tcpip_protocol |