home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / hamradio / wattcp.zip / README.2ND < prev    next >
Text File  |  1992-03-31  |  16KB  |  385 lines

  1. If you are programming with the Waterloo TCP library, the following notes
  2. may prove helpful and may have been ommitted from earlier copies of the
  3. programmers reference manual.
  4.  
  5. - - -
  6. General Changes                     (3/31/92)
  7.     This update has a lot of little bug fixes, optimizations and
  8.     general improvements thanks to a lot of people's input.  In
  9.     particular, Jason Dent and Graham Robinson (author of PKTMUX10).
  10.  
  11. 1. Push bit handling is improved.  This is mostly necessary for 3270
  12.    protocols, most others treat tcp as a simple binary stream.
  13.  
  14. 2. Zero window probing has been fixed.  This will keep things rolling
  15.    even when the remote machine is swamped and the network becomes lossy
  16.    around the same time.
  17.  
  18. 3. A bug in the ASCII tcp stuff was introduced on my site this month
  19.    and has been fixed.  I don't know if the bug was on my old distribution.
  20.  
  21. 4. Significant changes were made to the internal handling of acknowledgements
  22.    and handling data within the receive window.
  23.  
  24. 5. A bug used to annoy SCO and possibly other system consoles - fixed.
  25.    When WATTCP wished to refuse unwanted sessions from remote systems, it
  26.    would be missing a small flag.  Most tcp's didn't notice this flaw.
  27.  
  28. 6. Type of Service flag now RFC compliant - currently unused in non-military
  29.    installations, this flag could be used to set priorities for TELNET
  30.    sessions versus bulk data transfers like FTP, particularly over slow
  31.    lines.  Phil Karn (Mr. KA9Q) is currently researching this area and
  32.    so this upgrade should make WATTCP code react properly (unlike SunOS, BSD,
  33.    etc.) in sites which use his TCPs.
  34.  
  35. Erick
  36.  
  37. - - -
  38. Speed/Performance               (1/04/1992)
  39.  
  40.     The tcp code has undergone some mods to make it much faster, with
  41.     reads up to 120 kilobytes/s and writes up to 42 kilobytes/s on the
  42.     same subnet as my Sun.
  43.  
  44.     These speed were great, but my pc is usually on a subnet.  There, the
  45.     speeds were about 26 kB/s in writes and 70 kB/s in reads.
  46.  
  47.     For read's I was able to use good old sock_fastread.  For writes,
  48.     sock_fastwrite / sock_write just don't cut it because they are limited
  49.     to the small buffer size located in the tcp_Socket structure.
  50.  
  51.     I've added a new call which let's you get around that limitation,
  52.     sock_enqueue().  This new routine let's you specify a buffer of data
  53.     you wish to enqueue for transmission.  WATTCP records the address of
  54.     that buffer and its length, and starts to transmit it according to
  55.     the TCP rules.  You are not allowed to touch that buffer until all
  56.     the data is fully transmitted, something you can tell by using the
  57.     sock_tbused( s ) until it returns zero.  You must also keep calling
  58.     tcp_tick() or sock_tick() as those routines schedule transmissions.
  59.  
  60.  
  61.     Here is some sample code which writes out a disk file:
  62.  
  63.     tcp_open...
  64.     f->dhanle = open( ....
  65.     ...
  66.     while ( 1 ) {
  67.         /* check connection and do background stuff */
  68.         if (tcp_tick( s ) == 0) break;
  69.  
  70.         /* see if we can schedule more data */
  71.         if ( sock_tbused( s ) == 0 ){
  72.             printf("disk reading %u bytes\n", ftpdbufferlen );
  73.             if ((diff = read( f->dhandle, ftpdbuffer, ftpdbufferlen )) <= 0 ) {
  74.                 /* eof or possibly error condition */
  75.                 break;
  76.             } else {
  77.                 /* data ready to send */
  78.                 sock_enqueue( s, ftpdbuffer, diff );
  79.             }
  80.         }
  81.     }
  82.  
  83.     close( f->dhandle );
  84.     sock_close( s );
  85. - - -
  86. SMTPSERV  (in separate file: SMTPSERV.ZIP)
  87.  
  88.     This program accepts inbound mail and places it into mail spool files
  89.     almost identically to the way Phil Karn's NOS does.  You can download the
  90.     executable in pub/wattcp/smtpserv.zip.  If you find it useful or wish
  91.     to have it changed, let me know.
  92.  
  93. -----------------------------------------------------------------------------
  94.  
  95. Large Model                     (9/13/1991)
  96.     You can compile large or small model applications.  Check out the
  97.     MAKEFILE in the .\APPS subdirectory to see how easy it is to switch.
  98.  
  99.     The fullsrc.zip collection automatically produces large and small
  100.     model libraries.
  101.  
  102.     There is a potential problem when you compile applications because
  103.     you make the same mistake I did and place tcp_Socket on the stack
  104.     by declaring it an automatic variable.  The 'C' stack is normally
  105.     only four K, slightly less than the tcp_Socket structure.
  106.  
  107.     I didn't figure this one out very quickly, so tcp_open, udp_open,
  108.     and tcp_listen have code to warn you immediately and exit in case
  109.     you forget.
  110.  
  111. -----------------------------------------------------------------------------
  112.  
  113. TCP Fixes                       (9/13/1991)
  114.      The TCP portion of WATTCP has had numerous improvements.  I've managed
  115.      to significantly reduce the packet count while improving performance
  116.      and reliability.
  117.  
  118. -----------------------------------------------------------------------------
  119.  
  120. New Wattcp Programs
  121.      The latest release of MS-Kermit includes the WATTCP kernel, letting you
  122.      use it as a TELNET program.  I do not know where the ftp site is,
  123.      but it will probably be announced soon on Comp.protocols.tcp-ip.ibmpc
  124.      in the near future.
  125.  
  126.      LPD is a line printer server which will let a PC accept jobs from UNIX.
  127.      It offers some simple device restriction capabilities.  You can spool
  128.      jobs out any DOS file or device.  It requires a little few lines
  129.      of work to be used at any site other than mine.  It is available
  130.  
  131.      COMD.EXE is a simple program can be used to allow network access to
  132.      RS232 devices.  With a little work it could be converted into a modem
  133.      pool.  It is available from [129.97.128.196] pub/wattcp/comd.zip.
  134.  
  135.      If you have any improvements or new applications, please let me know.
  136.      I will gladly distribute them for you.
  137.  
  138. -----------------------------------------------------------------------------
  139.  
  140. Nested Config Files             (7/16/91)
  141.     Wattcp config files may be easily nested to allow for centralized
  142.     control of most parameters with local overrides, or user specific
  143.     extensions.
  144.  
  145.     To include a nested config file, use the following line in the
  146.     main config file:
  147.  
  148.         include = filename
  149.     eg. include = c:\local.cfg
  150.  
  151.     If the local file could not be found, a warning message is displayed.
  152.     You may wish to use a local file if it exists, but not display a message
  153.     if it does not.  To do that, simply prepend the filename with a question
  154.     mark.
  155.  
  156.     eg. include = ?c:\local.cfg
  157.  
  158.     When the nested file is complete it will return to the main file.
  159.  
  160.     The nesting limit is dependant upon the number of unused file handles
  161.     and the stack size.
  162.  
  163. -----------------------------------------------------------------------------
  164.  
  165. TCP/UDP Packet Dumps            (7/10/1991)
  166.     TCP/UDP packet dumping features have been added and may prove useful
  167.     for testing and debugging your applications.
  168.  
  169.     The debugger dumps packets, which gives you a feel for what the
  170.     kernal and the other end are trying to do.
  171.  
  172.     It's my job to try to make things go as fast as possible with as
  173.     few packets as possible (least load).  Actually, when you use the
  174.     dumping feature you usually INCREASE the packet count because the
  175.     dumper takes time which times out the scheduler and causes
  176.     retransmits.
  177.  
  178.     To include the debugging features in your program, add the line
  179.         dbuginit();
  180.     to your program *before* you call sock_init();
  181.  
  182.     To enable/disable the debugger, include the following lines in your
  183.     WATTCP.CFG file:
  184.         DEBUG.FILE=somename     # otherwise it will open a file called
  185.                                 # WATTCP.DBG in the current subdirectory
  186.                                 # somename could be con which will dump
  187.                                 # to the screen
  188.         DEBUG.MODE=DUMP         # to dump TCP/UDP data, looks a bit like
  189.                                 # DEBUG.COM
  190.    or   DEBUG.MODE=HEADERS      # to dump TCP/UDP headers
  191.    or   DEBUG.MODE=ALL          # to dump everything, headers and data
  192.  
  193.    You may write some textual data directly to the file.  Remember, you
  194.    must send a 'C' string ending with a 0, and you must include your
  195.    own CRLFs.
  196.  
  197.         db_write( char *msg );
  198.  
  199.    NOTE: If you use this feature and you also use usr_init, you
  200.          must chain usr_init as described in the programmers manual,
  201.          and as show in TCPINFO.C.
  202.  
  203. -----------------------------------------------------------------------------
  204. Good UDP Support                (6/5/1991)
  205.    Initially, only standard socket calls could be used for UDP.  That was kind
  206.    of shabby because UDP tends to be higher traffic, has no flow control, and
  207.    you wish to know record boundaries.
  208.  
  209.    The new code allows you to declare a big buffer into which the incomming
  210.    UDP packets will be bufferred.  Once initialized with sock_recv_init, the
  211.    buffer is used until the socket is closed.  NOTE: sock_recv... and the
  212.    regular socket input routines are MUTUALLY EXCLUSIVE, you can not use
  213.    one and the other at the same time.  
  214.  
  215.         byte bigbuf[ 8192 ];
  216.         byte smallbuf[ 512 ];
  217.         int templen;
  218.  
  219.         if ( !udp_open( &data, localport, remote, remoteport, NULL) ) {
  220.             printf("Error opening UDP channel");
  221.             exit( 3 );
  222.         }
  223.         /* set the big buffer */
  224.         if ( sock_recv_init( &data, bigbuf, sizeof( bigbuf )) == -1 ) {
  225.             printf("Error setting the receive buffers");
  226.             exit( 3 );
  227.         }
  228.         while ( 1 ) {
  229.             tcp_tick( NULL );           /* got to do this or sock_tick */
  230.  
  231.             /* check for incomming udp data */
  232.             if ( templen = sock_recv( &data, smallbuf, sizeof( smallbuf ))) {
  233.                 /* something received and it was templen bytes long */
  234.             }
  235.         }
  236.         sock_Close( &data );
  237.  
  238.    sock_recv... adds extra code, so it need not be used for simple UDP sockets
  239.    such as BOOTP which expects only a single packet.
  240.  
  241.    See sock_mode checksums below for more interesting notes.
  242.  
  243. -----------------------------------------------------------------------------
  244. UDP Checksums                   (6/5/1991)
  245.    sock_mode can be used to enable or disable checksums for udp sessions
  246.    using the following calls:
  247.  
  248.         sock_mode( &socket, UDP_MODE_CHK );
  249.         sock_mode( &socket, UDP_MODE_NOCHK );
  250.  
  251.    Unlike *some* systems, Waterloo TCP correctly assumes checksums are active
  252.    and allows an application to disable them on the fly as they consider
  253.    appropriate.
  254.  
  255.    Either or both sides may disable or re-enable checksums.
  256.  
  257. -----------------------------------------------------------------------------
  258. TCP Nagle Algorithm             (6/5/1991)
  259.    The Nagle algorithm is now used to collect data.  Nagle is ideally suited
  260.    to programs like TELNET (TCPPORT), etc. which send a lot of small chunks
  261.    of data.  Some programs, like X-Windows, real-time data collection, etc.,
  262.    should turn of the Nagle feature.  Nagle is on by default and should not
  263.    be disabled unless a true problem is experienced.
  264.  
  265.         sock_mode( &socket, TCP_MODE_NONAGLE ); /* turns it off */
  266.         sock_mode( &socket, TCP_MODE_NAGLE );   /* re-enables it */
  267.  
  268. -----------------------------------------------------------------------------
  269. getdomainname Changes           (6/5/1991)
  270.    getdomainname always took a string and length parameter, just like UNIX.
  271.    Now, if the length is zero, getdomainname just returns the pointer to
  272.    a system copy of the domainstring.
  273.  
  274. -----------------------------------------------------------------------------
  275. gethostname sethostname Changes (6/5/1991)
  276.    gethostname and sethostname are now available.  They work identically to
  277.    get/setdomainname() (as enhanced above).  The host name can either be set
  278.    via the WATTCP.CFG file or via bootp.
  279. -----------------------------------------------------------------------------
  280.  
  281. sock_PreRead addition           (4/26/1991)
  282.  
  283.    int sock_PreRead( void *s, byte *dp, int len );
  284.  
  285.    Some situations arise where it would be nice to read data without causing
  286.    it to disappear from the socket's buffer.  Usually that means double
  287.    buffering.  sock_PreRead works exactly like sock_FastRead, except it does
  288.    not remove the read data from the data buffers.  The returned value is the
  289.    number of bytes transferred, 0 for no data waiting, or -1 on a socket
  290.    error.
  291.  
  292.    This function is intended for special cases which are not easily performed
  293.    using other methods.
  294.  
  295. -----------------------------------------------------------------------------
  296.  
  297. sethostid addition              (4/26/1991)
  298.  
  299.    longword sethostid( longword ip );
  300.  
  301.    This function sets the system's default ip address.  Changing the ip address
  302.    will destroy existing TCP and UDP sessions.  You should close all sockets
  303.    before calling this function.  The passed ip address is always returned.
  304.  
  305.    This function is low level and rarely useful to an application programmer.
  306.  
  307.    main()
  308.    {
  309.        longword ip = 0x80010101;   /* 128.1.1.1 */
  310.        char buffer[ 512 ];
  311.  
  312.        sock_init();
  313.        sethostid( ip );
  314.        printf("IP address has been set to %s\n\r",
  315.            inet_ntoa( buffer, getipaddr() );
  316.    }
  317.  
  318. -----------------------------------------------------------------------------
  319.  
  320. setdomainname addition          (4/26/1991)
  321.  
  322.    char *setdomainname( char *string);
  323.  
  324.    The domain name returned by getdomainname and used for resolve() is set to
  325.    the value in the string passed to setdomainname().  Note that changing the
  326.    contents of the string after a setdomainname() call may or may not change
  327.    the value of the system domain string and is not recommended.  You are
  328.    recommended to dedicate a static location which will permanently hold that
  329.    name.
  330.  
  331.    setdomainname( NULL ) is an acceptable way to totally remove any domain name
  332.    and subsequently resolves will not attempt to append a domain name.
  333.  
  334.    The passed string is always returned, as demonstrated below.
  335.  
  336.    This function is low level and rarely useful to an application programmer.
  337.  
  338.    #include <stdio.h>
  339.    #include <tcp.h>
  340.    char buffer[ 512 ];  /* use a static or a calloc, do not place the name
  341.                            in a local variable on the stack, it may get lost! */
  342.    main()
  343.    {
  344.        sock_init();
  345.        puts("Enter a new domain");
  346.        gets( buffer );
  347.        printf("Was using %s\n\r", getdomainname());
  348.        printf("Now using %s\n\r", setdomainname( buffer ));
  349.  
  350.        setdomainname( NULL );
  351.        puts("Now using no domain name");
  352.    }
  353.  
  354. -----------------------------------------------------------------------------
  355.  
  356. _arp_resolve addition           (4/26/1991)
  357.  
  358.    _arp_resolve( longword ina, void *ethap)
  359.  
  360.    Given an ip address (ina), find the hardware address.  If ethap is non-NULL,
  361.    place the hardware address in the buffer pointed to by ethap.
  362.  
  363.    Each call to _arp_resolve checks a local cache to see if we already know
  364.    the hardware address.  If no entry exists for that IP address, steps
  365.    are taken to find a hardware address.  If the ip node is on our subnet,
  366.    an ARP request is broadcast, otherwise _arp_resolve is called recursively
  367.    to find the address to the gateway.
  368.  
  369.    Socket opens intrinsically call _arp_resolve and place the hardware address
  370.    in the socket structure so they are no longer dependant upon existance in
  371.    the cache.  This means existing tcp and udp sessions do not automatically
  372.    reconfigure if a new route is found to the remote host, but this is typical
  373.    of pc implementations and is quite reasonable.
  374.  
  375.    Programs which wish to force the hardware address to be in the arp cache
  376.    need only specify the ip address and NULL for the ethap buffer.
  377.  
  378.    Returns 1 on success or 0 if the ip address could not be resolved.
  379.  
  380.    This is a special use function and is rarely necessary for user
  381.    applications.
  382.  
  383. -----------------------------------------------------------------------------
  384.  
  385.