自制Ping(2) Structures
IP Helper ICMP相关接口主要用到两个结构,ICMP_ECHO_REPLY和IP_OPTION_INFORMATION ICMP_ECHO_REPLY structure ICMP_ECHO_REPLY 表示IPv4请求的响应信息所返回的数据 语法 typedef struct icmp_echo_reply { IPAddr Address; ULONG Status; ULONG RoundTripT
IP Helper ICMP相关接口主要用到两个结构, ICMP_ECHO_REPLY和IP_OPTION_INFORMATION
ICMP_ECHO_REPLY structure
ICMP_ECHO_REPLY表示IPv4请求的响应信息所返回的数据
语法
typedef struct icmp_echo_reply { IPAddr Address; ULONG Status; ULONG RoundTripTime; USHORT DataSize; USHORT Reserved; PVOID Data; struct ip_option_information Options; } ICMP_ECHO_REPLY, *PICMP_ECHO_REPLY;
成员
Address
Type: IPAddr
响应的IPv4地址,IPAddr 格式.
Status
Type: ULONG
请求状态类型为IP_STATUS.可以是下列值, 这些值定义在Ipexport.h中:
Value |
Meaning |
IP_SUCCESS 0 |
成功 |
IP_BUF_TOO_SMALL 11001 |
接受数据的缓存太小 |
IP_DEST_NET_UNREACHABLE 11002 |
目标网络无法访问 |
IP_DEST_HOST_UNREACHABLE 11003 |
目标主机无法访问 |
IP_DEST_PROT_UNREACHABLE 11004 |
目标协议无法访问 |
IP_DEST_PORT_UNREACHABLE 11005 |
目标端口无法访问 |
IP_NO_RESOURCES 11006 |
可用IP资源不足 |
IP_BAD_OPTION 11007 |
指定了一个有问题的IP选项(option) |
IP_HW_ERROR 11008 |
发生硬件错误 |
IP_PACKET_TOO_BIG 11009 |
数据报太大 |
IP_REQ_TIMED_OUT 11010 |
请求超时 |
IP_BAD_REQ 11011 |
有问题的请求 |
IP_BAD_ROUTE 11012 |
有问题的路由 |
IP_TTL_EXPIRED_TRANSIT 11013 |
传输时生存周期(TTL)过期. |
IP_TTL_EXPIRED_REASSEM 11014 |
分段重组时生存周期(TTL)过期 |
IP_PARAM_PROBLEM 11015 |
一个参数有问题 |
IP_SOURCE_QUENCH 11016 |
数据报到达太快处理不过来, 并且数据报可能已被丢弃. |
IP_OPTION_TOO_BIG 11017 |
一个IP选项(option)被舍得过大. |
IP_BAD_DESTINATION 11018 |
一个有问题的目的地. |
IP_GENERAL_FAILURE 11050 |
常规错误. 当某些ICMP数据报格式不正确时可能会收到此错误. |
RoundTripTime
Type: ULONG
往返时间,单位毫秒
DataSize
Type: USHORT
应答数据大小,单位byte
Reserved
Type: USHORT
系统保留.
Data
Type: PVOID
应答数据
Options
Type: structip_option_information
应答数据的IP标头中的IP选项(options),格式为IP_OPTION_INFORMATION . 内涵TTL等信息.
备注
IcmpParseReplies()分析ICMP_ECHO_REPLY得到IPv4 请求的应答数据. 64位平台对应ICMP_ECHO_REPLY32.
对于IPv4,成员Status 的组合方式遵循RFC 792.
GetIpErrorString()用于根据对应于IP_STATUS中的错误状态,检索IP helper失败描述信息
ICMP_ECHO_REPLY结构定义在Ipexport.h在中,而Ipexport.h被自动包含在Iphlpapi.h中.头文件Ipexport.h不应被直接使用.
要求
Minimum supported client |
Windows 2000 Professional [desktop apps only] |
Minimum supported server |
Windows 2000 Server [desktop apps only] |
Header |
Ipexport.h (include Iphlpapi.h) |
IP_OPTION_INFORMATION structure
IP_OPTION_INFORMATION结构体存放了IP标头中的配置选项(options)
语法
typedef struct ip_option_information { UCHAR Ttl; UCHAR Tos; UCHAR Flags; UCHAR OptionsSize; PUCHAR OptionsData; } IP_OPTION_INFORMATION, *PIP_OPTION_INFORMATION;
成员
Ttl
类型: UCHAR
在IPv4报头中表示生存周期字段.在IPv6报头中表示跳数限制(HopLimit)字段
Tos
类型: UCHAR
在IPv4中表示服务类型字段.该成员目前正被忽略.
Flags
类型: UCHAR
标志字段.在IPv4中这个标志包含在报头中.在IPv6中这个字段表示为选项(options)头
对于IPv4,Flags 可以是下列值的组合,它们都定义在Ipexport.h中:
Value |
Meaning |
IP_FLAG_REVERSE 0x01 |
使IP包添加到源IP路由表头中. 仅适用于Vista及以上版本. |
IP_FLAG_DF 0x02 |
表示IP包不应被分段. |
OptionsSize
类型: UCHAR
IP选项数据大小,单位bytes.
OptionsData
类型: PUCHAR
选项(options)数据.
备注
IP_OPTION_INFORMATION表示IP报头中的选项(options).在64位平台上,对应IP_OPTION_INFORMATION32.
TTL, TOS 和 Flags对应于IP报头的特定字段.
OptionsData对应于紧随标准IP报头的options中.
除了IPv4的源路由选项(options)以外,选项(options)数据必须遵循RFC 791协议在链路中按照指定格式发送.一个IPv4源路由选项(option)应该包含从第一跳到目的地的完整路由.
对于IPv6,选项(options)数据必须遵循RFC 2460协议在链路上按照指定格式发送.
IP_OPTION_INFORMATION是ICMP_ECHO_REPLY的一个成员,它在IcmpSendEcho, IcmpSendEcho2,和 Icmp6SendEcho2中都有应用.
该结构体定义在Ipexport.h中,而Ipexport.h包含在Iphlpapi.h中.Ipexport.h头文件不应直接使用.
要求
Minimum supported client |
Windows 2000 Professional [desktop apps only] |
Minimum supported server |
Windows 2000 Server [desktop apps only] |
Header |
Ipexport.h (include Iphlpapi.h) |

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Xbox consoles have improved dramatically over the years. Over the years, games have evolved with life-like features that gamers can't seem to get enough of. Playing your favorite games on Xbox can be a completely engrossing experience. However, sometimes using these advanced features, we end up with lag or ping issues if the internet speed is not that good. Sometimes we want games to download faster. Today, games like Forza Horizon 5 and Mortal Kombat require over 100GB of RAM. Downloading such games can take a long time if we don't have the right internet settings to help us. Method 1: Pass

The reasons for the ping request timeout include unreachable target host, network congestion, firewall or security settings, and DNS resolution issues. Detailed introduction: 1. The target host is unreachable. The Ping request timeout may mean that the target host cannot be accessed through the network. This may be due to the target host closing the network connection, the network where the target host is located failing, the target host IP address being set incorrectly, etc. ; 2. Network congestion. Ping request timeout may also be caused by network congestion. Network congestion may be due to large amounts of data transmission, network equipment failures, etc.

The network cannot ping, what's going on? In fact, this is a very common problem. It is mainly divided into two situations: pinging fails on the same network segment and pinging fails on different network segments. Let’s take a look at the details below. There are usually two reasons why the ping command cannot connect to the same network segment: one is an IP address that cannot be pinged in the same network segment, and the other is an IP address that cannot be pinged in a different network segment. These two situations have different solutions. First, let’s discuss the situation where ping fails within the same network segment. 1. Ping fails on the same network segment, and the result is "Unable to access the target host." The destination IP and source IP are on the same network segment, and the ping result is &l

Solution: 1. Click the "Start" button, click "Control Panel" - "System" in the start menu; 2. In the settings interface, click "Advanced System Settings" - "Advanced" - "Environment Variables"; 3. . Check whether there is a Path variable in Administrator's user variables. If you do not see this variable, click "New" and add the variable Path and variable value.

The reasons why the IP address cannot be pinged are: 1. The other party is shut down or the IP address does not exist; 2. The network segment is different and cannot be found through routing; 3. The firewall filters the ICMP packets sent by ping; 4. The IP address is set incorrectly; 5. Network cable failure; 6. The gateway is not set.

I found that there are quite a lot of ping commands under Linux. Here are a few examples: 1. pingwww.baidu.com, the roughest usage. At this time, the host will continue to send ICMPechorequest packets to the destination address until you press Ctrl +c2, ping-Ieth0www.baidu.com or ping-I192.168.8.151www.baidu.com, that is, the -I option can specify the network card that sends the ping packet. -I can be followed by the network card name or the IP address of the network card. 3. Ping-c3www.baidu.com, the -c option can specify how many ICMP packets to send, and you can see the host connection

The type of some operating systems can often be roughly judged by the ttl value of ping. Here is a summary: The TTL field value of the ICMP echo response of UNIX and UNIX-like operating systems is 255. CompaqTru645.0 The TTL field value of the ICMP echo response is 64. The TTL field value of the ICMP echo response of the Microsoft Windows NT/2K operating system is 128. The TTL field value of the ICMP echo response of the Microsoft Windows 95 operating system is 32. Of course, these ttl values can also be changed. Windows series systems can modify the following key values in the registry. Implementation: [HKEY_LOCAL_MACHINE\system\Curren

CakePHP is a popular PHP framework that provides many practical tools and features to make developers' work more efficient. One of them is the Helper mechanism, which provides useful functions and methods in view files. In this article, we will explore how to create a custom Helper in CakePHP. 1. Create the Helper class. In CakePHP, Helpers are stored in the 'app/View/Helper' directory. Create a new Hel
