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

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

?? asyncmaclayer.cc.bak

?? 基于omnet++開發的Mf框架下的802.11協議仿真。
?? BAK
?? 第 1 頁 / 共 2 頁
字號:
/* -*- mode:c++ -*- ********************************************************
 * file:        AsyncMacLayer.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-11 15:36 $
 *              by:              $Author: Yupeng.hu $
 ***************************************************************************/
 
#include "AsyncMacLayer.h"
#include<fstream>
#include <time.h>
#include <cmath>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <windows.h>
#include <iterator>
#include <mysql.h>
#include "RadioState.h"

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

Define_Module( AsyncMacLayer );

MYSQL mysql_mac; 
std::deque<std::string> x_energe;
/**
 * First we have to initialize the module from which we derived ours,
 * in this case BasicModule.
 *
 * Then we have to intialize the gates and - if necessary - some own
 * variables.
 *
 * If you subclass your own message classes you need to overwrite the
 * createCapsulePkt function.
 *
 **/
void AsyncMacLayer::initialize(int stage)
{
	BasicMacLayer::initialize(stage); 
  	
  	if(stage==0){    
    	ev << logName() << "::AsyncMacLayer:" <<" AsyncMacLayer is loaded!!!"<<endl;    	
    	energyConsumption=0;
    
    	sleepTimestamp=simTime();
//      numBurstMessage=0;
      ackTap=2;
   		WATCH_VECTOR(backupVector);
   		
   		//the consumed energy of recieving msg per second
	    rxEnergy=par("rxEnergy");
	    //the consumed energy of sending msg per second
	    txEnergy=par("txEnergy");
	    //the consumed energy per second while sleeping
	    sleepEnergy=par("sleepEnergy");
            
			resendCounter=0;
			WATCH(resendCounter);
			tempAddr=-2;
			WATCH(tempAddr);
	    	    
	    sleepEvent = new cMessage("sleepEvent");
	    activeEvent = new cMessage("activeEvent");
	    popEvent = new cMessage("popEvent");   
	    iniEvent=new cMessage("iniEvent");
	    timeOut=new cMessage("timeOut");
	    energe=new cMessage("energe");
	   
	   
	    //
	    groupSize=(double)par("groupSize");
	    status=IS_SLEEP;	//initialize node in IS_SLEEP mode
	    WATCH(status);
	    
	    
	    distance=-1;    			
	    scheduleAt(0.0, iniEvent);
	    if(findHost()->index()==0)//if the node is sink, ready for calculating the energy
	    {
	    	scheduleAt(simTime()+5.0,energe);
	    }
	    
	    /*
	  		**初始化數據庫
	  		*/
	  		if(mysql_init(&mysql_mac) == NULL)
	  		{
	  			std::cout<<"init mysql data status fail"<<std::endl;
	  			return;
	  		}
	  		else
	  			std::cout<<"init mysql data status success"<<std::endl;
	  		if(NULL == mysql_real_connect(&mysql_mac,"localhost","root","","wsnss",MYSQL_PORT,NULL,0))
	  		{
	  			std::cout<<"connect database fail"<<std::endl<<mysql_error(&mysql_mac)<<std::endl;;
	  			return;
	  		}	
	  		else
	  			std::cout<<"connect database success"<<std::endl;
	  	  /*
	  	  **初始化數據庫結束
	  	  */
  	}
  	else if(stage==1){
    	
  	}
}

//send the msg in queue
void AsyncMacLayer::startPop()
{
	if(status==IS_ACTIVE)    
	{		   		 	
		if(queue.length()>0)
		{	
			
			MacPkt  *msg=(MacPkt* )queue.pop();	
    		ev << logName() << "::AsyncMacLayer: node-" << findHost()->index() << " currently queue length is: " << queue.length()+1 << endl;    		
    		ev << logName() << "::AsyncMacLayer: node-" << findHost()->index() << " Starting transmission of msg in queue,length:" << msg->length()<<endl;    		
    		
    		ev<<"Make a copy!"<<endl;     		
			MacPkt* bkMsg=(MacPkt* )(msg->dup());						
			bkMsg->setRetryLimit(0);//初始化重發次數			backupVector.push_back(bkMsg);	
    		
    		//energy consumption for transmission     		    
    		energyConsumption += txEnergy*msg->length()/(double)par("bitrate");      		    		          		
    		scheduleAt(simTime()+msg->length()/(double)par("bitrate")+0.001, popEvent);  
    		sendDown((MacPkt *)msg);    		
    	}
		else
		{	
			ev << logName() << "::AsyncMacLayer::startPop():: node-" << findHost()->index() <<" queue is empty, so switch to sleep right now!"<< endl;    		
		}				
   }
   else
      	error("goint to popup but I am is sleep .....");	
}


//顯示信息
/**void AsyncMacLayer::displayStatus(bool isBusy)
{
    char string[50];
    if(findHost()->index()!=(int)findHost()->submodule("appl")->par("destAddress"))
    {
    sprintf( string, "%d-%d", queue.length(), backupVector.size());    
    findHost()->displayString().setTagArg("t",0, string);    
}}

*/

