Ejemplo n.º 1
0
//GENG 2014/9/11更改
int Do_judge_rnti(u16 receive_rnti)
{

    FIN(Do_judge_rnti());
 	SV_PTR_GET(mac_sv);
	if( C_RNTI == find_type_rnti(receive_rnti) )//C-RNTI
		{
			FRET(2);					
		}
	if( TC_RNTI==find_type_rnti(receive_rnti) )//TC-RNTI
		{
			
			if( 1==SV(RAR_receive_crnti) )//同时,如果MAC控制单元中存在C-RNTI
				{
					recall_rnti(receive_rnti);//将该receive_rnti(即TC-RNTI收回)
					SV(RAR_receive_crnti)=0;//
				}
			else
			{
				fsm_printf("[xxx]: This UE is first access!\n");
			}
			FRET(1);	
		}
    if( 0==find_type_rnti(receive_rnti))
    	{
    		fsm_printf("##error: system hasn't allocated the rnti\n");
			FRET(0);
    	}	
	
}
Ejemplo n.º 2
0
List*
aodv_packet_queue_all_pkts_to_dest_get (AodvT_Packet_Queue* pkt_queue_ptr, InetT_Address dest_addr, 
											Boolean remove, Boolean update_discovery_time_stat)
	{
	AodvT_Packet_Entry*		pkt_entry_ptr;
	List*					pkt_lptr;
	List*					data_pkt_lptr;
	int						num_pkts, count;
	
	/** Based on the input flag either access or	**/
	/** remove packets from the queue 				**/
	FIN (aodv_packet_queue_all_pkts_to_dest_get (<args>));
	
	/* Based on the input flag either just access	*/
	/* or remove the packets from the packet queue	*/
	if (remove)
		{
		/* Remove the packets from the queue	*/
		data_pkt_lptr = (List *) inet_addr_hash_table_item_remove (pkt_queue_ptr->pkt_queue_table, &dest_addr);
		
		/* Return if there's no packet to remove */
		if (data_pkt_lptr == OPC_NIL)
			FRET (OPC_NIL);
		
		if (update_discovery_time_stat)
			{
			/* Write the statistic for the route discovery	*/
			/* time for this destination.					*/
			aodv_packet_queue_route_discovery_time_stat_update (pkt_queue_ptr, data_pkt_lptr);
			}
		
		if (op_prg_list_size (data_pkt_lptr) > 0)
			{
			/* Update the packet queue size statistic	*/
			aodv_packet_queue_size_stat_update (pkt_queue_ptr);
			}
		
		pkt_queue_ptr->current_queue_size -= op_prg_list_size (data_pkt_lptr);
		
		}
	else
		{
		/* Only access the packets in the queue	*/
		pkt_lptr = (List *) inet_addr_hash_table_item_get (pkt_queue_ptr->pkt_queue_table, &dest_addr);

		/* Create a list to return the packets	*/
		data_pkt_lptr = op_prg_list_create ();

		num_pkts = op_prg_list_size (pkt_lptr);
		
		for (count = 0; count < num_pkts; count++)
			{
			pkt_entry_ptr = (AodvT_Packet_Entry*) op_prg_list_access (pkt_lptr, count);
			op_prg_list_insert (data_pkt_lptr, pkt_entry_ptr->pkptr, OPC_LISTPOS_TAIL);
			}
		}
	
	FRET (data_pkt_lptr);
	}
