This is an implementation of the TCP protocol defined in RFC793, RFC1122
and RFC2001 with the NewReno extensions.
It implements a reliable stream oriented full duplex stream
between
two sockets. TCP ensures that packets are not reordered and retransmits them
when they are dropped. It generates and checks a per packet checksum to catch
transmission errors.
A fresh TCP socket has no remote or local address and is not fully specified.
To create an outgoing TCP connection the
connect (2)
function is called on the socket. To accept incoming connections
bind (2)
the socket first to a local address and port and then call
listen (2)
to allow the accepting of incoming connections. Then use
accept (2)
to get a new socket with the incoming connection. The listening socket
stays. After
accept (2)
or
connect (2)
a socket is fully specified.
Data may be only transferred on fully specified sockets.
When the initial connection request packet carries IP options and the
accept_source_routes sysctl is enabled all outgoing datagrams on this
connection will carry the reversed source route.
Linux 2.2 supports the RFC1323 TCP high performance extensions.
They include window scaling to support large windows and the timestamp option with
protection against wrapped sequence numbers (
PAWS
).
Large windows are needed for good performance over links with long latencies
or very high bandwidth. To use them the send and receive buffers have to be
increased from the default values. This can be either done globally using the
net.core.wmen_default
and
net.core.rmem_default
sysctls, or on a per socket basis using the
SO_SNDBUF
and
SO_RCVBUF
socket options. The maximum receive buffer size settable on a socket
is limited by the global
net.core.rmem_max
and
net.core.wmem_max
sysctls. See
socket (4)
for more information.
TCP supports urgent data. Urgent data is used to signal the receiver
that some important message is part of the data stream and that is should
be processed as soon as possible.
To send urgent data specify the
MSG_OOB
option to
sendfile(2).
When urgent data is received the kernel sends an SIGURG signal to the
reading process or the process or process group that has been set for the socket
using the
FIOCSPGRP
or
FIOCSETOWN
ioctls. When the
SO_OOBINLINE
socket option is enabled urgent data is put into the normal data stream
(and can be tested for by the
SIOCATMARK
ioctl),
otherwise it can be only received when the
MSG_OOB
flag is set for
sendmsg(2). Note that Linux per default uses the BSD compatible
interpretation of the urgent pointer field, see the
tcp_stdurg
sysctl below.