The ping command, by default, sends relatively small data packets. However, you can adjust the size of this data payload, and doing so can significantly affect your network test results, providing valuable insights into network performance and potential problems. This article explains how ping payload size influences testing and how to use it for effective network diagnostics.
Default Payload Sizes
The default payload size for ping varies depending on the operating system:
- Windows: 32 bytes of data (plus 8 bytes for the ICMP header, and 20 bytes for the IP header, totaling 60 bytes on the wire).
- Linux/macOS: 56 bytes of data (plus 8 bytes for the ICMP header, and 20 bytes for the IP header, totaling 84 bytes on the wire).
These default sizes are generally sufficient for basic connectivity testing, but they don't fully represent typical network traffic, which often involves much larger packets.
Effects of Larger Payloads (Bandwidth, MTU, Fragmentation)
Increasing the ping payload size has several important effects:
- Bandwidth Consumption: Larger packets consume more bandwidth. While a single large ping packet won't significantly impact a modern network, sending many large packets in rapid succession (e.g., using the
-f
flood option, with caution) can be used to stress-test a network's bandwidth capacity. However, for accurate bandwidth testing, dedicated tools like iperf are generally preferred over ping. - MTU Issues: The Maximum Transmission Unit (MTU) is the largest packet size that can be transmitted over a network link without fragmentation. The standard Ethernet MTU is 1500 bytes. If you send a ping packet larger than the MTU of any link along the path, the packet will be fragmented.
- Fragmentation: Fragmentation is the process of dividing a large packet into smaller fragments that can fit within the MTU. Fragmentation introduces overhead:
- The sending host or router must fragment the packet.
- The receiving host must reassemble the fragments.
- If any fragment is lost, the entire packet must be retransmitted.
- Latency: Larger packets will generally result in slightly higher Round Trip Time (RTT) values, even if there's no fragmentation. This is simply because it takes longer to transmit a larger amount of data.
Using Payload Size for MTU Discovery
One of the most valuable uses of adjusting ping payload size is for Path MTU Discovery (PMTUD). PMTUD is the process of determining the smallest MTU along the entire path between two hosts. Here's how you can use ping for this:
- Start with a large payload: Begin by sending ping packets with a large payload size (e.g., 1500 bytes or larger).
- Set the "Don't Fragment" (DF) bit: This is crucial. The DF bit tells routers not to fragment the packet.
- On Linux/macOS, the DF bit is typically set by default when you increase packet size.
- On Windows, you need to use the
-f
option (note: this is different from the Linux-f
flood option). The Windows-f
option sets the DF bit.
- Observe the results:
- If the ping is successful, the MTU along the path is at least as large as your payload size.
- If you receive a "Packet needs to be fragmented but DF set" error (or a similar message), it means the packet was too large for some link along the path, and the router was unable to fragment it because of the DF bit.
- Iteratively decrease the payload size: If you get the fragmentation error, gradually decrease the payload size until the ping is successful. The largest payload size that works without fragmentation is the Path MTU.
This process allows you to identify bottlenecks in your network where the MTU is lower than expected.
Command Syntax for Adjusting Payload Size (OS-specific)
Here's how to adjust the ping payload size on different operating systems:
- Windows:
ping -l [size] [target]
[size]
is the payload size in bytes.- Example:
ping -l 1472 google.com
(sends packets with a 1472-byte payload. With 28 bytes of overhead for ICMP and IP this will result in 1500-byte packets.) - To set the Don't Fragment bit:
ping -f -l [size] [target]
(e.g.,ping -f -l 1472 google.com
)
- Linux/macOS:
ping -s [size] [target]
[size]
is the payload size in bytes.- Example:
ping -s 1472 google.com
(sends packets with a 1472-byte payload) - The Don't Fragment bit is usually set automatically when you increase the packet size. You can explicitly control it with the
-M
option on some systems (e.g.,ping -M do -s 1472 google.com
to force fragmentation to be disallowed).
By strategically adjusting the ping payload size, you can gain valuable insights into your network's bandwidth capacity, MTU limitations, and potential fragmentation issues. This makes ping a more versatile tool for network diagnostics and troubleshooting. Please find our main article about ping and our guide about ping options.