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 pack
NS2中Mac802_11::recv(Packet *p, Handler *h )函数解析
最新推荐文章于 2024-06-16 11:22:43 发布
本文详细解析了NS2模拟器中Mac802_11类的recv函数,主要涉及对下行数据的处理、MAC层状态检查以及碰撞和干扰的处理。当MAC层处于空闲状态时,会切换到接收状态并调度接收工作;若在发送状态下收到数据,由于信道繁忙,将设置错误标志丢弃数据;若接收到的新数据功率低于当前接收数据至少捕获阈值,忽略新数据,否则判定为碰撞。
摘要由CSDN通过智能技术生成