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

📄 cnetworkdrive.cpp

📁 此程序为wcdma系统当中ftp/video业务模型的c++程序仿真 通过此程序 能得到此两种业务在多种条件下的吞吐量和无码率的性能
💻 CPP
📖 第 1 页 / 共 4 页
字号:
 ///////////////////////////////////////////////////////////////////
//                            WCDMA TEAM                         //
//                     BUPT Radio Research Center                //
///////////////////////////////////////////////////////////////////
//
//                        CNetworkDrive.cpp
//
//////////////////////////////////////////////////////////////////////
//                                                                  //
//              网络驱动类CNetworkDrive的成员函数的声明             //
//                                                                  //
// Written by:     李晶 陈美娅 周建华                               //
// Date:      200405                                                // 
//                                                                  //
//////////////////////////////////////////////////////////////////////

#include "CNetworkDrive.h"
#include "CChannelModel.h"
#include <afx.h>
#include <string.h>
#include <iostream.h>
#include <crtdbg.h>

//fastfading value arrays,read from the linklevel simulation 
float fFastFadingValue_1[SubslotNumber*FastFadingValueLength];
float fFastFadingValue_2[SubslotNumber*FastFadingValueLength];
float fFastFadingValue_3[SubslotNumber*FastFadingValueLength];
float fFastFadingValue_4[SubslotNumber*FastFadingValueLength];
float fFastFadingValue_5[SubslotNumber*FastFadingValueLength];

int iVideoPacketSize[36000];//zl 20060329

///////////////////////////////////////////////////////////////////////////
//
//	TITLE:	系统初始化函数
//
//	PURPOSE:初始化本类的各个参数,调用包含的各个类的初始化函数,完成系统
//			初始化。主要工作是从数据文件中读入参数
//
//	SAMPLE CALL:
//			CNetworkDrive mysystem;
//			mysystem.SystemInitialization()
//
//	CALLED BY FUNCTIONS:
//			CNetworkDrive::SimulationRun()
//
//	CALLING FUNCTIONS:
//			CServiceArea::Initialization()
//			CMsManager::Initialization()
//			CLinkPrediction::Initialization()
//
//	AUTHOR:	Ouyang Hui
//
//	DATE:	01/04/04
//
//	MODIFICATIONS SINCE 01/04/04:
//			01/05/17	move m_ServiceArea.Initialization() to DropInitialization() 
//			01/05/18	modify the arguments of m_MsManager.Initialization()
//////////////////////////////////////////////////////////////////////////
	
void CNetworkDrive::SystemInitialization()
{
	ReadData();		//Read data from the parameter file

	//////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////
	//////////////////////////////////////////////////////////////////////

	Random R;		//initialize the random numbers
 	R.Set(0.6616);

	//initialize the class CLinkPrediction
	m_LinkPrediction.Initialization();
	m_LinkPrediction.HSInitialization(); //by slj

	//initialize the class CMsManager
	m_MsManager.Initialization(m_iSlotNum,float(SlotSize),
	float(m_fTimePerDrop),&(m_LinkPrediction));
	m_ServiceArea.TTINumInitialization();//wlm
}

/////////////////////////////////////////////////////////////////////////////
//
//	TITLE:	Reading-data Function
//
//	PURPOSE:Read data from the parameter file (testdata.txt).
//
//	CALLED BY FUNCITONS:
//			CNetworkDrive::SystemInitialization()
//
//	CALLING FUNCTIONS:
//			CNetworkDrive::ReadData_Simulation()
//			CNetworkDrive::ReadData_ServiceArea()
//			CNetworkDrive::ReadData_ChannelModel()
//			CNetworkDrive::ReadData_VoiceMs()
//			CNetworkDrive::ReadData_DataMs()
//			CNetworkDrive::ReadData_HttpMs()
//			CNetworkDrive::ReadData_Handoff()
//			CNetworkDrive::ReadData_Statics()
//
//	AUTHOR:	Ouyang Hui
//
//	DATE:	01/04/04
//
//	MODIFICTIONS SINCE 01/04/04:
//			01/04/06 Ouyang Hui
//				Move the parts of reading data into their correspondent 
//				functions.
//
/////////////////////////////////////////////////////////////////////////////

