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

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

?? asyncnetlayer.cc

?? 基于omnet++開(kāi)發(fā)的Mf框架下的802.11協(xié)議仿真。
?? CC
字號(hào):
/* -*- mode:c++ -*- ********************************************************
 * file:        AsyncNetwLayer.cc
 *
 * author:      Yupeng.hu
 *
 * copyright:   (C) 2006 HUNAN Universtiy, ChangSha China
 *
 ***************************************************************************
 * part of:     Async Simulation
 * description: - Async Description
 *
 ***************************************************************************
 * changelog:   $Revision$
 *              last modified:   $Date: 2006-7-7 10:21 $
 *              by:              $Author: Yupeng.hu $
 ***************************************************************************/
//#include <iostream.h>
//#include <fstream.h>
#include "AsyncNetLayer.h"
#include <NetwPkt_m.h>
#include <time.h>
#include<fstream>

#define EV (ev.disabled()||!debug) ? (std::ostream&)ev : ev << logName() << "::AsyncNetLayer: "

Define_Module(AsyncNetLayer);


/**
 * Reads all parameters from the ini file. If a parameter is not
 * specified in the ini file a default value will be set.
 **/
void AsyncNetLayer::initialize(int stage)
{
	BasicNetwLayer::initialize(stage);
  
	if(stage==0)
	{       	   	
    	maxHops=14;
    	for(int i=0;i<maxHops;i++)
    	{
    		mean[i]=0;
    	}
    	for(int i=0;i<maxHops;i++)
    		for(int j=0;j<2;j++)
    			{delay[i][j]=0;}
    	
    	for(int i=0; i<15; ++i)
    	  clu[i]=0;
    	head[0]=48;
    	head[1]=43;
    	head[2]=36;
    	head[3]=14;
    	head[4]=22;
    	head[5]=27;
    	head[6]=33;
    	head[7]=7;
    	/*for(int i=0;i<15;i++)
    	{ EV<<endl;
    		EV<<"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"<<endl;
    		EV<<clu[i]<<endl;
    		//EV<<endl;
    	}*/

    	status=NO_CLUSTER;
    	conStatus=NO_CONNECT;
    	r=par("round");  //簇的穩(wěn)定的時(shí)間,一段時(shí)間后要重新生成簇頭。    	clusterEvent=new cMessage("clusterEvent");
    	scheduleAt(simTime(), clusterEvent);
    	topo = new cTopology("topo");
     //	int clusterHead=0;  //這個(gè)地方好像有點(diǎn)問(wèn)題      clusterHead=0;
    	WATCH(status);
    	WATCH(conStatus);
    	WATCH(clu);  //多的    	
    	EV <<"AsyncNetLayer is loaded"<<endl;
    	
  	}
}


/** 
 * Convienience function which calls sendDelayedDown with delay set to
 * 0.0.
 *
 * @sa sendDelayedDown
 **/
void AsyncNetLayer::handleUpperMsg(NetwPkt* msg)
{    
   
    msg->setTimestamp();
    ev<<logName()<<"AsyncNetLayer::"<<"The timeStamp is"<<msg->timestamp()<<endl;
    topo = new cTopology("topo");
    topo->extractByModuleType(findHost()->className(), NULL); 
    int dest=findHost()->submodule("appl")->par("destAddress");//topo->node 's index() is i 		  		
    topo->unweightedSingleShortestPathsTo(topo->node(dest));
    int  distance=topo->nodeFor(findHost())->distanceToTarget();
        
    ev << logName() << "::AsyncNetLayer:" <<" distance to sink node is: "<<distance<<endl;
    msg->setKind(distance);//put hops into packet
    if(status==IS_CLUSTER)//如果是簇頭節(jié)點(diǎn)生成的數(shù)據(jù)報(bào)則進(jìn)入路由,尋找下一跳;否則,直接    {                     //賦值下一跳為簇頭       Routing(msg);
    }
    else if(status==NO_CLUSTER && conStatus==NO_CONNECT) //既不是簇頭,也不是簇內(nèi),則按原有路由    {
    	Routing(msg);
    }
    else
    {
	    MacControlInfo* cInfo = new MacControlInfo;
	    cInfo->setNextHopMac(clusterHead);
	    //msg->setControlInfo(cInfo);
	    sendDown(msg,-2,lowergateOut);
	    EV <<"ControlInfo set; sending down msg\n";
    }
}


