|   UDP报头为: 
 
    
        
            | 源端口(16) | 目的端口(16) |  
            | 报文长(16) | 校验和(16) |    对应的数据结构为: 
 
    
        
            | typedef struct _udphdr //定义UDP报头 {
 unsigned short uh_sport;//16位源端口
 unsigned short uh_dport;//16位目的端口
 unsigned short uh_len;//16位长度
 unsigned short uh_sum;//16位校验和
 } UDP_HEADER;
 |    ICMP协议是网络层中一个非常重要的协议,其全称为Internet Control Message Protocol(因特网控制报文协议),ICMP协议弥补了IP的缺限,它使用IP协议进行信息传递,向数据包中的源端节点提供发生在网络层的错误信息反馈。ICMP报头为: 
   常用的回送与或回送响应ICMP消息对应数据结构为: 
 
    
        
            | typedef struct _icmphdr //定义ICMP报头(回送与或回送响应) {
 unsigned char i_type;//8位类型
 unsigned char i_code; //8位代码
 unsigned short i_cksum; //16位校验和
 unsigned short i_id; //识别号(一般用进程号作为识别号)
 unsigned short i_seq; //报文序列号
 unsigned int timestamp;//时间戳
 } ICMP_HEADER;
 |    常用的ICMP报文包括ECHO-REQUEST(响应请求消息)、ECHO-REPLY(响应应答消息)、Destination Unreachable(目标不可到达消息)、Time Exceeded(超时消息)、Parameter Problems(参数错误消息)、Source Quenchs(源抑制消息)、Redirects(重定向消息)、Timestamps(时间戳消息)、Timestamp Replies(时间戳响应消息)、Address Masks(地址掩码请求消息)、Address Mask Replies(地址掩码响应消息)等,是Internet上十分重要的消息。后面章节中所涉及到的ping命令、ICMP拒绝服务攻击、路由欺骗都与ICMP协议息息相关。   另外,本系列文章中的部分源代码参考了一些优秀程序员的开源项目,由于篇幅的关系我们不能一一列举,在此一并表示感谢。   So, let's go.    (参考链接: http://dev.yesky.com/43/2663043.shtml)  共4页: 上一页 [1] [2] [3] 4 下一页 |