在common\packet.h hdr_cmn结构体中定义了addr_type_,分别有NS_AF_NONE, NS_AF_ILINK, NS_AF_INET这几项
我们在aodv.cc里面看到这几行代码:
- ch->addr_type() = NS_AF_INET;
- ch->addr_type() = NS_AF_NONE;
其实在mac\ll.cc里面的sendDown(Packet* p)函数很好的解释了上面代码的作用:
- switch(ch->addr_type()) {
- case NS_AF_ILINK:
- mac_->hdr_dst((char*) HDR_MAC(p), ch->next_hop());
- break;
- case NS_AF_INET:
- dst = ch->next_hop();
- /* FALL THROUGH */
- case NS_AF_NONE:
- if (IP_BROADCAST == (u_int32_t) dst)
- {
- mac_->hdr_dst((char*) HDR_MAC(p), MAC_BROADCAST);
- break;
- }
- /* Assuming arptable is present, send query */
- if (arptable_) {
- tx = arptable_->arpresolve(dst, p, this);
- break;
- }
NS_AF_NONE代表广播报文
NS_AF_ILINK代表不需要调用arp,具体用处不太清楚。