IPStatus 枚举

定义

报告向计算机发送 Internet 控制消息协议 (ICMP) 回送消息的状态。Reports the status of sending an Internet Control Message Protocol (ICMP) echo message to a computer.

public enum class IPStatus
public enum IPStatus
type IPStatus = 
Public Enum IPStatus
继承
IPStatus

字段

BadDestination 11018

由于目标 IP 地址无法收到 ICMP 回送请求或者永远都不应当出现在任何 IP 数据报的目标地址字段中,ICMP 回送请求失败。The ICMP echo request failed because the destination IP address cannot receive ICMP echo requests or should never appear in the destination address field of any IP datagram. 例如,调用 Send 并指定 IP 地址“000.0.0.0”将返回此状态。For example, calling Send and specifying IP address "000.0.0.0" returns this status.

BadHeader 11042

由于标头无效,ICMP 回送请求失败。The ICMP echo request failed because the header is invalid.

BadOption 11007

由于包含无效选项,ICMP 回送请求失败。The ICMP echo request failed because it contains an invalid option.

BadRoute 11012

由于在源计算机和目标计算机之间没有有效的路由,ICMP 回送请求失败。The ICMP echo request failed because there is no valid route between the source and destination computers.

DestinationHostUnreachable 11003

由于无法访问目标计算机,ICMP 回送请求失败。The ICMP echo request failed because the destination computer is not reachable.

DestinationNetworkUnreachable 11002

由于无法访问包含目标计算机的网络,ICMP 回送请求失败。The ICMP echo request failed because the network that contains the destination computer is not reachable.

DestinationPortUnreachable 11005

由于目标计算机上的端口不可用,ICMP 回送请求失败。The ICMP echo request failed because the port on the destination computer is not available.

DestinationProhibited 11004

由于管理员禁止联系目标计算机,ICMPv6 回送请求失败。The ICMPv6 echo request failed because contact with the destination computer is administratively prohibited. 此值仅适用于 IPv6。This value applies only to IPv6.

DestinationProtocolUnreachable 11004

由于无法访问 ICMP 回送消息中指定的目标计算机,ICMP 回送请求失败,这是因为目标计算机不支持数据包的协议。The ICMP echo request failed because the destination computer that is specified in an ICMP echo message is not reachable, because it does not support the packet's protocol. 此值仅适用于 IPv4。This value applies only to IPv4. 此值在 IETF RFC 1812 中描述为“Communication Administratively Prohibited”(在管理上禁止通信)。This value is described in IETF RFC 1812 as Communication Administratively Prohibited.

DestinationScopeMismatch 11045

由于 ICMP 回送消息中指定的源地址和目标地址不在同一范围内,ICMP 回送请求失败。The ICMP echo request failed because the source address and destination address that are specified in an ICMP echo message are not in the same scope. 这通常是因路由器使用了源地址范围以外的接口转发数据包而导致的。This is typically caused by a router forwarding a packet using an interface that is outside the scope of the source address. 地址范围(本地链接、本地站点和全局范围)确定地址在网络上的有效位置。Address scopes (link-local, site-local, and global scope) determine where on the network an address is valid.

DestinationUnreachable 11040

由于无法访问 ICMP 回送消息中指定的目标计算机,ICMP 回送请求失败;此问题的确切原因未知。The ICMP echo request failed because the destination computer that is specified in an ICMP echo message is not reachable; the exact cause of problem is unknown.

HardwareError 11008

由于硬件错误,ICMP 回送请求失败。The ICMP echo request failed because of a hardware error.

IcmpError 11044

由于 ICMP 协议错误,ICMP 回送请求失败。The ICMP echo request failed because of an ICMP protocol error.

NoResources 11006

由于网络资源不足,ICMP 回送请求失败。The ICMP echo request failed because of insufficient network resources.

PacketTooBig 11009

由于包含请求的数据包的大小超过了位于源和目标之间的节点(路由器或网关)的最大传输单位 (MTU),ICMP 回送请求失败。The ICMP echo request failed because the packet containing the request is larger than the maximum transmission unit (MTU) of a node (router or gateway) located between the source and destination. MTU 定义可传送数据包的最大大小。The MTU defines the maximum size of a transmittable packet.

ParameterProblem 11015

由于节点(路由器或网关)在处理数据包标头时遇到问题,ICMP 回送请求失败。The ICMP echo request failed because a node (router or gateway) encountered problems while processing the packet header. 例如,当标头包含无效的字段数据或无法识别的选项时会出现这种状况。This is the status if, for example, the header contains invalid field data or an unrecognized option.

SourceQuench 11016

由于已放弃数据包,ICMP 回送请求失败。The ICMP echo request failed because the packet was discarded. 当源计算机的输出队列中没有足够的存储空间时,或者当数据包到达目标过快而无法进行处理时,就会发生这种情况。This occurs when the source computer's output queue has insufficient storage space, or when packets arrive at the destination too quickly to be processed.

