[C# ] 执行ping命令,获得网络状态

代码:

string  ipStr = "192.168.1.10";            
Ping p1 = new Ping();
PingReply reply = p1.Send(ip);


reply返回的状态:


public enum IPStatus
    {
        //
        // 摘要:
        //     The ICMP echo request succeeded; an ICMP echo reply was received. When you get
        //     this status code, the other System.Net.NetworkInformation.PingReply properties
        //     contain valid data.
        Success = 0,
        //
        // 摘要:
        //     The ICMP echo request failed because the network that contains the destination
        //     computer is not reachable.
        DestinationNetworkUnreachable = 11002,
        //
        // 摘要:
        //     The ICMP echo request failed because the destination computer is not reachable.
        DestinationHostUnreachable = 11003,
        //
        // 摘要:
        //     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.
        DestinationProtocolUnreachable = 11004,
        //
        // 摘要:
        //     The ICMP echo request failed because the port on the destination computer is
        //     not available.
        DestinationPortUnreachable = 11005,
        //
        // 摘要:
        //     The ICMP echo request failed because contact with the destination computer is
        //     administratively prohibited.
        DestinationProhibited = 11004,
        //
        // 摘要:
        //     The ICMP echo request failed because of insufficient network resources.
        NoResources = 11006,
        //
        // 摘要:
        //     The ICMP echo request failed because it contains an invalid option.
        BadOption = 11007,
        //
        // 摘要:
        //     The ICMP echo request failed because of a hardware error.
        HardwareError = 11008,
        //
        // 摘要:
        //     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. The MTU defines the maximum size of a transmittable
        //     packet.
        PacketTooBig = 11009,
        //
        // 摘要:
        //     The ICMP echo Reply was not received within the allotted time. The default time
        //     allowed for replies is 5 seconds. You can change this value using the Overload:System.Net.NetworkInformation.Ping.Send
        //     or Overload:System.Net.NetworkInformation.Ping.SendAsync methods that take a
        //     timeout parameter.
        TimedOut = 11010,
        //
        // 摘要:
        //     The ICMP echo request failed because there is no valid route between the source
        //     and destination computers.
        BadRoute = 11012,
        //
        // 摘要:
        //     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,
        //
        // 摘要:
        //     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 (available at www.ietf.org) specifies 60 seconds as
        //     the time limit within which all packet fragments must be received.
        TtlReassemblyTimeExceeded = 11014,
        //
        // 摘要:
        //     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.
        ParameterProblem = 11015,
        //
        // 摘要:
        //     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.
        SourceQuench = 11016,
        //
        // 摘要:
        //     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. For example, calling Overload:System.Net.NetworkInformation.Ping.Send
        //     and specifying IP address "000.0.0.0" returns this status.
        BadDestination = 11018,
        //
        // 摘要:
        //     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.
        DestinationUnreachable = 11040,
        //
        // 摘要:
        //     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.
        TimeExceeded = 11041,
        //
        // 摘要:
        //     The ICMP echo request failed because the header is invalid.
        BadHeader = 11042,
        //
        // 摘要:
        //     The ICMP echo request failed because the Next Header field does not contain a
        //     recognized value. The Next Header field indicates the extension header type (if
        //     present) or the protocol above the IP layer, for example, TCP or UDP.
        UnrecognizedNextHeader = 11043,
        //
        // 摘要:
        //     The ICMP echo request failed because of an ICMP protocol error.
        IcmpError = 11044,
        //
        // 摘要:
        //     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.
        DestinationScopeMismatch = 11045,
        //
        // 摘要:
        //     The ICMP echo request failed for an unknown reason.
        Unknown = -1
    }

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.xdnf.cn/news/144493.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

【C#】.Net基础语法一

目录 一、程序集信息 【1.1】Properties中AssemblyInfo文件 二、.Net程序的两次编译过程 三、.Net中命名空间和类 【3.1】引入命名空间 【3.2】修改默认的命名空间 【3.3】命名空间的总结 四、.Net中数据类型 【4.1】数值型 【4.2】非数值型 五、.Net中变量 【5.1】…

零代码编程:用ChatGPT批量自动下载archive.org上的音频书

http://archive.org 是一个神奇的网站,可以下载各种古旧的软件、书籍、音频、视频,还可以搜索各个网站的历史网页。 比如说,一些儿童故事音频就可以在http://archive.org下载到,可以用来做英语听力启蒙用。 举个例子&#xff0c…

vue3 和vue2 的比较

文章目录 生命周期多根节点Composition API组合式APIOptions API与composition API对比优化逻辑组织优化逻辑复用 异步组件(Suspense)Suspense组件 响应式原理性能体积优化编译优化diff算法优化静态提升数据劫持(响应式系统)优化 生命周期 vue3在组合AP…

【面试经典 150 | 滑动窗口】串联所有单词的子串

文章目录 写在前面Tag题目来源题目解读解题思路方法一:两个哈希表方法二:滑动窗口 写在最后 写在前面 本专栏专注于分析与讲解【面试经典150】算法,两到三天更新一篇文章,欢迎催更…… 专栏内容以分析题目为主,并附带一…

信创办公–基于WPS的PPT最佳实践系列 (项目8创建电子相册)

信创办公–基于WPS的PPT最佳实践系列 (项目8创建电子相册) 目录 应用背景操作步骤 应用背景 如果我们想把图片弄成相册,或者弄成一段有音乐的视频分享给朋友。我们可以利用PPT来制作。那我们如何用PPT制作电子相册或视频呢?可以跟…

2012 款宝马 X6 xDrive35i 车 中央显示屏经常会提示“发动机异常”

故障现象 一辆2012 款宝马X6 xDrive35i车(开发系列号为E71),搭载N55发动机,累计行驶里程约为21.2万km。车主反映,车辆加速过程中,中央显示屏经常会提示“发动机异常”。 故障诊断 接车后,进行路…

零代码编程:用ChatGPT批量将多个文件夹中的视频转为音频

有多个文件夹中的 视频,都要批量转换成音频格式。 转换完成后要删除视频。虽然现在已经有很多格式转换软件可以实现这个功能,但是需要一个个文件夹的操作,还要手动去删除视频。用ChatGPT来写一个批量自动操作程序吧: 输入提示词如…

Matlab随机数的产生

1、常见分布随机数的产生 1.1 二项分布 在贝努力试验中,某事件A发生的概率为p,重复该实验n次,X表示这n次实验中A发生的次数,则随机变量X服从的概率分布律(概率密度)为 记为 binopdf(x,n,p) p…

【深度学习实验】卷积神经网络(六):卷积神经网络模型(VGG)训练、评价

目录 一、实验介绍 二、实验环境 1. 配置虚拟环境 2. 库版本介绍 三、实验内容 0. 导入必要的工具包 1. 构建数据集(CIFAR10Dataset) a. read_csv_labels() b. CIFAR10Dataset 2. 构建模型(FeedForward&…

uni-app:获取元素宽高

效果 代码 这里我定义的宽为500px,高为200排序,控制台输出的结果是502,202。原因是我设置了上下左右宽度各为1px的border边框导致 核心代码分析 // const query uni.createSelectorQuery();表示创建了一个选择器查询实例。通过这个实例,你可以使用不同的方法来选择…

数据库数据恢复-SQL SERVER数据库分区被格式化的数据恢复方案

SQL SERVER数据库故障类型: 1、SQL SERVER数据库文件被删除。 2、SQL SERVER数据库所在分区格式化。 3、SQL SERVER数据库文件大小变为“0”。 4、使用备份还原数据库时覆盖原数据库。 SQL SERVER数据库故障原因: 1、人为误操作。 2、文件系统损坏&#…

vue安装步骤

1、winR ->cmd 打开运行窗口 2、如下两种方式,测试电脑现有vue版本,提示"MODULE_NOT_FOUND"错误 (1)方式一:vue -V (2)方式二:vue -version 3、输入以下命令: 参考链接:https://blog.csdn.n…

Android Logcat 命令行工具

关于作者:CSDN内容合伙人、技术专家, 从零开始做日活千万级APP。 专注于分享各领域原创系列文章 ,擅长java后端、移动开发、商业变现、人工智能等,希望大家多多支持。 目录 一、导读二、概览三、日常用法3.1 面板介绍3.2 日志过滤…

获取dom元素

<button type"button" click"greet">count is {{ count }}</button>function greet(event) {if (event) {console.log(event)console.log(event.target)console.log(event.target.tagName)} } 很明显没传参数&#xff0c;但是获取到了相应的值…

【VUE复习·3】@keyup.xxx 键盘事件触发函数(单按键 or 组合按键触发)

总览 1.keyup.xxx or keydown.xxx 单按键触发 2.组合按键触发 一、keyup.xxx or keydown.xxx 1.用法 在我们使用 keyup.enter 时&#xff0c;那么我们可以这样写&#xff1a; <div><input type"text" placeholder"按下回车键以确定..." keyu…

数据结构---课后习题(第一章)

&#x1f388;数据结构 &#x1f388;☀️☀️第一章 &#x1f388;☀️☀️&#x1f4a1;&#x1f4a1;&#x1f4a1;k阶m项斐波那契数 题目1.17&#xff1a; 已知k阶斐波那契序列的定义为 试编写求k阶斐波那契序列的第m项值的函数算法&#xff0c;k和m均以值调用的形式在函数…

二十,镜面IBL--打印BRDF积分贴图

比起以往&#xff0c;这节应该是最轻松的了&#xff0c; 运行结果如下 代码如下&#xff1a; #include <osg/TextureCubeMap> #include <osg/TexGen> #include <osg/TexEnvCombine> #include <osgUtil/ReflectionMapGenerator> #include <osgDB/Re…

新来个技术总监,把限流实现的那叫一个优雅,佩服!

新来个技术总监&#xff0c;把限流实现的那叫一个优雅&#xff0c;佩服&#xff01; 在电商高并发场景下&#xff0c;我们经常会使用一些常用方法&#xff0c;去应对流量高峰&#xff0c;比如限流、熔断、降级&#xff0c;今天我们聊聊限流。什么是限流呢&#xff1f;限流是限…

RocketMQ高性能核心原理与源码架构剖析

文章目录 1、源码环境搭建1.1、主要功能模块1.2、源码启动服务1.2.1、 启动nameServer1.2.2、 启动Broker1.2.3、 发送消息1.2.4、 消费消息 2、源码剖析2.1、NameServer的启动过程2.2、Broker服务启动过程2.3、Netty服务注册框架2.3.1、关注重点2.3.2、源码重点 1、源码环境搭…

【Linux】多线程

目录 一、线程1.线程概念2.二级页表3.线程的优点4.线程的缺点 二、进程和线程三、线程控制1.POSIX线程库2.线程创建3.线程等待4.线程终止5.线程分离 四、线程ID 一、线程 1.线程概念 什么是线程&#xff1f; 1.在一个程序里的一个执行路线就叫做线程&#xff08;thread&#x…