Download Dynamic C TCP IP 1

Transcript
How does all this apply to sizing of TCP socket buffers? It basically means that there is little point
in making the buffers (both transmit and receive) larger than the expected maximum DBP of the
communications channel. For connections which are expected to traverse the Internet, you may
need quite large buffers. For local Ethernet only, the buffers need not be larger than, say, two
packets.
The maximum packet size is a compromise between performance and memory usage. The largest
packet supported by dcrtcp.lib is 1500 bytes, which is dictated by the limits of Ethernet.
Dynamic C’s default packet size is 600 bytes. Using large packet sizes improves performance for
bulk data transfer, but has little effect for interactive traffic. Performance is improved for large
packet sizes mainly because there is less CPU overhead per byte. There is a roughly fixed amount
of CPU time required to process each packet. This is obviously better utilized if there are a large
number of bytes per packet.
When using Ethernet, the Rabbit processor is limited in its overall TCP/IP throughput by CPU
power. 10Base-T Ethernet is capable of 1MB/sec for TCP sockets1, however the Rabbit 2000 running at 21MHz will only be able to transmit at about 270kB/sec when sending 1500 byte packets.
Receive rate is slightly slower at about 220kB/sec. This scales approximately linearly with respect
to CPU clock speed as well as application use of the CPU. In short, current Rabbit-based boards
cannot use the full bandwidth of a local Ethernet link.
The situation changes for PPP over serial. In this case, the serial port bandwidth is less than the
rate at which packets can be generated or received. Also, PPP is typically used to access peers over
the Internet, so there may be a much larger DBP than for a pure point-to-point link. For PPP serial
links, smaller packet sizes, e.g. 256 bytes, are satisfactory for bulk data transfers without impacting interactive traffic, should that be required. Socket buffer sizes should be determined based on
the expected Internet RTTs, which may be 1 second or more. For a 57.6kbps serial link, the DBP
is 5000 bytes for 1 second RTT, thus the socket buffers should be about this size for receive and
transmit.
TCP is adaptive to changing network conditions. For example, the RTT can vary considerably at
different times of day, and communication channels can become congested. TCP is designed to
cope with these conditions without exacerbating any existing problems, however socket buffer and
packet sizes are usually constants for the application so they need to be selected with due consideration to the most common conditions.
1. Assuming there is no other traffic on the Ethernet, and that collisions are rare. This is rarely the case, so a
50-80% utilization of bandwidth is considered the maximum desirable Ethernet load.
Chapter 4: Optimizing TCP/IP Performance
59