walter2001的博客walter2001.blog.chinaunix.net
walter2001
全部博文(16)
2012年(1)
2011年(1)
2010年(2)
2009年(1)
2007年(11)
ly199205
Zuoyeban
mwqyygy
59197549
99634791
at1a5
ss_ll_jj
guixin00
gaga1228
分类: 系统运维
2007-04-07 22:31:54
struct hdr_cmn { ...... /*关键在这里两行*/ // called if pkt can't obtain media or isn't ack'd. not called if droped by a queue FailureCallback xmit_failure_; void *xmit_failure_data_; /*关键在上面这里两行*/ /* * MONARCH wants to know if the MAC layer is passing this back because * it could not get the RTS through or because it did not receive * an ACK. */ int xmit_reason_; #define XMIT_REASON_RTS 0x01 #define XMIT_REASON_ACK 0x02 // Monarch extn ends; ...... };
void XmitFailureCallback(Packet *pkt, void *data) { DSRAgent *agent = (DSRAgent *)data; // cast of trust agent->xmitFailed(pkt); } void XmitFlowFailureCallback(Packet *pkt, void *data) { DSRAgent *agent = (DSRAgent *)data; agent->xmitFlowFailed(pkt); }
void DSRAgent::sendOutPacketWithRoute(SRPacket& p, bool fresh, Time delay) { if (dsragent_enable_flowstate && p.src == net_id && !srh->route_request() && !srh->cur_addr() && !srh->route_error() && !srh->route_reply()) { ...... cmnh->xmit_failure_ = srh->num_addrs() ? XmitFailureCallback : XmitFlowFailureCallback; cmnh->xmit_failure_data_ = (void *) this; } else { if (srh->route_request()) { // broadcast forward cmnh->xmit_failure_ = 0; cmnh->next_hop() = MAC_BROADCAST; cmnh->addr_type() = NS_AF_ILINK; } else { // forward according to source route cmnh->xmit_failure_ = XmitFailureCallback; cmnh->xmit_failure_data_ = (void *) this; ...... } } }
void Mac802_11::RetransmitRTS() { ....... macmib_.RTSFailureCount++; ssrc_ += 1; // STA Short Retry Count if(ssrc_ >= macmib_.getShortRetryLimit()) { discard(pktRTS_, DROP_MAC_RETRY_COUNT_EXCEEDED); pktRTS_ = 0; /* tell the callback the send operation failed before discarding the packet */ hdr_cmn *ch = HDR_CMN(pktTx_); if (ch->xmit_failure_) { /* Need to remove the MAC header so that re-cycled packets don't keep getting bigger. */ ch->size() -= phymib_.getHdrLen11(); ch->xmit_reason_ = XMIT_REASON_RTS; ch->xmit_failure_(pktTx_->copy(),->xmit_failure_data_); } discard(pktTx_, DROP_MAC_RETRY_COUNT_EXCEEDED); pktTx_ = 0; ssrc_ = 0; rst_cw(); } else { ...... } } void Mac802_11::RetransmitDATA() { ...... (*rcount)++; if(*rcount >= thresh) { /* IEEE Spec section 9.2.3.5 says this should be greater than or equal */ macmib_.FailedCount++; /* tell the callback the send operation failed before discarding the packet */ hdr_cmn *ch = HDR_CMN(pktTx_); if (ch->xmit_failure_) { ch->size() -= phymib_.getHdrLen11(); ch->xmit_reason_ = XMIT_REASON_ACK; ch->xmit_failure_(pktTx_->copy(),->xmit_failure_data_); } ....... } else { ....... } }
上一篇:手动安装Eclipse+CDT开发环境
下一篇:NS中Scheduler类的工作机制简述
登录 注册