Index:
CPU_ELAN(4)CPU_SOEKRIS(4)
aac(4)
acd(4)
acpi(4)
acpi_asus(4)
acpi_panasonic(4)
acpi_thermal(4)
acpi_toshiba(4)
acpi_video(4)
ad(4)
adv(4)
adw(4)
afd(4)
agp(4)
agpgart(4)
aha(4)
ahb(4)
ahc(4)
ahd(4)
aic(4)
aio(4)
alpm(4)
altq(4)
amd(4)
amdpm(4)
amr(4)
an(4)
apm(4)
ar(4)
arcmsr(4)
arl(4)
arp(4)
asr(4)
ast(4)
ata(4)
atapicam(4)
ath(4)
ath_hal(4)
atkbd(4)
atkbdc(4)
aue(4)
awi(4)
axe(4)
bfe(4)
bge(4)
bktr(4)
blackhole(4)
bpf(4)
bridge(4)
brooktree(4)
bt(4)
cam(4)
card(4)
cardbus(4)
carp(4)
cbb(4)
ccd(4)
cd(4)
cdce(4)
ch(4)
ciss(4)
cm(4)
cnw(4)
cp(4)
cpufreq(4)
crypto(4)
cryptodev(4)
cs(4)
ct(4)
ctau(4)
cue(4)
cx(4)
cy(4)
da(4)
dc(4)
dcons(4)
dcons_crom(4)
ddb(4)
de(4)
devctl(4)
digi(4)
disc(4)
divert(4)
dpt(4)
dummynet(4)
ed(4)
ef(4)
ehci(4)
el(4)
em(4)
en(4)
ep(4)
esp(4)
ex(4)
exca(4)
faith(4)
fast_ipsec(4)
fatm(4)
fd(4)
fdc(4)
fe(4)
fea(4)
firewire(4)
fla(4)
fpa(4)
fwe(4)
fwip(4)
fwohci(4)
fxp(4)
gbde(4)
gdb(4)
gem(4)
geom(4)
gif(4)
gre(4)
gx(4)
harp(4)
hatm(4)
hfa(4)
hifn(4)
hme(4)
hptmv(4)
i4b(4)
i4bcapi(4)
i4bctl(4)
i4bing(4)
i4bipr(4)
i4bisppp(4)
i4bq921(4)
i4bq931(4)
i4brbch(4)
i4btel(4)
i4btrc(4)
iavc(4)
ichsmb(4)
ichwd(4)
icmp(4)
icmp6(4)
ida(4)
idt(4)
ie(4)
ieee80211(4)
if_an(4)
if_aue(4)
if_awi(4)
if_axe(4)
if_bfe(4)
if_bge(4)
if_cue(4)
if_dc(4)
if_de(4)
if_disc(4)
if_ed(4)
if_ef(4)
if_em(4)
if_en(4)
if_faith(4)
if_fatm(4)
if_fwe(4)
if_fwip(4)
if_fxp(4)
if_gem(4)
if_gif(4)
if_gre(4)
if_gx(4)
if_hatm(4)
if_hme(4)
if_idt(4)
if_kue(4)
if_lge(4)
if_my(4)
if_ndis(4)
if_nge(4)
if_oltr(4)
if_patm(4)
if_pcn(4)
if_ppp(4)
if_re(4)
if_rl(4)
if_rue(4)
if_sbni(4)
if_sbsh(4)
if_sf(4)
if_sis(4)
if_sk(4)
if_sl(4)
if_sn(4)
if_ste(4)
if_stf(4)
if_tap(4)
if_ti(4)
if_tl(4)
if_tun(4)
if_tx(4)
if_txp(4)
if_udav(4)
if_vge(4)
if_vlan(4)
if_vr(4)
if_wb(4)
if_wi(4)
if_xe(4)
if_xl(4)
ifmib(4)
ifpi(4)
ifpi2(4)
ifpnp(4)
ihfc(4)
iic(4)
iicbb(4)
iicbus(4)
iicsmb(4)
iir(4)
imm(4)
inet(4)
inet6(4)
intpm(4)
intro(4)
io(4)
ip(4)
ip6(4)
ipaccounting(4)
ipacct(4)
ipf(4)
ipfirewall(4)
ipfw(4)
ipl(4)
ipnat(4)
ips(4)
ipsec(4)
isic(4)
isp(4)
ispfw(4)
itjc(4)
iwic(4)
ixgb(4)
joy(4)
kame(4)
keyboard(4)
kld(4)
kmem(4)
ktr(4)
kue(4)
led(4)
lge(4)
linux(4)
lnc(4)
lo(4)
longrun(4)
loop(4)
lp(4)
lpbb(4)
lpt(4)
mac(4)
mac_biba(4)
mac_bsdextended(4)
mac_ifoff(4)
mac_lomac(4)
mac_mls(4)
mac_none(4)
mac_partition(4)
mac_portacl(4)
mac_seeotheruids(4)
mac_stub(4)
mac_test(4)
mcd(4)
md(4)
mem(4)
meteor(4)
miibus(4)
mlx(4)
mly(4)
mouse(4)
mpt(4)
mse(4)
mtio(4)
multicast(4)
my(4)
natm(4)
natmip(4)
ncr(4)
ncv(4)
ndis(4)
net(4)
netgraph(4)
netintro(4)
networking(4)
ng_UI(4)
ng_async(4)
ng_atm(4)
ng_atmllc(4)
ng_atmpif(4)
ng_bluetooth(4)
ng_bpf(4)
ng_bridge(4)
ng_bt3c(4)
ng_btsocket(4)
ng_ccatm(4)
ng_cisco(4)
ng_device(4)
ng_echo(4)
ng_eiface(4)
ng_etf(4)
ng_ether(4)
ng_fec(4)
ng_frame_relay(4)
ng_gif(4)
ng_gif_demux(4)
ng_h4(4)
ng_hci(4)
ng_hole(4)
ng_hub(4)
ng_iface(4)
ng_ip_input(4)
ng_ksocket(4)
ng_l2cap(4)
ng_l2tp(4)
ng_lmi(4)
ng_mppc(4)
ng_netflow(4)
ng_one2many(4)
ng_ppp(4)
ng_pppoe(4)
ng_pptpgre(4)
ng_rfc1490(4)
ng_socket(4)
ng_split(4)
ng_sppp(4)
ng_sscfu(4)
ng_sscop(4)
ng_tee(4)
ng_tty(4)
ng_ubt(4)
ng_uni(4)
ng_vjc(4)
ng_vlan(4)
nge(4)
nmdm(4)
npx(4)
nsp(4)
null(4)
ohci(4)
oldcard(4)
oltr(4)
opie(4)
orm(4)
pae(4)
pass(4)
patm(4)
pccard(4)
pccbb(4)
pcf(4)
pci(4)
pcic(4)
pcm(4)
pcn(4)
pcvt(4)
perfmon(4)
pf(4)
pflog(4)
pfsync(4)
pim(4)
plip(4)
pnp(4)
pnpbios(4)
polling(4)
ppbus(4)
ppc(4)
ppi(4)
ppp(4)
psm(4)
pst(4)
pt(4)
pty(4)
puc(4)
random(4)
rawip(4)
ray(4)
rc(4)
re(4)
rl(4)
rndtest(4)
route(4)
rp(4)
rue(4)
sa(4)
sab(4)
safe(4)
sbni(4)
sbp(4)
sbp_targ(4)
sbsh(4)
sc(4)
scbus(4)
scd(4)
sched_4bsd(4)
sched_ule(4)
screen(4)
screensaver(4)
scsi(4)
sem(4)
ses(4)
sf(4)
si(4)
sio(4)
sis(4)
sk(4)
skey(4)
sl(4)
smapi(4)
smb(4)
smbus(4)
smp(4)
sn(4)
snc(4)
snd(4)
snd_ad1816(4)
snd_als4000(4)
snd_cmi(4)
snd_cs4281(4)
snd_csa(4)
snd_ds1(4)
snd_emu10k1(4)
snd_es137x(4)
snd_ess(4)
snd_fm801(4)
snd_gusc(4)
snd_ich(4)
snd_maestro(4)
snd_maestro3(4)
snd_neomagic(4)
snd_sbc(4)
snd_solo(4)
snd_uaudio(4)
snd_via8233(4)
snd_via82c686(4)
snd_vibes(4)
snp(4)
sound(4)
speaker(4)
spic(4)
spkr(4)
splash(4)
sppp(4)
sr(4)
stderr(4)
stdin(4)
stdout(4)
ste(4)
stf(4)
stg(4)
streams(4)
svr4(4)
sym(4)
syncache(4)
syncer(4)
syncookies(4)
syscons(4)
sysmouse(4)
tap(4)
targ(4)
tcp(4)
tdfx(4)
termios(4)
ti(4)
tl(4)
trm(4)
ttcp(4)
tty(4)
tun(4)
twa(4)
twe(4)
tx(4)
txp(4)
uart(4)
ubsa(4)
ubsec(4)
ubser(4)
ubtbcmfw(4)
ucom(4)
udav(4)
udbp(4)
udp(4)
ufm(4)
uftdi(4)
ugen(4)
uhci(4)
uhid(4)
uhidev(4)
ukbd(4)
ulpt(4)
umass(4)
umct(4)
umodem(4)
ums(4)
unix(4)
uplcom(4)
urio(4)
usb(4)
uscanner(4)
utopia(4)
uvisor(4)
uvscom(4)
vga(4)
vge(4)
viapm(4)
vinum(4)
vinumdebug(4)
vlan(4)
vn(4)
vpd(4)
vpo(4)
vr(4)
vt(4)
vx(4)
watchdog(4)
wb(4)
wd(4)
wdc(4)
wi(4)
witness(4)
wl(4)
wlan(4)
worm(4)
xe(4)
xl(4)
xpt(4)
zero(4)
tcp(4)
NAME
tcp -- Internet Transmission Control Protocol
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
int
socket(AF_INET, SOCK_STREAM, 0);
DESCRIPTION
The TCP protocol provides reliable, flow-controlled, two-way transmission
of data. It is a byte-stream protocol used to support the SOCK_STREAM
abstraction. TCP uses the standard Internet address format and, in addi-
tion, provides a per-host collection of ``port addresses''. Thus, each
address is composed of an Internet address specifying the host and net-
work, with a specific TCP port on the host identifying the peer entity.
Sockets utilizing the TCP protocol are either ``active'' or ``passive''.
Active sockets initiate connections to passive sockets. By default, TCP
sockets are created active; to create a passive socket, the listen(2)
system call must be used after binding the socket with the bind(2) system
call. Only passive sockets may use the accept(2) call to accept incoming
connections. Only active sockets may use the connect(2) call to initiate
connections. TCP also supports a more datagram-like mode, called Trans-
action TCP, which is described in ttcp(4).
Passive sockets may ``underspecify'' their location to match incoming
connection requests from multiple networks. This technique, termed
``wildcard addressing'', allows a single server to provide service to
clients on multiple networks. To create a socket which listens on all
networks, the Internet address INADDR_ANY must be bound. The TCP port
may still be specified at this time; if the port is not specified, the
system will assign one. Once a connection has been established, the
socket's address is fixed by the peer entity's location. The address
assigned to the socket is the address associated with the network inter-
face through which packets are being transmitted and received. Normally,
this address corresponds to the peer entity's network.
TCP supports a number of socket options which can be set with
setsockopt(2) and tested with getsockopt(2):
TCP_NODELAY Under most circumstances, TCP sends data when it is pre-
sented; when outstanding data has not yet been acknowledged,
it gathers small amounts of output to be sent in a single
packet once an acknowledgement is received. For a small
number of clients, such as window systems that send a stream
of mouse events which receive no replies, this packetization
may cause significant delays. The boolean option
TCP_NODELAY defeats this algorithm.
TCP_MAXSEG By default, a sender- and receiver-TCP will negotiate among
themselves to determine the maximum segment size to be used
for each connection. The TCP_MAXSEG option allows the user
to determine the result of this negotiation, and to reduce
it if desired.
every user call to write(2) or writev(2). The TCP_NOPUSH
option is provided to allow servers to easily make use of
Transaction TCP (see ttcp(4)). When this option is set to a
non-zero value, TCP will delay sending any data at all until
either the socket is closed, or the internal send buffer is
filled.
TCP_MD5SIG This option enables the use of MD5 digests (also known as
TCP-MD5) on writes to the specified socket. In the current
release, only outgoing traffic is digested; digests on
incoming traffic are not verified. The current default
behavior for the system is to respond to a system advertis-
ing this option with TCP-MD5; this may change.
One common use for this in a FreeBSD router deployment is to
enable based routers to interwork with Cisco equipment at
peering points. Support for this feature conforms to RFC
2385. Only IPv4 (AF_INET) sessions are supported.
In order for this option to function correctly, it is neces-
sary for the administrator to add a tcp-md5 key entry to the
system's security associations database (SADB) using the
setkey(8) utility. This entry must have an SPI of 0x1000
and can therefore only be specified on a per-host basis at
this time.
If an SADB entry cannot be found for the destination, the
outgoing traffic will have an invalid digest option
prepended, and the following error message will be visible
on the system console: tcp_signature_compute: SADB lookup
failed for %d.%d.%d.%d.
The option level for the setsockopt(2) call is the protocol number for
TCP, available from getprotobyname(3), or IPPROTO_TCP. All options are
declared in <netinet/tcp.h>.
Options at the IP transport level may be used with TCP; see ip(4).
Incoming connection requests that are source-routed are noted, and the
reverse source route is used in responding.
MIB Variables
The TCP protocol implements a number of variables in the net.inet.tcp
branch of the sysctl(3) MIB.
TCPCTL_DO_RFC1323 (rfc1323) Implement the window scaling and timestamp
options of RFC 1323 (default is true).
TCPCTL_DO_RFC1644 (rfc1644) Implement Transaction TCP, as described in
RFC 1644.
TCPCTL_MSSDFLT (mssdflt) The default value used for the maximum seg-
ment size (``MSS'') when no advice to the contrary is
received from MSS negotiation.
TCPCTL_SENDSPACE (sendspace) Maximum TCP send window.
TCPCTL_RECVSPACE (recvspace) Maximum TCP receive window.
slowstart_flightsize
The number of packets allowed to be in-flight during
the TCP slow-start phase on a non-local network.
local_slowstart_flightsize
The number of packets allowed to be in-flight during
the TCP slow-start phase to local machines in the same
subnet.
msl The Maximum Segment Lifetime, in milliseconds, for a
packet.
keepinit Timeout, in milliseconds, for new, non-established TCP
connections.
keepidle Amount of time, in milliseconds, that the connection
must be idle before keepalive probes (if enabled) are
sent.
keepintvl The interval, in milliseconds, between keepalive
probes sent to remote machines. After TCPTV_KEEPCNT
(default 8) probes are sent, with no response, the
connection is dropped.
always_keepalive Assume that SO_KEEPALIVE is set on all TCP connec-
tions, the kernel will periodically send a packet to
the remote host to verify the connection is still up.
icmp_may_rst Certain ICMP unreachable messages may abort connec-
tions in SYN-SENT state.
do_tcpdrain Flush packets in the TCP reassembly queue if the sys-
tem is low on mbufs.
blackhole If enabled, disable sending of RST when a connection
is attempted to a port where there is not a socket
accepting connections. See blackhole(4).
delayed_ack Delay ACK to try and piggyback it onto a data packet.
delacktime Maximum amount of time, in milliseconds, before a
delayed ACK is sent.
newreno Enable TCP NewReno Fast Recovery algorithm, as
described in RFC 2582.
path_mtu_discovery
Enable Path MTU Discovery.
tcbhashsize Size of the TCP control-block hash table (read-only).
This may be tuned using the kernel option TCBHASHSIZE
or by setting net.inet.tcp.tcbhashsize in the
loader(8).
pcbcount Number of active process control blocks (read-only).
syncookies Determines whether or not SYN cookies should be gener-
ated for outbound SYN-ACK packets. SYN cookies are a
will occur. Reseeding should not be necessary, and
will break TIME_WAIT recycling for a few minutes.
rexmit_min, rexmit_slop
Adjust the retransmit timer calculation for TCP. The
slop is typically added to the raw calculation to take
into account occasional variances that the SRTT
(smoothed round-trip time) is unable to accommodate,
while the minimum specifies an absolute minimum.
While a number of TCP RFCs suggest a 1 second minimum,
these RFCs tend to focus on streaming behavior, and
fail to deal with the fact that a 1 second minimum has
severe detrimental effects over lossy interactive con-
nections, such as a 802.11b wireless link, and over
very fast but lossy connections for those cases not
covered by the fast retransmit code. For this reason,
we use 200ms of slop and a near-0 minimum, which gives
us an effective minimum of 200ms (similar to Linux).
inflight.enable Enable TCP bandwidth-delay product limiting. An
attempt will be made to calculate the bandwidth-delay
product for each individual TCP connection, and limit
the amount of inflight data being transmitted, to
avoid building up unnecessary packets in the network.
This option is recommended if you are serving a lot of
data over connections with high bandwidth-delay prod-
ucts, such as modems, GigE links, and fast long-haul
WANs, and/or you have configured your machine to
accommodate large TCP windows. In such situations,
without this option, you may experience high interac-
tive latencies or packet loss due to the overloading
of intermediate routers and switches. Note that band-
width-delay product limiting only effects the transmit
side of a TCP connection.
inflight.debug Enable debugging for the bandwidth-delay product algo-
rithm. This may default to on (1), so if you enable
the algorithm, you should probably also disable debug-
ging by setting this variable to 0.
inflight.min This puts a lower bound on the bandwidth-delay product
window, in bytes. A value of 1024 is typically used
for debugging. 6000-16000 is more typical in a pro-
duction installation. Setting this value too low may
result in slow ramp-up times for bursty connections.
Setting this value too high effectively disables the
algorithm.
inflight.max This puts an upper bound on the bandwidth-delay prod-
uct window, in bytes. This value should not generally
be modified, but may be used to set a global per-con-
nection limit on queued data, potentially allowing you
to intentionally set a less than optimum limit, to
smooth data flow over a network while still being able
to specify huge internal TCP buffers.
inflight.stab The bandwidth-delay product algorithm requires a
slightly larger window than it otherwise calculates
reduce both inflight.min and inflight.stab, trying
values of 15, 10, or 5 for the latter. Never use a
value less than 5. Reducing inflight.stab can lead to
upwards of a 20% underutilization of the link as well
as reducing the algorithm's ability to adapt to chang-
ing situations and should only be done as a last
resort.
rfc3042 Enable the Limited Transmit algorithm as described in
RFC 3042. It helps avoid timeouts on lossy links and
also when the congestion window is small, as happens
on short transfers. This is a standards track RFC and
is off by default.
rfc3390 Enable support for RFC 3390, which allows for a vari-
able-sized starting congestion window on new connec-
tions, depending on the maximum segment size. This
helps throughput in general, but particularly affects
short transfers and high-bandwidth large propagation-
delay connections. This is a standards track RFC and
support for it is off by default.
When this feature is enabled, the slowstart_flightsize
and local_slowstart_flightsize settings are not
observed for new connection slow starts, but they are
still used for slow starts that occur when the connec-
tion has been idle and starts sending again.
sack.enable Enable support for RFC 2018, TCP Selective Acknowledg-
ment option, which allows the receiver to inform the
sender about all successfully arrived segments, allow-
ing the sender to retransmit the missing segments
only.
sack.initburst Control the number of SACK retransmissions done upon
initiation of SACK recovery.
ERRORS
A socket operation may fail with one of the following errors returned:
[EISCONN] when trying to establish a connection on a socket
which already has one;
[ENOBUFS] when the system runs out of memory for an internal
data structure;
[ETIMEDOUT] when a connection was dropped due to excessive
retransmissions;
[ECONNRESET] when the remote peer forces the connection to be
closed;
[ECONNREFUSED] when the remote peer actively refuses connection
establishment (usually because no process is listening
to the port);
[EADDRINUSE] when an attempt is made to create a socket with a port
which has already been allocated;
getsockopt(2), socket(2), sysctl(3), blackhole(4), inet(4), intro(4),
ip(4), syncache(4), ttcp(4), setkey(8)
V. Jacobson, R. Braden, and D. Borman, TCP Extensions for High
Performance, RFC 1323.
R. Braden, T/TCP - TCP Extensions for Transactions, RFC 1644.
A. Heffernan, Protection of BGP Sessions via the TCP MD5 Signature
Option, RFC 2385.
HISTORY
The TCP protocol appeared in 4.2BSD. The RFC 1323 extensions for window
scaling and timestamps were added in 4.4BSD.
FreeBSD 5.4 October 12, 2004 FreeBSD 5.4
SPONSORED LINKS
Man(1) output converted with man2html , sed , awk
FreeBSD Man Pages