void CNetworkDrive::ReadData()
{
	////////////////////////////////////////////////////////////////////
	//仿真程序参数的读入
	ReadData_Simulation();
	
	////////////////////////////////////////////////////////////////////
	//服务区环境参数的读入
	ReadData_ServiceArea();

	//////////////////////////////////////////////////////////////////////
	//链路模型参数读入
	ReadData_ChannelModel();
	
	//////////////////////////////////////////////////////////////////////
	//话音移动台参数的读入
	ReadData_VoiceMs();
	
	//////////////////////////////////////////////////////////////////////
	//数据业务移动台参数的读入
	ReadData_DataMs();
	
	//////////////////////////////////////////////////////////////////////
	//HTTP移动台参数的读入
	ReadData_HttpMs();
	
	//////////////////////////////////////////////////////////////////
	//软切换与小区交换参数的读入
	ReadData_Handoff();
	
	//////////////////////////////////////////////////////////////////
	//数据统计参数读入
	ReadData_Statics();
 
	//////////////////////////////////////////////////////////////////
	//快衰参数读入
	ReadData_FastFadingValue();

	//////////////////////////////////////////////////////////////////
	//Video Packet值读入
	ReadData_VideoPacketValue();

	CheckTheInputs();
	
}

/////////////////////////////////////////////////////////////////////////
//
//	TITLE:	Functions Reading Data
//
//	PURPOSE:Reading Simulation's parameter from the data file
//
//	CALLED BY FUNCTIONS:
//			CNetworkDrive::ReadData()
//
//	COMMENTS:
//			The format of this part of data in the file is:
//			<begin>
//			1.仿真程序参数
//			仿真的drop数 = 10
//			每drop内的时间长度 = 5 (s)
//			每扇区的话音用户数 = 1
//			每扇区的DCH分组用户数 = 2
//          每扇区的HSDSCH分组用户数 = 2
//			分组用户中的HTTP用户比例 = 0.5
//			分组用户中的FTP用户比例 = 0.5
//			<end>
//
//			Notes:
//			1.The first line should contain the specific string, (Here is
//			"仿真程序参数").
//			2.On the left of '=' there must be the parameter name, which
//			should be typed exactly regardless of blank and tab.
//			3.On the right of '=' there must be the value of the parameter.
//			And between '=' and the figure there should be no other characters
//			than blank and tab.
//			4.The order of parameters should not be changed. And none of
//			them can be omitted.
//			5.You can insert some lines without '=' for comments. You can
//			also add strings after the figures which indicate some information
//			like unit.
//
//	AUTHOR:	Ouyang Hui
//
//	DATE:	01/04/06
//
//	MODIFICTIONS SINCE 01/04/06
//
/////////////////////////////////////////////////////////////////////////
//revised by zl  05/04  
//zl 20060308
void CNetworkDrive::ReadData_Simulation()
{

//	cout<<"The function CNetworkDrive::ReadData_Simulation() is being called!\n";

	int NUM_VALUE;
	const char* cSpecificString;
	bool bFlag;
	char* pname[17];
		
	double pval[17];
	CStdioFile f1;		//定义一个I/O文件对象
	CString s1,s2,s3;		//定义三个字符串对象
	double x;
	int i,j,k,iEqualPos;
	char* q;
	char buf[100];	//定义一个数据缓冲区,用于存放一行字符串

//	cout<<ParameterFile<<endl;
	
	/* 打开数据文件准备读*/
	if(!f1.Open(ParameterFile,CFile::modeRead))
	{
	#ifdef _DEBUG
		afxDump<<"Unable to open file"<<"\n";	//异常处理
	#endif
	}

	pname[0]="仿真的drop数";
	pname[1]="每drop内的时间长度";
	pname[2]="每扇区的话音用户数";
	pname[3]="每扇区的DCH分组用户数";
    pname[4]="每扇区的HSDSCH分组用户数";
    pname[5]="分组用户中的HTTP用户比例";
	pname[6]="分组用户中的FTP用户比例";
	pname[7]="分组用户中的VIDEO用户比例";
    pname[8]="EP误块率目标值";
	pname[9]="门限调整DownStep";
	pname[10]="VideoEP误块率目标值";
	pname[11]="Video门限调整DownStep";
	pname[12]="门限调整范围";
	pname[13]="门限调整LocalDownStep";
	pname[14]="门限调整GlobalDownStep";
	pname[15]="门限调整方法Algorithm(AL1,AL2,AL3,AL4)";
    pname[16]="调度方法Schedule_Algorithm(MAXC2I,PROPFAIRNESS,RANDOMR,GradePF,AdaptiveGPF,Utility,M_LWDF,EXP)";  
			//20051205 20060111
			//20060405 by huangfan

	i=0;NUM_VALUE=17;
	cSpecificString="仿真程序参数";
	bFlag=FALSE;
	
	while(f1.ReadString(buf,100)!=NULL)
	{
		s1=buf; //把这一行字符串内容赋给对象s1
		if (s1.Find(cSpecificString)>=0) 
		{
			bFlag=TRUE;
			break;
		}
	}

	if (!bFlag)
	{
		cerr<<"Cannot find the specific string "<<cSpecificString<<endl;
		f1.Close();
		exit(0);
	}

	/*从数据文件依次读入每一行字符串,对每一行字符串进行处理*/
	while(f1.ReadString(buf,100)!=NULL)
	{
		if (i>=NUM_VALUE)
			break;

		s1=buf; //把这一行字符串内容赋给对象s1

		iEqualPos=s1.Find("=");
		if (iEqualPos<0)
			continue;

		s2=s1.Left(iEqualPos);
		s3=s1.Right(s1.GetLength()-iEqualPos-1);

		j=0;
		k=iEqualPos-1;
		while ((s2[j]==' ')||(s2[j]=='\t')) j++;
		while ((s2[k]==' ')||(s2[k]=='\t')) k--;
		s2=s2.Mid(j,k-j+1);

		if (s2!=pname[i]) 
		{
			cerr<<"Unexpected parameter name  "<<s2<<"."<<endl
				<<"Should be "<<pname[i]<<endl;
			f1.Close();
			exit(0);
		}

		x=strtod(s3,&q);

		pval[i]=x;
		i++;
	}

	m_iDropNum=(int)pval[0];
	m_fTimePerDrop=(float)pval[1];
	m_iSlotNum=(int)(pval[1]*1500);
	m_MsManager.SetVoiceNumPerSector((int)pval[2]);
	m_MsManager.SetDCHDataNumPerSector((int)pval[3]);
    m_MsManager.SetHSDSCHDataNumPerSector((int)pval[4]);
	m_MsManager.SetFractionHttp((float)pval[5]);
	m_MsManager.SetFractionFtp((float)pval[6]);
	m_MsManager.SetFractionVideo((float)pval[7]);
	
    m_MsManager.SetDataNumPerSector((int)pval[3]+(int)pval[4]);

	m_MsManager.m_fEPTargetErrorRate = (float)pval[8];
	m_MsManager.m_fTADownStep = (float)pval[9];
    m_MsManager.m_fVideoEPTargetErrorRate = (float)pval[10];
	m_MsManager.m_fVideoTADownStep = (float)pval[11];
	m_MsManager.m_fTARange = (float)pval[12];
	m_MsManager.m_fTALocalDownStep = (float)pval[13];
	m_MsManager.m_fTAGlobalDownStep = (float)pval[14];
	m_MsManager.m_iAlgorithm = (int)pval[15];
    m_MsManager.m_iScheduleAlgorithm = (int)pval[16];


	f1.Close();//关闭参数文件



}

