1 .\" Copyright 1994, 1995 Massachusetts Institute of Technology
3 .\" Permission to use, copy, modify, and distribute this software and
4 .\" its documentation for any purpose and without fee is hereby
5 .\" granted, provided that both the above copyright notice and this
6 .\" permission notice appear in all copies, that both the above
7 .\" copyright notice and this permission notice appear in all
8 .\" supporting documentation, and that the name of M.I.T. not be used
9 .\" in advertising or publicity pertaining to distribution of the
10 .\" software without specific, written prior permission. M.I.T. makes
11 .\" no representations about the suitability of this software for any
12 .\" purpose. It is provided "as is" without express or implied
15 .\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
16 .\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 .\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 .\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
19 .\" SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 .\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
22 .\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 .\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" $FreeBSD: src/share/man/man4/ttcp.4,v 1.8.2.6 2001/12/17 11:30:12 ru Exp $
29 .\" $DragonFly: src/share/man/man4/ttcp.4,v 1.3 2007/07/14 21:48:15 swildner Exp $
36 .Nd Transmission Control Protocol Extensions for Transactions
43 .Fn setsockopt sock IPPROTO_TCP TCP_NOPUSH &One "sizeof One"
45 .Fn sendto sock msg len MSG_EOF &sin "sizeof sin"
47 .Fn sendto sock msg len MSG_EOF 0 0
50 refers to a set of extensions to the
54 which permit hosts to reliably exchange a small amount of data in a
55 two-packet exchange, thus eliminating the extra round-trip delays
56 inherent in a standard
58 connection. The socket interface includes modifications to support
60 detailed here for the specific case, and in the
64 manual pages for the protocol-independent support.
66 is defined in RFC 1644.
70 extensions work by including certain options in all segments of a
71 particular connection, which enable the implementation to avoid the
72 three-way handshake for all but the first connection between a pair of
73 hosts. These same options also make it possible to more reliably
74 recognize old, duplicate packets, which in turn reduces the amount of
77 protocol must maintain state after a connection closes. The
78 .Va net.inet.tcp.rfc1644
79 MIB variable can be used to disable
81 negotiation at run time; however, the protocol has been designed to
82 ensure that attempts by non-T/TCP
83 systems to communicate with T/TCP-enhanced
84 ones automatically degenerate into standard
87 The expected model of a
91 is a fairly simple one:
94 A client program generates a request to be sent to the server, which
95 is small enough to fit in a single
97 segment, and sends a SYN PUSH FIN segment with options and data to the
100 The server program accepts the request in the same manner as for
103 connections, interprets it, and generates a reply which may be small
104 enough to fit in a single segment. If it is, the reply is sent in a
105 single SYN PUSH FIN ACK segment with (different) options and data back
106 to the client. If not, then the connection degenerates into (almost)
109 The server then closes its socket.
111 The client reads the reply and closes its socket.
114 Support on the client side is provided by extending the semantics of
119 system calls to understand the notion of
122 .Dq send and shutdown .
123 To send the request in a transaction, the
125 system call is typically used, as in the following example:
126 .Bd -literal -offset indent
127 char request[REQ_LEN];
128 struct sockaddr_in sin;
131 sock = socket(PF_INET, SOCK_STREAM, 0);
133 /* prepare request[] and sin */
135 err = sendto(sock, request, req_len, MSG_EOF,
136 (struct sockaddr *)&sin, sin.sin_len);
138 /* do something if error */
140 req_len = read(sock, request, sizeof request);
143 /* do something with the reply */
150 the socket is now in the same state as if the
154 system calls had been used. That is to say, the only reasonable
155 operations to perform on this socket are
159 (Because the client's
161 sender is already shut down, it is not possible to
163 this socket to another destination.)
165 There are two different options available for servers using
171 socket option, and use normal
173 calls when formulating the response.
179 flag, as in the client, but with the destination unspecified.
182 The first option is generally the appropriate choice when converting
183 existing servers to use
185 extensions; simply add a call to
186 .Fn setsockopt sock IPPROTO_TCP TCP_NOPUSH &One "sizeof One"
189 is an integer variable with a non-zero value). The server socket must
190 be closed before any data is sent (unless the socket buffers fill up).
192 The second option is preferable for new servers, and is sometimes easy
193 enough to retrofit into older servers. In this case, where the reply
194 phase would ordinarily have included a call to
198 .Dl "sendto(sock, buf, len, MSG_EOF, NULL, 0)"
200 In this case, the reply is sent immediately, but as in the client
201 case, the socket is no longer useful for anything and should be
206 extensions require the
207 .Va net.inet.tcp.rfc1644
208 MIB variable to be true in order for the appropriate
210 options to be sent. See
212 for more information.
220 .%T "T/TCP \- TCP Extensions for Transactions"
228 based on code written by Bob Braden and Liming Wei at the
229 University of Southern California, Information Sciences Institute, and
230 ported by Andras Olah at the University of Twente.