PingReply.Options プロパティ


ICMP (インターネット制御メッセージ プロトコル) エコー要求に応答を送信するために使用するオプションを取得します。Gets the options used to transmit the reply to an Internet Control Message Protocol (ICMP) echo request.

 property System::Net::NetworkInformation::PingOptions ^ Options { System::Net::NetworkInformation::PingOptions ^ get(); };
public System.Net.NetworkInformation.PingOptions? Options { get; }
public System.Net.NetworkInformation.PingOptions Options { get; }
member this.Options : System.Net.NetworkInformation.PingOptions
Public ReadOnly Property Options As PingOptions



PingOptionsStatus の場合は、応答の送信に使用する有効期間 (TTL: Time to Live) とフラグメンテーション ディレクティブを格納した Success オブジェクト。それ以外の場合は nullA PingOptions object that contains the Time to Live (TTL) and the fragmentation directive used for transmitting the reply if Status is Success; otherwise, null.

次のコード例では、ICMP エコー要求を同期的に送信し、 PingOptions このプロパティによって返されるオブジェクトに格納されている値を表示します。The following code example sends an ICMP echo request synchronously and displays the values stored in the PingOptions object returned by this property.

void LocalPing()
   // Ping's the local machine.
   Ping ^ pingSender = gcnew 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 );
      Console::WriteLine( reply->Status );

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);
        Console.WriteLine (reply.Status);


TTL は、ノードが送信元と送信先の間を行き来する際にパケットを転送できる回数を定義します。The TTL defines the number of times nodes can forward a packet as it travels between its source and destination. 転送の数 (ホップとも呼ばれる) が TTL に指定された値を超える場合、パケットは配信不能と見なされ、破棄されます。If the number of forwards, also known as hops, exceeds the value specified for the TTL, the packet is deemed undeliverable and is discarded.

DontFragmentICMP エコー要求で指定された値は、パケットの断片化を制御します。The DontFragment value specified in the ICMP echo request controls packet fragmentation. DontFragmentがで true 、パケットサイズがパケットによって取得されるネットワークパスの最大転送単位を超えている場合、パケットは破棄され、 PacketTooBig エラーが返されます。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.