Tech Blog

TCP Packet Sizes

After doing some more networking I did some research revolving around the ideal TCP packet sizes. As I have been making a custom TCP library, I thought I would share some of my findings that I thought could be helpful. 

Absolute Limits

The absolute limitation on TCP packet size is 64K (65535 bytes), but in reality this is far larger than the size of any packet you will see, because the lower layers (e.g. ethernet) have lower packet sizes, so anything larger than what the lower layers can handle will be segmented.


The  MTU (Maximum Transmission Unit) for Ethernet, is 1500 bytes. Some types of networks (like Token Ring) have larger MTUs, and some types have smaller MTUs, but the values are fixed for each physical technology.

The  MSS, is the maximum segment size, is a parameter of the options field of the TCP clients. For the common IP there is an MSS of 1460 Bytes.


When transmitting the packet, the TCP & IP headers equals 40 bytes. So this gets added on top of the MSS packet. Thus being that the MSS limit is 1460, because if you add the 40 byte headers you get 1500, the maximum packet size to be passed into the MTU before segmentation. 


After doing some more research, I found a study that calculated the efficiencies of the packets given their headers. The findings found here stated this

 for data payloads in excess of the common TCP payload maximum segment size (the MSS) of 1460 Bytes, the TCP over IP bandwidth overhead is approximately 2.8%. If you add Ethernet (and VLAN tagging) into the mix then the throughput of a 100Mb link is 100 X 0.9733 (TCP/IP efficiency) x 0.9728 (Ethernet (with tagging) efficiency) which equals 94.68Mbps, which I assume means the combined efficiency is 94.68%. Add in your security protocol (AES would drop the figure to 87.7%),


Simply put, the maximum packet size should be 1500 including headers. In order to find the ideal packet size for any individual application then you must take that 1500, subtract the 40 byte IP/TCP headers, any encryption headers and other application headers and then you can find the efficiency of your network protocols. With Http and cookies you can see upwards of a 25% overhead! So be mindful of you packets and always try to fill them to the brim. If you had 1461 byte packet, then it would fragment that into two packets each being 1460 and 1, and you would have a huge loss in efficiency. So 1460 is your magic number if you don't have any other headers you need to add. 

It should be noted that the above efficiencies assume 0% packet loss and the full bandwidth is available, so in reality your efficiency could be lower due to packet loss or bandwidth consumption by other applications. 

dan flan