Ejemplo n.º 3
0
static unsigned short Do_Data_of_MacRarPdu_BI(u16 subframe,u16 cqi)
{
    //
    FIN(Do_Data_of_MacRarPdu_BI());
    if(Do_ulgrant_ulDelay(subframe,cqi)==1)
	{
		FRET(1);
	} 
    else
        FRET(0);//backoff=0;
}
Ejemplo n.º 4
0
//根据rnti的值,返回该rnti值对应的数据量,给令牌桶使用byte
int Do_cal_datasize(u16 rnti)
{
	int i;
	FIN(Do_cal_datasize());
	SV_PTR_GET(mac_sv);

	for(i=0;i<DL_SCHEDULE_NUM;i++)
		{
			if(SV(schedule_scheme[i]).m_rnti==rnti)
				FRET(SV(schedule_scheme[i]).m_data_size);
		}
	FRET(0);//modified by lhl 没有匹配的RNTI,返回0
}
Ejemplo n.º 5
0
/*
输入:随机接入队列,当前节点的指针
输出:随机接入调度完成后,剩余的资源
		如果没有资源,则返回0
*/
static unsigned int Do_DL_RIV(u16 rapid)
{
	int Nprb,lcrbs;
	int RBstart,RIV;
	int i;
u16 rnti;
	FIN(Do_DL_RIV());
	SV_PTR_GET(mac_sv);
	Nprb=GetNprb();
	lcrbs=Nprb/DL_SCHEDULE_NUM;
lcrbs=lcrbs/4;//decrease the value of RIV to send;
rnti=convert_rapid_rnti(rapid);
	switch(rnti)//5个用户中的第几个,0:0-19PRB 1:20-39prb,以此类推
	{
		case RNTI_A: RBstart=0;break;
		case RNTI_B : RBstart=20;break;
		case RNTI_C : RBstart=40;break;
		case RNTI_D : RBstart=60;break;
		case RNTI_E : RBstart=80;break;
		default: fsm_printf("Do_DL_RIV function sth is wrong!");break;
	}
//note:the length of RIV->RAR_DCI,is 9bit----means the biggest value is:2^9-1=511
	if(lcrbs <= 1 + Nprb/2)         //down limit
    	{
        	RIV=Nprb*(lcrbs-1)+RBstart;//420
    	}
    	else
    	{
	        RIV=Nprb*(Nprb-lcrbs+1)+(Nprb-1-RBstart);
	}
//test code Geng 20141027
fsm_printf("\nIn the function DL_RIV the value of RIV is:%d\n",RIV);
	FRET(RIV);
	
}
Ejemplo n.º 6
0
//此函数生成的是整个RAR下行数据包的DCI,由于RA-RNTI相同,多个UE可能仅RAPID不同;
//但是在目前最简系统中,我们随机选择一个正在进行随机接入的UE的下行资源用来发送RAR,
//就不会发生冲突(因为其还处于随机接入过程,没有下行数据发送,信道没有被占用)
int Do_RAR_DCI1C(struct S_RAinfo *ra_UEinfo)
{
	ENBMAC_TO_PHY_Rardci * p_rar_ici_dci;
	
    FIN(Do_RAR_DCI());
    p_rar_ici_dci=(ENBMAC_TO_PHY_Rardci *)fsm_mem_alloc(sizeof(ENBMAC_TO_PHY_Rardci));

	p_rar_ici_dci->m_rnti				=ra_UEinfo->ra_rnti;
	p_rar_ici_dci->m_tbsize				=Get_Format1C_TbSize(ra_UEinfo->cqi);//这个为什么是这样的,与RIV是对应的吗?
	p_rar_ici_dci->dci_format=4;//format 1C
	p_rar_ici_dci->cfi=Do_DlDci_cfi();
	
    p_rar_ici_dci->rar_dci.m_gap				=1;//还未找到出处,暂时使用Gap2(频域距离)
    //20141022由于为下行数据,下行用户是固定的,所以最简系统目前的RIV是与bitmap相对应的
    //由于在随机接入前,UE并未获取C-RNTI,所以为了让下行静态调度结果与随机分配相结合,宏定义任意5个中的一个RNTI,得到RIV值(5个值是相同的)
    p_rar_ici_dci->rar_dci.RIV					=Do_DL_RIV(ra_UEinfo->rapid);
	//此处还没有更改完全,RIV的资源分配应该和下行调度有关系
	p_rar_ici_dci->rar_dci.I_TBS				=Get_ITbSize(ra_UEinfo->cqi);
	p_rar_ici_dci->rar_dci.emptybits			=0;
	//Test code Geng 20141027
	fsm_printf("\n##After Test Do_RAR_DCI1C:");
	fsm_printf("\nSome important paramters are:");
	fsm_printf("  RA-RNTI:%d",p_rar_ici_dci->m_rnti);
	fsm_printf("  dci_format:%d",p_rar_ici_dci->dci_format);
	fsm_printf("  m_tbsize:%d",p_rar_ici_dci->m_tbsize);
	fsm_printf("  CFI:%d",p_rar_ici_dci->cfi);
	fsm_printf("  RIV:%d",p_rar_ici_dci->rar_dci.RIV);
	fsm_printf("  m_gap:%d",p_rar_ici_dci->rar_dci.m_gap);
	fsm_printf("  I_TBS:%d\n",p_rar_ici_dci->rar_dci.I_TBS);

	fsm_do_ioctrl(STRM_TO_SRIO, IOCCMD_MACTOPHY_RAR_DCI, (void *) p_rar_ici_dci, sizeof(ENBMAC_TO_PHY_Rardci));
	fsm_mem_free(p_rar_ici_dci);
	FRET(Cal_usable_ResOfBitmap(ra_UEinfo->cqi,ra_UEinfo->subframeN));  
}
Ejemplo n.º 7
0
Opencell_Func_Fin_Status 
opencell_cur_frame_calc (Opencell_Frame_Struct* frame_struct, simtime_t cur_time)
{
    int cur_slot_num;

    FIN(opencell_cur_frame_calc(frame_struct, cur_time));

    assert(frame_struct);

    cur_slot_num = (int)(cur_time-global_share->start_of_epoch)/SLOT_DURATION;
    frame_struct->ts_seq = cur_slot_num % SLOT_PER_FRAME;
    frame_struct->hyper_frame_seq = (int) frame_struct->ts_seq / SLOT_PER_HYPERFRAME;
    frame_struct->super_frame_seq = frame_struct->ts_seq / SLOT_PER_SUPERFRAME;
    if (frame_struct->super_frame_seq>=2048) frame_struct->super_frame_seq %= 2048;
    
    /*how many TDMA frames are there?*/
    frame_struct->tdma_frame_seq = (int) (frame_struct->ts_seq / SLOT_PER_FRAME);
    if (frame_struct->multiframe_type==Opencell_Ctrl) {
	frame_struct->multi_frame_seq = (int) (frame_struct->tdma_frame_seq / 51);
	frame_struct->tdma_frame_seq %= 51;
    } else {
	frame_struct->multi_frame_seq = (int) (frame_struct->tdma_frame_seq / 26);
	frame_struct->tdma_frame_seq %= 26;
    }

    FRET (OPENCELL_SUCCESS);
}
Ejemplo n.º 8
0
Compcode
aodv_route_table_entry_next_hop_update (AodvT_Route_Table* route_table_ptr, AodvT_Route_Entry* route_entry_ptr,
	InetT_Address new_next_hop_addr, int new_hop_count, IpT_Port_Info new_out_port_info)
	{
	AodvC_Route_Entry_State 	route_entry_state;
	
	/** Updates the route table entry with the new	**/
	/** next hop parameters and metric				**/
	FIN (aodv_route_table_entry_next_hop_update (<args>));
	
	route_entry_state = route_entry_ptr->route_entry_state;
	
	if (route_entry_state == AodvC_Valid_Route)
		{
		/* Update the common route table with the new information	*/
		Inet_Cmn_Rte_Table_Entry_Update (route_table_ptr->ip_cmn_rte_table_ptr, route_entry_ptr->dest_prefix,
			route_entry_ptr->next_hop_addr, route_table_ptr->aodv_protocol_id, new_next_hop_addr, new_out_port_info,
			new_hop_count, OPC_NIL);
		}

	/* Free the old information	*/
	inet_address_destroy (route_entry_ptr->next_hop_addr);
	
	/* Set the new information	*/
	route_entry_ptr->next_hop_addr = new_next_hop_addr;
	
	FRET (OPC_COMPCODE_SUCCESS);
	}
Ejemplo n.º 9
0
AodvT_Request_Table*
aodv_request_table_create (double expiry_time, int max_retries, InetT_Addr_Family addr_family)
	{
	AodvT_Request_Table*		req_table_ptr;
	
	/** Allocates and initializes the request table	**/
	FIN (aodv_request_table_create (<args>));
	
	/* Allocate memory.								*/
	req_table_ptr = (AodvT_Request_Table*) op_prg_mem_alloc (sizeof (AodvT_Request_Table));
	
	/* Create the Hash tables.						*/
	req_table_ptr->orig_request_table = prg_bin_hash_table_create (4, sizeof (int));
	
	if (addr_family == InetC_Addr_Family_v4)
		req_table_ptr->forward_request_table = inet_addr_hash_table_create (16, 0);
	else
		req_table_ptr->forward_request_table = inet_addr_hash_table_create (0, 16);
	
	/* Set the remaining parameters.				*/
	req_table_ptr->forward_request_expiry_time = expiry_time;
	req_table_ptr->max_rreq_retries            = max_retries;
	
	FRET (req_table_ptr);
	}
Ejemplo n.º 10
0
AodvT_Route_Entry*
aodv_route_table_entry_create (AodvT_Route_Table* route_table_ptr, InetT_Address dest_addr, InetT_Subnet_Mask subnet_mask,
	InetT_Address next_hop_addr, IpT_Port_Info out_port_info, int num_hops, int dest_seq_num, double expiry_time)
	{
	AodvT_Route_Entry*			route_entry_ptr;
	AodvT_Global_Stathandles*	global_stathandle_ptr;
	void*						old_contents_ptr;
	
	/** Adds a new route table entry	**/
	/** in the route table				**/
	FIN (aodv_route_table_entry_create (<args>));

	/* Allocate memory for the route entry	*/
	route_entry_ptr = aodv_route_table_entry_mem_alloc ();
	route_entry_ptr->dest_prefix = ip_cmn_rte_table_dest_prefix_create (dest_addr, subnet_mask);
	route_entry_ptr->dest_seq_num = dest_seq_num;
	
	if (dest_seq_num != AODVC_DEST_SEQ_NUM_INVALID)
		route_entry_ptr->valid_dest_sequence_number_flag = OPC_TRUE;
	else
		route_entry_ptr->valid_dest_sequence_number_flag = OPC_FALSE;
	
	route_entry_ptr->route_entry_state = AodvC_Valid_Route;
	route_entry_ptr->next_hop_addr = inet_address_copy (next_hop_addr);
	route_entry_ptr->next_hop_port_info = out_port_info;
	route_entry_ptr->hop_count = num_hops;
	route_entry_ptr->route_expiry_time = op_sim_time () + expiry_time;
	
	/* This event will be processed by aodv_rte_entry_expiry_handle */
	/* function when the timer expires.								*/
	route_entry_ptr->route_expiry_evhandle = op_intrpt_schedule_call (route_entry_ptr->route_expiry_time,
		AODVC_ROUTE_ENTRY_INVALID,	aodv_rte_entry_expiry_handle, route_entry_ptr);
	
	/* Set the route entry for this destination	*/
	/* in the route table						*/
	inet_addr_hash_table_item_insert (route_table_ptr->route_table, &dest_addr, route_entry_ptr, &old_contents_ptr);
	
	/* Insert the route in the IP common route table	*/
	Inet_Cmn_Rte_Table_Entry_Add_Options (route_table_ptr->ip_cmn_rte_table_ptr, OPC_NIL, route_entry_ptr->dest_prefix, 
		route_entry_ptr->next_hop_addr, route_entry_ptr->next_hop_port_info, route_entry_ptr->hop_count, 
		route_table_ptr->aodv_protocol_id, 1, OPC_NIL, IPC_CMN_RTE_TABLE_ENTRY_ADD_INDIRECT_NEXTHOP_OPTION);
	
	/* Update the size of the route table	*/
	route_table_ptr->active_route_count++;

	/* Update the route table size statistic	*/
	op_stat_write (route_table_ptr->stat_handles_ptr->route_table_size_shandle, route_table_ptr->active_route_count);
	
	/* Update the statistic for the number of hops	*/
	op_stat_write (route_table_ptr->stat_handles_ptr->num_hops_shandle, route_entry_ptr->hop_count);	
	
	/* Get a handle to the global statistics	*/
	global_stathandle_ptr = aodv_support_global_stat_handles_obtain ();
	
	/* Update the global statistic for the number of hops	*/
	op_stat_write (global_stathandle_ptr->num_hops_global_shandle, route_entry_ptr->hop_count);

	FRET (route_entry_ptr);
	}
