PING - CMD


Overview

The PING command in Windows CMD is a diagnostic tool used to test the connectivity between the current host and another networked device. It operates by sending Internet Control Message Protocol (ICMP) Echo Request messages to the target host and listens for ICMP Echo Response replies. This command helps users verify if a network device is accessible and measures the round-trip time for messages sent from the originating host to a destination computer.

Syntax

The basic syntax for PING is:

PING [options] destination
  • destination: Specifies the target host, either by IP address or hostname.

Options/Flags

  • -t: Pings the specified host until stopped manually (Ctrl+C). Use this to monitor the network connection continuously.
  • -a: Resolves addresses to hostnames. Helps identify which host is actually responding.
  • -n count: Specifies the number of ICMP Echo Requests to send. Default is 4 if not specified.
  • -l size: Sends buffer size (default is 32 bytes). Increasing this can test the network’s ability to handle larger packets.
  • -f: Sets the Don’t Fragment flag in packet (IPv4 only). Useful for diagnosing path MTU issues.
  • -i TTL: Sets the Time To Live (TTL) for the packet, useful for tracing packet routing.
  • -v TOS: Sets the Type of Service (TOS) for the packet.
  • -w timeout: Timeout in milliseconds to wait for each reply. The default timeout is 4000 ms (4 seconds).

Examples

  1. Simple Ping:

    PING google.com
    

    This command pings google.com with the default number of echo requests (4).

  2. Continuous Ping:

    PING -t example.com
    

    Continuously pings example.com until the command is manually stopped.

  3. Ping with Custom Packet Size:

    PING -l 1000 example.com
    

    Sends packets of 1000 bytes to example.com, useful for testing network throughput.

  4. Ping with Specified Count:

    PING -n 10 example.com
    

    Sends 10 ICMP Echo requests to example.com.

Common Issues

  • Request Timed Out: Indicates a lack of connection or a very high latency. Check network connections and firewalls.
  • Unknown host: The hostname is incorrect or DNS resolution is failing. Verify the hostname and network settings.

Integration

PING can be used in batch scripts or combined with other commands for network troubleshooting or monitoring:

FOR /L %i IN (1,1,10) DO (
    PING -n 1 example.org
    TIMEOUT /T 5
)

This script pings example.org every 5 seconds, 10 times.

  • TRACERT: Traces the route packets take to a network host.
  • IPCONFIG: Displays network configuration, including IP addresses.
  • NETSTAT: Displays network connections (incoming and outgoing), routing tables, and a number of network interface statistics.

Read more about network commands in the Microsoft Windows Command Reference.