ADC Home > Reference Library > Technical Q&As > Carbon > Networking >

Numerous Small Packet Exchanges Resultin Poor TCP Performance


Q: My Open Transport TCP application exchanges a number of small packets of information, which may or may not generate a response from the other side. In some cases, I find that the application delays sending packets, and performance is terrible. How can I solve this problem?

A: One possible reason for this behavior is explained by the TCP_NODELAY option. As per the XTI specification, under most circumstances TCP sends data as soon as it is presented to TCP. However, when outstanding data has not yet been acknowledged, TCP delays sending small amounts of data, gathering it into a single packet which is sent when an acknowledgment is received. This technique, known as the Nagle Algorithm, is designed to prevent "send-side silly window syndrome." If an application generates data one byte at a time, this algorithm prevents it from filling the network with lots of one-byte payload TCP packets.

For some applications, this packetization may cause significant delays. Setting the TCP_NODELAY option defeats this algorithm. The following snippet shows how to set this option.

err = SetFourByteOption(ep, INET_TCP, TCP_NODELAY, 1);

This snippet relies on the SetFourByteOption, shown in Listing 7-5 of Inside Macintosh: Networking with Open Transport.

In general, disabling the Nagle Algorithm is a bad idea because it decreases the efficiency with which you use the network. A better solution is for you to structure your application so that it sends all logically associated data in one chunk. You may find OT's ability to send non-contiguous data helpful in this case.

[May 25 1998]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.