This documentation is archived and is not being maintained.

PingReply.Options Property

Gets the options used to transmit the reply to an Internet Control Message Protocol (ICMP) echo request.

Namespace:  System.Net.NetworkInformation
Assembly:  System (in System.dll)

public PingOptions Options { get; }

Property Value

Type: System.Net.NetworkInformation.PingOptions
A PingOptions object that contains the Time to Live (TTL) and the fragmentation directive used for transmitting the reply if Status is Success; otherwise, null.

The TTL defines the number of times nodes can forward a packet as it travels between its source and destination. If the number of forwards, also known as hops, exceeds the value specified for the TTL, the packet is deemed undeliverable and is discarded.

The DontFragment value specified in the ICMP echo request controls packet fragmentation. If DontFragment is true and the packet size exceeds the maximum transmission unit of the network path taken by the packet, the packet is discarded and the PacketTooBig error is returned.

The following code example sends an ICMP echo request synchronously and displays the values stored in the PingOptions object returned by this property.

public static void LocalPing ()
{
    // Ping's the local machine.
    Ping pingSender = new Ping ();
    IPAddress address = IPAddress.Loopback;
    PingReply reply = pingSender.Send (address);

    if (reply.Status == IPStatus.Success)
    {
        Console.WriteLine ("Address: {0}", reply.Address.ToString ());
        Console.WriteLine ("RoundTrip time: {0}", reply.RoundtripTime);
        Console.WriteLine ("Time to live: {0}", reply.Options.Ttl);
        Console.WriteLine ("Don't fragment: {0}", reply.Options.DontFragment);
        Console.WriteLine ("Buffer size: {0}", reply.Buffer.Length);
    }
    else
    {
        Console.WriteLine (reply.Status);
    }
}
void LocalPing ()
{
    // Ping's the local machine.
    Ping* pingSender = new Ping ();
    IPAddress* address = IPAddress::Loopback;
    PingReply* reply = pingSender->Send (address);

    if (reply->Status == IPStatus::Success)
    {
        Console::WriteLine (S"Address: {0}", reply->Address->ToString ());
        Console::WriteLine (S"RoundTrip time: {0}", __box(reply->RoundTripTime));
        Console::WriteLine (S"Time to live: {0}", __box(reply->Options->Ttl));
        Console::WriteLine (S"Don't fragment: {0}", __box(reply->Options->DontFragment));
        Console::WriteLine (S"Buffer size: {0}", __box(reply->Buffer->Length));
    }
    else
    {
        Console::WriteLine (reply->Status);
    }
}

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Show: