1995-02-15 22:07:28 +00:00
|
|
|
.\" Copyright 1994, 1995 Massachusetts Institute of Technology
|
|
|
|
.\"
|
|
|
|
.\" Permission to use, copy, modify, and distribute this software and
|
|
|
|
.\" its documentation for any purpose and without fee is hereby
|
|
|
|
.\" granted, provided that both the above copyright notice and this
|
|
|
|
.\" permission notice appear in all copies, that both the above
|
|
|
|
.\" copyright notice and this permission notice appear in all
|
|
|
|
.\" supporting documentation, and that the name of M.I.T. not be used
|
|
|
|
.\" in advertising or publicity pertaining to distribution of the
|
|
|
|
.\" software without specific, written prior permission. M.I.T. makes
|
|
|
|
.\" no representations about the suitability of this software for any
|
|
|
|
.\" purpose. It is provided "as is" without express or implied
|
|
|
|
.\" warranty.
|
2001-07-14 19:41:16 +00:00
|
|
|
.\"
|
1995-02-15 22:07:28 +00:00
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
|
|
|
|
.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
|
|
|
|
.\" SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
|
|
.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
|
.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1995-02-15 22:07:28 +00:00
|
|
|
.\"
|
1996-01-18 21:33:42 +00:00
|
|
|
.Dd January 18, 1995
|
1995-02-15 22:07:28 +00:00
|
|
|
.Dt TTCP 4
|
2001-07-10 15:31:11 +00:00
|
|
|
.Os
|
1995-02-15 22:07:28 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm ttcp
|
|
|
|
.Nd Transmission Control Protocol Extensions for Transactions
|
2000-11-10 17:46:15 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In sys/types.h
|
|
|
|
.In sys/socket.h
|
|
|
|
.In netinet/in.h
|
|
|
|
.In netinet/tcp.h
|
1995-02-15 22:07:28 +00:00
|
|
|
.Ft int
|
|
|
|
.Fn setsockopt sock IPPROTO_TCP TCP_NOPUSH &One "sizeof One"
|
|
|
|
.Ft ssize_t
|
|
|
|
.Fn sendto sock msg len MSG_EOF &sin "sizeof sin"
|
|
|
|
.Ft ssize_t
|
|
|
|
.Fn sendto sock msg len MSG_EOF 0 0
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
.Tn T/TCP
|
|
|
|
refers to a set of extensions to the
|
|
|
|
.Tn TCP
|
|
|
|
protocol (see
|
|
|
|
.Xr tcp 4 )
|
|
|
|
which permit hosts to reliably exchange a small amount of data in a
|
|
|
|
two-packet exchange, thus eliminating the extra round-trip delays
|
|
|
|
inherent in a standard
|
|
|
|
.Tn TCP
|
2003-06-28 23:53:39 +00:00
|
|
|
connection.
|
|
|
|
The socket interface includes modifications to support
|
1996-01-18 21:33:42 +00:00
|
|
|
.Tn T/TCP ,
|
|
|
|
detailed here for the specific case, and in the
|
1995-02-15 22:07:28 +00:00
|
|
|
.Xr socket 2
|
|
|
|
and
|
|
|
|
.Xr send 2
|
|
|
|
manual pages for the protocol-independent support.
|
|
|
|
.Tn T/TCP
|
|
|
|
is defined in RFC 1644.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Tn T/TCP
|
|
|
|
extensions work by including certain options in all segments of a
|
|
|
|
particular connection, which enable the implementation to avoid the
|
|
|
|
three-way handshake for all but the first connection between a pair of
|
2003-06-28 23:53:39 +00:00
|
|
|
hosts.
|
|
|
|
These same options also make it possible to more reliably
|
1995-02-15 22:07:28 +00:00
|
|
|
recognize old, duplicate packets, which in turn reduces the amount of
|
|
|
|
time the
|
|
|
|
.Tn TCP
|
2003-06-28 23:53:39 +00:00
|
|
|
protocol must maintain state after a connection closes.
|
|
|
|
The
|
1996-01-18 21:33:42 +00:00
|
|
|
.Dq Li net.inet.tcp.rfc1644
|
|
|
|
MIB variable can be used to disable
|
1995-02-15 22:07:28 +00:00
|
|
|
.Tn T/TCP
|
|
|
|
negotiation at run time; however, the protocol has been designed to
|
|
|
|
ensure that attempts by non-T/TCP
|
|
|
|
systems to communicate with T/TCP-enhanced
|
|
|
|
ones automatically degenerate into standard
|
|
|
|
.Tn TCP .
|
|
|
|
.Sh TRANSACTION MODEL
|
|
|
|
The expected model of a
|
|
|
|
.Dq transaction
|
|
|
|
as used by
|
|
|
|
.Tn T/TCP
|
|
|
|
is a fairly simple one:
|
|
|
|
.Bl -enum
|
|
|
|
.It
|
|
|
|
A client program generates a request to be sent to the server, which
|
|
|
|
is small enough to fit in a single
|
|
|
|
.Tn TCP
|
|
|
|
segment, and sends a SYN PUSH FIN segment with options and data to the
|
|
|
|
server.
|
|
|
|
.It
|
|
|
|
The server program accepts the request in the same manner as for
|
|
|
|
regular
|
|
|
|
.Tn TCP
|
|
|
|
connections, interprets it, and generates a reply which may be small
|
2003-06-28 23:53:39 +00:00
|
|
|
enough to fit in a single segment.
|
|
|
|
If it is, the reply is sent in a
|
1995-02-15 22:07:28 +00:00
|
|
|
single SYN PUSH FIN ACK segment with (different) options and data back
|
2003-06-28 23:53:39 +00:00
|
|
|
to the client.
|
|
|
|
If not, then the connection degenerates into (almost) the usual case for
|
1995-02-15 22:07:28 +00:00
|
|
|
.Tn TCP .
|
1996-01-18 21:33:42 +00:00
|
|
|
The server then closes its socket.
|
|
|
|
.It
|
|
|
|
The client reads the reply and closes its socket.
|
1995-02-15 22:07:28 +00:00
|
|
|
.El
|
|
|
|
.Sh CLIENT SUPPORT
|
|
|
|
Support on the client side is provided by extending the semantics of
|
|
|
|
the
|
|
|
|
.Xr sendto 2
|
|
|
|
and
|
|
|
|
.Xr sendmsg 2
|
|
|
|
system calls to understand the notion of
|
|
|
|
.Dq implied connect
|
|
|
|
and
|
2001-02-01 16:38:02 +00:00
|
|
|
.Dq send and shutdown .
|
1995-02-15 22:07:28 +00:00
|
|
|
To send the request in a transaction, the
|
|
|
|
.Xr sendto 2
|
|
|
|
system call is typically used, as in the following example:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
char request[REQ_LEN];
|
|
|
|
struct sockaddr_in sin;
|
|
|
|
int sock, req_len;
|
|
|
|
|
|
|
|
sock = socket(PF_INET, SOCK_STREAM, 0);
|
|
|
|
|
|
|
|
/* prepare request[] and sin */
|
|
|
|
|
2001-07-14 19:41:16 +00:00
|
|
|
err = sendto(sock, request, req_len, MSG_EOF,
|
1995-02-15 22:07:28 +00:00
|
|
|
(struct sockaddr *)&sin, sin.sin_len);
|
|
|
|
|
|
|
|
/* do something if error */
|
|
|
|
|
|
|
|
req_len = read(sock, request, sizeof request);
|
|
|
|
close(sock);
|
|
|
|
|
|
|
|
/* do something with the reply */
|
|
|
|
|
|
|
|
.Ed
|
|
|
|
.Pp
|
2001-07-14 19:41:16 +00:00
|
|
|
Note that, after the
|
1995-02-15 22:07:28 +00:00
|
|
|
call to
|
|
|
|
.Fn sendto ,
|
|
|
|
the socket is now in the same state as if the
|
|
|
|
.Xr connect 2
|
|
|
|
and
|
|
|
|
.Xr shutdown 2
|
2003-06-28 23:53:39 +00:00
|
|
|
system calls had been used.
|
|
|
|
That is to say, the only reasonable operations to perform on this socket are
|
1995-02-15 22:07:28 +00:00
|
|
|
.Xr read 2
|
|
|
|
and
|
|
|
|
.Xr close 2 .
|
2003-06-28 23:53:39 +00:00
|
|
|
(As the client's
|
1995-02-15 22:07:28 +00:00
|
|
|
.Tn TCP
|
|
|
|
sender is already shut down, it is not possible to
|
|
|
|
.Xr connect 2
|
|
|
|
this socket to another destination.)
|
|
|
|
.Sh SERVER SUPPORT
|
|
|
|
There are two different options available for servers using
|
|
|
|
.Tn T/TCP :
|
|
|
|
.Bl -enum
|
|
|
|
.It
|
|
|
|
Set the
|
|
|
|
.Dv TCP_NOPUSH
|
|
|
|
socket option, and use normal
|
|
|
|
.Xr write 2
|
|
|
|
calls when formulating the response.
|
|
|
|
.It
|
|
|
|
Use
|
|
|
|
.Xr sendto 2
|
|
|
|
with the
|
|
|
|
.Dv MSG_EOF
|
|
|
|
flag, as in the client, but with the destination unspecified.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The first option is generally the appropriate choice when converting
|
|
|
|
existing servers to use
|
|
|
|
.Tn T/TCP
|
|
|
|
extensions; simply add a call to
|
|
|
|
.Fn setsockopt sock IPPROTO_TCP TCP_NOPUSH &One "sizeof One"
|
|
|
|
(where
|
|
|
|
.Va One
|
2003-06-28 23:53:39 +00:00
|
|
|
is an integer variable with a non-zero value).
|
|
|
|
The server socket must
|
1995-02-15 22:07:28 +00:00
|
|
|
be closed before any data is sent (unless the socket buffers fill up).
|
|
|
|
.Pp
|
|
|
|
The second option is preferable for new servers, and is sometimes easy
|
2003-06-28 23:53:39 +00:00
|
|
|
enough to retrofit into older servers.
|
|
|
|
In this case, where the reply phase would ordinarily have included a call to
|
1996-01-18 21:33:42 +00:00
|
|
|
.Fn write ,
|
|
|
|
one substitutes:
|
|
|
|
.Pp
|
|
|
|
.Dl "sendto(sock, buf, len, MSG_EOF, (struct sockaddr *)0, 0)"
|
|
|
|
.Pp
|
1995-02-15 22:07:28 +00:00
|
|
|
In this case, the reply is sent immediately, but as in the client
|
2000-03-07 13:21:14 +00:00
|
|
|
case, the socket is no longer useful for anything and should be
|
1995-02-15 22:07:28 +00:00
|
|
|
immediately closed.
|
|
|
|
.Sh MIB VARIABLES
|
|
|
|
The
|
|
|
|
.Tn T/TCP
|
2001-07-14 19:41:16 +00:00
|
|
|
extensions require the
|
1996-01-18 21:33:42 +00:00
|
|
|
.Dq Li net.inet.tcp.rfc1644
|
|
|
|
MIB variable to be true in order for the appropriate
|
1995-02-15 22:07:28 +00:00
|
|
|
.Tn TCP
|
2004-07-03 18:29:24 +00:00
|
|
|
options to be sent.
|
|
|
|
See
|
1995-02-15 22:07:28 +00:00
|
|
|
.Xr tcp 4
|
|
|
|
for more information.
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr send 2 ,
|
|
|
|
.Xr setsockopt 2 ,
|
|
|
|
.Xr inet 4 ,
|
|
|
|
.Xr tcp 4
|
|
|
|
.Rs
|
|
|
|
.%A R. Braden
|
2004-05-14 20:07:49 +00:00
|
|
|
.%T "T/TCP - TCP Extensions for Transactions"
|
1995-02-15 22:07:28 +00:00
|
|
|
.%O RFC 1644
|
|
|
|
.Re
|
|
|
|
.Sh HISTORY
|
|
|
|
Support for
|
|
|
|
.Tn T/TCP
|
|
|
|
first appeared in
|
1996-08-22 23:51:58 +00:00
|
|
|
.Fx 2.1 ,
|
|
|
|
based on code written by Bob Braden and Liming Wei at the
|
1995-02-15 22:07:28 +00:00
|
|
|
University of Southern California, Information Sciences Institute, and
|
|
|
|
ported by Andras Olah at the University of Twente.
|