PingReply.Buffer Property

Gets the buffer of data received in an Internet Control Message Protocol (ICMP) echo reply message.

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

public byte[] Buffer { get; }

Property Value

Type: System.Byte[]
A Byte array containing the data received in an ICMP echo reply message, or an empty array, if no reply was received.

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. 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. For additional information, see "Traceroute" in RFC 1574, Section 3.2, available at http://www.ietf.org.

The default buffer used with Send and SendAsync contains 32 bytes of data.

The following code example sends an ICMP echo request synchronously and displays the size of the buffer returned by this property.

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

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft