LINUX协议栈详解 ARP协议
来源:互联网 发布:轩通大数据是干嘛的 编辑:程序博客网 时间:2024/05/16 06:08
ARP协议负责从IP地址到物理MAC地址的转换。
ARP格式
/* * This structure defines an ethernet arpheader. */ struct arphdr { __be16 ar_hrd; /* format of hardware address */ __be16 ar_pro; /* format of protocol address */ unsignedchar ar_hln; /* length of hardware address */ unsignedchar ar_pln; /* length of protocol address */ __be16 ar_op; /* ARP opcode (command) */ #if 0 /* * Ethernet looks like this : This bit is variable sized however... */ unsignedchar ar_sha[ETH_ALEN]; /* sender hardware address */ unsignedchar ar_sip[4]; /* sender IP address */ unsignedchar ar_tha[ETH_ALEN]; /* target hardware address */ unsignedchar ar_tip[4]; /* target IP address */#endif };
接收ARP的函数是arp_rcv,在跑完NFPROTO_ARP钩子后,调用arp_process处理ARP请求,简单考虑,ARP操作分为
/* ARP protocol opcodes. */#define ARPOP_REQUEST 1 /*ARP request */#define ARPOP_REPLY 2 /*ARP reply */#define ARPOP_RREQUEST 3 /*RARP request */#define ARPOP_RREPLY 4 /*RARP reply */#define ARPOP_InREQUEST 8 /*InARP request */#define ARPOP_InREPLY 9 /*InARP reply */#define ARPOP_NAK 10 /*(ATM)ARP NAK */
1, ARPOP_REQUEST
如果到本地,则更新arp表,并且发送ARPOP_REPLY回应。
如果是到其他地方,则看是否开启arp代理,如果开启,则发送,并且更新arp表。
2, 如果为其他的操作,则也更新neigh_update
发送ARP的函数是arp_send,调用arp_create负责创建一个新的skb包,最后调用arp_xmit发送,当然发送过程也要经过NFPROTO_ARP钩子,最后调用最通用的发送函数:dev_queue_xmit。
- LINUX协议栈详解 ARP协议
- ARP协议(2)ARP协议格式详解
- ARP协议解码详解
- ARP协议详解
- ARP协议详解
- ARP协议解码详解
- ARP协议解码详解
- ARP协议详解
- ARP协议详解
- ARP协议详解
- ARP协议详解
- ARP协议详解
- ARP协议详解
- ARP协议详解
- ARP协议详解
- ARP协议详解
- ARP协议详解
- ARP协议详解
- redis的AOF文件格式的解析以及AOF文件的离线优化
- Infosys 推出 Finacle Analyz(TM)
- vsftp使用中的一些问题
- 深入理解C语言指针的奥秘
- oracle中varchar,varchar2,nvarchar,nvarchar2的区别
- LINUX协议栈详解 ARP协议
- Sybase中的BCP用法实践 与 Oracle的SQLLDR用法实践
- openCV测试
- win7 xampp内filezilla使用
- css概述
- char类型与string类型的区别
- android hal 层GPS 研究总结
- unity
- hadoop