Пример #1
0
void Print_value(tree_node* node){
	if (NULL != node->L_chlid){
		Print_value(node->L_chlid);
		printf("%d ", node->value);
		if (NULL != node->R_chlid){
			Print_value(node->R_chlid);
		}
	}
	else{
		printf("%d ", node->value);
		if (NULL != node->R_chlid){
			Print_value(node->R_chlid);
		}
	}
}
Пример #2
0
int main(int argc, char** argv){
	tree_node num_buf[NUMBER_SIZE];
	int bol;
	//bol = Load_file(num_buf, "1.txt");
	bol = Load_file(num_buf, argv[1]);
	if (bol < 0){
		printf("Àɮ׿ù»~!!");
		return 0;
	}

	tree_node root = num_buf[0];
	Bulid_tree(num_buf, &root, bol);
	Print_value(&root);

	system("pause");
	return 0;
}
Пример #3
0
/*
 * function name: FDD_simulation
 * brief: LBPS simulation for FDD environment.
 * param: none
 * return: none
 */
void FDD_simulation(void)
{
	Subframe RF;
	//deque<int> tmp_ue;
	//deque <Subframe> tmpRF;
	//int tmpRF_len = 0;
	//int CompletedRFSize = 0;
	srand((unsigned)time(NULL));
#ifdef RandomWayPoint
	Read_RWP_CQI();
#endif
	for(int ntime = 0; ntime < 10; ntime++)
	{
		int runtime = 0;

		system_initial();
		Configure_Load(is_load,R_UE_num);
		UE_initial(ue,system_load);
		while(runtime < RunTime)
		{printf("*");
			ue_10ms_cqi(ue);
			system_10ms_capacity(ue,system_capacity,system_load);
			virtual_10ms_capacity(system_capacity,virtual_capacity);
			for(int i = 0; i < 10; i++)
			{
				bool is_send[UE_number] = {false};
				 //transmit packet of ue in a subframe for DL or UL
				if(virtualframe[DL].size() <= 0/* && tmp_ue.size() <= 0*/)
				{
					/*for(int j = 0; j < UE_number; j++)
						ue[j].pkt[DL].clear();*/
					Split(ue,virtualframe,virtual_capacity,DL,group);
				}
				
				FD_mapping(virtualframe[DL],&RF);
				//sort_ue2(&u_len,&drt,&RF,tmp_ue);
				drt = RF.drt;
				tmpRF[drt].push_back(RF);
				tmpRF_len[drt] = tmpRF[drt].size();
				tmp_sc = system_capacity[drt];
			    
				for(int index = 0; index < tmpRF_len[drt]; index++)
				{
					sort_ue(&u_len,&drt,&tmpRF[drt][index]);
					for(int j = 0; j < u_len; j++)
					{
						//ue_num = RF.UE_num[j];
						ue_num = tmpRF[drt][index].UE_num[j];
						if(is_send[ue_num])
							continue;
						ue[ue_num].awake++;
						is_send[ue_num] = true;
						if(tmp_sc <= 0)
						{
							//tmp_ue.push_back(ue_num);
							continue;
						}
						//p_len = ue[ue_num].pkt[drt].size();
						p_len = ue[ue_num].pkt_buffer[drt];
						for(int l = 0; l < p_len; l++)
						{
							tmp_pkt = ue[ue_num].pkt[drt][0];
							if(tmp_pkt.pkt_size <= tmp_sc)
							{
								tmp_sc -= tmp_pkt.pkt_size;
								ue[ue_num].delay[drt] += (runtime + i) - tmp_pkt.arr_time; 
								/*ue[ue_num].pkt[drt].erase(ue[ue_num].pkt[drt].begin());*/
								ue[ue_num].pkt_buffer[drt]--;
								ue[ue_num].pkt[drt].pop_front();
								ue[ue_num].pkt_num[drt]++;
							}
							else
							{
								ue[ue_num].pkt[drt][0].pkt_size -= tmp_sc;
								tmp_sc = -1;
								//tmp_ue.push_back(ue_num);
								break;
							}
						}
					}

					if(tmp_sc >= 0)
						CompletedRFSize[drt]++;
				}
				for(int index = 0; index < CompletedRFSize[drt]; index++)
				{
					tmpRF[drt].pop_front();
				}
				CompletedRFSize[drt] = 0;
#ifdef RN_1st
			if(radioframe[i].is_RN || u_len > 0)
				ue[UE_number].awake++;
#endif
				 //create packet of UE in a subframe
				/*UE_1ms_pkt(ue,system_load,runtime+i);*/
				Create_UE_pkt(ue,runtime+i);
			}
			runtime += 10;
		}
		Print_value(ue);
	}
}
Пример #4
0
/*
 * function name: DRX_simulation
 * brief: DRX simulation for TDD(c0~6)/FDD(c7) environment.
 * param: none
 * return: none
 */