/**
 * Redefine this function if you want to process messages from lower
 * layers before they are forwarded to upper layers
 *
 *
 * If you want to forward the message to upper layers please use
 * @ref sendUp which will take care of decapsulation and thelike
 **/
void AsyncNetLayer::handleLowerMsg(NetwPkt* msg) //變化了{
	  ev<<logName()<<"!!!!!!!!!!!!!!!!"<<endl;
    ev<<logName()<<"msg->getTag()="<<msg->getTag()<<endl;
    topo = new cTopology("topo");
    topo->extractByModuleType(findHost()->className(), NULL); 
    int dest=findHost()->submodule("appl")->par("destAddress");//topo->node 's index() is i 		  		
    topo->unweightedSingleShortestPathsTo(topo->node(dest));
    int distance=topo->nodeFor(findHost())->distanceToTarget();
    ev<<logName()<<"distance is "<<distance<<endl;
    
    
    if(msg->getTag()==4&& status==NO_CLUSTER&& conStatus==NO_CONNECT&&distance!=0)//kind()不能用    {   //msg->getTag()is verdicting whether it is a broadcasting frame or not
    	  //status == N0_CLUSTER is verdicting whether it is a cluster or not
    	  //conStatus == NO_CONNECT is verdicting whether it is connecting to other cluster or not
    	  //distance != 0 is verdicting it is not a sink node
    	findHost()->displayString().setTagArg("i",1, "green");
    	ev<<logName()<<"AsyncNetLayer:: Is connected with clusterHead node!"<<endl;
    	conStatus=IS_CONNECT;
    	ev<<logName()<<"AsyncNetLayer::clusterHead's macAddr is"<<msg->getSrcAddr()<<endl;
    	clusterHead=msg->getSrcAddr()+1;
    	WATCH(clusterHead);
    	ev<<logName()<<"clusterHead="<<clusterHead<<endl;
    	delete msg;
    	sendClusterAckMsg();  //多的    }
    else if(msg->getTag()==5&&status==IS_CLUSTER)  //多的    {
    	int i=0;
    	//EV<<"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"<<endl;
     	while(clu[i]!=0)
     	{
     		i++;
     	}
     	clu[i]=msg->getSrcAddr();     	
    }
    else if(msg->getTag()!=4&&msg->getTag()!=5)
    {
   	  double t = simTime()-msg->timestamp();	
      EV<<"pkt delay:"<<t<<"="<<simTime()<<"-"<<msg->timestamp()<<endl;
      delay[msg->kind()-1][0]+=t;
      delay[msg->kind()-1][1]+=1;
      ev<<"hop-"<<msg->kind()<<" delay:"<<delay[msg->kind()-1][0]<<"*****"<<delay[msg->kind()-1][1]<<endl;

      qstats.collect( t );
    
      if(status==IS_CLUSTER)
      {
      	int flag = 0;
      	for(int i=0;i<15;i++)
        {
          if(msg->getSrcAddr()==clu[i])//如果數(shù)據(jù)報(bào)來(lái)自于簇內(nèi)節(jié)點(diǎn),上傳到app層進(jìn)行相關(guān)數(shù)據(jù)報(bào)的小波變換          {
        	   ev<<"This msg is from the node of cluster"<<endl;
        	   flag = 1;
        	   //sendUp(msg);
        	   break;
          }
        }
        if(flag == 1)
        {
        	sendUp(msg);
        }
        else
        	Routing(msg);
      }
      else{
     	 Routing(msg);
      }
   }
    
}


/** 
 * Convienience function which calls sendDelayedDown with delay set to
 * 0.0.
 *
 * @sa sendDelayedDown
 **/
void AsyncNetLayer::sendDown(NetwPkt *msg, int nHop, int nicGate)
{
	sendDelayedDown( msg, 0.0, nHop, nicGate );
}


