home *** CD-ROM | disk | FTP | other *** search
- <!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
-
- <HTML>
-
- <HEAD>
- <TITLE>Windows HTTPD and TCP: A Report</TITLE>
- <META NAME="GENERATOR" CONTENT="Vermeer FrontPage 1.0">
- </HEAD>
-
- <BODY>
- <H1>The FrontPage Personal Web Server and TCP<BR>
- </H1>
- <HR>
- <H2>INTRODUCTION</H2>
- <P>This report describes research on why the server appears to go to sleep or causes some sort of a system fault.</P>
- <P></P>
- <H2>BACKGROUND</H2>
- <P>First, it is important to understand that servers use a different set of functionality in a TCP package when compared to
- clients. Therefore, you can expect to see different sorts of problems with servers versus clients. Secondly, HTTP (the Web
- protocol) is unique in its high frequency of aborting connections. This is a normal part of HTTP, but it must be done with
- care, else the underlying TCP machinery can get out of whack. Finally, and probably most importantly, the TCP packages
- <EM>at each end</EM> of the connection must perfom the protocol correctly. If <EM>either</EM> package screws up, it is possible for one or
- both ends to get out of whack. The network manifesto is "strict in what you do, permissive in what you'll accept".
- Nonetheless, some packages can get disturbed by misbehavior at the other end. Needless to say, this has far-reaching
- consequences for server operators... In order to understand the specific causes of the observed problems, you need to
- understand a bit about TCP connection opening and closing. This is a long topic, and more than we can explain in detail
- here, so if you need more information, have a look at Douglas Comer's bibles <I>Internetworking with TCP/IP</I> (2 volumes).</P>
- <P>NOTE: My explanations will take the view of a client/browser and a server, but the process is more general, and needn't
- follow the steps we describe.</P>
- <P></P>
- <H3>Opening a Connection</H3>
- <P>The opening process is a 3-way handshake where the client sends a <CODE>SYN</CODE> packet to the server, the server sends a <CODE>SYN/ACK</CODE>
- back to the client ("I saw your <CODE>SYN</CODE>, and here's mine"), then the client sends an <CODE>ACK</CODE> back to the server ("OK, I saw your
- <CODE>SYN</CODE> too, we're all set"). At this point the connection is established. </P>
- <H3>Closing a connection</H3>
- <P>Either end may close a connection. Normally, the server sends the response data and then closes the connection. The client
- reads until it sees the closure, at which time it assumes it has received the response. If the client desires to abort the
- connection <I>it</I> closes the connection, not the server.</P>
- <P>There are 2 ways to close a connection, the "hard" way and the "soft" way. When the server sends its response and closes
- the connection, it must do a soft close, wherein all unsent data is delivered to the client before the socket is actually closed.
- On the other hand, if the client wants to abort the connection, it should do a hard close, where unsent data is trashed and
- the connection is closed immediately.</P>
- <P>In TCP terms a soft close is done by one end (A) sending a <CODE>FIN</CODE> message. The other end (B) sees the <CODE>FIN</CODE>, but it may have
- more to do, so it notes it and goes on. Eventually B is finished and sends a <CODE>FIN</CODE> back to A. Meanwhile, A is still alive
- responding to B so B can finish up. When A sees B's <CODE>FIN</CODE>, it knows it's all over and shuts down. B can shut down when it
- sends the FIN to A. <B>This is actually a white lie</B>, there are several interlock states in the TCP machine that the sockets go
- through on their way down and they involve <CODE>ACK</CODE> exchanges and the using program calling <CODE>closesocket()</CODE>.</P>
- <P>A hard close is where A sends a <CODE>RST</CODE> packet to B. At that point, B says "forget it", dumps its unsent data on the floor and
- shuts down the socket (again through a few intermediate states). A does the same. End of story. </P>
- <P></P>
- <HR>
- <P>Copyright (C) 1995 Vermeer Technologies, Inc. All rights reserved. </P>
- </BODY>
-
- </HTML>
-