void DRX_simulation(void)
{
	srand((unsigned)time(NULL));
#ifdef RandomWayPoint
	Read_RWP_CQI();
#endif
	//Subframe RF;
	UE_Status ue_status[UE_number];
	for(int ntime = 0; ntime < 11; ntime++)
	{
		int runtime = 0;
		DRX_initial(ue_status,UE_number);
		system_initial();
		Configure_Load(is_load,R_UE_num);
		UE_initial(ue,system_load);
		while(runtime < RunTime)
		{printf("*");
			ue_10ms_cqi(ue);
			system_10ms_capacity(ue,system_capacity,system_load);
			DRX_Mapping(radioframe);
			for(int i = 0; i < 10; i++)
			{
				 //transmit packet of ue in a subframe for DL or UL
				/*u_len = radioframe[i].UE_num.size();*/
				Check_Status(ue,ue_status,&radioframe[i]);
				drt = radioframe[i].drt;
				//RF.drt = drt;
				/*sort_ue(&u_len,&drt,&radioframe[i]);*/
				if(drt == S)
				{
					//create packet of UE in a subframe
					/*UE_1ms_pkt(ue,system_load,runtime+i);*/
					u_len = radioframe[i].UE_num.size();
					for(int index = 0; index < u_len; index++)
						ue[index].awake++;
					Create_UE_pkt(ue,runtime+i);
					continue;
				}
				tmpRF[drt].push_back(radioframe[i]);
				tmpRF_len[drt] = tmpRF[drt].size();
				tmp_sc = system_capacity[drt];
				int send_packet = 0;

				for(int index = 0; index < tmpRF_len[drt]; index++)
				{
					sort_ue(&u_len,&drt,&tmpRF[drt][index]);
					for(int j = 0; j < u_len; j++)
					{
						/*ue_num = radioframe[i].UE_num[j];*/
						ue_num = tmpRF[drt][index].UE_num[j];;
						ue[ue_num].awake++;
						if(tmp_sc <= 0)
							continue;
						/*p_len = ue[ue_num].pkt[drt].size();*/
						p_len = ue[ue_num].pkt_buffer[drt];
						for(int l = 0; l < p_len; l++)
						{
							tmp_pkt = ue[ue_num].pkt[drt][0];
							if(tmp_pkt.pkt_size <= tmp_sc)
							{
								tmp_sc -= tmp_pkt.pkt_size;
								ue[ue_num].delay[drt] += (runtime + i) - tmp_pkt.arr_time; 
								/*ue[ue_num].pkt[drt].erase(ue[ue_num].pkt[drt].begin());*/
								ue[ue_num].pkt_buffer[drt]--;
								ue[ue_num].pkt[drt].pop_front();
								ue[ue_num].pkt_num[drt]++;
								send_packet++;
							}
							else
							{
								ue[ue_num].pkt[drt][0].pkt_size -= tmp_sc;
								tmp_sc = -1;
								break;
							}
						}

					}
					//if(tmp_sc >= 0)
					//	CompletedRFSize[drt]++;
				}
				//for(int index = 0; index < CompletedRFSize[drt]; index++)
				//{
					tmpRF[drt].pop_front();
				//}
				//CompletedRFSize[drt] = 0;
#ifdef RN_1st
			if(radioframe[i].is_RN || u_len > 0)
				ue[UE_number].awake++;
#endif
				 //create packet of UE in a subframe
				Create_UE_pkt(ue,runtime+i);
			}
			runtime += 10;
		}
		Print_value(ue);
	}
}
Пример #5
0
/*
 * function name: TDD_simulation
 * brief: LBPS simulation for TDD environment.
 * param: none
 * return: none
 */