/**
 * Call this function to hand your message to layer n-1
 *
 * It just calls the OMNeT++ sendDelayed function.
 *
 * In the case of the network layer we also have to provide a nextHop (nHop)
 * network address the msg has to be send to. nHop may be read
 * from a static table or the result of a routing query or whatever
 * else you want to implement.
 *
 * Additionally the network layer has to provide a mapping of the nHop
 * network address to the corresponding mac address (if the message is
 * no broadcast message). getMacAddr() is called to achive this task.
 *
 * The returned mac address is attached to the netwPkt within the
 * ControlInfo object MacControlInfo used to pass control information
 * from the network to the mac layer.
 * @todo update as soon as Andras updated the ControlInfo stuff in omnet
 * 
 * This function is only for convenience so that the programmer does
 * not have to take care about the details of message sending
 * 
 * @param msg msg to send
 * @param delay Delay (in seconds) to wait before sending the message
 * @param nHop next hop netw address to forward the msg to
 * @param nicGate gate of the nic to send the packet out on
 * @sa getMacAddr()
 *
 * to be called within @ref handleUpperMsg
 **/
void AsyncNetLayer::sendDelayedDown(NetwPkt* msg, double delay, int nHop, int nicGate)
{
	int macAddr;
  	if( nHop == -1 )
  	{
    	EV <<"sendDown: nHop=-1 -> message has to be broadcasted -> set destMac=-1\n";
    	macAddr=-2;
    }
    else if(nHop==-2)
    {
       EV <<"sendDown: nHop=-2 -> message has to sent to clusterHead -> set destMac="<<clusterHead<<endl;
	     macAddr=clusterHead;
    }
    else{
    	EV <<"sendDown: get the MAC address\n";//?
    	macAddr = getMacAddr( nHop );
  	}

  	MacControlInfo* cInfo = new MacControlInfo;
  	cInfo->setNextHopMac( macAddr );
  	msg->setControlInfo( cInfo );
  	EV <<"ControlInfo set; sending down msg\n";
  	sendDelayed((cMessage*) msg, delay, nicGate);
}


/** 
 * map the net module id to parent host's index
 * @param id to map
 **/
int AsyncNetLayer::NetModuleID2Index(int id)
{
  	int index=-1;
  	for (int i=0; i<topo->nodes(); i++)
  	{
  		if( topo->node(i)->module()->findSubmodule("net")==id)
    	{
    		index=topo->node(i)->module()->index();   			
   			return index;
    	}    		
  	}			
	return index;	
}


/** 
 * find the next hop to all other nodes
 * @param topo the topology
 **/
void AsyncNetLayer::findNextHop(cTopology *topo)
{	
  	topo->extractByModuleType(parentModule()->className(), NULL); 	  	
  	cTopology::Node *thisNode = topo->nodeFor(parentModule());
  	for (int i=0; i<topo->nodes(); i++)
  	{
  		if (topo->node(i)==thisNode)
  			 continue; // skip ourselves
    	topo->unweightedSingleShortestPathsTo(topo->node(i));//find route to node(i) for this host	    	
    	if (thisNode->paths()==0) continue; // not connected		
    	
    	int address = topo->node(i)->module()->findSubmodule("net");
    	int nHop = thisNode->path(0)->remoteNode()->module()->findSubmodule("net");    	
  		rtable[address] = nHop;
   		EV << "  towards address " << NetModuleID2Index(address) << " next hop is: " << NetModuleID2Index(nHop) <<endl;
  	}	
}


/** 
 * handle all packets
 * @param msg msg to send
 **/
