NS2中Mac802_11::recv(Packet *p, Handler *h )函数解析
2017-06-30 13:53
801 查看
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) { //if currently being idle, then, the state being set: recv ,2、判断MAC层的状态,如果MAC层空闲,则将信道状态改变成接收状态 setRxState(MAC_RECV); pktRx_ = p; /* * Schedule the reception of this packet, in * txtime seconds. */ mhRecv_.start(txtime(p)); } else { /* * If the power of the incoming packet is smaller than the * power of the packet currently being received by at least * the capture threshold, then we ignore the new packet. */ if(pktRx_->txinfo_.RxPr / p->txinfo_.RxPr >= p->txinfo_.CPThresh) { //there exits collision. //pktRx_: is the previes received packets(先前接收到的分组), packet p: is the newly received packet(新接收到的分组).
capture(p); } else { collision(p); } } }
相关文章推荐
- 解析包的关键字 获得handler 映射到具体的实现函数 client_packet.h
- 解析包的关键字 获得handler 映射到具体的实现函数 client_packet.cpp
- NS2中Mac802_11定时器介绍
- NS2中Mac802_11定时器介绍(转帖)
- send和recv函数解析
- Send函数和Recv函数解析
- send和recv函数解析(转)
- Send函数和Recv函数解析
- send和recv函数解析(转)
- socket使用TCP协议时,send、recv函数解析以及TCP连接关闭的问题
- SGI STL 函数static void (* set_malloc_handler(void (*f)()))()与函数指针解析
- send和recv函数解析(转)
- Send函数和Recv函数解析
- socket使用TCP协议时,send、recv函数解析以及TCP连接关闭的问题
- Send函数和Recv函数解析
- Send函数和Recv函数解析
- recv函数解析
- socket使用TCP协议时,send、recv函数解析以及TCP连接关闭的问题
- 解析SGI STL 函数static void (* __set_malloc_handler(void (*__f)()))()
- send和recv函数解析(转)