?? cmsmanager.cpp
字號:
/////////////////////////////////////////////////////////////////////////
//
// CMsManager.cpp 移動臺管理類的實現
// 建立者:程宇
//
/////////////////////////////////////////////////////////////////////////
//
// 修改記錄:
//
// 2001年3月23日 歐陽暉
// 實現Initialization()函數
//
/////////////////////////////////////////////////////////////////////////
#include "CMsManager.h"
#include "CVoiceMs.h"
#include "CHttpDataMs.h"
#include "CFtpDataMs.h"
#include "sys_random.h"
#include "newran.h"
#include "CServiceArea.h"
#include "CLinkPrediction.h"
//#include "CVoiceLinkPrediction.h"//added by cqm
#include <string.h>
#include <stdio.h>
//////////////////////////////////////////////////////////////////////////////
//
// PURPOSE:
//
// AUTHOR:
//
// AUDITOR:
//
// DATE: 01/04/09
//
// TEST RECORD:
//
// MODIFICATIONS:
//
//////////////////////////////////////////////////////////////////////////////
CMsManager::~CMsManager()
{
Clean();
}
void CMsManager::Clean()
{
//clean the voice mobiles' list
POSITION pos;
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();
}
//////////////////////////////////////////////////////////////////////////////
//
// PURPOSE:
//
// AUTHOR:
//
// AUDITOR:
//
// DATE: 01/04/09
//
// TEST RECORD:
//
// MODIFICATIONS:
//
//////////////////////////////////////////////////////////////////////////////
void CMsManager::Initialization(int iSlotNum,float fSlotTime,
float fDropTime,
CLinkPrediction* pLink)
{
//完成類的初始化工作
m_iVoiceNumInSys=m_iVoiceNumPerSector*SectorNumber;
m_iDataNumInSys=m_iDataNumPerSector*SectorNumber;
m_iHttpNum=int(m_iDataNumInSys*m_fFractionHttp);
m_iFtpNum=int(m_iDataNumInSys*m_fFractionFtp);
m_iSlotNum=iSlotNum;
m_fSlotTime=fSlotTime;
m_fDropTime=fDropTime;
m_pLinkPrediction=pLink;
m_fTotalBits=0.0; //總的傳輸比特量
m_lTotalErrorEP=0; //總的差錯EP數
m_lTotalGoodEP=0; //總的正確EP數
m_fMeanThroughputPerSector=0.0; //Drop內的平均吞吐量
m_fMeanPER=0.0; //Drop內的平均分組差錯概率
m_lRealErrorSP=0;
m_lRealTotalSP=0;
m_lDiscardedPacket=0;
m_lErrorSPDCCH=0;
//...... modified by cqm, Apr.9 ......//
for(int i=0;i<SectorNumber;i++)
{
m_iDataNumGenerated[i]=0;
m_iVoiceNumGenerated[i]=0;
}
//....................................//
//...... added by cqm, Apr.9 ......//
//話音FER vs Eb/N0表
int ii;
double fC2IIndex[26]=
{ -21.10, -20.85, -20.60, -20.35, -20.10, -19.85, -19.60, -19.35,
-19.10, -18.85, -18.60, -18.35, -18.10, -17.85, -17.60, -17.35,
-17.10, -16.85, -16.60, -16.35, -16.10, -15.85, -15.60, -15.35,
-15.10, -14.85
};
for (ii=0;ii<26;ii++)
m_fC2IIndex[ii]=(float)fC2IIndex[ii];
double fFER_3[26]=
{ 1, 1, 1, 1, 1, 0.90, 0.80, 0.70,
0.60, 0.50, 0.45, 0.40, 0.35, 0.30, 0.20, 0.15,
0.09, 0.04, 0.015, 0.007, 0.004, 0.002, 0.001, 0.0005,
0.0003, 0.00015
};
for (ii=0;ii<26;ii++)
m_fFER_3[ii]=(float)fFER_3[ii];
double fFER_30[26]=
{ 1, 1, 1, 1, 0.95, 0.85, 0.70, 0.60,
0.55, 0.45, 0.40, 0.30, 0.20, 0.15, 0.07, 0.04,
0.025, 0.012, 0.004, 0.003, 0.002, 0.001, 0.0005, 0.0003,
0.00015,0.00008
};
for (ii=0;ii<26;ii++)
m_fFER_30[ii]=(float)fFER_30[ii];
double fFER_100[26]=
{ 1, 1, 1, 0.90, 0.80, 0.75, 0.70, 0.55,
0.50, 0.40, 0.30, 0.20, 0.15, 0.10, 0.05, 0.02,
0.011, 0.008, 0.003, 0.002, 0.0015, 0.0008, 0.0004, 0.0002,
0.0001, 0.00005
};
for (ii=0;ii<26;ii++)
m_fFER_100[ii]=(float)fFER_100[ii];
double fFER_0[26]=
{ 1, 1, 1, 0.80, 0.60, 0.55, 0.40, 0.35,
0.30, 0.25, 0.20, 0.10, 0.07, 0.04, 0.02, 0.008,
0.004, 0.001, 0.0005, 0.0002, 0.0001, 0.00005,0.00003,0.00002,
0.00001,0.000005
};
for (ii=0;ii<26;ii++)
m_fFER_0[ii]=(float)fFER_0[ii];
//..................................//
}
void CMsManager::AddUser()
{
//移動臺管理模塊根據移動臺數量、類型分布等參數循環產生相應數量的
//各種移動臺模塊
//產生話音移動臺模塊
for(int 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);
}
}
/////////////////////////////////////////////////////////////////////////
//
// TITLE: Functions initializing the mobiles' lists
//
// PURPOSE:Initialize the three mobiles' lists:
// Voice mobiles' list
// Http data mobiles' list
// Ftp data mobiles' list
//
// ALGORITHMS:
// In this function, the mobiles' lists will be initialized by
// the initialization functions. Since these initialization
// functions are parallel, all of them should be called.
// Specificly, when initializing a voice mobile, we should call
// the two initialization functions: CMobile::MobileInitialization(),
// and CVoiceMs::VoiceInitialization(). And three in the case
// of initializing a http of ftp data mobile.
//
// The function scans each items in the three lists and calls
// the corresponding initialization functions.
//
// The function CMobile::MobileInitialization() is called by each
// mobile. When calling this function, we should give four input
// arguments: the ID, the channel type, the velocity, and the
// standard dviation of slow fanding. The ID can be added before
// initialization. The standard dviation of slow fanding is fixed.
// And the channel type and the velocity are corresponding. They
// are all determined stochasticly.
//
// For example, there are 5 types of channel models, the probabilities
// of them are 0.3, 0.3, 0.2, 0.1, 0.1. Then we can let the function
// produce a random pp between 0 and 1. When pp<0.3, the channel
// type is 1. When 0.3<=pp<0.6, the channel type is 2, and so on.
//
// So the function does it like this:
// 1.Determine the intervals. In the case of the above example, the
// intervals should be: (0, 0.3), (0.3, 0.6), (0.6, 0.8), (0.8, 0.9),
// and (0.9, 1.0). In fact, the function determines the point dividing
// the intervals. The dividing points are stored in the array called
// fV[10]. Considering the extendability of the function, I give the
// array ten units of space and let fV[4] to fV[9] be 1.0.
// 2.Produce a random in uniform distribution between 0 and 1.
// 3.Compare the random with the dividing points, and determine the
// channel type and velocity according to the result.
//
// CALLING FUNCTIONS:
// CDataMs::DataMsInitialization()
// CMobile::MobileInitialization()
// CFtpDataMs::FtpInitialization()
// CHttpDataMs::HttpInitialization()
// CVoiceMs::VoiceInitialization()
//
// CALLED BY FUNCTIONS:
// CNetworkDrive::DropInitialization()
//
// AUTHOR: Ouyang Hui
//
// DATE: 01/04/06
//
// MODIFICTIONS SINCE 01/04/06
//
//////////////////////////////////////////////////////////////////////////
void CMsManager::MsInitialization(CServiceArea* pService)
{
POSITION pos;
int ID=0;
int nType=0;
float fV[10];
float fVelocity,pp;
//determine the interval division points
fV[0]=m_fFractionOfChannel[0];
for (int i=1;i<10;i++)
fV[i]=1.;
for (i=1;i<m_iChannelNumber;i++)
fV[i]=fV[i-1]+m_fFractionOfChannel[i];
//initialize the voice mobiles' list
pos=m_VoiceList.GetHeadPosition();
CVoiceMs* pVoiceMs=NULL;
while (pos!=NULL)
{
//...... added by cqm, Apr.8 .......//
int iVoice=Voice; //產生話音業務移動臺
//..................................//
pVoiceMs=m_VoiceList.GetNext(pos);
//
ID++; //determine the ID
cout<<"Mobile #"<<ID<<" initialization..."<<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
//...... modified by cqm, Apr.8 ......//
pVoiceMs->MobileInitialization(ID,this,pService,
fVelocity,nType,m_fStdSlowFading,iVoice); //加了一個參數
//....................................//
pVoiceMs->VoiceInitialization();
}
//initialize the http data mobiles' list
pos=m_HttpDataList.GetHeadPosition();
CHttpDataMs* pHttpDataMs=NULL;
while (pos!=NULL)
{
//...... added by cqm, Apr.8 .......//
int iData=Data; //產生數據業務移動臺
//..................................//
pHttpDataMs=m_HttpDataList.GetNext(pos);
ID++; //determine the ID
cout<<"Mobile #"<<ID<<" initialization..."<<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
pHttpDataMs->MobileInitialization(ID,this,pService,
fVelocity,nType,m_fStdSlowFading,iData);
pHttpDataMs->DataMsInitialization(
m_pLinkPrediction);
pHttpDataMs->HttpInitialization();
}
//initialize the ftp mobiles' list
pos=m_FtpDataList.GetHeadPosition();
CFtpDataMs* pFtpDataMs=NULL;
while (pos!=NULL)
{
//...... added by cqm, Apr.9 .......//
int iData=Data; //產生數據業務移動臺
//..................................//
pFtpDataMs=m_FtpDataList.GetNext(pos);
ID++; //determine the ID
cout<<"Mobile #"<<ID<<" initialization..."<<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->MobileInitialization(ID,this,pService,
fVelocity,nType,m_fStdSlowFading,iData);
pFtpDataMs->DataMsInitialization(
m_pLinkPrediction);
pFtpDataMs->FtpInitialization();
}
//initialize other parameters
//zdy
//還應加入一些統計packet和時延的屬性
//
m_fTotalBits=0.0; //總的傳輸比特量
m_fMeanThroughputPerSector=0.0; //Drop內的平均吞吐量
m_pServiceArea=pService;
m_fMeanPER=0.0;
//zdy新加屬性初始化
m_lTotalErrorPacket=0; //總的差錯Packet數
m_lTotalGoodPacket=0; //總的正確Packet數
//cyu于5.14修改
m_iDropNumOfVoice=0; //話音業務掉話用戶數
m_iBadNumOfVoice=0; //話音業務不滿意用戶數
m_iVoiceUserOfCurrentDrop=0; //本時隙結束通話的話音用戶
m_fDropTimeLimit=(float)5000./m_fSlotTime; //話音業務掉話時間限
//定義為5秒鐘,此處折換為時隙
m_fBadRatioOfVoice=0; //話音用戶的不滿意率
m_fDropRatioOfVoice=0; //話音用戶掉話率
}
//////////////////////////////////////////////////////////////////////////////
//
// PURPOSE:Process the voice mobiles
//
// AUTHOR: Cheng Yu
//
// AUDITOR:Ouyang Hui
//
// DATE: 01/04/09
//
// TEST RECORD:
//
// MODIFICATIONS:
//
//////////////////////////////////////////////////////////////////////////////
void CMsManager::VoiceProcess()
{
// float i;
int m=0;
int p=0,q=0;
POSITION pos;
pos=m_VoiceList.GetHeadPosition();
CVoiceMs* pVoiceMs=NULL;
//...... added by cqm, Apr.9 ......//
int iVoice=Voice;
//.................................//
while(pos!=NULL)
{
pVoiceMs=m_VoiceList.GetNext(pos);
//cyu于5.14修改
//在對每個移動臺進行處理時,同時判斷服務時長是否到時以及用戶是否掉話
//若服務時長到時,則判斷是否為不滿意用戶,是則累加不滿意用戶數
//若掉話,則完成對掉話用戶數的累加
//若已經完成或掉話,則重新調用移動臺初始化函數,重新初始化,并增加激活話音用戶數。
//...... modified by cqm, Apr.9 ......//
if(pVoiceMs->IsServiceOver())//去掉另外一個條件,即不考慮掉話
{
//cyu于5.17修改
p=pVoiceMs->GetFERIndicator();//單位為幀
q=pVoiceMs->GetServiceTime(); //單位為幀
// if((float(p)/(float(q)/20.)>0.01)&&(q>2000)&&(!pVoiceMs->m_bIsSHOOut))//統計的幀數應該大于1000幀
// m_iBadNumOfVoice++;
//...................................//
//只累加包括本時隙結束通話的話音用戶,跨drop通話的用戶不統計
// if((q>2000)&&(!pVoiceMs->m_bIsSHOOut))//test
// m_iVoiceUserOfCurrentDrop++;
m_iVoiceNumGenerated[pVoiceMs->GetLocationSector().s-1]--;
int ID=pVoiceMs->GetMsID();
int nType=0;
float fV[10];
float fVelocity,pp;
fV[0]=m_fFractionOfChannel[0];
for (int i=1;i<10;i++)
fV[i]=1.;
for (i=1;i<m_iChannelNumber;i++)
fV[i]=fV[i-1]+m_fFractionOfChannel[i];
pp=xUniform(0.,1.);
if (pp<fV[0])
{fVelocity=3.;nType=1;}
else if (pp<fV[1])
{fVelocity=10.;nType=2;}
else if (pp<fV[2])
{fVelocity=30.;nType=3;}
else if (pp<fV[3])
{fVelocity=120.;nType=4;}
else
{fVelocity=0.;nType=5;}
pVoiceMs->MobileInitialization(ID,this,m_pServiceArea,
fVelocity,nType,m_fStdSlowFading,iVoice);
pVoiceMs->Clean();
pVoiceMs->VoiceInitialization();
//test by cqm
pVoiceMs->SetFERIndicator(p);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -