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

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

?? aodv.cpp

?? OMNET++仿真三色算法的源碼,三色算法是無線傳感器中一個(gè)典型的分簇算法
?? CPP
?? 第 1 頁 / 共 3 頁
字號(hào):
			//the RREP originating node (the RREQ target node)			d("update the precursor list");			f->updatePrecList((int)msg->par("source"));			//e->updatePrecList((int)msg->par("source"));			//send the ack message to the neighbour node			broadcast( generateACKmsg(msg) );			//set the RREP future next hop			reply->par("mac")= f->nextHop;			/*Perkins...			 *Also, at each node the (reverse) route used to forward     		         *a RREP has its lifetime changed to be the maximum   			 *of (existing-lifetime, (current time +   ACTIVE_ROUTE_TIMEOUT)).			 */			 f->expiration = max(f->expiration,simTime() +ACTIVE_ROUTE_TIMEOUT);			//shift the invalidation of the route			if( f->deleteMessage->isScheduled() )				cancelEvent(f->deleteMessage);			scheduleAt(f->expiration, f->deleteMessage);			//setup the wait for the ack message			waitForAck(reply);			return reply;		}	}	else	{		//I am the destination,now a new reoute is available		//and all data can be sent		WaitingPkt* p = NULL;		bool done = false;		e = findNode( (int)msg->par("dest") );		d("I received the RREP that I needed...");		if(e == NULL)		{			d("error: newly aquired route unaviable!");			exit(1);		}		//send the ack message to the neighbour node		broadcast( generateACKmsg(msg));		d("....sending data.");		cQueue::Iterator iter(pktBuffer,1);		while( ( !iter.end() )  && ( !done ) )		{			p = (WaitingPkt*) iter();			if( ( p->dest ==(int) msg->par("dest")))			 {				//now it is possible to send data, cancel the RREQ failre trigger				if(p->deleteEvent->isScheduled())					cancelEvent(p->deleteEvent);				//send all the pakets				for(int i=0 ;  i < p->pktNum ; i++)				{					d("sending pkt...");					reply = generateDATAmsg(e,p->pktSize);					statistics.sentDataPkt++;					broadcast(reply);				}				pktBuffer.remove(p);				delete (p);				done = true;			}			else iter++;		}		return NULL;	}}cMessage* AODV::generateRREPmsg(cMessage* msg, int seqNumD,int hops){	cMessage* rrep = new cMessage("RREP",RREP,CTRL_PKT_SIZE,P_RREP);	d("genRREP");	//spcify the node addtess for wich a route	//is supplyed	rrep->addPar("dest") = msg->par("dest");	//the destination seqNum associated to	//the route	rrep->addPar("seqNumD") = seqNumD;	//rrep.originator is the address of the	//node which originated the RREQ	rrep->addPar("originator") =(int)  msg->par("originator");	//the time for wich nodes receiving the RREP cosider	//the route to be valid	rrep->addPar("lifetime") = MY_ROUTE_TIMEOUT;	//if the node is the destinatary of the rreq then hopcount is 0	//otherwise it is the distance to the destination	rrep->addPar("hopCount")=0;	//ask for a RREP-ACK. used for unidir.links	rrep->addPar("flagA") = 1;	rrep->addPar("seqNumS") = sequenceNumber;	rrep->addPar("ttl") = hops ;	rrep->addPar("mac") = msg->par("source");	return rrep;}cMessage* AODV::generateRREQmsg(RouteTableElement* e,int dest,int ttl){	cMessage* reply = new cMessage("RREQ",RREQ,CTRL_PKT_SIZE,P_RREQ);	d("genRREQ");	reply->addPar("originator") = parentModule()->id();	reply->addPar("dest") = dest;	reply->addPar("seqNumS") = sequenceNumber++;	reply->addPar("seqNumD") = (e == NULL? 0 : e->seqNum);	reply->addPar("reqId") = reqId++;	reply->addPar("hopCount") = 0;	reply->addPar("ttl") = ttl;	reply->addPar("mac") = BROADCAST;	return reply;}void AODV::handleACK(cMessage* msg){	d("handle ACK");	//if it is not for this node, discard	if((int) msg->par("mac") != parentModule()->id())	{		d("received an ACK message not for me, discarding...");	}	else	{		bool done = false;		WaitingRREP* e = NULL;		cQueue::Iterator iter(waitingRrep,1);		while( ( !iter.end() )  && ( !done ) )		{			e = (WaitingRREP*) iter();			if( ( e->destId ==(int) msg->par("originator")))		 	{				//it is the right rrep				d("buffered RREP found and acked");				if(e->espireEvent->isScheduled())					cancelEvent(e->espireEvent);				waitingRrep.remove(e);				//delete all the triggers				delete e->espireEvent;				delete (e);				done = true;			}			else iter++;		}	}}cMessage* AODV::generateACKmsg(cMessage* msg){	cMessage* reply = new cMessage("RREP_ACK",RREP_ACK,CTRL_PKT_SIZE,P_RREP_ACK);	d("generateACK");	reply->addPar("mac") = msg->par("source");	reply->addPar("originator") = msg->par("originator");	reply->addPar("ttl") = 1;	reply->addPar("hopCount") = 0;	return reply;}cMessage* AODV::handleRREQ(cMessage *msg){	cMessage* reply;	RouteTableElement * e;	d("hndRREQ");	//check if the message has been alredy received and processed	if (! isNewReq(msg) )		return NULL;	else		addNewReq(msg);	//avoid the RREQ messages form black list's node	if( isInBlackList(msg->par("source") ) )	{		d("received a RREQ msg from a node in the black list. DISCARDING");		return NULL;	}	//check the neighbour node that sent the message	d("check the neighbour node that sent the message");	e =  findNode( (int)msg->par("source") );	if(e == NULL)		//add a new neighbour		//but I don't know the seqNumber -->0		//the hopCount is 1		addNewDestination((int)msg->par("source"),				(int)msg->par("source"),0,1,simTime()+ACTIVE_ROUTE_TIMEOUT);	else		updateRouteTable(e,e->seqNum,1,				(int)msg->par("source"),				simTime()+ACTIVE_ROUTE_TIMEOUT);
	//check if the originator node is known
	d("check if the originator node is known");
	if( (int)msg->par("originator") != (int) msg->par("source"))
	{
		e = findNode( (int)msg->par("originator") );
		if( e == NULL)
			//add a new destination
			addNewDestination((int)msg->par("originator"),
					(int)msg->par("source"),
					(int)msg->par("seqNumS"),
					(int)msg->par("hopCount"),
					simTime()+REV_ROUTE_LIFE);
		else
			//check whether there is the need of
			//a refresh in the table data
			updateRouteTable(e, (int)msg->par("seqNumS"),
					(int)msg->par("hopCount"),
					(int)msg->par("source"),
					max(e->expiration,simTime()+ REV_ROUTE_LIFE));
	}

	//now check the destination	e = findNode((int) msg->par("dest") );	d("now check the RREQ destination");	if( parentModule()->id() == (int)msg->par("dest") )	{		// I am the destination		d("---- I am the RREQ destination generate RREP ---- ");		//a host must increment his seq.num		//before genereting a new RREP mesage		sequenceNumber = max(sequenceNumber,(int)msg->par("seqNumD"));		reply = generateRREPmsg(msg, sequenceNumber,(int) msg->par("hopCount"));		//setup the wait for the ack message		waitForAck(reply);		return reply;	}	else	if (e == NULL)	{		// the destination is unknown		// copy the RREQ message,increment hopCount,		// decrement TTL and rebroadcast it  		d("RREQ destination unknown, forwarding...");		reply = new cMessage(*msg);		reply->par("hopCount") = (int) reply->par("hopCount")+1;		return reply;;	}	else 	if( (e->seqNum < (int) msg->par("seqNumD") ) || (!e->active) )	{		//I am an intermediary node but		//the informations in the routeTable are old.Do nothing		d("the informations in the routeTable are old, do nothing...");		return NULL;	}	else	{		//I am an intermediary node.		d("I am an intermediary node: I've got a route to the destination!");		//uses the last known sequence number as seqNumberD		//rrep ttl is the sum of the rreq made hops and the hops remaining toward the destination		reply = generateRREPmsg(msg, e->seqNum,(int) msg->par("hopCount"));		reply->par("hopCount") =  e->hopCount ;		reply->par("lifetime") = e->expiration - simTime();		//add the source node into the precursor list of the destination		e->updatePrecList( (int)msg->par("source"));		//setup the wait for the ack message		waitForAck(reply);		return reply;	}}cMessage* AODV::copyMessage(cMessage* msg){	//copy the data within the msg oject	cMessage* newMsg = new cMessage(*msg);	return newMsg;	d("cpy");}RouteTableElement* AODV::addNewDestination(int dest,int source,int seqN,int hopCount,simtime_t expire){	RouteTableElement* e = new RouteTableElement();	d("addNewDest");	char d[20];	d("aggiungo :"<<dest);	e->destId = dest;	//the neighbour node that sent the message	e->nextHop = source;	e->seqNum = seqN;	e->hopCount = hopCount ;	d("hops:"<<hopCount);	e->expiration = expire;	d("add new dest : espire = "<<expire);	e->active = true;	sprintf(d,"r.time out to %d",dest);	e->deleteMessage = new cMessage(d,MK_DELETE,0,P_DELETE);	e->deleteMessage->addPar("node") = (cObject*) e;	//if whithin a preconfigured period the route	//will not be refreshed it will be cancelled	scheduleAt(expire ,e->deleteMessage);	routeTab.insert( (RouteTableElement*) e);	return e;}void AODV::updateRouteTable(RouteTableElement* e,int seqNum,int hopCount,int nextHop, simtime_t time){	d("updRoute per :"<<e->destId);	if( (seqNum > e->seqNum) ||	    ((seqNum==e->seqNum) && (hopCount < e->hopCount )) ||	    ((seqNum==e->seqNum) && (hopCount == e->hopCount) && (e->expiration < time) )	    )	{		d("updating... ");		//update the entry		e->hopCount = hopCount;		e->nextHop = nextHop;		e->seqNum = seqNum;		e->active = true;		e->expiration = time;		//shift the invalidation of the route		cancelEvent(e->deleteMessage);		scheduleAt(e->expiration, e->deleteMessage);	}	else d("table not upadated");}RouteTableElement* AODV::findNode(int n){	RouteTableElement * e = NULL;	d("find :"<<n);	for( cQueue::Iterator iter(routeTab,1) ; !iter.end(); iter++)	{		e = (RouteTableElement*) iter();		if(e->destId  == n )			return e;	}	return NULL;}void AODV::addNewReq(cMessage* msg){	OldReqs* r = new OldReqs();	d("addNewReq");	r->originator = msg->par("originator");	r->reqId = msg->par("reqId");	r->time = simTime();	oldReqs.insert( (OldReqs*) r);}bool AODV::isNewReq(cMessage *msg){	int origin,	    reqId;	d("isNewReq msg:"<<msg->name());	origin = msg->par("originator");	reqId = msg->par("reqId");	OldReqs* r = NULL;	for(cQueue::Iterator iter(oldReqs,1); !iter.end(); iter++)	{		r =(OldReqs*) iter();		if((r->originator == origin)&&(r->reqId == reqId ))		{			//the same request can not be served twice			//within a period of  PATH_TRAVERSAL_TIME			if( (simTime()- r->time) >= PATH_TRAVERSAL_TIME)			{				//the request is processable				//remove just unlik r from the queue				oldReqs.remove( (OldReqs*)r);				delete r;				return true;			}			else				return false;		}	}	return true;}bool RouteTableElement:: updatePrecList(int ip){	PrecursorElement * e = NULL;	for( cQueue::Iterator iter(precList,1) ; !iter.end(); iter++)	{		e = (PrecursorElement*) iter();		if(e->ip == ip)		{			 return false;		}	}	//ip is a new element so add it to the list	e = new PrecursorElement();	e->ip = ip;	precList.insert( (PrecursorElement*) e);	return true;}void Statistics::collect(cMessage* msg, double now){	double latency = now - (double) msg->par("sendingTime");	int i = (int)msg->par("hopCount");	maxHop = max(maxHop, i);	//if the vector cell is not empty	PartialStat* cell = (PartialStat*)hopsV[i];	if(cell)	{		cell->latencySum += latency;		cell->throughSum += msg->length() / latency;		cell->samples ++;	}	else	{		PartialStat* cell = new PartialStat(latency, msg->length() / latency);		hopsV.addAt(i,cell) ;	}	hopsSum += i;	deliveredDataMsg++;}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产在线一区观看| 日韩一卡二卡三卡| 亚洲精品中文在线| 91国偷自产一区二区三区观看 | 欧美一区二区三区四区久久 | 欧美精品日韩一区| 另类欧美日韩国产在线| 久久亚洲春色中文字幕久久久| 国产一区二区三区免费播放| 国产精品私人自拍| 色狠狠色狠狠综合| 日韩高清不卡一区| 欧美亚男人的天堂| 久久av资源站| 国产精品美女视频| 欧美日韩三级一区| 精品无人码麻豆乱码1区2区| 国产日韩在线不卡| 一本一道久久a久久精品| 三级久久三级久久| 久久久另类综合| 日本电影亚洲天堂一区| 蜜桃av一区二区在线观看| 中文字幕免费在线观看视频一区| 91免费观看视频在线| 日本伊人午夜精品| 国产精品久久久一本精品 | 亚洲一区二区成人在线观看| 日韩一区二区在线看| eeuss鲁片一区二区三区在线观看| 亚洲国产成人av网| 国产日韩精品一区二区三区| 欧美中文字幕一区二区三区| 精品一区精品二区高清| 亚洲精选视频免费看| 精品sm捆绑视频| 在线亚洲精品福利网址导航| 国产精品2024| 日韩制服丝袜av| 国产精品理论在线观看| 日韩一区二区电影在线| 一本大道久久a久久精二百| 国产美女精品在线| 五月激情综合网| 亚洲欧美日韩国产综合| 精品国产露脸精彩对白| 欧美日韩一区二区三区视频| 成人av在线观| 国内精品国产三级国产a久久| 亚洲一区二区免费视频| 国产精品欧美一区二区三区| 91精品国产色综合久久不卡电影| 91丨九色丨蝌蚪丨老版| 国产精品一区二区三区网站| 免费高清在线视频一区·| 亚洲欧美日本韩国| 亚洲国产成人在线| 久久免费午夜影院| 日韩精品中文字幕在线一区| 欧美三级中文字| 日本精品一区二区三区高清| 成+人+亚洲+综合天堂| 国产精品资源在线观看| 精品一区二区三区日韩| 日本欧美韩国一区三区| 亚洲超丰满肉感bbw| 一区二区三区视频在线看| 国产精品白丝在线| 国产精品久久午夜夜伦鲁鲁| 国产精品污网站| 国产日本欧美一区二区| 久久九九全国免费| 久久婷婷综合激情| xvideos.蜜桃一区二区| 亚洲精品一区二区三区香蕉| 日韩久久久精品| 91蝌蚪国产九色| 99久久精品情趣| 在线视频亚洲一区| 97se狠狠狠综合亚洲狠狠| 91在线一区二区| 一本到不卡免费一区二区| 欧洲av一区二区嗯嗯嗯啊| 日本韩国视频一区二区| 欧美在线观看禁18| 欧美精品久久久久久久久老牛影院| 欧美日本一区二区三区| 日韩欧美国产一区在线观看| 日韩欧美一区二区三区在线| 欧美精品一区二区三区一线天视频| 精品国内二区三区| 国产日产亚洲精品系列| 亚洲欧美怡红院| 亚洲妇女屁股眼交7| 日韩vs国产vs欧美| 黄色资源网久久资源365| 国产99久久精品| 91久久国产综合久久| 91麻豆精品国产91久久久久久 | 欧美成人vps| 国产色产综合色产在线视频| 17c精品麻豆一区二区免费| 亚洲成av人片在www色猫咪| 蜜臀久久99精品久久久画质超高清| 国产在线一区二区综合免费视频| 成人99免费视频| 欧美三级一区二区| 久久夜色精品国产欧美乱极品| 国产精品久久久久影院亚瑟| 亚洲国产视频a| 精品一区二区三区视频| 91免费版在线| 精品久久久久久久久久久久久久久久久 | 亚洲国产精品99久久久久久久久| 亚洲美女视频在线观看| 日本大胆欧美人术艺术动态| 国产99久久久国产精品潘金网站| 色婷婷久久99综合精品jk白丝| 欧美精品三级日韩久久| 国产精品成人免费| 蜜乳av一区二区| 91在线观看高清| 精品国产91乱码一区二区三区| 亚洲日本欧美天堂| 老鸭窝一区二区久久精品| 99视频精品在线| 精品国精品自拍自在线| 亚洲午夜私人影院| 国产福利91精品| 91精品国产综合久久婷婷香蕉 | 国产馆精品极品| 欧美日韩一级二级| 国产精品成人在线观看| 麻豆国产精品官网| 欧美亚洲国产一区在线观看网站| 国产欧美一区二区精品性色| 日本va欧美va瓶| 一本到高清视频免费精品| 国产日韩欧美综合一区| 奇米精品一区二区三区四区| 色先锋aa成人| 国产农村妇女毛片精品久久麻豆| 无码av免费一区二区三区试看 | 国产精品538一区二区在线| 欧美男男青年gay1069videost | 国产精品美女久久福利网站| 奇米色777欧美一区二区| 欧美三电影在线| 综合精品久久久| 丁香激情综合五月| 久久久久国产精品麻豆ai换脸| 日韩国产一二三区| 欧美三级中文字幕| 亚洲一二三四区不卡| 色婷婷久久综合| 亚洲人精品一区| 96av麻豆蜜桃一区二区| 综合在线观看色| 亚洲精品一区二区三区在线观看 | 国产精品视频在线看| 国产精品性做久久久久久| 精品久久久三级丝袜| 精品综合免费视频观看| 日韩视频免费直播| 亚洲精品亚洲人成人网在线播放| 成人性色生活片| 国产精品美女久久久久aⅴ国产馆| 丰满少妇在线播放bd日韩电影| 国产无人区一区二区三区| 国产一二精品视频| 久久久91精品国产一区二区精品| 国产美女久久久久| 国产精品欧美一级免费| av福利精品导航| 亚洲精品成人天堂一二三| 在线精品视频小说1| 午夜在线成人av| 日韩一二三四区| 国产一区二区免费在线| 国产视频一区二区在线观看| 99re8在线精品视频免费播放| 一区二区三区欧美| 欧美电影一区二区| 韩国精品主播一区二区在线观看 | 91亚洲精品久久久蜜桃网站| 亚洲精品欧美激情| 欧美日韩dvd在线观看| 美女视频网站黄色亚洲| 国产亚洲综合在线| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 国产成人精品亚洲777人妖 | 亚洲h在线观看| 日韩欧美二区三区| www.亚洲国产| 亚欧色一区w666天堂| 欧美xxxx老人做受| 99re成人精品视频| 青青草成人在线观看| 欧美激情艳妇裸体舞| 色妹子一区二区|