Ejemplo n.º 11
0
/*
******************************
->Change Data and time:
->Function:About DATA manage
->Change:
->Details:下面几个函数主要是完成数据的处理和计算
->Special:GetNprb()函数,信道带宽取值为1.4/3/5/10/15/20,因为linux内核不支持浮点数,所以(int)(1.4)=1.
*******************************
*/
static unsigned int GetMcsFromCqi (u16 cqi)
{
	unsigned int mcs;
	
    FIN(GetMcsFromCqi());
    mcs = McsforCqi[cqi];
    FRET(mcs);
}
Ejemplo n.º 12
0
static unsigned int Get_Format1C_TbSize(u16 cqi)
{
	unsigned int itbs;
	
    FIN(Get_Format1C_TbSize());
    itbs=Get_ITbSize (cqi);
    FRET(TBSizeTableofFormat1c[itbs]);
   
}
Ejemplo n.º 13
0
static unsigned int Get_ITbSize(u16 cqi)
{
	unsigned int mcs,itbs;
	
    FIN(Get_ITbSize());
    mcs=GetMcsFromCqi (cqi);
    itbs = Ul_McsToItbsize[mcs];
    FRET(itbs);
}
Ejemplo n.º 14
0
static unsigned int Get_Dl_TbSize(u16 cqi,int nprb)
{
	unsigned int mcs,itbs;

    FIN(Get_Dl_TbSize());
    mcs=GetMcsFromCqi(cqi);
    
    itbs = Dl_McsToItbsize[mcs];
    FRET(TransportBlockSizeTable[nprb - 1][itbs]);
}
Ejemplo n.º 15
0
int
aodv_packet_queue_num_pkts_get (AodvT_Packet_Queue* pkt_queue_ptr, InetT_Address dest_addr)
	{
	List*					pkt_lptr;
	
	FIN (aodv_packet_queue_num_pkts_get (<args>));
	
	/* Only access the packets in the queue	*/
	pkt_lptr = (List *) inet_addr_hash_table_item_get (pkt_queue_ptr->pkt_queue_table, &dest_addr);

	if (pkt_lptr == OPC_NIL)
		{
		FRET (0);
		}
	else
		{
		FRET (op_prg_list_size (pkt_lptr));
		}	  
	}		
