PingReply.Buffer プロパティ

定義

ICMP (インターネット制御メッセージ プロトコル) エコー応答メッセージで受信したデータのバッファーを取得します。Gets the buffer of data received in an Internet Control Message Protocol (ICMP) echo reply message.

public:
 property cli::array <System::Byte> ^ Buffer { cli::array <System::Byte> ^ get(); };
public byte[] Buffer { get; }
member this.Buffer : byte[]
Public ReadOnly Property Buffer As Byte()

プロパティ値

Byte[]

ICMP エコー応答メッセージで受信したデータを格納している Byte 配列。応答を受信しなかった場合は空の配列。A Byte array containing the data received in an ICMP echo reply message, or an empty array, if no reply was received.

次のコード例では、ICMP エコー要求を同期的に送信し、このプロパティによって返されるバッファーのサイズを表示します。The following code example sends an ICMP echo request synchronously and displays the size of the buffer returned by this property.

void ComplexPing()
{
   Ping ^ pingSender = gcnew Ping;
   
   // Create a buffer of 32 bytes of data to be transmitted.
   String^ data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
   array<Byte>^buffer = Encoding::ASCII->GetBytes( data );
   
   // Wait 10 seconds for a reply.
   int timeout = 10000;
   
   // Set options for transmission:
   // The data can go through 64 gateways or routers
   // before it is destroyed, and the data packet
   // cannot be fragmented.
   PingOptions ^ options = gcnew PingOptions( 64,true );
   
   // Send the request.
   PingReply ^ reply = pingSender->Send( "www.contoso.com", timeout, buffer, options );
   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 ComplexPing ()
{
    Ping pingSender = new Ping ();

    // Create a buffer of 32 bytes of data to be transmitted.
    string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    byte[] buffer = Encoding.ASCII.GetBytes (data);

    // Wait 10 seconds for a reply.
    int timeout = 10000;

    // Set options for transmission:
    // The data can go through 64 gateways or routers
    // before it is destroyed, and the data packet
    // cannot be fragmented.
    PingOptions options = new PingOptions (64, true);

    // Send the request.
    PingReply reply = pingSender.Send ("www.contoso.com", timeout, buffer, options);

    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);
    }
}

注釈

ICMP エコー要求と共に送信されるデータバッファーは、エコー応答の送信側に返されます。これにより、既知のサイズのパケットの往復移動時間を計算できます。The data buffer sent with the ICMP echo request is returned to the sender in the echo reply so the roundtrip travel time for a packet of a known size can be computed. データバッファーをオプションと組み合わせて DontFragment 使用すると、移行元コンピューターと移行先コンピューター間のネットワークパスの最大転送単位を検出できます。The data buffer, combined with the DontFragment option, can be used to discover the maximum transmission unit for the network path between the source and destination computers. 詳細については、RFC 1574 のセクション3.2 の「Traceroute」を参照 https://www.ietf.org してください。For additional information, see "Traceroute" in RFC 1574, Section 3.2, available at https://www.ietf.org.

とで使用される既定のバッファーには、 Send SendAsync 32 バイトのデータが含まれています。The default buffer used with Send and SendAsync contains 32 bytes of data.

適用対象