void
Mac802_11::recv(Packet *p, Handler *h)
{
struct hdr_cmn *hdr = HDR_CMN(p);
/*
* Sanity Check
*/
assert(initialized());
/*
* Handle outgoing packets.
*/
if(hdr->direction() == hdr_cmn::DOWN) { //1、先判断数据是从MAC层发送出去的海试要接收的数据,如果是要发送给下层的数据,那么直接调用send()函数
send(p, h);
return;
}
/*
* Handle incoming packets.
*
* We just received the 1st bit of a packet on the network
* interface.
*
*/
/*
* If the interface is currently in transmit mode, then
* it probably won't even see this packet. However, the
* "air" around me is BUSY so I need to let the packet
* proceed. Just set the error flag in the common header
* to that the packet gets thrown away.
*/
if(tx_active_ && hdr->error() == 0) { //tx_active_=1:represent the MAC currently being sending.MAC层正在发送数据
hdr->error() = 1; //then, mark the packet error.那么,在包头标记错误
}
if(rx_state_ == MAC_IDLE) {
NS2中Mac802_11::recv(Packet *p, Handler *h )函数解析
最新推荐文章于 2017-08-30 14:26:14 发布