在节点接收到数据后,要经过phy.mac层进行依次处理。如下代码
//phy.cc
Phy::recv(Packet* p, Handler*)
{
struct hdr_cmn *hdr = HDR_CMN(p);
//struct hdr_sr *hsr = HDR_SR(p);
/*
* Handle outgoing packets
*/
switch(hdr->direction()) {
case hdr_cmn::DOWN :
/*
* The MAC schedules its own EOT event so we just
* ignore the handler here. It's on
* it distinguishing between incoming and outgoing
* packets.
*/
sendDown(p);
return;
case hdr_cmn::UP :
if (sendUp(p) == 0) {
/*
* XXX - This packet, even though not detected,
* contributes to the Noise floor and hence
* may affect the reception of other packets.
*/
Packet::free(p);
return;
} else {
uptarget_->recv(p, (Handler*) 0);//send the packet to up layer,the mac layer
}
break;
default:
printf("Direction for pkt-flow not specified; Sending pkt up the stack on default.\n\n");
if (sendUp(p) == 0) {
/*
* XXX - This packet, even though not detected,
* contributes to the Noise floor and hence
* may affect the reception of other packets.
*/
Packet::free(p);
return;
} else {
uptarget_->recv(p, (Handler*) 0);
}
}
}
在节点配置脚本中配置了phy的uptarget-是mac层对象。见mobilenode(tcl).
这个知识点经常会忘记,所以在这记一笔。