/**
 * The basic handle message function.
 *
 * Depending on the gate a message arrives handleMessage just calls
 * different handle*Msg functions to further process the message.
 *
 * You should not make any changes in this function but implement all
 * your functionality into the handle*Msg functions called from here.
 *
 * @sa handleUpperMsg, handleLowerMsg, handleSelfMsg
 **/
void AsyncMacLayer::handleSelfMsg(cMessage* msg)
{       
	
	if(msg==iniEvent)//parameters initializtion
  	{
  	 	topo = new cTopology("topo");
  	 	//the topo include the AsynHost's all modules
  		topo->extractByModuleType(findHost()->className(), NULL);
  		
  		
  		int dest=findHost()->submodule("appl")->par("destAddress");//topo->node(i)'s index() is i 		  		
  		topo->unweightedSingleShortestPathsTo(topo->node(dest));
  	  ev<<logName()<<"AsyncMacLayer::"<<"The queue length is"<<queue.length()<<endl;
    	//the hops to the dest
    	distance=topo->nodeFor(findHost())->distanceToTarget();
    	ev<<logName() << "::AsyncMacLayer:" <<" distance to sink node is: "<<distance<<endl;  		
  	  
    	cycleTime=(double)par("roundTime");
    	activeTime=cycleTime*(double)par("dutyCycle")*((1/groupSize));
      sleepTime=cycleTime-activeTime;
      
        //孤立節點      if(sleepTime<=0)
      {
       	sleepTime=10000;
      }
      //???有必要設置節點部署后第一次喚醒時間呈階梯行
      

      
      //??
      if((((int)distance)%(int)groupSize)!=0)
      	   		wakeupTime=uniform((groupSize-((int)distance)%(int)groupSize)*cycleTime/groupSize,(groupSize-((int)distance)%(int)groupSize+1)*cycleTime/groupSize);
      else
      	  		wakeupTime=uniform(0,cycleTime/groupSize);
      	  		    	ev<<logName()<<"the sleeptime is:"<<sleepTime<<endl;   	
    	ev<<logName()<<"the activetime is:"<<activeTime<<endl;
    	ev << logName() << "::AsyncMacLayer: wakeup time: "<<wakeupTime<<endl;   
  	  scheduleAt(simTime()+wakeupTime, activeEvent); 
  	  
    	
  		delete msg;
  		delete topo;
  	} 
  	//************************************
    //* when receiving self active event *
    //************************************
    else if (msg==activeEvent)//activation the node
    {    	
    	char str[1024];
    	sprintf(str,"insert into energy_mac(ID,value)values('%d','%lf');",
					findHost()->index(),energyConsumption);
				
			std::string insert(str);
			x_energe.push_back(insert);
			
    	ev << logName() << "::AsyncMacLayer:  node-" << findHost()->index() << " receiving--self-- " << msg << endl;    	
    	// we begin to IS_ACTIVE and send frames in queue.    	   	
    	if(status==IS_SLEEP)
    	{
    		status=IS_ACTIVE;
    		
    		sleepTime=cycleTime-activeTime*(tempCount.size()+1);//???tempCount可以去掉?
    		scheduleAt(simTime()+activeTime, sleepEvent);    	    		
    		
    		if(ackTap==0)
    		{

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本不卡一二三| 亚洲免费在线电影| 欧美美女一区二区| 91在线视频网址| 99久久精品国产一区| 99精品在线观看视频| 91麻豆自制传媒国产之光| 一道本成人在线| 欧美在线999| 国产免费久久精品| 久久精品亚洲乱码伦伦中文| www国产精品av| 中文字幕乱码亚洲精品一区| 久久久久久久久97黄色工厂| 国产精品视频九色porn| 亚洲精品日韩专区silk| 亚洲一区二区影院| 日韩激情av在线| 韩国精品一区二区| av不卡在线播放| 在线日韩一区二区| 日韩视频在线永久播放| 久久亚洲私人国产精品va媚药| 国产日韩精品久久久| 亚洲免费观看高清完整版在线 | 亚洲一区在线免费观看| 同产精品九九九| 经典三级视频一区| 99综合影院在线| 欧美性一级生活| 精品粉嫩超白一线天av| 国产精品伦理在线| 视频一区二区三区入口| 国产麻豆精品95视频| 91啪在线观看| 精品人在线二区三区| 中文字幕制服丝袜成人av| 亚洲va在线va天堂| 国产超碰在线一区| 久久久久久综合| 亚洲激情欧美激情| 国产在线播放一区| 色天使色偷偷av一区二区| 欧美mv日韩mv国产| 亚洲国产一区二区视频| 岛国精品一区二区| 欧美一区二区视频免费观看| 欧美国产日产图区| 卡一卡二国产精品| 欧美日韩精品综合在线| 中文字幕精品三区| 韩国一区二区三区| 91麻豆精品国产| 亚洲另类在线视频| 懂色av一区二区三区免费看| 欧美一二三四在线| 亚洲一级二级在线| 99re视频精品| 国产人伦精品一区二区| 看片网站欧美日韩| 宅男噜噜噜66一区二区66| 亚洲三级在线免费观看| 成人午夜大片免费观看| 2021久久国产精品不只是精品| 亚洲香肠在线观看| 精品国产91洋老外米糕| 亚洲国产精品一区二区www| www.日本不卡| 国产精品毛片无遮挡高清| 久久精品国产成人一区二区三区| 欧美三区在线观看| 亚洲最新视频在线观看| 色偷偷久久一区二区三区| 日韩美女视频一区二区| av亚洲精华国产精华| 国产精品欧美一区二区三区| 国产成人午夜视频| 久久久精品影视| 国产精品1区2区3区| 久久久久久久综合| 懂色av一区二区三区免费观看| 国产亚洲午夜高清国产拍精品 | 国产一区二区三区久久久| 日韩美女视频在线| 极品少妇xxxx精品少妇偷拍| 欧美www视频| 国产精品综合二区| 国产欧美日韩在线视频| 成人性生交大片免费看在线播放| 中文字幕精品—区二区四季| caoporm超碰国产精品| 亚洲人吸女人奶水| 欧美视频精品在线| 免费成人在线影院| 久久久亚洲精品石原莉奈 | 国产欧美在线观看一区| 成人91在线观看| 一区二区三区资源| 欧美精品第1页| 国产在线精品一区二区三区不卡| 亚洲国产高清不卡| 色偷偷一区二区三区| 日韩精品欧美精品| 国产午夜精品理论片a级大结局| 国产成人av一区二区| 亚洲蜜桃精久久久久久久| 91.com在线观看| 国产精品一品二品| 一区二区三区日韩欧美| 制服丝袜国产精品| 成人av网站在线观看| 婷婷久久综合九色综合绿巨人| 精品久久久久久无| 欧美丰满一区二区免费视频| 国产精品456| 亚洲成va人在线观看| 久久久99精品免费观看不卡| 在线亚洲高清视频| 国产精品亚洲午夜一区二区三区| 一区二区三区精品久久久| 精品国产成人系列| 欧美伊人久久久久久午夜久久久久| 九色|91porny| 亚洲综合999| 国产日产欧美一区二区视频| 欧美精品欧美精品系列| 97久久人人超碰| 国产一区二区不卡老阿姨| 午夜精品久久久久久久久| 国产精品国产三级国产aⅴ原创| 5858s免费视频成人| 一本高清dvd不卡在线观看| 国产福利电影一区二区三区| 免费成人av在线播放| 艳妇臀荡乳欲伦亚洲一区| 国产精品久久久久精k8| 欧美精品一区二区三区视频| 欧美丰满美乳xxx高潮www| 91浏览器打开| 不卡的电影网站| 粉嫩一区二区三区性色av| 久久国产婷婷国产香蕉| 日韩制服丝袜av| 午夜一区二区三区在线观看| 亚洲日本在线视频观看| 国产精品久久精品日日| 中文字幕av一区二区三区免费看| 欧美成人女星排名| 日韩欧美国产一区二区在线播放| 91麻豆精品久久久久蜜臀| 欧美日韩中字一区| 欧美日本国产一区| 欧美日韩高清一区二区不卡| 欧美在线观看一区| 欧美色视频一区| 欧美色涩在线第一页| 欧美久久一区二区| 91精品啪在线观看国产60岁| 欧美高清视频不卡网| 精品视频在线免费| 91精品蜜臀在线一区尤物| 欧美一区二区三区小说| 日韩一区二区三免费高清| 91精品国产免费| 精品少妇一区二区三区 | 久久―日本道色综合久久| 精品国产污网站| 国产人成一区二区三区影院| 国产精品麻豆一区二区| 亚洲欧美偷拍三级| 亚洲成va人在线观看| 免费一级片91| 国产xxx精品视频大全| av高清久久久| 欧美日韩成人一区二区| 日韩精品中文字幕一区| 国产欧美一区二区三区鸳鸯浴 | 丝袜美腿高跟呻吟高潮一区| 成人精品免费看| 一本大道久久a久久综合| 欧美日韩精品免费观看视频| 欧美一区在线视频| 亚洲国产精品国自产拍av| 一区二区高清免费观看影视大全| 日韩国产精品久久久久久亚洲| 精品中文字幕一区二区| 99久久国产综合精品女不卡| 欧美视频在线一区二区三区 | 99国产精品久久久久久久久久久| 色婷婷久久综合| 精品国产一区二区三区久久影院| 中文字幕av资源一区| 亚洲成人福利片| 国产成人综合亚洲网站| 欧美三级乱人伦电影| 国产香蕉久久精品综合网| 亚洲影院理伦片| 国产精品538一区二区在线| 欧美视频一区二区三区在线观看| www久久精品|