home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Internet Business Development Kit / PRODUCT_CD.iso / ftpage / disk7 / tcp-repo.ht_ / tcp-repo.ht
Encoding:
Text File  |  1995-09-07  |  4.0 KB  |  56 lines

  1. <!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
  2.  
  3. <HTML>
  4.  
  5. <HEAD>
  6. <TITLE>Windows HTTPD and TCP: A Report</TITLE>
  7. <META NAME="GENERATOR" CONTENT="Vermeer FrontPage 1.0">
  8. </HEAD>
  9.  
  10. <BODY>
  11. <H1>The FrontPage Personal Web Server and TCP<BR>
  12. </H1>
  13. <HR>
  14. <H2>INTRODUCTION</H2>
  15. <P>This report describes research on why the server appears to go to sleep or causes some sort of a system fault.</P>
  16. <P></P>
  17. <H2>BACKGROUND</H2>
  18. <P>First, it is important to understand that servers use a different set of functionality in a TCP package when compared to 
  19. clients. Therefore, you can expect to see different sorts of problems with servers versus clients. Secondly, HTTP (the Web 
  20. protocol) is unique in its high frequency of aborting connections. This is a normal part of HTTP, but it must be done with 
  21. care, else the underlying TCP machinery can get out of whack. Finally, and probably most importantly, the TCP packages 
  22. <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 
  23. both ends to get out of whack. The network manifesto is "strict in what you do, permissive in what you'll accept". 
  24. Nonetheless, some packages can get disturbed by misbehavior at the other end. Needless to say, this has far-reaching 
  25. consequences for server operators... In order to understand the specific causes of the observed problems, you need to 
  26. understand a bit about TCP connection opening and closing. This is a long topic, and more than we can explain in detail 
  27. here, so if you need more information, have a look at Douglas Comer's bibles <I>Internetworking with TCP/IP</I> (2 volumes).</P>
  28. <P>NOTE: My explanations will take the view of a client/browser and a server, but the process is more general, and needn't 
  29. follow the steps we describe.</P>
  30. <P></P>
  31. <H3>Opening a Connection</H3>
  32. <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> 
  33. 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 
  34. <CODE>SYN</CODE> too, we're all set"). At this point the connection is established. </P>
  35. <H3>Closing a connection</H3>
  36. <P>Either end may close a connection. Normally, the server sends the response data and then closes the connection. The client 
  37. reads until it sees the closure, at which time it assumes it has received the response. If the client desires to abort the 
  38. connection <I>it</I> closes the connection, not the server.</P>
  39. <P>There are 2 ways to close a connection, the "hard" way and the "soft" way. When the server sends its response and closes 
  40. the connection, it must do a soft close, wherein all unsent data is delivered to the client before the socket is actually closed. 
  41. On the other hand, if the client wants to abort the connection, it should do a hard close, where unsent data is trashed and 
  42. the connection is closed immediately.</P>
  43. <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 
  44. 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 
  45. 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 
  46. 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 
  47. through on their way down and they involve <CODE>ACK</CODE> exchanges and the using program calling <CODE>closesocket()</CODE>.</P>
  48. <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 
  49. shuts down the socket (again through a few intermediate states). A does the same. End of story. </P>
  50. <P></P>
  51. <HR>
  52. <P>Copyright (C) 1995 Vermeer Technologies, Inc. All rights reserved. </P>
  53. </BODY>
  54.  
  55. </HTML>
  56.