亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? mac-802_11.cc

?? ns-2 simulation code manet
?? CC
?? 第 1 頁 / 共 3 頁
字號:
/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- * * Copyright (c) 1997 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by the Computer Systems *	Engineering Group at Lawrence Berkeley Laboratory. * 4. Neither the name of the University nor of the Laboratory may be used *    to endorse or promote products derived from this software without *    specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Header: /nfs/jade/vint/CVSROOT/ns-2/mac/mac-802_11.cc,v 1.50 2005/09/18 23:33:33 tomh Exp $ * * Ported from CMU/Monarch's code, nov'98 -Padma. * Contributions by: *   - Mike Holland *   - Sushmita */#include "delay.h"#include "connector.h"#include "packet.h"#include "random.h"#include "mobilenode.h"// #define DEBUG 99#include "arp.h"#include "ll.h"#include "mac.h"#include "mac-timers.h"#include "mac-802_11.h"#include "cmu-trace.h"#include "flags.h"  // ktnahm// Added by Sushmita to support event tracing#include "agent.h"#include "basetrace.h"/* our backoff timer doesn't count down in idle times during a * frame-exchange sequence as the mac tx state isn't idle; genreally * these idle times are less than DIFS and won't contribute to * counting down the backoff period, but this could be a real * problem if the frame exchange ends up in a timeout! in that case, * i.e. if a timeout happens we've not been counting down for the * duration of the timeout, and in fact begin counting down only * DIFS after the timeout!! we lose the timeout interval - which * will is not the REAL case! also, the backoff timer could be NULL * and we could have a pending transmission which we could have * sent! one could argue this is an implementation artifact which * doesn't violate the spec.. and the timeout interval is expected * to be less than DIFS .. which means its not a lot of time we * lose.. anyway if everyone hears everyone the only reason a ack will * be delayed will be due to a collision => the medium won't really be * idle for a DIFS for this to really matter!! */inline voidMac802_11::checkBackoffTimer(){	if(is_idle() && mhBackoff_.paused())		mhBackoff_.resume(phymib_.getDIFS());	if(! is_idle() && mhBackoff_.busy() && ! mhBackoff_.paused())		mhBackoff_.pause();}inline voidMac802_11::transmit(Packet *p, double timeout){	tx_active_ = 1;		if (EOTtarget_) {		assert (eotPacket_ == NULL);		eotPacket_ = p->copy();	}	/*	 * If I'm transmitting without doing CS, such as when	 * sending an ACK, any incoming packet will be "missed"	 * and hence, must be discarded.	 */	if(rx_state_ != MAC_IDLE) {		//assert(dh->dh_fc.fc_type == MAC_Type_Control);		//assert(dh->dh_fc.fc_subtype == MAC_Subtype_ACK);		assert(pktRx_);		struct hdr_cmn *ch = HDR_CMN(pktRx_);		ch->error() = 1;        /* force packet discard */	}	/*	 * pass the packet on the "interface" which will in turn	 * place the packet on the channel.	 *	 * NOTE: a handler is passed along so that the Network	 *       Interface can distinguish between incoming and	 *       outgoing packets.	 */	downtarget_->recv(p->copy(), this);		mhSend_.start(timeout);	mhIF_.start(txtime(p));}inline voidMac802_11::setRxState(MacState newState){	rx_state_ = newState;	checkBackoffTimer();}inline voidMac802_11::setTxState(MacState newState){	tx_state_ = newState;	checkBackoffTimer();}/* ======================================================================   TCL Hooks for the simulator   ====================================================================== */static class Mac802_11Class : public TclClass {public:	Mac802_11Class() : TclClass("Mac/802_11") {}	TclObject* create(int, const char*const*) {	return (new Mac802_11());}} class_mac802_11;/* ======================================================================   Mac  and Phy MIB Class Functions   ====================================================================== */PHY_MIB::PHY_MIB(Mac802_11 *parent){	/*	 * Bind the phy mib objects.  Note that these will be bound	 * to Mac/802_11 variables	 */	parent->bind("CWMin_", &CWMin);	parent->bind("CWMax_", &CWMax);	parent->bind("SlotTime_", &SlotTime);	parent->bind("SIFS_", &SIFSTime);	parent->bind("PreambleLength_", &PreambleLength);	parent->bind("PLCPHeaderLength_", &PLCPHeaderLength);	parent->bind_bw("PLCPDataRate_", &PLCPDataRate);}MAC_MIB::MAC_MIB(Mac802_11 *parent){	/*	 * Bind the phy mib objects.  Note that these will be bound	 * to Mac/802_11 variables	 */		parent->bind("RTSThreshold_", &RTSThreshold);	parent->bind("ShortRetryLimit_", &ShortRetryLimit);	parent->bind("LongRetryLimit_", &LongRetryLimit);}/* ======================================================================   Mac Class Functions   ====================================================================== */Mac802_11::Mac802_11() : 	Mac(), phymib_(this), macmib_(this), mhIF_(this), mhNav_(this), 	mhRecv_(this), mhSend_(this), 	mhDefer_(this), mhBackoff_(this){		nav_ = 0.0;	tx_state_ = rx_state_ = MAC_IDLE;	tx_active_ = 0;	eotPacket_ = NULL;	pktRTS_ = 0;	pktCTRL_ = 0;			cw_ = phymib_.getCWMin();	ssrc_ = slrc_ = 0;	// Added by Sushmita        et_ = new EventTrace();		sta_seqno_ = 1;	cache_ = 0;	cache_node_count_ = 0;		// chk if basic/data rates are set	// otherwise use bandwidth_ as default;		Tcl& tcl = Tcl::instance();	tcl.evalf("Mac/802_11 set basicRate_");	if (strcmp(tcl.result(), "0") != 0) 		bind_bw("basicRate_", &basicRate_);	else		basicRate_ = bandwidth_;	tcl.evalf("Mac/802_11 set dataRate_");	if (strcmp(tcl.result(), "0") != 0) 		bind_bw("dataRate_", &dataRate_);	else		dataRate_ = bandwidth_;        EOTtarget_ = 0;       	bss_id_ = IBSS_ID;	//printf("bssid in constructor %d\n",bss_id_);}intMac802_11::command(int argc, const char*const* argv){	if (argc == 3) {		if (strcmp(argv[1], "eot-target") == 0) {			EOTtarget_ = (NsObject*) TclObject::lookup(argv[2]);			if (EOTtarget_ == 0)				return TCL_ERROR;			return TCL_OK;		} else if (strcmp(argv[1], "bss_id") == 0) {			bss_id_ = atoi(argv[2]);			return TCL_OK;		} else if (strcmp(argv[1], "log-target") == 0) { 			logtarget_ = (NsObject*) TclObject::lookup(argv[2]);			if(logtarget_ == 0)				return TCL_ERROR;			return TCL_OK;		} else if(strcmp(argv[1], "nodes") == 0) {			if(cache_) return TCL_ERROR;			cache_node_count_ = atoi(argv[2]);			cache_ = new Host[cache_node_count_ + 1];			assert(cache_);			bzero(cache_, sizeof(Host) * (cache_node_count_+1 ));			return TCL_OK;		} else if(strcmp(argv[1], "eventtrace") == 0) {			// command added to support event tracing by Sushmita                        et_ = (EventTrace *)TclObject::lookup(argv[2]);                        return (TCL_OK);                }	}	return Mac::command(argc, argv);}// Added by Sushmita to support event tracingvoid Mac802_11::trace_event(char *eventtype, Packet *p) {        if (et_ == NULL) return;        char *wrk = et_->buffer();        char *nwrk = et_->nbuffer();	        //char *src_nodeaddr =	//       Address::instance().print_nodeaddr(iph->saddr());        //char *dst_nodeaddr =        //      Address::instance().print_nodeaddr(iph->daddr());	        struct hdr_mac802_11* dh = HDR_MAC802_11(p);	        //struct hdr_cmn *ch = HDR_CMN(p);		if(wrk != 0) {		sprintf(wrk, "E -t "TIME_FORMAT" %s %2x ",			et_->round(Scheduler::instance().clock()),                        eventtype,                        //ETHER_ADDR(dh->dh_sa)                        ETHER_ADDR(dh->dh_ta)                        );        }        if(nwrk != 0) {                sprintf(nwrk, "E -t "TIME_FORMAT" %s %2x ",                        et_->round(Scheduler::instance().clock()),                        eventtype,                        //ETHER_ADDR(dh->dh_sa)                        ETHER_ADDR(dh->dh_ta)                        );        }        et_->dump();}/* ======================================================================   Debugging Routines   ====================================================================== */voidMac802_11::trace_pkt(Packet *p) {	struct hdr_cmn *ch = HDR_CMN(p);	struct hdr_mac802_11* dh = HDR_MAC802_11(p);	u_int16_t *t = (u_int16_t*) &dh->dh_fc;	fprintf(stderr, "\t[ %2x %2x %2x %2x ] %x %s %d\n",		*t, dh->dh_duration,		 ETHER_ADDR(dh->dh_ra), ETHER_ADDR(dh->dh_ta),		index_, packet_info.name(ch->ptype()), ch->size());}voidMac802_11::dump(char *fname){	fprintf(stderr,		"\n%s --- (INDEX: %d, time: %2.9f)\n",		fname, index_, Scheduler::instance().clock());	fprintf(stderr,		"\ttx_state_: %x, rx_state_: %x, nav: %2.9f, idle: %d\n",		tx_state_, rx_state_, nav_, is_idle());	fprintf(stderr,		"\tpktTx_: %lx, pktRx_: %lx, pktRTS_: %lx, pktCTRL_: %lx, callback: %lx\n",		(long) pktTx_, (long) pktRx_, (long) pktRTS_,		(long) pktCTRL_, (long) callback_);	fprintf(stderr,		"\tDefer: %d, Backoff: %d (%d), Recv: %d, Timer: %d Nav: %d\n",		mhDefer_.busy(), mhBackoff_.busy(), mhBackoff_.paused(),		mhRecv_.busy(), mhSend_.busy(), mhNav_.busy());	fprintf(stderr,		"\tBackoff Expire: %f\n",		mhBackoff_.expire());}/* ======================================================================   Packet Headers Routines   ====================================================================== */inline intMac802_11::hdr_dst(char* hdr, int dst ){	struct hdr_mac802_11 *dh = (struct hdr_mac802_11*) hdr;	       if (dst > -2) {               if ((bss_id() == ((int)IBSS_ID)) || (addr() == bss_id())) {                       /* if I'm AP (2nd condition above!), the dh_3a                        * is already set by the MAC whilst fwding; if                        * locally originated pkt, it might make sense                        * to set the dh_3a to myself here! don't know                        * how to distinguish between the two here - and                        * the info is not critical to the dst station                        * anyway!                        */                       STORE4BYTE(&dst, (dh->dh_ra));               } else {                       /* in BSS mode, the AP forwards everything;                        * therefore, the real dest goes in the 3rd                        * address, and the AP address goes in the                        * destination address                        */                       STORE4BYTE(&bss_id_, (dh->dh_ra));                       STORE4BYTE(&dst, (dh->dh_3a));               }       }       return (u_int32_t)ETHER_ADDR(dh->dh_ra);}inline int Mac802_11::hdr_src(char* hdr, int src ){	struct hdr_mac802_11 *dh = (struct hdr_mac802_11*) hdr;        if(src > -2)               STORE4BYTE(&src, (dh->dh_ta));        return ETHER_ADDR(dh->dh_ta);}inline int Mac802_11::hdr_type(char* hdr, u_int16_t type){	struct hdr_mac802_11 *dh = (struct hdr_mac802_11*) hdr;	if(type)		STORE2BYTE(&type,(dh->dh_body));	return GET2BYTE(dh->dh_body);}/* ======================================================================   Misc Routines   ====================================================================== */inline intMac802_11::is_idle(){	if(rx_state_ != MAC_IDLE)		return 0;	if(tx_state_ != MAC_IDLE)		return 0;	if(nav_ > Scheduler::instance().clock())		return 0;		return 1;}voidMac802_11::discard(Packet *p, const char* why){	hdr_mac802_11* mh = HDR_MAC802_11(p);	hdr_cmn *ch = HDR_CMN(p);	/* if the rcvd pkt contains errors, a real MAC layer couldn't	   necessarily read any data from it, so we just toss it now */	if(ch->error() != 0) {		Packet::free(p);		return;	}	switch(mh->dh_fc.fc_type) {	case MAC_Type_Management:		drop(p, why);		return;	case MAC_Type_Control:		switch(mh->dh_fc.fc_subtype) {		case MAC_Subtype_RTS:			 if((u_int32_t)ETHER_ADDR(mh->dh_ta) ==  (u_int32_t)index_) {				drop(p, why);				return;			}			/* fall through - if necessary */		case MAC_Subtype_CTS:		case MAC_Subtype_ACK:			if((u_int32_t)ETHER_ADDR(mh->dh_ra) == (u_int32_t)index_) {				drop(p, why);				return;			}			break;		default:			fprintf(stderr, "invalid MAC Control subtype\n");			exit(1);		}		break;	case MAC_Type_Data:		switch(mh->dh_fc.fc_subtype) {		case MAC_Subtype_Data:			if((u_int32_t)ETHER_ADDR(mh->dh_ra) == \                           (u_int32_t)index_ ||                          (u_int32_t)ETHER_ADDR(mh->dh_ta) == \                           (u_int32_t)index_ ||                          (u_int32_t)ETHER_ADDR(mh->dh_ra) == MAC_BROADCAST) {                                drop(p,why);                                return;			}			break;		default:			fprintf(stderr, "invalid MAC Data subtype\n");			exit(1);		}		break;	default:		fprintf(stderr, "invalid MAC type (%x)\n", mh->dh_fc.fc_type);		trace_pkt(p);		exit(1);	}	Packet::free(p);}voidMac802_11::capture(Packet *p){	/*	 * Update the NAV so that this does not screw	 * up carrier sense.	 */		set_nav(usec(phymib_.getEIFS() + txtime(p)));	Packet::free(p);}voidMac802_11::collision(Packet *p){	switch(rx_state_) {	case MAC_RECV:		setRxState(MAC_COLL);		/* fall through */	case MAC_COLL:		assert(pktRx_);		assert(mhRecv_.busy());		/*		 *  Since a collision has occurred, figure out		 *  which packet that caused the collision will		 *  "last" the longest.  Make this packet,		 *  pktRx_ and reset the Recv Timer if necessary.		 */		if(txtime(p) > mhRecv_.expire()) {			mhRecv_.stop();			discard(pktRx_, DROP_MAC_COLLISION);			pktRx_ = p;			mhRecv_.start(txtime(pktRx_));		}		else {			discard(p, DROP_MAC_COLLISION);		}		break;	default:		assert(0);	}}voidMac802_11::tx_resume(){	double rTime;	assert(mhSend_.busy() == 0);	assert(mhDefer_.busy() == 0);	if(pktCTRL_) {		/*		 *  Need to send a CTS or ACK.		 */		mhDefer_.start(phymib_.getSIFS());	} else if(pktRTS_) {		if (mhBackoff_.busy() == 0) {			// ktnahm according to Federico			// rTime = (Random::random() % cw_) * phymib_.getSlotTime();			// mhDefer_.start( phymib_.getDIFS() + rTime);			// ktnahm - Federico - start			mhBackoff_.start(cw_, is_idle(), phymib_.getDIFS());			// ktnahm - Federico - end		}	} else if(pktTx_) {		if (mhBackoff_.busy() == 0) {			hdr_cmn *ch = HDR_CMN(pktTx_);			struct hdr_mac802_11 *mh = HDR_MAC802_11(pktTx_);			

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品久久一级| 国产毛片精品一区| 亚洲图片欧美色图| 一区二区三区日本| 亚洲午夜国产一区99re久久| 亚洲精品视频在线观看免费| 日韩一区中文字幕| 亚洲女与黑人做爰| 一区二区三区精品视频| 一区二区免费在线播放| 亚洲成人午夜影院| 麻豆精品精品国产自在97香蕉| 日本不卡一二三| 国产主播一区二区三区| 成人一区二区在线观看| 99麻豆久久久国产精品免费 | 国产酒店精品激情| 国产精品自在欧美一区| 丁香婷婷综合五月| 97成人超碰视| 欧美色图12p| 日韩欧美中文字幕一区| 久久伊人中文字幕| 亚洲图片激情小说| 午夜影视日本亚洲欧洲精品| 久久9热精品视频| 成人爱爱电影网址| 欧美中文字幕久久| 精品国产乱码久久久久久闺蜜 | 亚洲黄色小说网站| 日韩国产在线一| 老司机午夜精品| 成人av在线电影| 欧美日韩视频一区二区| 亚洲精品一区二区三区精华液 | 色综合天天综合网天天狠天天| 日本韩国一区二区三区视频| 国产成人在线视频播放| 美国十次了思思久久精品导航| 樱花影视一区二区| 国产精品久久久久影院亚瑟 | 亚洲一区在线观看免费| 26uuu亚洲| 91精品免费在线观看| 精品国产麻豆免费人成网站| 欧美精品久久一区| 精品三级av在线| 色天天综合久久久久综合片| 日韩欧美在线1卡| 国产三级精品视频| 蜜桃av一区二区在线观看 | 精品久久久久久久久久久院品网| 最近日韩中文字幕| 日本亚洲天堂网| 婷婷中文字幕一区三区| 午夜精品影院在线观看| 精品视频资源站| 91在线国产福利| 久久综合狠狠综合久久激情| 亚洲精品免费看| 久久 天天综合| 久久精品久久久精品美女| 日韩三区在线观看| 久久网站热最新地址| 久久网站最新地址| 日韩黄色免费电影| 97久久精品人人做人人爽50路| 性做久久久久久免费观看| 精品国精品国产| 日韩电影免费在线观看网站| 中文字幕亚洲精品在线观看| 国产精品国产a级| 一区二区三区欧美| 视频一区国产视频| 午夜亚洲国产au精品一区二区| 亚洲尤物在线视频观看| 日本一区中文字幕| 亚洲日本韩国一区| 亚洲综合色视频| 图片区小说区区亚洲影院| 另类小说一区二区三区| 国产精品自拍在线| 免费在线观看一区二区三区| 国产综合色产在线精品| 精品国产三级电影在线观看| 久久综合色天天久久综合图片| 欧美不卡一区二区三区四区| 精品国产成人在线影院| 日韩理论电影院| 日韩制服丝袜先锋影音| 老司机精品视频线观看86| 日韩欧美在线网站| 国产蜜臀av在线一区二区三区| 亚洲人妖av一区二区| 国产欧美精品一区二区色综合| 国产欧美一区二区三区鸳鸯浴| 亚洲黄色在线视频| 国产精品 欧美精品| 色综合视频一区二区三区高清| 亚洲男人电影天堂| 国产呦萝稀缺另类资源| 91啪亚洲精品| 欧美一区二区三区四区视频| 久久午夜电影网| 成人av在线资源网| 日韩一区二区精品在线观看| 国产精品女主播在线观看| 午夜精品久久久久影视| 一区二区三区久久久| 国内成人免费视频| 欧美日韩国产首页在线观看| 精品久久久久香蕉网| 亚洲天堂成人在线观看| 青青国产91久久久久久| 午夜精品久久久久久久99水蜜桃| 国产精品情趣视频| 青青草国产精品97视觉盛宴| 不卡一区二区在线| 精品黑人一区二区三区久久| 欧美va亚洲va在线观看蝴蝶网| 亚洲欧美电影院| 99久久精品免费精品国产| 日韩精品中文字幕在线一区| 91麻豆精品91久久久久同性| 在线一区二区三区| 中文字幕成人在线观看| 日韩 欧美一区二区三区| 国产午夜精品美女毛片视频| 亚洲人成网站影音先锋播放| 激情综合亚洲精品| 6080日韩午夜伦伦午夜伦| 日本一区二区三区免费乱视频| xf在线a精品一区二区视频网站| 亚洲欧美一区二区三区极速播放| 国产麻豆成人传媒免费观看| 欧美精品久久一区| 欧美日韩一区二区三区视频 | 蜜桃传媒麻豆第一区在线观看| 在线国产电影不卡| 国产精品国产三级国产普通话蜜臀| 久久成人18免费观看| 国产呦精品一区二区三区网站| 欧美日韩一区二区不卡| 成人爽a毛片一区二区免费| 国产成人精品aa毛片| 久久麻豆一区二区| 日韩av中文字幕一区二区三区 | 欧美天天综合网| 自拍偷拍亚洲欧美日韩| 国产精品一区二区在线观看不卡 | 亚洲免费毛片网站| xnxx国产精品| 国产在线乱码一区二区三区| 日韩网站在线看片你懂的| 有坂深雪av一区二区精品| 精品理论电影在线| 久久99精品久久久久久| 欧美日韩一区二区欧美激情| 一区二区三区不卡视频在线观看| 99精品欧美一区| 美日韩一区二区三区| 欧美精品一区二区三区在线| 麻豆国产精品777777在线| 国产亚洲短视频| 成人高清免费观看| 中文字幕制服丝袜成人av| eeuss鲁片一区二区三区| 国产精品国产三级国产三级人妇| 91性感美女视频| 一区二区在线电影| 99精品1区2区| 亚洲午夜精品久久久久久久久| 欧美日韩色综合| 狠狠色丁香婷婷综合久久片| 久久久久久久久久久久久女国产乱| 久久精品久久久精品美女| 欧美一级xxx| 国产成人一区二区精品非洲| 日韩av网站免费在线| 午夜激情综合网| 亚洲第一福利视频在线| 欧美日本国产视频| 国产黄色精品网站| 国产91精品精华液一区二区三区| 国产精品剧情在线亚洲| 国产亚洲人成网站| 色欲综合视频天天天| 91精品国产91热久久久做人人| 91看片淫黄大片一级| 亚洲18色成人| 精品国产一区a| 337p日本欧洲亚洲大胆精品| 欧美一区二区三区免费在线看| 欧美亚洲禁片免费| 日韩二区在线观看| 男男视频亚洲欧美| 亚洲一区日韩精品中文字幕| 宅男噜噜噜66一区二区66| 亚洲精品视频观看| 亚洲精品一二三|