Ejemplo n.º 16
0
//计算绝对值上限的小函数,输入除数和被除数,输出商的上限。
static int cal_ul_abs(int divisor,int dividend)
{
	int val;
	FIN(cal_ul_abs());
	if(divisor % dividend != 0)
		val=(int)(divisor / dividend)+1;
	else
		val=(int)(divisor / dividend);
	FRET(val);
}
Ejemplo n.º 17
0
//返回接收到的rnti对应的类型
//可以用来调用,以确认rnti是那种类型,从而判断当前系统处于什么状态
static unsigned short find_type_rnti(u16 receive_rnti)
{
	int i;
	FIN(find_rnti());
	SV_PTR_GET(mac_sv);
	for(i=0;i<NUM_RNTI;i++)
		{
			if(SV(rntiarray[i]).m_rnti==receive_rnti)
				FRET(SV(rntiarray[i]).Type_rnti);
		}
}
Ejemplo n.º 18
0
Compcode
aodv_route_table_entry_param_set (AodvT_Route_Entry* route_entry_ptr, int param, ...)
	{
	va_list						arg_list;
	
	/** Set the fields of the route table entry	**/
	FIN (aodv_route_table_entry_param_set (<args>));
	
	if (route_entry_ptr == OPC_NIL)
		FRET (OPC_COMPCODE_FAILURE);
	
	/* Initialize the list of arguments. Though a list arguments may	*/
    /* not always be passed this approach will help us identify the		*/
    /* data type of the parameters and appropriately cast it.			*/
    va_start (arg_list, param);
	
	/* Based on the input parameter, set	*/
	/* the appropriate parameter			*/
	switch (param)
		{
		case (AODVC_ROUTE_ENTRY_DEST_SEQ_NUM):
			{
			route_entry_ptr->dest_seq_num = va_arg (arg_list, int);
			break;
			}
			
		case (AODVC_ROUTE_ENTRY_VALID_SEQ_NUM_FLAG):
			{
			route_entry_ptr->valid_dest_sequence_number_flag = va_arg (arg_list, Boolean);
			break;
			}
			
		default :
			{
			/* Unknown input parameter	*/
			FRET (OPC_COMPCODE_FAILURE);
			}
		}
	
	FRET (OPC_COMPCODE_SUCCESS);
	}
