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
35 .Nd Transmission Control Protocol Extensions for Transactions
37 .Fd #include <sys/types.h>
38 .Fd #include <sys/socket.h>
39 .Fd #include <netinet/in.h>
40 .Fd #include <netinet/tcp.h>
42 .Fn setsockopt sock IPPROTO_TCP TCP_NOPUSH &One "sizeof One"
45 .Fn sendto sock msg len MSG_EOF &sin "sizeof sin"
48 .Fn sendto sock msg len MSG_EOF 0 0
51 refers to a set of extensions to the
55 which permit hosts to reliably exchange a small amount of data in a
56 two-packet exchange, thus eliminating the extra round-trip delays
57 inherent in a standard
59 connection. The socket interface includes modifications to support
61 detailed here for the specific case, and in the
65 manual pages for the protocol-independent support.
67 is defined in RFC 1644.
71 extensions work by including certain options in all segments of a
72 particular connection, which enable the implementation to avoid the
73 three-way handshake for all but the first connection between a pair of
74 hosts. These same options also make it possible to more reliably
75 recognize old, duplicate packets, which in turn reduces the amount of
78 protocol must maintain state after a connection closes. The
79 .Dq Li net.inet.tcp.rfc1644
80 MIB variable can be used to disable
82 negotiation at run time; however, the protocol has been designed to
83 ensure that attempts by non-T/TCP
84 systems to communicate with T/TCP-enhanced
85 ones automatically degenerate into standard
88 The expected model of a
92 is a fairly simple one:
95 A client program generates a request to be sent to the server, which
96 is small enough to fit in a single
98 segment, and sends a SYN PUSH FIN segment with options and data to the
101 The server program accepts the request in the same manner as for
104 connections, interprets it, and generates a reply which may be small
105 enough to fit in a single segment. If it is, the reply is sent in a
106 single SYN PUSH FIN ACK segment with (different) options and data back
107 to the client. If not, then the connection degenerates into (almost)
110 The server then closes its socket.
112 The client reads the reply and closes its socket.
115 Support on the client side is provided by extending the semantics of
120 system calls to understand the notion of
123 .Dq send and shutdown.
124 To send the request in a transaction, the
126 system call is typically used, as in the following example:
127 .Bd -literal -offset indent
128 char request[REQ_LEN];
129 struct sockaddr_in sin;
132 sock = socket(PF_INET, SOCK_STREAM, 0);
134 /* prepare request[] and sin */
136 err = sendto(sock, request, req_len, MSG_EOF,
137 (struct sockaddr *)&sin, sin.sin_len);
139 /* do something if error */
141 req_len = read(sock, request, sizeof request);
144 /* do something with the reply */
151 the socket is now in the same state as if the
155 system calls had been used. That is to say, the only reasonable
156 operations to perform on this socket are
160 (Because the client's
162 sender is already shut down, it is not possible to
164 this socket to another destination.)
166 There are two different options available for servers using
172 socket option, and use normal
174 calls when formulating the response.
180 flag, as in the client, but with the destination unspecified.
183 The first option is generally the appropriate choice when converting
184 existing servers to use
186 extensions; simply add a call to
187 .Fn setsockopt sock IPPROTO_TCP TCP_NOPUSH &One "sizeof One"
190 is an integer variable with a non-zero value). The server socket must
191 be closed before any data is sent (unless the socket buffers fill up).
193 The second option is preferable for new servers, and is sometimes easy
194 enough to retrofit into older servers. In this case, where the reply
195 phase would ordinarily have included a call to
199 .Dl "sendto(sock, buf, len, MSG_EOF, (struct sockaddr *)0, 0)"
201 In this case, the reply is sent immediately, but as in the client
202 case, the socket is no longer useful for anything and should be
207 extensions require the
208 .Dq Li net.inet.tcp.rfc1644
209 MIB variable to be true in order for the appropriate
211 options to be sent. See
213 for more information.
221 .%T "T/TCP \- TCP Extensions for Transactions"
229 based on code written by Bob Braden and Liming Wei at the
230 University of Southern California, Information Sciences Institute, and
231 ported by Andras Olah at the University of Twente.