⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmsmanager.cpp

📁 此程序为wcdma系统当中ftp/video业务模型的c++程序仿真 通过此程序 能得到此两种业务在多种条件下的吞吐量和无码率的性能
💻 CPP
📖 第 1 页 / 共 5 页
字号:

	//初始化http数据用户链表
	pos=m_HttpDataList.GetHeadPosition();
	CHttpDataMs* pHttpDataMs=NULL;
	while (pos!=NULL)
	{
		tt=T_data;
		pHttpDataMs=m_HttpDataList.GetNext(pos);
		ID++;	//determine the ID
		cout<<"Mobile #"<<ID<<" initialization...  HTTP"<<endl;

		//determine the channel type and the correspondent velocity
		//the way to determine them is similar to the way of the voice users'
		pp=xUniform(0.,1.);		//produce a random between 0 and 1
		if (pp<fV[0])			//if the random is between 0 and fV[0]
		{fVelocity=3.;nType=1;}
		else if (pp<fV[1])		//if the random is between fV[0] and fV[1]
		{fVelocity=10.;nType=2;}
		else if (pp<fV[2])		//if the random is between fV[1] and fV[2]
		{fVelocity=30.;nType=3;}
		else if (pp<fV[3])		//if the random is between fV[2] and fV[3]
		{fVelocity=120.;nType=4;}
		else			        //the random is between fV[3] and fV[4]
		{fVelocity=0.;nType=5;}

		cout<<"	Channel type:	"<<nType<<endl;

		//调用初始化函数
		pHttpDataMs->MobileInitialization(ID,this,pService,
			fVelocity,nType,m_fStdSlowFading,tt);
		pHttpDataMs->DataMsInitialize(
			m_pLinkPrediction,0);
		pHttpDataMs->HttpInitialization();
	}

//通过设定参数,在仿真时系统中只有FTP用户

	//初始化ftp数据用户链表
	pos=m_FtpDataList.GetHeadPosition();
	CFtpDataMs* pFtpDataMs=NULL;
	while (pos!=NULL)
	{
		tt=T_data;
		pFtpDataMs=m_FtpDataList.GetNext(pos);
		ID++;	//determine the ID

		cout<<"Mobile #"<<ID<<" initialization...  FTP"<<endl;

		//determine the channel type and the correspondent velocity
		pp=xUniform(0.,1.);		//produce a random between 0 and 1
		if (pp<fV[0])			//if the random is between 0 and fV[0]
		{fVelocity=3.;nType=1;}
		else if (pp<fV[1])		//if the random is between fV[0] and fV[1]
		{fVelocity=10.;nType=2;}
		else if (pp<fV[2])		//if the random is between fV[1] and fV[2]
		{fVelocity=30.;nType=3;}
		else if (pp<fV[3])		//if the random is between fV[2] and fV[3]
		{fVelocity=120.;nType=4;}
		else					//if the random is between fV[3] and fV[4]
		{fVelocity=0.;nType=5;}

		cout<<"	Channel type:	"<<nType<<endl;

		//call the initializing functions
		pFtpDataMs->FtpInitialization();
		pFtpDataMs->MobileInitialization(ID,this,pService,
			fVelocity,nType,m_fStdSlowFading,tt);
		pFtpDataMs->DataMsInitialize(
			m_pLinkPrediction,0);
		

		//notice 如果将CDataMs作为基类,则所有函数都能够处理CDataMs的指针,不必将
		//相应的代码都写成http/ftp两部分
	}	

	//初始化Video数据用户链表    20060116
	pos=m_VideoDataList.GetHeadPosition();
	CVideoDataMs* pVideoDataMs=NULL;
	while (pos!=NULL)
	{
		tt=T_data;
		pVideoDataMs=m_VideoDataList.GetNext(pos);
		ID++;	//determine the ID

		cout<<"Mobile #"<<ID<<" initialization...  Video"<<endl;

		//determine the channel type and the correspondent velocity
		pp=xUniform(0.,1.);		//produce a random between 0 and 1
		if (pp<fV[0])			//if the random is between 0 and fV[0]
		{fVelocity=3.;nType=1;}
		else if (pp<fV[1])		//if the random is between fV[0] and fV[1]
		{fVelocity=10.;nType=2;}
		else if (pp<fV[2])		//if the random is between fV[1] and fV[2]
		{fVelocity=30.;nType=3;}
		else if (pp<fV[3])		//if the random is between fV[2] and fV[3]
		{fVelocity=120.;nType=4;}
		else					//if the random is between fV[3] and fV[4]
		{fVelocity=0.;nType=5;}

		cout<<"	Channel type:	"<<nType<<endl;

		//call the initializing functions
		pVideoDataMs->VideoInitialization();
		pVideoDataMs->MobileInitialization(ID,this,pService,
			fVelocity,nType,m_fStdSlowFading,tt);
		pVideoDataMs->DataMsInitialize(
			m_pLinkPrediction,0);
		

		//notice 如果将CDataMs作为基类,则所有函数都能够处理CDataMs的指针,不必将
		//相应的代码都写成http/ftp两部分
	}	

}



//////////////////////////////////////////////////////////////////////////
//TITLE:      AddUser(增加各类用户函数)				        
//
//PARAMETERS:NULL           
//
//PURPOSE AND ALGORITHMS:
//            根据移动台数量、类型分布等参数循环产生相应数量的各种移动台模块
//                                               
//AUTHOR:     Li Jing
//
//CALLING FUNCTIONS:
//            
//////////////////////////////////////////////////////////////////////////
void CMsManager::AddUser()
{
	int i;

	//产生话音移动台链表
	for( i=0;i<m_iVoiceNumInSys;i++)
	{
		CVoiceMs* pVoiceMs=new CVoiceMs;
		m_VoiceList.AddTail(pVoiceMs);
	}

	

	//产生Http移动台链表
	for(i=0;i<m_iHttpNum;i++)
	{
		CHttpDataMs* pHttpDataMs=new CHttpDataMs;
		m_HttpDataList.AddTail(pHttpDataMs);
	}



	//产生Ftp移动台链表
	for(i=0;i<m_iFtpNum;i++)
	{
		CFtpDataMs* pFtpDataMs=new CFtpDataMs;
		m_FtpDataList.AddTail(pFtpDataMs);
	}

	//产生Video移动台链表    20060116
	for(i=0;i<m_iVideoNum;i++)
	{
		CVideoDataMs* pVideoDataMs=new CVideoDataMs;
		m_VideoDataList.AddTail(pVideoDataMs);
	}
}



//////////////////////////////////////////////////////////////////////////
//TITLE:      Clean(清除用户链表函数)				        
//
//PARAMETERS:NULL           
//
//PURPOSE AND ALGORITHMS:
//            由析构函数调用,清除话音、http、ftp的用户链表
//                                               
//AUTHOR:     Li Jing
//
//CALLING FUNCTIONS:
//            
//////////////////////////////////////////////////////////////////////////
void CMsManager::Clean()
{
	POSITION pos;

	//clean the voice mobiles' list
	pos=m_VoiceList.GetHeadPosition();
	while (pos!=NULL)
	{
		delete m_VoiceList.GetNext(pos);
	}
	m_VoiceList.RemoveAll();


	//clean the http data mobiles' list
	pos=m_HttpDataList.GetHeadPosition();
	while (pos!=NULL)
	{
		delete m_HttpDataList.GetNext(pos);
	}
	m_HttpDataList.RemoveAll();


	//clean the ftp data mobiles' list
	pos=m_FtpDataList.GetHeadPosition();
	while (pos!=NULL)
	{
		delete m_FtpDataList.GetNext(pos);
	}
	m_FtpDataList.RemoveAll();

	//clean the Video data mobiles' list    20060116
	pos=m_VideoDataList.GetHeadPosition();
	while (pos!=NULL)
	{
		delete m_VideoDataList.GetNext(pos);
	}
	m_VideoDataList.RemoveAll();

}



//////////////////////////////////////////////////////////////////////////
//TITLE:      StatisticsReset()清除相关统计量参数	        
//
//PARAMETERS:NULL           
//
//PURPOSE AND ALGORITHMS:
//           
//                                               
//AUTHOR:     Chen Meiya
//
//MODIFIED:   Li Jing,20041121
//            
//////////////////////////////////////////////////////////////////////////
void CMsManager::StatisticsReset()
{
	//在仿真结束重新初始化相关统计参量
    m_iSlotCurrentNum = 0;
	m_iSwitchCounter = 0;

	//话音业务相关统计量的初始化
	m_iVoiceUserOfCurrentDrop=0;		    //本Drop内所有的话音用户初始化为0
	m_iBlockUserOfVoice=0;                  //初始化话音业务接入失败的用户数
    m_fBlockRatioOfVoice=0;                 //初始化话音用户接入失败率
    m_iOutageUserOfVoice=0;                 //初始化话音业务中断的用户数
    m_fOutageRatioOfVoice=0;                //初始化话音用户中断率
    m_iDropUserOfVoice=0;			        //初始化话音业务掉话用户数
    m_fDropRatioOfVoice=0;			        //初始化话音用户掉话率
	m_iUnsatisfiedUserOfVoice=0;            //初始化不满意话音用户数
	m_fSatisfiedRadioOfVoice=0;             //初始化话音用户满意率

	//New added
	m_lTotalVoiceFailedBLNum=0;             //初始化话音用户总的传输错误传输块数
	m_lTotalVoiceBLNum=0;                   //初始化话音用户总的传输块数
	m_fMeanVoiceBLER=0.0;                   //初始化话音用户总的误块率

	//软切换开销相关统计量初始化
	m_fSpendingOfSHO = 0.0;
	m_lTotalSlotOfActiveSetSize = 0;
	for ( int i = 0; i < ActiveSetMaxSize; i++)
	{
		m_lSlotOfActiveSetSize[i] = 0;
		m_fScaleOfActiveSetSize[i] = 0.0;
	}

	//New added
	m_lTotalBLNumInSHO = 0;             //初始化软切换下总的传输块数
	m_lTotalFailedBLNumInSHO = 0;       //初始化记录软切换下错误传输块数
	m_lTotalSlotOfSHO = 0;              //初始化处于软切换总时隙
	m_fScaleOfSHO = 0.0;                //初试化软切换比例
	m_fBLERInSHO = 0.0;                 //初始化软切换下误块率
	m_fTotalMsPowerInSHO = 0.0;         //初始化总发射功率
	m_lTotalMsSlotInSHO = 0;            //初始化处于软切换所有移动台
	m_fMeanPowerInSHO = 0.0;            //初始化软切换下平均功率


	//初始化数据用户相关统计属性
	m_lTotalSucfulBitNum = 0;		//成功传输比特的总量
	m_lTotalFailedBLNum = 0;	//记录数据移动台传输失败的传输块之和
	m_lTotalSucfulBLNum = 0;	//记录数据移动台成功传输的传输块之和
	m_fMeanBLER = 0.0;				//一个drop内的平均传输块错误率
	m_fMeanDataThrput = 0.0;		//一个drop内数据平均吞吐量

	m_lTotalFailedPacketNum = 0;	//记录数据移动台传输失败的分组之和
	m_lTotalSucfulPacketNum = 0;	//记录数据移动台传输成功的份组之和
	m_lTotalSucfulPCBit = 0;
	m_lTotalPacketDelay = 0;		//记录数据移动台总的分组时延
	m_lTotalPCDelay = 0;			//记录数据移动台总的分组呼叫时延
	

	m_iBlockedDCHMs = 0;			//记录一个drop内被block的DCH移动台数目
    m_fBlockedDCHRatio = 0.0;		//记录一个drop内被block的DCH移动台占数据移动台的比例

	//初始化DCH用户掉话相关统计量
	m_iDCHUserOfCurrentDrop = 0;
	m_iMsNumbelowWindow = 0;
	m_iMsNumUnAdmitted = 0;
	m_iInitDroppedUser = 0;
	m_iDropUserOfDCHMs = 0;
    m_fDropRatioOfDCHMs = 0.0;
	m_iUnsatisfiedUserOfDCHMs = 0;
	m_fSatisfiedRadioOfDCHMs = 0.0;


	
// 	for ( int iloop = 0;iloop <ActiveSetMaxSize; iloop++)
// 	{
// 		m_iDCHSHOSlot[iloop] = 0;
// 	}	
}



//////////////////////////////////////////////////////////////////////////
//TITLE:      DistanceCaculte(计算移动台到最近基站的距离函数)				        
//
//PARAMETERS:移动台坐标,归属扇区基站坐标
//
//PURPOSE AND ALGORITHMS:
//            调用GetCor函数,由扇区标号获得扇区的基站坐标,从而就可以计算出
//            移动台到最近扇区基站的距离
//                                               
//AUTHOR:     Li Jing
//
//CALLING FUNCTIONS:
//            
//////////////////////////////////////////////////////////////////////////
float CMsManager::DistanceCaculte(LOCATION_TYPE MsLocation,SECTORID_TYPE SectorID)
{
	float x1,x2,y1,y2;
	LOCATION_TYPE BsLocation;
	x1=MsLocation.x;
	y1=MsLocation.y;
	BsLocation=m_pServiceArea->GetCor(SectorID.stCellID);
	x2=BsLocation.x;
	y2=BsLocation.y;
	return (float)sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}



//////////////////////////////////////////////////////////////////////////
//TITLE:      VoiceProcess(话音用户处理函数)				        
//
//PARAMETERS:NULL           
//
//PURPOSE AND ALGORITHMS:
//            该函数循环处理话音用户链表中的每一个话音用户,对于还没有接纳
//            成功且没有接入超时的用户,则再次进行接入尝试。对于已经接纳成
//            功的话音用户,再进行处理软切换、更新激活集、功控、产生软切换
//            消息、递减服务时长等相关处理。
//                                               
//AUTHOR:     Li Jing
//
//CALLING FUNCTIONS:
//
//NOTES:      1.增加了DROP结束时,对话音用户链表上还未结束通话的用户的处理,
//            以增加统计的精确性
//
//            2.函数最开始对每个移动台加上更新最佳扇区操作
//
//////////////////////////////////////////////////////////////////////////
void CMsManager::VoiceProcess()
{
	int m=0;
	POSITION pos;
	pos=m_VoiceList.GetHeadPosition();
	CVoiceMs* pVoiceMs=NULL;
	float a,b,c,sum;
	
	while(pos!=NULL)
	{
		pVoiceMs=m_VoiceList.GetNext(pos);
		
		pVoiceMs->ObtainBestSector();

	    if(pVoiceMs->IsAdmitted())
		//进行话音处理之前先要判断移动台是否已经接纳成功
		//若是接纳成功,则进行话音处理
		//若是还没有接纳成功,则继续与现在的最佳扇区进行接纳尝试
		{
		        if((pVoiceMs->GetServiceLength()%TTISize==0)&&
					(pVoiceMs->GetServiceLength()!=0))
		        //一个TTI结束
		                 TTIBlockCumulate(pVoiceMs);

		        if((pVoiceMs->GetServiceLength()%WindowSize==0)&&
					(pVoiceMs->GetServiceLength()!=0))
		        //一个窗口结束
		                 OutageAndDropJudgement(pVoiceMs);
 
		        //在对每个移动台进行处理时,同时判断服务时长是否到时
		        //若已经到时,则重新调用移动台初始化函数,重新初始化,并增加本Drop话音用户数
		        if(pVoiceMs->IsServiceOver())
		        //服务到时或者是由于掉话原因被迫结束服务
		        {
		             a=(float)(pVoiceMs->GetTotalOutageWindow());
		             b=(float)(pVoiceMs->GetTotalWindow());
		             c=a/b;
		             pVoiceMs->SetOutageRatio(c);
		                 
		             if(c>UserOutageThreshold)
					 {
		                 m_iOutageUserOfVoice++;
					     if(pVoiceMs->IsDropped()==false)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -