PingReply.Options プロパティ

定義

ICMP (インターネット制御メッセージ プロトコル) エコー要求に応答を送信するために使用するオプションを取得します。

public:
 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 オブジェクト。それ以外の場合は null

次のコード例では、ICMP エコー要求を同期的に送信し、このプロパティによって返される オブジェクトに格納されている値を PingOptions 表示します。

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

注釈

TTL は、ノードが送信元と送信先の間を移動する際にパケットを転送できる回数を定義します。 転送の数 (ホップとも呼ばれます) が TTL に指定された値を超えると、パケットは配信不能と見なされ、破棄されます。

ICMP エコー要求で指定された値は DontFragment 、パケットの断片化を制御します。 が true で、パケット サイズがパケットによって取得されたネットワーク パスの最大伝送単位を超えた場合DontFragment、パケットは破棄され、PacketTooBigエラーが返されます。

適用対象