void TDD_simulation(void)
{
	srand((unsigned)time(NULL));
#ifdef RandomWayPoint
	Read_RWP_CQI();
#endif
	for(int ntime = 0; ntime < 11; ntime++)
	{
		int runtime = 0;
		double tmp_delay = 0.0;
		system_initial();
		Get_offset(&TD_offset);
		Configure_Load(is_load,R_UE_num);
		UE_initial(ue,system_load);
		while(runtime < RunTime)
		{printf("*");
			ue_10ms_cqi(ue);
			system_10ms_capacity(ue,system_capacity,system_load);
			virtual_10ms_capacity(system_capacity,virtual_capacity);
			while(virtualframe[DL].size() < 10 && is_load[DL])
			{
				if(R_UE_num[DL] > 0)
				    Split_R(ue,virtualframe,virtual_capacity,DL,&TD_offset,R_UE_num[DL],group);
				else
					Aggr(ue,virtualframe,virtual_capacity,DL,group);
			}
			while(virtualframe[UL].size() < 10 && is_load[UL])
			{
				if(R_UE_num[UL] > 0)
					Split_R(ue,virtualframe,virtual_capacity,DL,&TD_offset,R_UE_num[UL],group);
				else
					Split(ue,virtualframe,virtual_capacity,UL,group);
			}
			Mapping3(virtualframe,radioframe);
			for(int i = 0; i < 10; i++)
			{
				Discard_Pkt(ue,runtime+i);
				 //transmit packet of ue in a subframe for DL or UL
				/*u_len = radioframe[i].UE_num.size();*/
				drt = radioframe[i].drt;
				/*sort_ue(&u_len,&drt,&radioframe[i]);*/
				if(drt == S)
				{
					//create packet of UE in a subframe
					/*UE_1ms_pkt(ue,system_load,runtime+i);*/
					Create_UE_pkt(ue,runtime+i);
					continue;
				}
				bool is_send[UE_number] = {false};
				tmpRF[drt].push_back(radioframe[i]);
				tmpRF_len[drt] = tmpRF[drt].size();
				tmp_sc = system_capacity[drt];
				int send_packet = 0;

				for(int index = 0; index < tmpRF_len[drt]; index++)
				{
					sort_ue(&u_len,&drt,&tmpRF[drt][index]);
					for(int j = 0; j < u_len; j++)
					{
						/*ue_num = radioframe[i].UE_num[j];*/
						ue_num = tmpRF[drt][index].UE_num[j];
						if(is_send[ue_num])
							continue;
						ue[ue_num].awake++;
						is_send[ue_num] = true;
						if(tmp_sc <= 0)
							continue;
						/*p_len = ue[ue_num].pkt[drt].size();*/
						p_len = ue[ue_num].pkt_buffer[drt];
						for(int l = 0; l < p_len; l++)
						{
							tmp_pkt = ue[ue_num].pkt[drt][0];
							tmp_delay = (runtime + i) - tmp_pkt.arr_time;
							//if(ue[ue_num].delay_budget[drt] > 0 && (tmp_delay - ue[ue_num].delay_budget[drt]) > 0)
							//{
							//	//printf("%d\n",ue_num);
							//	ue[ue_num].pkt_buffer[drt]--;
							//	ue[ue_num].pkt[drt].pop_front();
							//	ue[ue_num].discard_pkt[drt]++;
							//	continue;
							//}
							if(tmp_pkt.pkt_size <= tmp_sc)
							{
								tmp_sc -= tmp_pkt.pkt_size;
								ue[ue_num].delay[drt] += tmp_delay; 
								/*ue[ue_num].pkt[drt].erase(ue[ue_num].pkt[drt].begin());*/
								ue[ue_num].pkt_buffer[drt]--;
								ue[ue_num].pkt[drt].pop_front();
								ue[ue_num].pkt_num[drt]++;
								send_packet++;
							}
							else
							{
								ue[ue_num].pkt[drt][0].pkt_size -= tmp_sc;
								tmp_sc = -1;
								break;
							}
							/*tmp_sc -= ue[ue_num].pkt[drt][l].pkt_size;
							if(tmp_sc >= 0)
							{
								ue[ue_num].delay += (runtime + i) - ue[ue_num].pkt[drt][l].arr_time;
								ue[ue_num].pkt_num++;
							}
							else
							{
								ue[ue_num].pkt[drt][l].pkt_size = -tmp_sc;
								ue[ue_num].pkt[drt].erase(ue[ue_num].pkt[drt].begin(),ue[ue_num].pkt[drt].begin()+l);
								break;
							}*/
						}
						/*if(tmp_sc >= 0)
							ue[ue_num].pkt[drt].clear();*/
					}
					if(tmp_sc >= 0)
						CompletedRFSize[drt]++;
				}
				for(int index = 0; index < CompletedRFSize[drt]; index++)
				{
					tmpRF[drt].pop_front();
				}
				CompletedRFSize[drt] = 0;
#ifdef RN_1st
			if(radioframe[i].is_RN || u_len > 0)
				ue[UE_number].awake++;
#endif
				
				 //create packet of UE in a subframe
				/*UE_1ms_pkt(ue,system_load,runtime+i);*/
				Create_UE_pkt(ue,runtime+i);
			}
			/*int packet_number = 0;
			for(int i = 0; i < UE_number; i++)
			{
				packet_number += ue[i].pkt[DL].size();
			}
			printf("packet number = %d\n",packet_number);*/
			runtime += 10;
		}
		Print_value(ue);
	}
}