void AsyncNetLayer::Routing(NetwPkt* msg)
{  	    
  	
  	findNextHop(topo);
  	
  	int destAddr = msg->getDestAddr();    
  	if (destAddr == myNetwAddr())
  	{        
     	EV << "local delivery of packet--- " << endl;
     	sendUp(msg);
     	return;
  	}
  	
  	ShortestNetwLayerTable::iterator it = rtable.find(destAddr);
    if (it==rtable.end())
   	{
    	EV << "address " << NetModuleID2Index(destAddr) << " unreachable, discarding packet " <<msg->name()<< endl;
       	delete msg;
       	return;
   	}
   	
    int nHop = (*it).second;
    EV<< "forwarding packet " << msg->name()<<" to next hop: " <<NetModuleID2Index(nHop) <<" to dest "<<NetModuleID2Index(destAddr)<< endl;
    sendDown(msg, nHop,lowergateOut);   
    
      
        
    	
}
/**
 * 利用時(shí)鐘調(diào)度,周期性的建立拓?fù)浣Y(jié)構(gòu)。 *(1)調(diào)用該函數(shù),通過(guò)門限判斷該節(jié)點(diǎn)是否能成為簇頭: *(2)是,則生成一個(gè)簇頭廣播報(bào); *(3)否,檢查隊(duì)列,是否有可通信鄰居節(jié)點(diǎn)已經(jīng)成為簇頭: *(4)        是,與該節(jié)點(diǎn)建立連接,將其作為數(shù)據(jù)報(bào)的目的節(jié)點(diǎn); *(5)         否,等待一段時(shí)間后,再進(jìn)入步驟(1)。**/

void AsyncNetLayer::handleSelfMsg(cMessage* msg)
{
	if(msg==clusterEvent)
	{       
	
		status=NO_CLUSTER;
		conStatus=NO_CONNECT;
		double a=1.0*rand()/32767;
		ev<<logName()<<"::AsyncNetLayer: "<<" a is "<<a<<endl;
		//if(a<(double)par("minLine")&&findHost()->index()!=(int)findHost()->submodule("appl")->par("destAddress"))//在ned文件中添加minLine變量		int flag=0;
		for(int i=0;i<8;i++)
		{
			if(findHost()->index()==(int)head[i])
				{
					flag=1;
					break;
					}
			}
		if(flag==1&&findHost()->index()!=(int)findHost()->submodule("appl")->par("destAddress"))
		{
			status=IS_CLUSTER;
			for(int i=0;i<15;i++)
			{
			 clu[i]=0;
			}
			
			findHost()->displayString().setTagArg("i",1, "red");
			ev<<a<<"<"<<par("minLine")<<endl;
			ev<<logName()<<" AsyncNetLayer:: this node is the cluster-head"<<endl;
			sendClusterMsg();
			scheduleAt(simTime()+r, clusterEvent);
		}
		else if(findHost()->index()!=(int)findHost()->submodule("appl")->par("destAddress"))
		{scheduleAt(simTime()+r, clusterEvent);
		findHost()->displayString().setTagArg("i",1, "black");
	
		}
		
	}
	
}

/**
 * 簇頭確定后,發(fā)送廣播幀**/
void AsyncNetLayer::sendClusterMsg()
{
	sendDown(buildClusterMsg(), -1,lowergateOut);  
	ev<<logName()<<":AsyncNetLayer:: send out the clusterMsg"<<endl;
	}

/**

/**
 * 簇內(nèi)節(jié)點(diǎn)向簇頭發(fā)送確認(rèn)幀**/
void AsyncNetLayer::sendClusterAckMsg()
{
	sendDown(buildClusterAckMsg(), -2,lowergateOut);  
	ev<<logName()<<":AsyncNetLayer:: send out the clusterMsg"<<endl;
	}

/**
*  build the message to tell the cluster
   Written by Fang shi
**/

NetwPkt* AsyncNetLayer::buildClusterMsg()
{

  NetwPkt* frame = static_cast<NetwPkt *>(createCapsulePkt());
  
  frame->setTag(CLUSTER);
  frame->setSrcAddr(myNetwAddr());
  frame->setDestAddr(-2);///???需在mac的handleLOwerMsg中增加對(duì)destAddr=-2情況的處理  //frame->setDuration(0);
  ev<<logName()<<":AsyncNetLayer:: a clusterMsg has been build!!!!"<<endl;
  return(frame);
}
/**
*  build the ackMessage to tell the cluster
   Written by Fang shi
**/

