IP address(host) -> link address(Ethernet card, 48bits)
Addressing Problem: 一个host对应多个IP地址,不容易对应
- 解决方案:gateway两侧ip地址不同,link address确定card,network address确定host
- 这有点历史遗留问题,ip和link address的机制没有完全地分离开,decoupled logically but coupled in practice
- 对于A,ip的目标是B,link的目标是gateway
ARP,地址解析协议:由IP得到MAC地址 => 进一步可得到gateway address
- 是一种request-reply protocol
- nodes cache mappings, cache entries expire
- 节点request a link layer broadcast address,然后收到回复,回复的packet有redundant data,看到它的节点都能生成mapping
- reply:原则上unicast,只回传给发送者=>实际实现时更常见broadcast
- No “sharing” of state: bad state will die eventually
- MacOS中保留20min
- gratuitous request: 要求不存在的mapping,推销自己
必看资料:ARP
链路层以太网(MAC)
ip、子网掩码、网关、默认网关
e.g.
hardware:1(Ethernet)
protocol: 0x0800(IP)
hardware length:6 (48 bit Ethernet)
protocol length:4(32 bit IP)
opcode: 1(request) /2(reply)
Destination: broadcast (ff:ff:ff:ff:ff:ff)