From: dwalton1@bach.helios.nd.edu (david walton)
Newsgroups: comp.sys.mac.programmer
Subject: ulpTimeout problems with MacTCP
Summary: Can't find cause of ulpTimeouts on TCPSend.
Keywords: TCP/IP MacTCP TCPSend timeout ulptimeout
Date: 21 Jan 93 23:30:37 GMT
Organization: OUC, University of Notre Dame

I could use some help from anyone who's had experience working with
TCP/IP protocols and programming with MacTCP in particular.

I'm writing a Macintosh server application that uses NNTP (Network
News Transfer Protocol) to send news stories from an electronic
newsfeed to a UNIX host over a TCP/IP network.  As an extension to
NNTP, I've added a command that lets the client receive multiple
articles with one request, with termination lines (\r\n.\r\n) added to
delimit the stories in the stream.  Rather than sending the data all
at once, I send a predetermined chunk each time through the event
loop; the current maximum is 4K.  I also check the receive window on
the remote TCP, and if it's smaller than 4K, I send however many bytes
it says it's willing to take.


The problem I'm having is that ulp (upper layer protocol) timer
expires on TCPSends.  The client will issue a request, the server will
chunk along sending data for a while, and then the ulp timer will
expire on a particular send, and everything will hang up.  The
asynchronous notification routine that I've registered with TCPCreate
gets called, reports a ulp timeout, the timer restarts as expected,
and the whole process repeats itself ad infinitum.

I've tried to isolate the cause of the timeouts to no avail.  I'm
assuming that my server isn't getting ACKed for a batch of data sent
to the client.  Problem is, I don't know why.  The connection doesn't
appear to have dropped.  Some hypotheses I've investigated:
   
*  Client gets swamped with data.  Well, yes, but how?  The transfer
   rates average around ~.75K/second--not blindingly fast.  Besides
   which, changing the send buffer size to smaller numbers doesn't
   have a consistent effect either way.

   I've also changed the size of the buffers supplied to TCP (though I
   can't see why this would help, since the supplied buffers are used
   to store *incoming* data).  Used sizes ranging from 4 to 128K.
   Didn't help.

*  Processor time.  When I'm running both client and server on the same
   machine, the timer expires more consistently if the server's in the
   foreground and the client's in the background, suggesting that the
   relative amount of processor time was the variable.  Trouble is,
   reversing the two doesn't eliminate the problem; changing
   sleepTicks in WaitNextEvent doesn't eliminate the problem; and
   moving the client to a different machine (even using Telnet on a
   UNIX box) doesn't eliminate the problem.

*  Network traffic.  This would be an obvious suggestion, except that I
   do much of my testing on my IIci at home, which has no actual
   physical network connection.  Moreover, I've used all varieties of
   LocalTalk and Ethernet networks, both lightly- and heavily-loaded.
   My testing hasn't revealed consistent differences.

Having failed to find the problem, I have two questions:
    
1.  Anyone have any idea why these timeouts might be happening?  Or
    could somebody explain generally what conditions might prevent
    MacTCP from sending data (or receiving an ACK for it)?

2.  Can I do anything from the Aynchronous Notification Routine to see
    that the data does get sent?  I.e., something like this: ulp timer
    expires, my routine gets called, routine does something magical
    that gets the data delivered?  As of now, all that happens is that
    the ulp timer is reset and times out repeatedly, which isn't a
    very helpful behavior.

If anyone has any insights that might help here (or knows of an M that
I might go RTF :-), please send me electronic mail.  Unfortunately, my
familiarity with TCP doesn't extend to a very low level, so I may be
missing something basic that I should know about; please tell me if so.

Finally, here's a description of my testing configurations:

* Machines: Macintosh IIci, SE/30, Quadra 700, SE, Classic.
* OS:	    System 7.0, 7.0*, 7.0.1, 7.0.1*, 7.1.
* MacTCP:   1.1.1
* Networks: Ethernet (Thin, TP), LocalTalk.  Have also used my IIci at
            home which has no physical network attached.  Have tested
            with client and server both on same and on different
            machines for all networks.
* Clients:  NCSA Telnet 2.3, 2.4.x, 2.5 for the Macintosh; Telnet for
            SUN OS 4.0.x (?), custom-designed Hypercard stack. 


Any suggestions will be rewarded with gushing replies of thanks.  :-)

David Walton
--
{  David Walton 	   Mail to dwal@midway.uchicago.edu  }
{  These opinions are all mine, and the University of Notre  }
{  Dame has no right (and probably no desire) to claim 'em.  }
Newsgroups: comp.sys.mac.programmer