Wednesday, October 20, 2004

Packet/MTU Size

Packet size, also referred to as MTU (Maximum Transmission Unit) is the largest amount of data that can be transferred in one physical frame on the network.
Standard MTU Sizes:Ethernet MTU = 1500 bytesPPPoE MTU = 1492 bytesDial-Up MTU = 576 bytes
A packet or "MTU" consists of a header and the actual data. The actual data is referred to as the Maximum Segment Size or "MSS". The MSS is the largest segment of TCP data that can be transmitted. In other words: MTU = MSS + TCPIP headers.
MSS = MTU - (TCP20 + IP20) or MSS = MTU - 40
no packet fragmentation
zero packet loss
zero router congestion
Packet Size vs. Latency

Let's examine a transfer of 1,500,000 bytes of data using different packet size over a T1 line (T1=1,544,000 bits/sec) using the following formula:
( MSS + header ) * 8 bits/byte------------------------------ = latency (per hop)1,544,000 bits/sec.

Then, using different MTU values, we can calculate the relevance of packet size to latency.
If MTU = 1500, then: (1460+40) * 8 / 1,544,000 = 7.772 ms delay per hop If MTU = 576, then: (536+40) * 8 / 1,544,000 = 2.924 ms delay
Assuming a transfer over 10 hops, the 1500 MTU would wield 77.72 ms delay, while a 576 MTU would take 29.24 ms to transfer over a T1 line.
So what are we getting at? Well, it takes more time to send/receive larger packets. DUH!? How much mathematics do we need to understand this?

Of course we also need to look at it this way:
Even though we are receiving the smaller packets and they are transmitting faster, the overall speed in which we receive the TOTAL file will vary. That is the point in changing your MTU.
In some instances, the Total File will be received faster by smaller packet sizes and vice versa. Larger packets will present the Total File to you in certain circumstances.

Throughput vs. Packet Size

Using this formula:
( MSS + header ) * 8 bits/byte------------------------------ = latency (per hop)1,544,000 bits/sec.
Assume we need to transfer 1 MByte file:
1MByte = 1024 KB = 1,048,576 bytes.
If MTU = 1500, then: (1460+40) * 8 / 1,544,000 = 7.772 ms delay per hop
1 MByte / MSS = 1,048,576 bytes / 1460 = 718.2, or effectively 719 packets to transfer 1 MByte.
Then, to transfer 1Mbyte: 719 packets * 7.772 ms delay per hop = 5588.068 ms, or 5.588 seconds per hop.
If we are transferring our 1 MByte file over 10 hops, it will take us 55.88 sec.
If MTU = 576, then: (536+40) * 8 / 1,544,000 = 2.924 ms delay per hop.
1 MByte / MSS = 1,048,576 bytes / 536 = 1956.3, or effectively 1957 packets to transfer 1 MByte.
Then, to transfer 1 MByte: 1957 packets * 2.924 ms delay per hop = 5722.268 ms, or 5.722 seconds per hop.

If we are transferring our 1 MByte file over the same 10 hops, it will take us 57.22 sec.
The difference comes from the fact that when using larger packets the overhead is smaller. To transfer 1 MByte, if using MTU of 1500 there are 719 * 40 = 28,760 bytes of overhead, while if using MTU of 576 1957 * 40 = 78,280 bytes, additional 49,520 bytes of headers transferred each MByte. For our 10-hop transfer, the additional overhead accounts for 1.34 seconds difference in transfer time for every MByte. This difference is a bit higher in practice, considering TCP options and the fact that modern TCP/IP implementations tend to use larger headers (additional 12 bytes header space for Timestamps for example).

Summary

It's logical to assume bigger packets are better, because of all the following factors:
network - reduced number of headers, as illustrated above
routers - less routing decisions
clients - less protocol processing and device interrupts
If throughput is not the goal, smaller packets may be a better selection since they take less time to travel throughout the network. That effect might be preferred in some applications and online gaming, at the expense of throughput.
Ultimately, packet size should be decided based on the type of the desired result, considering the underlying network as well, to avoid negative factors such as fragmentation of packets. Still one has to realize the fact that larger packets will still transmit more useful data than smaller packets, and that there is no single "best" solution for all applications.

(Dial-up) (DSL)
MTU Maximum Transmission Unit 576 1500

MSS Maximum Segment Size
(MTU - 40 bytes
for IP and TCP headers) 536 1460

"RWIN" TCP Receive Window
(Buffer)
or DefaultRcvWindow 8192 32768

0 Comments:

Post a Comment

<< Home