Ejemplo n.º 19
0
Packet* ra_aloha_ss_dequeue(void)
{
    Packet* pkptr;

    FIN(ra_aloha_ss_dequeue());

    //if (op_subq_empty()) return;
    //
    pkptr = op_subq_pk_remove(0, OPC_QPOS_HEAD);

    FRET (pkptr);
}
Ejemplo n.º 20
0
//上行子帧现假设全部资源可用,待物理层设计好上行链路后再细化
static unsigned int Get_Ul_PerPrb_Datasize(u16 cqi)/* u16 subframe*/
{
    unsigned int mcs;
    unsigned int modulation_order;
    unsigned int datasize;

    FIN(Get_Ul_PerPrb_Datasize());
    mcs=GetMcsFromCqi(cqi);
    modulation_order=Ul_ModulationSchemeForMcs[mcs];
	datasize=modulation_order*12*(CPMODE_OFDM*2);
    FRET(datasize);
}
Ejemplo n.º 21
0
Boolean
aodv_route_request_forward_entry_exists (AodvT_Request_Table* req_table_ptr, int req_id,
	InetT_Address originator_addr)
    {
    AodvT_Forward_Request_Entry*    req_entry_ptr;
    List*                           req_entry_lptr;
    int                             size, count;
   
    /** Checks if a specific request ID exists  **/
    /** in the route request table              **/
    FIN (aodv_route_request_forward_entry_exists (<args>));
   
    /* Check if there exists an entry for this address  */
    req_entry_lptr = (List*) inet_addr_hash_table_item_get (req_table_ptr->forward_request_table, &originator_addr);

    /* Error Check  */
    if ((req_entry_lptr == OPC_NIL))
        FRET (OPC_FALSE);

    size = op_prg_list_size (req_entry_lptr);

    for (count = 0; count < size; count++)
        {
        req_entry_ptr = (AodvT_Forward_Request_Entry*) op_prg_list_access (req_entry_lptr, count);

        if (req_entry_ptr->request_id == req_id)
            FRET (OPC_TRUE);
        }
			
	if (prg_list_size (req_entry_lptr) == 0)
		{
		inet_addr_hash_table_item_remove (req_table_ptr->forward_request_table, &originator_addr);
		
		prg_mem_free (req_entry_lptr);
		}
		

    FRET (OPC_FALSE);
    }