/////////////////////////////////////////////////////////////////////////
//
//	TITLE:	Functions Reading parameters
//
//	PURPOSE:Read the service area's parameters from the data file
//
//	CALLED BY FUNCTIONS:
//			CNetworkDrive::ReadData()
//
//	COMMENTS:
//			The format of this part of data in the file is:
//			<begin>
//			2.服务区环境参数
//			基站间间隔 = 2 (km)
//			BTS的最大发射功率 = 43 (dBm)
//			分组数据信道的最大功率比例 = 0.7
//			前向信道的正交因子 = 0.4
//			<end>
//
//			Notes:
//			1.The first line should contain the specific string, (Here is
//			"服务区环境参数").
//			2.On the left of '=' there must be the parameter name, which
//			should be typed exactly regardless of blank and tab.
//			3.On the right of '=' there must be the value of the parameter.
//			And between '=' and the figure there should be no other characters
//			than blank and tab.
//			4.The order of parameters should not be changed. And none of
//			them can be omitted.
//			5.You can insert some lines without '=' for comments. You can
//			also add strings after the figures which indicate some information
//			like unit.
//
//	AUTHOR:	Ouyang Hui
//
//	DATE:	01/04/06
//
//	MODIFICTIONS SINCE 01/04/06
//
/////////////////////////////////////////////////////////////////////////
void CNetworkDrive::ReadData_ServiceArea()
{
//	cout<<"The function CNetworkDrive::ReadData_ServiceArea() is being called!\n";

	int NUM_VALUE;
	const char* cSpecificString;
	bool bFlag;
	char* pname[15];
		
	double pval[15];
	CStdioFile f1;		//定义一个I/O文件对象
	CString s1,s2,s3;		//定义三个字符串对象
	double x;
	int i,j,k,iEqualPos;
	char* q;
	char buf[100];	//定义一个数据缓冲区,用于存放一行字符串

	/* 打开数据文件准备读*/
	if(!f1.Open(ParameterFile,CFile::modeRead))
	{
	#ifdef _DEBUG
		afxDump<<"Unable to open file"<<"\n";	//异常处理
	#endif
	}

	pname[0]="基站间间隔";
	pname[1]="BTS的最大发射功率";
	pname[2]="分组数据信道的最大功率比例";
	pname[3]="前向信道的正交因子";

	i=0;NUM_VALUE=4;
	cSpecificString="服务区环境参数";
	bFlag=FALSE;

	while(f1.ReadString(buf,100)!=NULL)
	{
		s1=buf; //把这一行字符串内容赋给对象s1
		if (s1.Find(cSpecificString)>=0)
		{
			bFlag=TRUE;
			break;
		}
	}

	if (!bFlag)
	{
		cerr<<"Cannot find the specific string "<<cSpecificString<<endl;
		f1.Close();
		exit(0);
	}

	/*从数据文件依次读入每一行字符串,对每一行字符串进行处理*/
	while(f1.ReadString(buf,100)!=NULL)
	{
		if (i>=NUM_VALUE)
			break;

		s1=buf; //把这一行字符串内容赋给对象s1

		iEqualPos=s1.Find("=");
		if (iEqualPos<0)
			continue;

		s2=s1.Left(iEqualPos);
		s3=s1.Right(s1.GetLength()-iEqualPos-1);

		j=0;
		k=iEqualPos-1;
		while ((s2[j]==' ')||(s2[j]=='\t')) j++;
		while ((s2[k]==' ')||(s2[k]=='\t')) k--;
		s2=s2.Mid(j,k-j+1);

		if (s2!=pname[i]) 
		{
			cerr<<"Unexpected parameter name  "<<s2<<"."<<endl
				<<"Should be "<<pname[i]<<endl;
			f1.Close();
			exit(0);
		}

		x=strtod(s3,&q);

		pval[i]=x;
		i++;
	}

	m_ServiceArea.SetSiteDistance((float)pval[0]);
	m_ServiceArea.SetOrthogonalFactor((float)pval[3]);
	float ptemp=(float)pow(10,(float)pval[1]/10.0);
	ptemp=(float)(ptemp*(float)pval[2]);
	for (int ii=0;ii<MM;ii++)
		for (int jj=0;jj<NN;jj++)
			for (int kk=0;kk<SectorNumber;kk++)
			{
				SECTORID_TYPE id;
				id.stCellID.m=ii+1;
				id.stCellID.n=jj+1;
				id.s=kk+1;
				m_ServiceArea.GetSector(id)
					->SetMaxPower((float)pow(10,pval[1]/10.0));
				m_MsManager.SetFractionOfPacketPower(float(pval[2]));
				m_ServiceArea.GetSector(id)->SetMaxPacketPower(ptemp);
			}
			
	f1.Close();
}

/////////////////////////////////////////////////////////////////////////
//
//	TITLE:	Function of Reading Parameters
//
//	PURPOSE:Reading channel model's parameters from the data file.
//
//	CALLED BY FUNCTIONS:
//			CNetworkDrive::ReadData()

⌨️ 快捷键说明

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