NetwPkt* AsyncNetLayer::buildClusterAckMsg()
{

  NetwPkt* frame = static_cast<NetwPkt *>(createCapsulePkt());
  
  frame->setTag(CLUSTER_ACK);
  frame->setSrcAddr(myNetwAddr());
  frame->setDestAddr(clusterHead);///???需在mac的handleLOwerMsg中增加對(duì)destAddr=-2情況的處理  //frame->setDuration(0);
  ev<<logName()<<":AsyncNetLayer:: a clusterMsg has been build!!!!"<<endl;
  return(frame);
}

void AsyncNetLayer::finish()
{    
    EV << " node ID: " << findHost()->index()<<endl;
    EV << " Total jobs processed: " << qstats.samples() << endl;    
    EV << " Max transmission:         " << qstats.max() << " sec" << endl;
    EV << " Min transmission:         " << qstats.min() << " sec" << endl;
    EV << " Avg transmission:         " << qstats.mean() << " sec" << endl;
    EV << " Standard deviation:   " << qstats.stddev() << " sec" << endl;
    
    if(findHost()->index()==0){
    	for(int i=0;i<maxHops;i++)
    	{   
    		mean[i]=(delay[i][0]/delay[i][1]);
     	 	EV<<mean[i]<<endl;
    	
    	} 
    
    }    
   
    recordScalar("node id",findHost()->index());
    recordScalar("avg trans time",qstats.mean());
    recordScalar("max trans time",qstats.max());
    recordScalar("min trans time",qstats.min());
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
www.性欧美| 中文字幕一区在线观看| 欧美精品在线一区二区三区| 亚洲综合视频网| 精品成人a区在线观看| 成人97人人超碰人人99| 在线国产电影不卡| 91官网在线免费观看| 在线观看日韩电影| 欧美四级电影在线观看| 欧美日产在线观看| 这里只有精品99re| 欧美一区二区三区免费在线看| 欧美日韩国产另类不卡| 欧美手机在线视频| 日韩欧美一卡二卡| 久久精品男人的天堂| 中文av一区二区| 亚洲免费av高清| 天天综合色天天综合| 奇米精品一区二区三区在线观看一| 琪琪久久久久日韩精品| 精品亚洲免费视频| fc2成人免费人成在线观看播放| 99精品国产一区二区三区不卡| 91啪九色porn原创视频在线观看| 在线免费不卡视频| 91精品国产综合久久小美女 | 欧美日韩免费视频| 欧美一区二区网站| xnxx国产精品| 一区在线中文字幕| 午夜婷婷国产麻豆精品| 国产最新精品精品你懂的| 成人激情电影免费在线观看| 色哟哟日韩精品| 日韩欧美的一区二区| 欧美激情综合在线| 五月激情综合网| 国产美女一区二区| 91久久精品国产91性色tv | 亚洲国产日韩一区二区| 日韩精品国产精品| 成人性生交大片免费看视频在线| 欧美专区日韩专区| 久久久久久久性| 亚洲成人免费看| 大白屁股一区二区视频| 欧美色国产精品| 国产精品久久久久久久午夜片| 亚洲成人三级小说| av亚洲产国偷v产偷v自拍| 欧美一区二区三区四区五区| 中文一区二区在线观看| 五月天一区二区三区| 国产福利一区在线| 欧美日韩国产小视频在线观看| 国产日韩精品一区二区三区| 亚洲成人久久影院| 成人免费观看视频| 欧美r级在线观看| 亚洲乱码国产乱码精品精可以看| 国产一区二区三区在线观看精品| 欧美性猛交一区二区三区精品| 国产亚洲欧洲997久久综合 | 成人激情图片网| 欧美白人最猛性xxxxx69交| 亚洲精品久久久蜜桃| 国产另类ts人妖一区二区| 欧美精品在线观看一区二区| 亚洲欧美另类久久久精品| 粉嫩嫩av羞羞动漫久久久| 亚洲欧美偷拍三级| 国产精品91一区二区| 日韩欧美的一区| 亚洲国产成人精品视频| 99re这里都是精品| 国产亚洲成年网址在线观看| 三级在线观看一区二区| 色乱码一区二区三区88| 国产欧美一区二区三区在线老狼| 蜜桃视频第一区免费观看| 欧美日韩综合不卡| 一区二区三区自拍| jlzzjlzz亚洲日本少妇| 久久久久久久一区| 国产精品主播直播| 久久免费美女视频| 国产精品影视在线观看| 精品99999| 久久精工是国产品牌吗| 欧美一级高清片在线观看| 亚洲成av人影院在线观看网| 日本丶国产丶欧美色综合| 最新日韩在线视频| 99精品黄色片免费大全| 中文字幕在线播放不卡一区| 成人午夜免费电影| 国产精品色哟哟网站| 国产成人av自拍| 国产欧美视频在线观看| 国产精品自拍网站| 国产校园另类小说区| 国产91露脸合集magnet| 中文字幕高清不卡| 波多野结衣在线aⅴ中文字幕不卡| 国产欧美久久久精品影院| 成人av集中营| 中文字幕在线观看一区| 97aⅴ精品视频一二三区| 一区二区三区四区乱视频| 91国产福利在线| 日韩精品亚洲一区二区三区免费| 51精品视频一区二区三区| 蜜桃av一区二区三区| 久久久精品免费观看| 成人国产在线观看| 亚洲制服欧美中文字幕中文字幕| 欧美在线啊v一区| 日本美女视频一区二区| 久久蜜桃一区二区| 国产成人精品综合在线观看| 国产精品欧美久久久久一区二区| 97久久久精品综合88久久| 亚洲品质自拍视频| 欧美精品1区2区3区| 久久超碰97人人做人人爱| 欧美激情在线一区二区| 91视频免费观看| 丝袜a∨在线一区二区三区不卡| 欧美一级在线观看| 国产成人无遮挡在线视频| 自拍偷拍亚洲激情| 欧美日本韩国一区二区三区视频 | 男人的j进女人的j一区| 国产日产欧产精品推荐色| 99精品国产91久久久久久 | av中文字幕亚洲| 午夜成人免费视频| 久久蜜桃av一区二区天堂| 91麻豆免费观看| 久久99热这里只有精品| 国产精品成人一区二区三区夜夜夜| 在线观看日产精品| 国产老妇另类xxxxx| 亚洲一区二区偷拍精品| 日韩精品中文字幕在线一区| 99r精品视频| 久久成人羞羞网站| 一个色综合网站| 精品日韩在线观看| 91麻豆精品秘密| 精品视频1区2区| 国产乱码精品一区二区三| 亚洲精品一二三四区| 精品少妇一区二区三区在线视频| 91小视频免费看| 精品一区二区三区在线观看 | 亚洲v日本v欧美v久久精品| 久久久亚洲精华液精华液精华液| 色综合久久综合| 国产一区二区0| 午夜激情一区二区三区| 最新国产の精品合集bt伙计| 日韩亚洲欧美在线| 欧美在线免费观看视频| 国产成人a级片| 精品在线一区二区三区| 亚洲国产成人精品视频| 中文字幕日韩一区二区| 精品国产区一区| 欧美午夜不卡在线观看免费| 波多野结衣亚洲一区| 久久精工是国产品牌吗| 日韩高清在线不卡| 亚洲小少妇裸体bbw| 国产精品传媒在线| 久久久久久麻豆| 欧美成人aa大片| 91精品国产综合久久精品图片| 91理论电影在线观看| 国产suv精品一区二区6| 精品一区二区三区蜜桃| 日日摸夜夜添夜夜添亚洲女人| 亚洲精品视频在线观看网站| 欧美激情一区二区三区全黄| 欧美精品一区在线观看| 日韩一区二区不卡| 56国语精品自产拍在线观看| 在线亚洲欧美专区二区| 91免费精品国自产拍在线不卡| 国产盗摄精品一区二区三区在线| 蜜臀国产一区二区三区在线播放| 亚洲一本大道在线| 一区二区三区在线视频播放| 中文字幕日本不卡| 国产精品成人在线观看| 国产精品传媒入口麻豆| 国产精品久久久爽爽爽麻豆色哟哟| 国产三级精品视频|