Ejemplo n.º 22
0
Compcode
aodv_route_table_precursor_add (AodvT_Route_Entry* route_entry_ptr, InetT_Address precursor_addr)
	{
	InetT_Address*				precursor_addr_ptr;
	InetT_Address*				pre_addr_ptr;
	InetT_Address				existing_precursor_addr;
	int 						num, size;
	Boolean						FOUND = OPC_FALSE;
	
	/** Adds a percursor node to the entry in	**/
	/** the route table for a destination		**/
	FIN (aodv_route_table_precursor_add (<args>));
	
	if (route_entry_ptr == OPC_NIL)
		FRET (OPC_COMPCODE_FAILURE);
		
	/* Insert this precursor node in the list					*/
	/* Here we need to check and insert the precursor addr		*/
	/* First check if the precursor addr is already in the list,*/
	/* if yes, then don't insert, if no then insert.			*/	
	size = op_prg_list_size (route_entry_ptr->precursor_lptr);
	for(num = 0; num < size; num++)
		{
		pre_addr_ptr = (InetT_Address*) op_prg_list_access (route_entry_ptr->precursor_lptr, num);
		existing_precursor_addr = *pre_addr_ptr;
		
		if(inet_address_equal (precursor_addr, existing_precursor_addr))
			FOUND = OPC_TRUE;		
		}
		   
	if(FOUND == OPC_FALSE)
		{		
		precursor_addr_ptr = inet_address_create_dynamic (precursor_addr);
		op_prg_list_insert (route_entry_ptr->precursor_lptr, precursor_addr_ptr, OPC_LISTPOS_TAIL);
		}
	
	FRET (OPC_COMPCODE_SUCCESS);
	}
Ejemplo n.º 23
0
AodvT_Route_Entry*
aodv_route_table_entry_get (AodvT_Route_Table* route_table_ptr, InetT_Address dest_addr)
	{
	AodvT_Route_Entry*			route_entry_ptr = OPC_NIL;
		
	/** Determines whether an entry exists	**/
	/** in the route table for a destination**/
	FIN (aodv_route_table_entry_get (<args>));
	
	/* Get the entry for this destination	*/
	route_entry_ptr = (AodvT_Route_Entry *) inet_addr_hash_table_item_get (route_table_ptr->route_table, &dest_addr);
	
	FRET (route_entry_ptr);
	}
Ejemplo n.º 24
0
Boolean
aodv_request_table_orig_rreq_exists (AodvT_Request_Table* req_table_ptr, InetT_Address dest_address)
	{
	AodvT_Orig_Request_Entry*	req_entry_ptr;
	List*						requests_lptr;
	int							num_requests, count;
	Boolean						retval = OPC_FALSE;
	
	/** Checks if an entry exists in the originating	**/
	/** table with the specified target address			**/
	FIN (aodv_request_table_orig_rreq_exists (<args>));
	
	/* Get the keys	*/
	requests_lptr = (List *) prg_bin_hash_table_item_list_get (req_table_ptr->orig_request_table);
	num_requests = op_prg_list_size (requests_lptr);
	
	if (requests_lptr == OPC_NIL)
		FRET (OPC_FALSE);
	
	for (count = 0; count < num_requests; count++)
		{
		/* Get the current request.	*/
		req_entry_ptr = (AodvT_Orig_Request_Entry *) op_prg_list_access (requests_lptr, count);
		
		if (inet_address_equal (req_entry_ptr->target_address, dest_address))
			{
			/* An entry exists for this target address	**/
			retval = OPC_TRUE;
			break;
			}
		}
	
	/* Destroy the list.	*/
	prg_list_destroy (requests_lptr, OPC_FALSE);
	
	FRET (retval);
	}
