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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? physic.cpp

?? OMNET++仿真三色算法的源碼,三色算法是無線傳感器中一個典型的分簇算法
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
#include "h/physic.h"#include <string.h>//define the sting that define the host displayDefine_Module(Physic);cNeighbour::cNeighbour(){};cNeighbour::~cNeighbour(){};void Physic::initialize(){	hosts.setName("hosts");	nbList.setName("nblist");	hosts.takeOwnership(false); // FIXME this is a terrible hack to prevent crash on exit because of double deletion --Andras	nbList.takeOwnership(false);	cModule *parent = parentModule();	cModule *mod;	char str[90];	//posX = (int)parent->par("x");	//posY = (int)parent->par("y");
	
	GetPos(parentModule()->id(), posX, posY);	numHost = (int)parent->par("numHost");	power = (double) par("txPower");	rxThreshold =  (double) par("rxThreshold");

	range = sqrt(power/rxThreshold); 	delay = &par("channelDelay");	error = &par("channelError");	dataRate = &par("channelDatarate");	gatesNum = 0;	nbCount = 0;	msgWithErr =0;	//show the node on the map	//sprintf(str,displayS,posX,posY,"red");
	sprintf(str, displayS, posX, posY, IDLE_COLOR);	parentModule()->setDisplayString(0,str,true);	//fullfill the hosts vector	detectNeighbours();}void Physic::handleMessage(cMessage* msg){	d("\t--- physic ---");	char tmpstr[128];	int i, msgkind , destid;
	bool blDraw;

	msgkind = msg->kind();
	if(msg->hasPar("dest"))
		destid = (int)msg->par("dest");
	else
		destid = -1;

	//send the messages to the neighbours
		
	//range = sqrt(power/rxThreshold);
	//updateConnections();
	if(msg->arrivedOn("fromMac"))	{	
		d("msg from Mac");
		if(msgkind == MSG_JOIN)
			blDraw = true;		
		else
			blDraw = false;

		updateConnections(blDraw,destid);		
		//sprintf(tmpstr, "physic: message from Mac range [%f]\n", range);		//send the message to all the neighbouts		broadcast(msg);		if( msg!= NULL )			delete msg;	}	else	{		//arrived from outside the module		d("msg from outside");		if(msg->hasBitError())		{			d("received message with errors...discarding!");			msgWithErr++;			delete msg;		}		else		{			d("got message from "<<msg->par("source"));			send(msg,"toMac"); // FIXME it is illegal to send a msg object and keep referencing it!!! -Andras		}	}}void Physic::broadcast(cMessage*msg){	cNeighbour* n = NULL;
	char tmpstr[128];
	d("broadcast Out");
	if(msg->hasPar("physic"))
		msg->par("physic") = id();
	else
		msg->addPar("physic") = id();

	
	sprintf(tmpstr, "[%d] Physic->bcast:: 消息類型 [%d]\n", parentModule()->id(), msg->kind );
	Log(tmpstr);

	for(int i =0; i < nbList.items() ;i++)	{		if(nbList[i])		{			//a new copy of message has to be made					cMessage* m = new cMessage(*msg);			n = (cNeighbour*) nbList[i];
			send(m,n->gateIndex);
			
			sprintf(tmpstr, "physic:bcast[%d]->[%d]\n", parentModule()->id(), n->mobHost);
			Log(tmpstr);
		}	}}void Physic::detectNeighbours(){	//pointer to the modules that are to be scanned	cModule* mod;	//stores the index returned by cArray.add()	int pos = 0;
	char tmpstr[128];
	memset(tmpstr, 0x00, sizeof(tmpstr));
	d("detectNeigh");
	for(int i=1; i<= simulation.lastModuleId(); i++)  	{		//scan the simulation module vector		mod = (cModule*)simulation.module(i);	   	if( strcmp(mod->name(), "physic")  == 0)	   	{		   cNeighbour *n = new cNeighbour;
					   
		   n->ph = mod->id();
		   //remember its parent module too		   n->mobHost = mod->parentModule()->id();		   n->gateIndex = -1;//not connected
		   n->degree = 0; //連通度為0		   pos =  hosts.add(n);		   if(i == id())			   myI = pos;	   	}	}

	//sprintf(tmpstr, "physic->查詢節點myi[%d] and id(%d)\n", myI, parentModule()->id()); }
void Physic::detectNB()
{
	cNeighbour* n;
	cNeighbour* nl;
	int i, j, count, band;
	bool bl=false;
	char tmpstr[128];

	for(i=0;i<hosts.items();i++)
	{
		n = (cNeighbour*)hosts[i];
		bl = false;
		if( (n->ph != id()) && (isReachable(id(),n->ph, band)))
		{
			//查找是否已經插入nbList了
			count = nbList.items();
			
			sprintf(tmpstr, "[%d] detectNB 發現范圍之內節點[%d] 現在度 [%d]\n", parentModule()->id(), n->mobHost, nbList.items(), count);
			Log(tmpstr);
			//for(i=0;i<nbList.items();i++)
			for(j=0;j<count;j++)
			{				
				nl = (cNeighbour*)nbList[j];
				sprintf(tmpstr,"[%d]是否已經加入列表了::已經加入的節點[%d]\n", n->mobHost, nl->mobHost);
				Log(tmpstr);

				if(n->mobHost == nl->mobHost)
				{
					bl=true;
					break;
				} //如果發現了, 直接跳出來就可以了
			}
			
			if(!bl) //如果沒有發現則加入
			//if(nbList.find(n)==-1) //如果沒有發現則加入
			{			
				n->status = UNCLUSTERED;
				n->degree = -1;
				n->gateIndex = -1;
				nbList.add(n);	
				
				sprintf(tmpstr,"&&&&&[%d]detectNB [%d]新加入現在鄰接點個數[%d]\n", parentModule()->id(), n->mobHost, nbList.items());
				Log(tmpstr);
			}
		}		
	}//end of for 

	//sprintf(tmpstr,"[%d]鄰節點個數 [%d]\n", parentModule()->id(), nbCount);
	//Log(tmpstr);
}void Physic::updateConnections(bool blDraw, int destid){	d("updateConnections");	cNeighbour* n;	for(int i=0; i< numHost ; i++)	{		//check the link avoiding to analyze itself		if ( ( i != myI) && checkConnection(i, blDraw, destid)){			n = (cNeighbour*)hosts[i];			d("link changed between this host and:"<<n->mobHost);			//make the other node do the check			if (n->mobHost < parentModule()->id())			{				d("notify the disconnection to the remote node-");				Physic* remote = (Physic*)simulation.module(n->ph);				// the index of this host on the remote hosts vector				remote->checkConnection( myI, blDraw, destid);			}		}	}}//returns true if the connection has changed statebool Physic::checkConnection(int i, bool blDraw, int destid){	d("checkConnection");	cNeighbour* n = (cNeighbour*)hosts[i];
	int band;
	char tmpstr[128];	//avoid the parent to this module parent
	if( (n->ph != id()) &&  isReachable(id(),n->ph, band))
	{
		//if it is not known
		if (nbList.find(n) == -1 )
		{
			nbList.add(n);
			nbCount++;
			d("connecting to"<<n->mobHost);
			if((n->mobHost == destid)&&blDraw)
			{
				sprintf(tmpstr,"%%%%nbList中[%d]--Join-->[%d],draw black line\n", parentModule()->id(), n->mobHost);
				Log(tmpstr);
				n->gateIndex= connectModules(n->ph,n->mobHost, true);
			}
			else
			{
				sprintf(tmpstr,"%%%%[%d]--not dest or join msg-->[%d],draw gray line\n", parentModule()->id(), n->mobHost);
				Log(tmpstr);
				n->gateIndex= connectModules(n->ph,n->mobHost, false);
			}
		}
		else //因為我在系統初始化時就取的鄰接點信息,但是沒有建立連接,所以現在建立
		{
			//if(n->gateIndex == -1)
		//	{
				if((n->mobHost == destid)&&blDraw)
				{
					sprintf(tmpstr,"&&&&[%d]-join ->[%d],draw black line\n", parentModule()->id(), n->mobHost);
					Log(tmpstr);
					n->gateIndex= connectModules(n->ph,n->mobHost, true);
				}
				else
				{
					sprintf(tmpstr,"&&&&[%d]--not dest or join msg-->[%d],draw gray line\n", parentModule()->id(), n->mobHost);
					Log(tmpstr);
					n->gateIndex= connectModules(n->ph,n->mobHost, false);
				}
		//	}
			
		} // end of if ...else..
	
		return true;
	}
	else
	{
		//check if it was connected
	 	int a = nbList.find(n);		d("host not reachable "<<n->mobHost);		if(a!= -1)		{			d("diconnect from neighbour:"<<n->mobHost);			cNeighbour* tmp;			//remove do not delete the object from the			//memory! the list stores only a pointer to the			//original host object.			nbList.remove(a);			//avoid holes in the array			if( (nbCount>1) && (a!=nbCount-1))			{				tmp = (cNeighbour*)nbList.remove(nbCount-1);				nbList.addAt(a,tmp);			}			nbCount--;			n->gateIndex = -1;				//disconnect			disconnectFrom(n->ph,n->mobHost);			return true;		}		else		{			d("but "<<n->ph<<" was not connected");			return false;		}	}}int Physic::connectModules(int rPhysic,int rMod, bool blDraw){	d("connectModules");	//a->b->c->d	int a,b,c,d;
	char tmpstr[128];	//pointer to the remote physical layer	Physic *ph = (Physic*)simulation.module(rPhysic);	//pointer to the remote host object	cModule* mod = (cModule*) simulation.module(rMod);	//create the gates and the connection whithin these modules	setUpConn('O',a,b);	//do the same for the remote node. Note that 'c' will be used later for the conn	//between the two mobile hosts.	ph->setUpConn('I',d,c);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产99久久久久久免费看农村| 日韩欧美专区在线| 国产精品久久久久久福利一牛影视| 国产在线看一区| 五月婷婷欧美视频| 一区二区三区 在线观看视频| 亚洲精选在线视频| 国产精品拍天天在线| 久久久激情视频| 亚洲精品综合在线| 日韩精品视频网站| 久久国产精品99精品国产| 美女视频第一区二区三区免费观看网站| 日韩国产在线观看一区| 日韩一区二区三区电影在线观看| 欧美三级视频在线| 日韩高清在线一区| www久久精品| 成人h动漫精品一区二区| 欧美韩国日本不卡| 99re视频精品| 免费高清在线一区| 精品久久99ma| 粉嫩av亚洲一区二区图片| 欧美激情一区二区三区不卡| aaa欧美大片| 亚洲国产综合色| 日韩欧美区一区二| 日韩和欧美的一区| 91国偷自产一区二区三区成为亚洲经典 | 精品国产一区二区三区忘忧草| 亚洲精品水蜜桃| 欧美色综合网站| 麻豆91精品91久久久的内涵| 久久九九99视频| 色诱亚洲精品久久久久久| 亚洲成人动漫一区| 精品99一区二区三区| 成人av在线播放网站| 亚洲一区二区三区不卡国产欧美| 日本韩国欧美一区二区三区| 精品在线播放午夜| 亚洲卡通动漫在线| 日韩视频免费观看高清完整版| 丁香六月久久综合狠狠色| 国产亚洲视频系列| 在线观看91精品国产入口| 免费成人在线视频观看| 久久久99免费| 一区二区三区精品在线| 欧美日韩在线三级| 中文字幕亚洲一区二区av在线| 日韩av电影免费观看高清完整版 | 色婷婷亚洲综合| 国产欧美视频一区二区| 91福利视频在线| 日本韩国欧美在线| 国产98色在线|日韩| 亚洲国产人成综合网站| 国产欧美精品一区二区色综合| 欧美无乱码久久久免费午夜一区| 国产激情视频一区二区在线观看 | 中文字幕不卡三区| 91精品国产欧美一区二区成人| 成人黄色免费短视频| 日本不卡在线视频| 一区二区三区高清在线| 国产午夜久久久久| 日韩视频在线你懂得| 色av成人天堂桃色av| 国产成人精品aa毛片| 久久99精品久久只有精品| 亚洲一区二区偷拍精品| 中文字幕一区在线| 久久精品亚洲一区二区三区浴池 | 国产精品99精品久久免费| 午夜不卡av免费| 亚洲成人综合在线| 亚洲欧美一区二区三区国产精品 | 亚洲精品一二三四区| 久久九九久久九九| 久久久久久久综合| 久久综合色一综合色88| 日韩午夜电影在线观看| 欧美综合天天夜夜久久| 色欧美日韩亚洲| av一二三不卡影片| 国产美女一区二区三区| 青青草伊人久久| 亚洲高清免费观看| 亚洲成人免费影院| 亚洲h在线观看| 亚洲一区中文日韩| 亚洲最大色网站| 五月天精品一区二区三区| 亚洲成人自拍网| 日韩二区三区四区| 免费观看一级特黄欧美大片| 日韩中文字幕麻豆| 老司机精品视频导航| 蜜臀久久久99精品久久久久久| 视频一区二区三区中文字幕| 五月天网站亚洲| 久久国产精品第一页| 精品制服美女丁香| 国产成人综合自拍| 成人不卡免费av| 欧美在线免费观看视频| 欧美日韩亚洲国产综合| 欧美一区二区三区啪啪| 亚洲女人****多毛耸耸8| 欧美va亚洲va| 欧美精品一区二区三区一线天视频 | 一区二区三区免费网站| 亚洲人精品一区| 亚洲成人av一区二区三区| 亚洲女同女同女同女同女同69| 国产日本亚洲高清| 久久久精品国产免大香伊| 国产肉丝袜一区二区| 亚洲欧美综合色| 亚洲国产精品一区二区久久| 精品在线免费视频| kk眼镜猥琐国模调教系列一区二区 | 99精品欧美一区二区蜜桃免费| 成人av第一页| 欧美日韩精品欧美日韩精品一综合| 日韩欧美一级在线播放| 国产精品日日摸夜夜摸av| 亚洲最新在线观看| 国产精品综合一区二区| 欧美无砖砖区免费| 久久色在线观看| 欧美国产乱子伦 | 欧美视频精品在线观看| 91精品国产日韩91久久久久久| 国产欧美一区二区精品性| 欧美日韩成人综合在线一区二区 | 国产一区二区三区在线看麻豆| 久久99精品国产.久久久久| 久久成人精品无人区| 成人网在线播放| 91麻豆精品国产91久久久| 亚洲国产精品尤物yw在线观看| 亚洲国产毛片aaaaa无费看| 高清成人在线观看| 欧美日韩一区二区三区四区| 亚洲欧美另类综合偷拍| 日韩精品在线一区| 久久免费电影网| 午夜成人免费电影| 99精品视频免费在线观看| 精品国产99国产精品| 一区二区三区 在线观看视频| 国产精品一二三四| 3d动漫精品啪啪1区2区免费| 亚洲色图20p| 国产精品亚洲第一区在线暖暖韩国| 欧美日韩国产首页| 成人欧美一区二区三区小说| 国产在线观看一区二区| 在线成人免费视频| 亚洲高清视频中文字幕| 97se亚洲国产综合自在线观| 久久亚洲影视婷婷| 爽好多水快深点欧美视频| 色88888久久久久久影院野外| 国产亚洲欧美日韩日本| 美女视频免费一区| 在线播放日韩导航| 亚洲电影一级片| 欧洲精品在线观看| 一区二区三区中文在线观看| 成人av集中营| 国产精品理论在线观看| 国产传媒日韩欧美成人| 久久亚洲免费视频| 国产在线精品不卡| 69av一区二区三区| 亚洲欧美精品午睡沙发| 国产不卡免费视频| 久久亚洲捆绑美女| 韩国欧美国产1区| 国产日韩精品一区二区浪潮av | 亚洲精品水蜜桃| 91麻豆福利精品推荐| 亚洲色图丝袜美腿| 色素色在线综合| 一区二区三区高清不卡| 欧美三级资源在线| 午夜精品一区二区三区免费视频| 欧洲精品视频在线观看| 亚洲一区在线观看免费观看电影高清| 色偷偷88欧美精品久久久| 一区二区三区毛片| 欧美一级欧美三级在线观看| 日韩精品亚洲一区二区三区免费| 日韩欧美视频一区| 成人午夜免费电影| 一区二区高清在线|