NS2中Mac802_11::recv(Packet *p, Handler *h )函数解析

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值