Ejemplo n.º 25
0
//用于检查prb_bitmap是否有剩余资源,prb_bitmap2、prb_bitmap7;
//目前资源分配的原则是顺序分配,即如果发现某个prb_bitmap位不等于0,则代表后面的资源均未被分配。
//输入:cqi,mac层bitmap映射物理层,但是不同的终端的cqi不同则调制方式可能不同,从而导致每个prb可以承载的数据量不同
static int Cal_usable_ResOfBitmap(u16 cqi,u16 subframe)
{
	int i,remain_res,idle_bit2,idle_bit7;
	FIN(Cal_usable_ResOfBitmap());
	SV_PTR_GET(mac_sv);
	idle_bit2=idle_bit7=0;//如果bitmap2和7均无剩余位,则函数返回0.
	if(subframe==2)
		{
			for(i=0;i<100;i++)
				{
					if(0==SV(next_prb_bitmap2[i]))
						{
							idle_bit2=100-i;
							break;
						}
				}
			for(i=0;i<100;i++)
				{
					if(0==SV(prb_bitmap7[i]))
						{
							idle_bit7=100-i;
							break;
						}
				}
		}
	if(subframe==7)
		{
			for(i=0;i<100;i++)
				{
					if(0==SV(next_prb_bitmap2[i]))
						{
							idle_bit2=100-i;
							break;
						}
				}
			for(i=0;i<100;i++)
				{
					if(0==SV(next_prb_bitmap7[i]))
						{
							idle_bit7=100-i;
							break;
						}
				}
		}
	
			
	remain_res=Get_Ul_PerPrb_Datasize(cqi) * (idle_bit2 + idle_bit7);
	FRET(remain_res);
}
Ejemplo n.º 26
0
simtime_t opencell_next_slot (simtime_t cur_time)
{
    simtime_t next_slot_time;
    //simtime_t delta;
    int times;
    double delta;
    double cur_time_;

    FIN(opencell_next_slot() );

    times = (int) ((double)cur_time) / SLOT_DURATION;
    next_slot_time = (times+1)*SLOT_DURATION;

    FRET (next_slot_time);
}
Ejemplo n.º 27
0
static unsigned int Get_Dl_PerPrb_Datasize(u16 cqi, u16 subframe)
{
	unsigned int mcs;
	unsigned int modulation_order;
	unsigned int datasize;

    FIN(Get_Dl_PerPrb_Datasize());    
    mcs=GetMcsFromCqi(cqi);
    modulation_order=Dl_ModulationSchemeForMcs[mcs];
	if(subframe==1 || subframe==6)
		datasize=modulation_order*12*(CPMODE_OFDM*2-CFI_OFDM-SPECIAL_OFDM)-8;//424 除去特殊子帧占用的部分,还需要减去天线RS占用的
    else
		datasize=modulation_order*12*(CPMODE_OFDM*2-CFI_OFDM)-12;//612 减去RS占用的
    FRET(datasize);
}
Ejemplo n.º 28
0
AodvT_Orig_Request_Entry*
aodv_route_request_orig_entry_get (AodvT_Request_Table* req_table_ptr, int req_id, Boolean remove)
	{
	AodvT_Orig_Request_Entry*	req_entry_ptr = OPC_NIL;
	
	/** Checks if a specific request ID exists	**/
	/** in the route request table				**/
	FIN (aodv_route_request_orig_entry_get (<args>));
	
	if (remove)
		req_entry_ptr = (AodvT_Orig_Request_Entry *) prg_bin_hash_table_item_remove (req_table_ptr->orig_request_table, (void *) &req_id);
	else
		req_entry_ptr = (AodvT_Orig_Request_Entry *) prg_bin_hash_table_item_get (req_table_ptr->orig_request_table, (void *) &req_id);
	
	FRET (req_entry_ptr);
	}
Ejemplo n.º 29
0
static unsigned short DoAllocate_Rnti(int m_type_rnti)
{
	int i;
	FIN(DoAllocate_Rnti());
SV_PTR_GET(mac_sv);
		for(i=5;i<NUM_RNTI;i++)
		{
		//07、30加,耿灿锡,目前仅考虑了分配TC-RNTI的情况,所以&&了tc-ranti的标记数组,防止在20ms内同一个rnti值被重复分配,引起tc-rnti定时清除的错误
			if(UNALLOCATED_RNTI==SV(rntiarray[i]).Type_rnti && SV(tc_rnti_notes[i])!=1)
				{
					SV(rntiarray[i]).Type_rnti=m_type_rnti;
					break;
				}
		}
	FRET(SV(rntiarray[i]).m_rnti);
}
Ejemplo n.º 30
0
static unsigned short convert_rapid_rnti(u16 RAPID)
{
	unsigned short rnti;
	FIN(convert_rapid_rnti());
	if(RAPID==1)
		rnti=RNTI_A;
	if(RAPID==2)
		rnti=RNTI_B;
	if(RAPID==3)
		rnti=RNTI_C;
	if(RAPID==4)
		rnti=RNTI_D;
	if(RAPID==5)
		rnti=RNTI_E;
	FRET(rnti);
}