Handling of Buffers in HOB Implementations Using TCP
TCP is a streaming interface; there are no record boundaries. But when data are sent over the network, they are enclosed in packets. The maximum packet size depends on the underlying network structure. So, for example, with Ethernet a maximum of 1536 information bytes can be transported in one packet, while with Token Ring the maximum packet size can be around 8
Kbytes on a 4 Mbit Token Ring and 18 Kbytes on a 16 Mbit Token Ring.
Most implementations of the TCP interface (for example sockets) require a buffer to be allocated which waits to be filled while a receive is being set up. (Exception: XTI non-blocking of Unix.)
Most applications have a receive outstanding all the time for every connection that has been set up. Therefore, the buffers for receiving may occupy a lot of memory. For example, if the buffer size is 8
Kbytes and 2,000 connections are active, this adds up to approximately 16 megabytes of buffer that
are wasted during this time, waiting to be filled.
But if the application sets up only a short buffer, the receive API has to be called more often. The result will be reduced throughput and a performance bottleneck.
Many protocols send only a small amount of data in a single packet. If you take an ASCII VT emulation, normally one
byte (keyboard input) is sent to the server and the server only sends one byte back (echo). So in this case, large buffers are useless. But when, for example, a file transfer is started, the packets sent are filled to the maximum.
Therefore, in many HOB TCP implementations the following strategy has been chosen
with the goal of using a minimum of memory and attaining high throughput:
The administrator has to specify a small and a large buffer size. If both are equal (or the large buffer size is less than the small buffer size), a small buffer will be used for all outstanding receive operations.
Normally, the receive operation will be done with the small buffer size. As long as this small buffer has
not been filled completely, all receive operations use this small buffer. But whenever this small buffer is filled completely with incoming data, the application acquires a new buffer in the large size and uses this buffer. When the following receive operations show (for a certain number of times) that the small buffer would have been big enough, the memory of the large buffer is freed again, and the small buffer is used for the receive operations that follow.
webmaster@hobsoft.com, Last Updated:
03. Jul 07
|