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 $
35 .Nd Transmission Control Protocol Extensions for Transactions
42 .Fn setsockopt sock IPPROTO_TCP TCP_NOPUSH &One "sizeof One"
44 .Fn sendto sock msg len MSG_EOF &sin "sizeof sin"
46 .Fn sendto sock msg len MSG_EOF 0 0
49 refers to a set of extensions to the
53 which permit hosts to reliably exchange a small amount of data in a
54 two-packet exchange, thus eliminating the extra round-trip delays
55 inherent in a standard
57 connection. The socket interface includes modifications to support
59 detailed here for the specific case, and in the
63 manual pages for the protocol-independent support.
65 is defined in RFC 1644.
69 extensions work by including certain options in all segments of a
70 particular connection, which enable the implementation to avoid the
71 three-way handshake for all but the first connection between a pair of
72 hosts. These same options also make it possible to more reliably
73 recognize old, duplicate packets, which in turn reduces the amount of
76 protocol must maintain state after a connection closes. The
77 .Dq Li net.inet.tcp.rfc1644
78 MIB variable can be used to disable
80 negotiation at run time; however, the protocol has been designed to
81 ensure that attempts by non-T/TCP
82 systems to communicate with T/TCP-enhanced
83 ones automatically degenerate into standard
86 The expected model of a
90 is a fairly simple one:
93 A client program generates a request to be sent to the server, which
94 is small enough to fit in a single
96 segment, and sends a SYN PUSH FIN segment with options and data to the
99 The server program accepts the request in the same manner as for
102 connections, interprets it, and generates a reply which may be small
103 enough to fit in a single segment. If it is, the reply is sent in a
104 single SYN PUSH FIN ACK segment with (different) options and data back
105 to the client. If not, then the connection degenerates into (almost)
108 The server then closes its socket.
110 The client reads the reply and closes its socket.
113 Support on the client side is provided by extending the semantics of
118 system calls to understand the notion of
121 .Dq send and shutdown .
122 To send the request in a transaction, the
124 system call is typically used, as in the following example:
125 .Bd -literal -offset indent
126 char request[REQ_LEN];
127 struct sockaddr_in sin;
130 sock = socket(PF_INET, SOCK_STREAM, 0);
132 /* prepare request[] and sin */
134 err = sendto(sock, request, req_len, MSG_EOF,
135 (struct sockaddr *)&sin, sin.sin_len);
137 /* do something if error */
139 req_len = read(sock, request, sizeof request);
142 /* do something with the reply */
149 the socket is now in the same state as if the
153 system calls had been used. That is to say, the only reasonable
154 operations to perform on this socket are
158 (Because the client's
160 sender is already shut down, it is not possible to
162 this socket to another destination.)
164 There are two different options available for servers using
170 socket option, and use normal
172 calls when formulating the response.
178 flag, as in the client, but with the destination unspecified.
181 The first option is generally the appropriate choice when converting
182 existing servers to use
184 extensions; simply add a call to
185 .Fn setsockopt sock IPPROTO_TCP TCP_NOPUSH &One "sizeof One"
188 is an integer variable with a non-zero value). The server socket must
189 be closed before any data is sent (unless the socket buffers fill up).
191 The second option is preferable for new servers, and is sometimes easy
192 enough to retrofit into older servers. In this case, where the reply
193 phase would ordinarily have included a call to
197 .Dl "sendto(sock, buf, len, MSG_EOF, (struct sockaddr *)0, 0)"
199 In this case, the reply is sent immediately, but as in the client
200 case, the socket is no longer useful for anything and should be
205 extensions require the
206 .Dq Li net.inet.tcp.rfc1644
207 MIB variable to be true in order for the appropriate
209 options to be sent. See
211 for more information.
219 .%T "T/TCP \- TCP Extensions for Transactions"
227 based on code written by Bob Braden and Liming Wei at the
228 University of Southern California, Information Sciences Institute, and
229 ported by Andras Olah at the University of Twente.