Engineer John Nagle devised the Nagle algorithm to address the problem of network congestion that could be caused by TCP applications, or small packet problems. The Nagle algorithm is a standard feature of TCP, since its first implementation during the 1980s in UNIX systems.
The Nagle Algorithm in Brief
The method of Nagling is employed by the Nagle algorithm to process data by the sending TCP application. The Nagle algorithm is capable of detecting messages which are small-sized and then accumulating those messages into TCP packets which are large, to send them across the wire. In this way, the Nagle algorithm generates enormous numbers of TCP packets. Later, TCP packets are sent across the wire, which ensures that large numbers of small packets are not generated.
RFC 896 contains the technical specification of the Nagle algorithm, which was published in the year 1984. Essential factors pertaining to the overall performance of the network performance include the decisions about how much data is to be accumulated and the duration to lapse between data sends.
The bandwidth of a network connection is utilized efficiently by Nagling, by adding latency delays. RFC 896 illustrates the benefits of bandwidth and the reasons for their creation, which are outlined below:
- A series of messages containing 1 byte of data each are produced by a TCP application which is capable of intercepting keystrokes. This TCP application can communicate each character being typed to the receiver.
- Messages must be packed with the TCP header information, as per the requirement of TCP/IP. Messages are packaged before they are sent across a network. Size ranges of header messages vary between 20 and 60 bytes.
- An application can generate network messages containing 95% more header information (which amounts to 20 out of 21 bytes) coupled with less than 5% actual data from the keyboard of the sender, without the use of the Nagling algorithm. The Nagling algorithm enables the delivery of the same data through the use of far fewer messages. These messages contain 95% keyboard information and can guarantee huge savings on network bandwidth.
The Nagle algorithm is used by applications along with the socket programming option TCP_NODELAY. Nagling is enabled by default in the Java, Linux, and Windows operating systems. When the applications which are designed for these environments do not require the use of the Nagling algorithm, they must explicitly specify their requirement through the TCP_NODELAY option.
Limitations of the Nagling Algorithm
Nagling is specific to the TCP protocol. Other protocols including the UDP protocol do not make use of this algorithm. When Nagle is enabled, TCP applications that require fast response may not work as desired. Such applications include first-person shooter games or Internet phone calls.
A noticeable lag can be created while the Nagle algorithm assembles small data chunks. The time delay is displayed on the screen or in the digital audio stream. These applications conventionally disable Nagle.
Computer networks supported much less bandwidth than they did today when the algorithm was developed. The period when Nagling benefited networks dates back early 1980s during the experiences of John Nagle at Ford Aerospace. At this time, Nagling posed an advantage to heavily loaded networks. However, there are far fewer situations where networking applications can benefit from the algorithm today.