Success 0

ICMP 回送请求成功;收到一个 ICMP 回送答复。The ICMP echo request succeeded; an ICMP echo reply was received. 当收到此状态代码时,另一个 PingReply 属性包含有效的数据。When you get this status code, the other PingReply properties contain valid data.

TimedOut 11010

在所分配的时间内未收到 ICMP 回送答复。The ICMP echo Reply was not received within the allotted time. 允许的默认答复时间为 5 秒。The default time allowed for replies is 5 seconds. 可以使用带 timeout 参数的 SendSendAsync 方法更改此值。You can change this value using the Send or SendAsync methods that take a timeout parameter.

TimeExceeded 11041

由于数据包的生存时间 (TTL) 值达到零,导致转发节点(路由器或网关)放弃数据包,ICMP 回送请求失败。The ICMP echo request failed because its Time to Live (TTL) value reached zero, causing the forwarding node (router or gateway) to discard the packet.

TtlExpired 11013

由于数据包的生存时间 (TTL) 值达到零,导致转发节点(路由器或网关)放弃数据包,ICMP 回送请求失败。The ICMP echo request failed because its Time to Live (TTL) value reached zero, causing the forwarding node (router or gateway) to discard the packet.

TtlReassemblyTimeExceeded 11014

由于数据包被分割为片段以便传输,但未在分配的时间内收到所有片段进行重组,ICMP 回送请求失败。The ICMP echo request failed because the packet was divided into fragments for transmission and all of the fragments were not received within the time allotted for reassembly. RFC 2460 将时间限制指定为 60 秒,必须在此时间内收到所有数据包片段。RFC 2460 specifies 60 seconds as the time limit within which all packet fragments must be received.

Unknown -1

由于未知原因,ICMP 回送请求失败。The ICMP echo request failed for an unknown reason.

UnrecognizedNextHeader 11043

由于“下一标头”字段中没有可识别的值,ICMP 回送请求失败。The ICMP echo request failed because the Next Header field does not contain a recognized value. “下一标头”字段指示扩展标头类型(如果存在)或者 IP 层上的协议(例如,TCP 或 UDP)。The Next Header field indicates the extension header type (if present) or the protocol above the IP layer, for example, TCP or UDP.

示例

下面的代码示例发送 ICMP 回送消息并检查状态。The following code example sends an ICMP echo message and checks the status.

#using <System.dll>

using namespace System;
using namespace System::Net;
using namespace System::Net::NetworkInformation;
using namespace System::Text;

// args[1] can be an IPaddress or host name.
int main()
{
   array<String^>^args = Environment::GetCommandLineArgs();
   
   Ping ^ pingSender = gcnew Ping;
   PingOptions ^ options = gcnew PingOptions;
   
   // Use the default Ttl value which is 128,
   // but change the fragmentation behavior.
   options->DontFragment = true;
   
   // Create a buffer of 32 bytes of data to be transmitted.
   String^ data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
   array<Byte>^buffer = Encoding::ASCII->GetBytes( data );
   int timeout = 120;
   PingReply ^ reply = pingSender->Send( args[ 1 ], 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 );
   }

   
}

using System;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;

namespace Examples.System.Net.NetworkInformation.PingTest
{
    public class PingExample
    {
        // args[0] can be an IPaddress or host name.
        public static void Main (string[] args)
        {
            Ping pingSender = new Ping ();
            PingOptions options = new PingOptions ();

            // Use the default Ttl value which is 128,
            // but change the fragmentation behavior.
            options.DontFragment = true;

            // Create a buffer of 32 bytes of data to be transmitted.
            string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
            byte[] buffer = Encoding.ASCII.GetBytes (data);
            int timeout = 120;
            PingReply reply = pingSender.Send (args[0], 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);
            }
        }
    }
}

注解

类使用此枚举中的值PingReply.Status设置属性。 PingThe Ping class uses the values in this enumeration to set the PingReply.Status property. Ping你调用PingReply Ping.Send或方法Ping.SendAsync来检查是否可以通过网络访问计算机时, 类将返回对象。The Ping class returns PingReply objects when you call the Ping.Send or Ping.SendAsync methods to check whether you can reach a computer across the network.

警告

DestinationProhibited 和 DestinationProtocolUnreachable 枚举值具有相同的数值。The DestinationProhibited and DestinationProtocolUnreachable enumeration values have the same numeric value. 这是可能的, 因为 DestinationProhibited 仅适用于 IPv6, DestinationProtocolUnreachable 仅适用于 IPv4。This is possible because DestinationProhibited applies only to IPv6 and DestinationProtocolUnreachable applies only to IPv4.

适用于