tcp_perf_ananlysis
Shared by: xiaopangnv
-
Stats
- views:
- 1
- posted:
- 12/9/2011
- language:
- pages:
- 4
Document Sample


TCP Performance Analysis
1. Objective: TCP Performance Tuning by varying transmission parameters.
The point of tuning TCP settings is to get the most throughput. I.e. to send the
maximum bytes of data per header that (1) the TCP sender can send; and (2) will fit
(along with 40 bytes of headers) in the smallest MTU along the IP routing path between
TCP sender and receiver, so as to avoid fragmentation slow-down.
2. Background
MSS and MTU
The best speed for long streams of TCP segments (like from an FTP or HTTP
download) is obtained with the largest MSS that will fit in the smallest MTU of all the IP
routers along the route (to avoid IP fragmentation). For Ethernet, the MSS value would
be 1460 (1500 - 40 = 1460). Where, 1500 is the MTU. TCP usually sets the MSS as 40
bytes less than the MTU.
Receive and Send Buffer.
The TCP Receive Buffer limits the number of TCP data segments the remote TCP
sender can launch onto the Internet before waiting for ACK from receiver. Since you
don't want the TCP sender to transmit fragments or leftovers, you should request a
Receive Buffer size that equals an integer number of TCP data segments. Consequently,
your Receive Buffer should be set to an integer multiple of your MSS. The Receive
Buffer should be large enough to allow the sender to keep sending while waiting for the
receiver to send the ACK. That will keep the pipeline full for maximum speed.
To get maximal throughput it is critical to use optimal TCP send and receive
socket buffer sizes for the link you are using. If the buffers are too small, the TCP
congestion window will never fully open up. If the buffers are too large, the sender can
overrun the receiver, and the TCP window will shut down.
3. Experiment Setup
a) Change the MSS and see how it affects TCP performance.
b) Change the buffer sizes:
We start with Receive Buffer=4*MSS. Then experiment with multiples of MSS to see the
difference. The optimal buffer size is twice the bandwidth*delay product of the link:
c) Toggle Nagle’s Algorithm off and see the difference.
The experiments are done by using your TCP client to fetch a file from your server. The
first set of experiments is with a file that has a small file size and the next set is with a
larger file. (Both files will be provided)
Note: The values obtained from the warm-up run should be entered in the warm-up
column, but while calculating averages, use only the values collected for the next 3 runs.
Experiment1 MTU
Settings Results
Packet count
MTU MSS R S Nagle Warm- Run1 Run2 Run3 Avg
Buffer Buffer up
(n x
MSS)
1500 1460 5840 5840 On
500 460 1840 5840 On
100 60 240 5840 On
Experiment2 Receive Buffer
Settings Results
Packet count Throughput
MTU MSS R S Nagle Warm- Run1 Run2 Run3 Avg Warm- Run1 Run2 Run3 Avg
Buffer Buffer up up
(n x
MSS)
1500 1460 5840 5840 On
1500 1460 8760 5840 On
1500 1460 11680 5840 On
1500 1460 32768 5840 On
Experiment3 Send Buffer
Settings Results
Packet count Throughput
MTU MSS R S Nagle Warm- Run1 Run2 Run3 Avg Warm- Run1 Run2 Run3 Avg
Buffer Buffer up up
(n x
MSS)
1500 1460 5840 5840 On
1500 1460 5840 8760 On
1500 1460 5840 11680 On
1500 1460 5840 32768 On
Experiment4 Nagle’s Algorithm
Settings Results
Packet count
MTU MSS R S Nagle Warm- Run1 Run2 Run3 Avg
Buffer Buffer up
(n x
MSS)
1500 1460 5840 5840 On
1500 1460 5840 8760 Off
Experiment1 MTU
Settings Results
Packet count
MTU MSS R S Nagle Warm- Run1 Run2 Run3 Avg
Buffer Buffer up
(n x
MSS)
1500 1460 5840 5840 On
500 460 1840 5840 On
100 60 240 5840 On
Experiment2 Receive Buffer
Settings Results
Packet count Throughput
MTU MSS R S Nagle Warm- Run1 Run2 Run3 Avg Warm- Run1 Run2 Run3 Avg
Buffer Buffer up up
(n x
MSS)
1500 1460 5840 5840 On
1500 1460 8760 5840 On
1500 1460 11680 5840 On
1500 1460 32768 5840 On
Experiment3 Send Buffer
Settings Results
Packet count Throughput
MTU MSS R S Nagle Warm- Run1 Run2 Run3 Avg Warm- Run1 Run2 Run3 Avg
Buffer Buffer up up
(n x
MSS)
1500 1460 5840 5840 On
1500 1460 5840 8760 On
1500 1460 5840 11680 On
1500 1460 5840 32768 On
Experiment4 Nagle’s Algorithm
Settings Results
Packet count
MTU MSS R S Nagle Warm- Run1 Run2 Run3 Avg
Buffer Buffer up
(n x
MSS)
1500 1460 5840 5840 On
1500 1460 5840 8760 Off
To vary the parameters, you need to make the following modifications in your Java code.
Changing Receive Buffer size of Sever
Use a setReceiveBufferSize () call followed by a getReceiveBufferSize () call to verify
that it has been changed.
Changing Send Buffer size of Server
Use a setSendBufferSize () call followed by a getSendBufferSize () call to verify that it
has been changed.
Int getReceiveBufferSize ()
Get value of the SO_RCVBUF option for this socket, i.e. the buffer size used by the
platform for input on this Socket.
Int getSendBufferSize ()
Get value of the SO_SNDBUF option for this socket, i.e. the buffer size used by the
platform for output on this Socket.
Void setReceiveBufferSize (int size)
Sets the SO_RCVBUF option to the specified value for this Socket.
Void setSendBufferSize (int size)
Sets the SO_SNDBUF option to the specified value for this Socket.
Toggling the Nagle’s Algorithm
Void setTcpNoDelay (boolean on)
Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm).
Changing the MTU
ifconfig –eth0 mtu xxxx
where xxxx is the value you want to set the MTU to.
(Note: don’t forget to reset mtu to 1500 at the end of the experiments.)
Obtaining the packet count and Throughput values
Run Ethereal on the Client.
Start Capture.
Type in tcp as the filter.
Stop Capture once the client has received the file requested from the server.
Tools-> Summary has the packet count and packets/sec information for the captured
packets.
Get documents about "