Commit cff0bbad authored by wetterwa's avatar wetterwa

Added dummy trigger for congestion (MEDIEVAL demo3)


git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4013 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 34836766
......@@ -73,5 +73,6 @@ int eRALlte_process_map_qos(int mt_ix, int ch_ix);
void RAL_printInitStatus(void);
void RAL_NAS_measures_polling(void);
void RAL_NAS_measures_analyze(void);
void RAL_NAS_report_congestion(int ix);
#endif
......@@ -26,6 +26,7 @@
#define RAL_REALTIME
//#define ENABLE_MEDIEVAL_DEMO3
//#define MUSER_CONTROL // in demo3, for triggering the congestion report manually
//flag to reduce the logs
#define DEBUG_RAL_DETAILS
......
......@@ -38,6 +38,7 @@
#include "nasrg_iocontrol.h"
#endif
/****************************************************************************/
/******************* G L O C A L D E F I N I T I O N S *****************/
/****************************************************************************/
......@@ -79,9 +80,152 @@ struct ral_lte_priv rl_priv;
#ifdef RAL_DUMMY
int netl_s; /* NAS net link socket */
#endif
/****************************************************************************/
/********************* L O C A L F U N C T I O N S *********************/
// Next part is used to receive the triggers
/****************************************************************************/
#ifdef MUSER_CONTROL
#define USER_IP_ADDRESS "127.0.0.1"
#define USER_REMOTE_PORT "0"
#define NAS_IP_ADDRESS "127.0.0.1"
#define NAS_LISTENING_PORT_FOR_USER "22222"
char *g_mih_user_ip_address = USER_IP_ADDRESS;
char *g_mih_user_remote_port = USER_REMOTE_PORT;
char *g_nas_ip_address = NAS_IP_ADDRESS;
char *g_nas_listening_port_for_mih_user = NAS_LISTENING_PORT_FOR_USER;
int g_sockd_user;
signed int g_user_congestion = 0;
unsigned int g_ratio_modif = 0;
//---------------------------------------------------------------------------
int lteRALenb_trigger_connect(void){
//---------------------------------------------------------------------------
struct addrinfo hints;
struct addrinfo *result, *rp;
int s, on;
struct sockaddr_in *addr = NULL;
struct sockaddr_in6 *addr6 = NULL;
unsigned char buf[sizeof(struct sockaddr_in6)];
memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC; /* Allow IPv4 or IPv6 */
hints.ai_socktype = SOCK_DGRAM; /* Datagram socket */
hints.ai_flags = 0;
hints.ai_protocol = 0; /* Any protocol */
s = getaddrinfo(g_mih_user_ip_address, g_mih_user_remote_port, &hints, &result);
if (s != 0) {
printf("ERR getaddrinfo: %s\n", gai_strerror(s));
return -1;
}
for (rp = result; rp != NULL; rp = rp->ai_next) {
g_sockd_user = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
if (g_sockd_user == -1)
continue;
on = 1;
setsockopt( g_sockd_user, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
if(rp->ai_family == AF_INET) {
printf("Destination address %s is an ipv4 address\n",g_mih_user_ip_address);
addr = (struct sockaddr_in *)(&buf[0]);
addr->sin_port = htons(atoi(g_nas_listening_port_for_mih_user));
addr->sin_family = AF_INET;
s = inet_pton(AF_INET, g_nas_ip_address, &addr->sin_addr);
if (s <= 0) {
if (s == 0) {
printf("ERR IP address should be a IPv4 ADDR - But found not in presentation format : %s\n", g_nas_ip_address);
} else {
printf("ERR %s - inet_pton( IPv4 ADDR %s): %s\n", __FUNCTION__, g_nas_ip_address, strerror(s));
}
return -1;
}
s = bind(g_sockd_user, (const struct sockaddr *)addr, sizeof(struct sockaddr_in));
if (s == -1) {
printf("ERR IPv4 Address Bind: %s\n", strerror(errno));
return -1;
}
// sockd_mihf is of type SOCK_DGRAM, rp->ai_addr is the address to which datagrams are sent by default
if (connect(g_sockd_user, rp->ai_addr, rp->ai_addrlen) != -1) {
printf(" lteRALeNB is now ready to receive triggers\n");
return 0;
} else {
close(g_sockd_user);
}
} else if (rp->ai_family == AF_INET6) {
printf("Destination address %s is an ipv6 address\n",g_mih_user_ip_address);
addr6 = (struct sockaddr_in6 *)(&buf[0]);
addr6->sin6_port = htons(atoi(g_nas_listening_port_for_mih_user));
addr6->sin6_family = AF_INET6;
s = inet_pton(AF_INET, g_nas_ip_address, &addr6->sin6_addr);
if (s <= 0) {
if (s == 0) {
printf("ERR IP address should be a IPv6 ADDR, But found not in presentation format : %s\n", g_nas_ip_address);
} else {
printf("ERR %s - inet_pton( IPv6 ADDR %s): %s\n", __FUNCTION__, g_nas_ip_address, strerror(s));
}
return -1;
}
s = bind(g_sockd_user, (const struct sockaddr *)addr6, sizeof(struct sockaddr_in));
if (s == -1) {
printf("ERR IPv6 Address Bind: %s\n", strerror(errno));
return -1;
}
if (connect(g_sockd_user, rp->ai_addr, rp->ai_addrlen) != -1) {
printf(" lteRALeNB is now ready to receive triggers\n");
return 0;
} else {
close(g_sockd_user);
}
} else {
printf("ERR %s is an unknown address format %d\n",g_mih_user_ip_address,rp->ai_family);
}
close(g_sockd_user);
}
if (rp == NULL) { /* No address succeeded */
printf("ERR Could not establish socket to MIH-User\n");
return -1;
}
return -1;
}
//---------------------------------------------------------------------------
int lteRALenb_trigger_receive(int sock){
//---------------------------------------------------------------------------
unsigned char str[50];
int t, done;
t=recv(sock, str, 50, 0);
if (t <= 0) {
if (t < 0) perror("lteRALenb_trigger_receive : recv");
done = 1;
}
printf("\nmessage from USER, length: %d\n", t);
switch (str[0]) {
case 0xff:
printf("USER ASK FOR STOPPING CONGESTION - not supported yet\n");
break;
case 0x01:
printf("USER ASK FOR TRIGGERING CONGESTION\n");
ralpriv->rlcBufferOccupancy[0] = 95;
RAL_NAS_report_congestion(0);
break;
default:
printf("received %hx\n", str[0]);
return -1;
}
return 0;
}
#endif
/****************************************************************************/
/****************************************************************************
** Name: arg_usage() **
......@@ -304,20 +448,9 @@ void get_IPv6_addr(const char* if_name){
** Name: RAL_initialize() **
** **
** Description: Performs overall RAL LTE initialisations: **
** - Default value of global variables **
** - Command line parsing **
** - List of supported MIH actions **
** - List of supported MIH link-events **
** - Communication channel with the NAS driver **
** - MIH link registration **
** **
** Inputs: argc: Number of parameters in the command line **
** argv: Command line parameters **
** Others: g_mihf_ip_address, g_mihf_remote_port **
** g_sockd_mihf, g_ral_ip_address, **
** g_ral_listening_port_for_mihf **
** g_link_id, g_mihf_id, g_log_output **
** g_sockd_nas, ralpriv **
***************************************************************************/
int RAL_initialize(int argc, const char *argv[]){
//-----------------------------------------------------------------------------
......@@ -374,14 +507,6 @@ int RAL_initialize(int argc, const char *argv[]){
// excluded MIH_C_BIT_LINK_HANDOVER_IMMINENT
// excluded MIH_C_BIT_LINK_HANDOVER_COMPLETE
// excluded MIH_C_BIT_LINK_PDU_TRANSMIT_STATUS
/*
ralpriv->mih_supported_link_event_list = MIH_C_BIT_LINK_UP | MIH_C_BIT_LINK_DOWN | MIH_C_BIT_LINK_PARAMETERS_REPORT;
// excluded MIH_C_BIT_LINK_GET_PARAMETERS
// excluded MIH_C_BIT_LINK_CONFIGURE_THRESHOLDS
ralpriv->mih_supported_link_command_list = MIH_C_BIT_LINK_EVENT_SUBSCRIBE | MIH_C_BIT_LINK_EVENT_UNSUBSCRIBE | \
MIH_C_BIT_LINK_GET_PARAMETERS | MIH_C_BIT_LINK_CONFIGURE_THRESHOLDS | MIH_C_BIT_LINK_ACTION;
*/
ralpriv->mih_supported_link_event_list = MIH_C_BIT_LINK_UP | MIH_C_BIT_LINK_DOWN | MIH_C_BIT_LINK_PARAMETERS_REPORT;
// excluded MIH_C_BIT_LINK_GET_PARAMETERS
// excluded MIH_C_BIT_LINK_CONFIGURE_THRESHOLDS
......@@ -409,6 +534,12 @@ int RAL_initialize(int argc, const char *argv[]){
#endif
DEBUG("NAS Driver Connected.\n\n");
/* Start listening to user commands for triggers*/
#ifdef MUSER_CONTROL
lteRALenb_trigger_connect();
#endif
/*Get the interface IPv6 address
*/
#ifdef RAL_DUMMY
......@@ -474,6 +605,9 @@ int main(int argc, const char *argv[]){
#ifdef RAL_DUMMY
FD_SET(g_sockd_nas, &readfds);
#endif
#ifdef MUSER_CONTROL
FD_SET (g_sockd_user, &readfds);
#endif
tv.tv_sec = MIH_C_RADIO_POLLING_INTERVAL_SECONDS;
tv.tv_usec = MIH_C_RADIO_POLLING_INTERVAL_MICRO_SECONDS;
......@@ -488,7 +622,6 @@ int main(int argc, const char *argv[]){
if (FD_ISSET(g_sockd_mihf, &readfds)) {
done = eRALlte_mih_link_process_message();
}
#ifdef RAL_DUMMY
/* Read data coming from the NAS driver */
if (FD_ISSET(g_sockd_nas, &readfds)) {
......@@ -496,6 +629,12 @@ int main(int argc, const char *argv[]){
done = eRALlte_NAS_process_message();
}
#endif
#ifdef MUSER_CONTROL
/* Get triggers */
if (FD_ISSET(g_sockd_user,&readfds)){
done = lteRALenb_trigger_receive(g_sockd_user);
}
#endif
/* Wait until next pending MT's timer expiration */
if (ralpriv->pending_mt_timer > 0) {
......
......@@ -547,25 +547,14 @@ void RAL_NAS_measures_polling(void){
}
//---------------------------------------------------------------------------
// Temp - Enter hard-coded measures in IAL
void RAL_NAS_measures_analyze(void){
// Common function to report congestion
void RAL_NAS_report_congestion(int ix){
//---------------------------------------------------------------------------
MIH_C_TRANSACTION_ID_T transaction_id;
MIH_C_LINK_TUPLE_ID_T link_identifier;
LIST(MIH_C_LINK_PARAM_RPT, LinkParametersReportList);
int ix;
LinkParametersReportList_list.length = 0;
if (ralpriv->congestion_flag == RAL_FALSE){
// Check congestion
for (ix=0; ix<ralpriv->num_UEs; ix++){
if ((ralpriv->rlcBufferOccupancy[ix] > ralpriv->congestion_threshold)&&
((ralpriv->mih_subscribe_req_event_list && MIH_C_BIT_LINK_PARAMETERS_REPORT )>0)){
DEBUG("Congestion detected for UE%d, sending congestion notification to MIH User \n", ix);
// void eRALlte_send_link_parameters_report_indication(MIH_C_TRANSACTION_ID_T *tidP,
// MIH_C_LINK_TUPLE_ID_T *lidP,
// MIH_C_LINK_PARAM_RPT_LIST_T *lparam_listP)
transaction_id = MIH_C_get_new_transaction_id();
link_identifier.link_id.link_type = MIH_C_WIRELESS_UMTS;
link_identifier.link_id.link_addr.choice = MIH_C_CHOICE_3GPP_3G_CELL_ID;
......@@ -575,11 +564,11 @@ void RAL_NAS_measures_analyze(void){
free_BitBuffer(plmn);
link_identifier.link_id.link_addr._union._3gpp_3g_cell_id.cell_id = ralpriv->curr_cellId;
link_identifier.choice = MIH_C_LINK_TUPLE_ID_CHOICE_NULL;
//
//
LinkParametersReportList_list.val[LinkParametersReportList_list.length].link_param.link_param_type.choice = MIH_C_LINK_PARAM_TYPE_CHOICE_LTE;
LinkParametersReportList_list.val[LinkParametersReportList_list.length].link_param.link_param_type._union.link_param_lte = MIH_C_LINK_PARAM_LTE_L2_BUFFER_STATUS;
// LinkParametersReportList_list.val[LinkParametersReportList_list.length].link_param.link_param_type.choice = MIH_C_LINK_PARAM_TYPE_CHOICE_GEN;
// LinkParametersReportList_list.val[LinkParametersReportList_list.length].link_param.link_param_type._union.link_param_gen = MIH_C_LINK_PARAM_LTE_L2_BUFFER_STATUS;
// LinkParametersReportList_list.val[LinkParametersReportList_list.length].link_param.link_param_type.choice = MIH_C_LINK_PARAM_TYPE_CHOICE_GEN;
// LinkParametersReportList_list.val[LinkParametersReportList_list.length].link_param.link_param_type._union.link_param_gen = MIH_C_LINK_PARAM_LTE_L2_BUFFER_STATUS;
LinkParametersReportList_list.val[LinkParametersReportList_list.length].link_param.choice = MIH_C_LINK_PARAM_CHOICE_LINK_PARAM_VAL;
LinkParametersReportList_list.val[LinkParametersReportList_list.length].link_param._union.link_param_val = ralpriv->rlcBufferOccupancy[ix];
......@@ -588,10 +577,28 @@ void RAL_NAS_measures_analyze(void){
LinkParametersReportList_list.val[LinkParametersReportList_list.length]._union.threshold.threshold_xdir = MIH_C_ABOVE_THRESHOLD;
LinkParametersReportList_list.length = LinkParametersReportList_list.length + 1;
//
//
eRALlte_send_link_parameters_report_indication(&transaction_id, &link_identifier, &LinkParametersReportList_list);
ralpriv->congestion_flag = RAL_TRUE;
}
//---------------------------------------------------------------------------
// Temp - Enter hard-coded measures in IAL
void RAL_NAS_measures_analyze(void){
//---------------------------------------------------------------------------
MIH_C_TRANSACTION_ID_T transaction_id;
MIH_C_LINK_TUPLE_ID_T link_identifier;
LIST(MIH_C_LINK_PARAM_RPT, LinkParametersReportList);
int ix;
LinkParametersReportList_list.length = 0;
if (ralpriv->congestion_flag == RAL_FALSE){
// Check congestion
for (ix=0; ix<ralpriv->num_UEs; ix++){
if ((ralpriv->rlcBufferOccupancy[ix] > ralpriv->congestion_threshold)&&
((ralpriv->mih_subscribe_req_event_list && MIH_C_BIT_LINK_PARAMETERS_REPORT )>0)){
RAL_NAS_report_congestion(ix);
break;
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment