ns-allinone-2.35/dei80211mr-1.1.4/src/mac-802_11mr.cc
void
Mac802_11mr::sendRTS(int dst)
{
	Packet *p = Packet::alloc();
	hdr_cmn* ch = HDR_CMN(p);
	MultiRateHdr *mrh = HDR_MULTIRATE(p);
	struct rts_frame *rf = (struct rts_frame*)p->access(hdr_mac::offset_);
	
	assert(pktTx_);
	assert(pktRTS_ == 0);

	/*
	 *  If the size of the packet is larger than the
	 *  RTSThreshold, then perform the RTS/CTS exchange.
	 */
	if( (u_int32_t) HDR_CMN(pktTx_)->size() < macmib_.getRTSThreshold() ||
            (u_int32_t) dst == MAC_BROADCAST) {
		Packet::free(p);
		return;
	}

	ch->uid() = 0;
	ch->ptype() = PT_MAC;
	ch->size() = phymib_.getRTSlen();
	ch->iface() = -2;
	ch->error() = 0;

	bzero(rf, MAC_HDR_LEN);

	rf->rf_fc.fc_protocol_version = MAC_ProtocolVersion;
 	rf->rf_fc.fc_type	= MAC_Type_Control;
 	rf->rf_fc.fc_subtype	= MAC_Subtype_RTS;
 	rf->rf_fc.fc_to_ds	= 0;
 	rf->rf_fc.fc_from_ds	= 0;
 	rf->rf_fc.fc_more_frag	= 0;
 	rf->rf_fc.fc_retry	= 0;
 	rf->rf_fc.fc_pwr_mgt	= 0;
 	rf->rf_fc.fc_more_data	= 0;
 	rf->rf_fc.fc_wep	= 0;
 	rf->rf_fc.fc_order	= 0;

	//rf->rf_duration = RTS_DURATION(pktTx_);
	STORE4BYTE(&dst, (rf->rf_ra));
	
	/* store rts tx time */
	mrh->mode() = basicMode_;
 	ch->txtime() = txtime(ch->size(), basicMode_);
	
	STORE4BYTE(&index_, (rf->rf_ta));

	/* calculate rts duration field */	
	rf->rf_duration = usec(phymib_.getSIFS()
			       + txtime(phymib_.getCTSlen(), basicMode_)
			       + phymib_.getSIFS()
                               + txtime(pktTx_)
			       + phymib_.getSIFS()
			       + txtime(phymib_.getACKlen(), basicMode_));
	pktRTS_ = p;
}
/*
 * Low-level transmit functions that actually place the packet onto
 * the channel.
 */
Low-level transmit functions that actually place the packet onto
the channel.
Low - level transmit functions that actually place the packet onto the channel .
void
Mac802_11mr::sendRTS(int dst)
{
	Packet *p = Packet::alloc();
	hdr_cmn* ch = HDR_CMN(p);
	MultiRateHdr *mrh = HDR_MULTIRATE(p);
	struct rts_frame *rf = (struct rts_frame*)p->access(hdr_mac::offset_);
	assert(pktTx_);
	assert(pktRTS_ == 0);
	if( (u_int32_t) HDR_CMN(pktTx_)->size() < macmib_.getRTSThreshold() ||
            (u_int32_t) dst == MAC_BROADCAST) {
		Packet::free(p);
		return;
	}
	ch->uid() = 0;
	ch->ptype() = PT_MAC;
	ch->size() = phymib_.getRTSlen();
	ch->iface() = -2;
	ch->error() = 0;
	bzero(rf, MAC_HDR_LEN);
	rf->rf_fc.fc_protocol_version = MAC_ProtocolVersion;
 	rf->rf_fc.fc_type	= MAC_Type_Control;
 	rf->rf_fc.fc_subtype	= MAC_Subtype_RTS;
 	rf->rf_fc.fc_to_ds	= 0;
 	rf->rf_fc.fc_from_ds	= 0;
 	rf->rf_fc.fc_more_frag	= 0;
 	rf->rf_fc.fc_retry	= 0;
 	rf->rf_fc.fc_pwr_mgt	= 0;
 	rf->rf_fc.fc_more_data	= 0;
 	rf->rf_fc.fc_wep	= 0;
 	rf->rf_fc.fc_order	= 0;
	STORE4BYTE(&dst, (rf->rf_ra));
	mrh->mode() = basicMode_;
 	ch->txtime() = txtime(ch->size(), basicMode_);
	STORE4BYTE(&index_, (rf->rf_ta));
	rf->rf_duration = usec(phymib_.getSIFS()
			       + txtime(phymib_.getCTSlen(), basicMode_)
			       + phymib_.getSIFS()
                               + txtime(pktTx_)
			       + phymib_.getSIFS()
			       + txtime(phymib_.getACKlen(), basicMode_));
	pktRTS_ = p;
}
void Mac802_11mr :: sendRTS ( int dst ) { Packet * p = Packet :: alloc ( ) ; hdr_cmn * ch = HDR_CMN ( p ) ; MultiRateHdr * mrh = HDR_MULTIRATE ( p ) ; struct rts_frame * rf = ( struct rts_frame * ) p -> access ( hdr_mac :: offset_ ) ; assert ( pktTx_ ) ; assert ( pktRTS_ == 0 ) ; if ( ( u_int32_t ) HDR_CMN ( pktTx_ ) -> size ( ) < macmib_ . getRTSThreshold ( ) || ( u_int32_t ) dst == MAC_BROADCAST ) { Packet :: free ( p ) ; return ; } ch -> uid ( ) = 0 ; ch -> ptype ( ) = PT_MAC ; ch -> size ( ) = phymib_ . getRTSlen ( ) ; ch -> iface ( ) = -2 ; ch -> error ( ) = 0 ; bzero ( rf , MAC_HDR_LEN ) ; rf -> rf_fc . fc_protocol_version = MAC_ProtocolVersion ; rf -> rf_fc . fc_type = MAC_Type_Control ; rf -> rf_fc . fc_subtype = MAC_Subtype_RTS ; rf -> rf_fc . fc_to_ds = 0 ; rf -> rf_fc . fc_from_ds = 0 ; rf -> rf_fc . fc_more_frag = 0 ; rf -> rf_fc . fc_retry = 0 ; rf -> rf_fc . fc_pwr_mgt = 0 ; rf -> rf_fc . fc_more_data = 0 ; rf -> rf_fc . fc_wep = 0 ; rf -> rf_fc . fc_order = 0 ; STORE4BYTE ( & dst , ( rf -> rf_ra ) ) ; mrh -> mode ( ) = basicMode_ ; ch -> txtime ( ) = txtime ( ch -> size ( ) , basicMode_ ) ; STORE4BYTE ( & index_ , ( rf -> rf_ta ) ) ; rf -> rf_duration = usec ( phymib_ . getSIFS ( ) + txtime ( phymib_ . getCTSlen ( ) , basicMode_ ) + phymib_ . getSIFS ( ) + txtime ( pktTx_ ) + phymib_ . getSIFS ( ) + txtime ( phymib_ . getACKlen ( ) , basicMode_ ) ) ; pktRTS_ = p ; }
Low-level transmit functions that actually place the packet onto
 the channel.
Low - level transmit functions that actually place the packet onto the channel .
/*
	 *  If the size of the packet is larger than the
	 *  RTSThreshold, then perform the RTS/CTS exchange.
	 */ //rf->rf_duration = RTS_DURATION(pktTx_); /* store rts tx time */ /* calculate rts duration field */