Commit 14d9a764 authored by gauthier's avatar gauthier

Starting debug, remainig TODO report new mme_ue_id

parent 7f9543a9
......@@ -112,7 +112,7 @@ typedef struct net_ip_address_s {
unsigned ipv4:1;
unsigned ipv6:1;
char ipv4_address[16];
char ipv6_address[40];
char ipv6_address[46];
} net_ip_address_t;
typedef uint64_t bitrate_t;
......
......@@ -100,6 +100,7 @@ static STAILQ_HEAD(sctp_cnx_list_head, sctp_cnx_list_elm_s) sctp_cnx_list;
static uint16_t sctp_nb_cnx = 0;
//------------------------------------------------------------------------------
struct sctp_cnx_list_elm_s *sctp_get_cnx(int32_t assoc_id, int sd)
{
struct sctp_cnx_list_elm_s *elm;
......@@ -119,6 +120,7 @@ struct sctp_cnx_list_elm_s *sctp_get_cnx(int32_t assoc_id, int sd)
return NULL;
}
//------------------------------------------------------------------------------
void
sctp_handle_new_association_req(
const instance_t instance,
......@@ -388,6 +390,7 @@ sctp_handle_new_association_req(
sd, sctp_nb_cnx, assoc_id);
}
//------------------------------------------------------------------------------
void sctp_send_data(
instance_t instance,
task_id_t task_id,
......@@ -430,6 +433,7 @@ void sctp_send_data(
sctp_cnx->assoc_id);
}
//------------------------------------------------------------------------------
static int sctp_close_association(
const instance_t instance,
const task_id_t requestor,
......@@ -456,6 +460,7 @@ static int sctp_close_association(
return 0;
}
//------------------------------------------------------------------------------
static int sctp_create_new_listener(
const instance_t instance,
const task_id_t requestor,
......@@ -580,6 +585,7 @@ err:
return -1;
}
//------------------------------------------------------------------------------
static inline
void
sctp_eNB_accept_associations(
......@@ -646,6 +652,7 @@ sctp_eNB_accept_associations(
}
}
//------------------------------------------------------------------------------
static inline
void
sctp_eNB_read_from_socket(
......@@ -770,6 +777,7 @@ sctp_eNB_read_from_socket(
}
}
//------------------------------------------------------------------------------
void
sctp_eNB_flush_sockets(
struct epoll_event *events, int nb_events)
......@@ -799,6 +807,7 @@ sctp_eNB_flush_sockets(
}
//------------------------------------------------------------------------------
void *sctp_eNB_task(void *arg)
{
int nb_events;
......
This diff is collapsed.
......@@ -39,7 +39,6 @@
#define PLAY_SCENARIO_H_
# include <time.h>
# include <stdint.h>
# include <pthread.h>
# include <libxml/tree.h>
# include <netinet/in.h>
......@@ -274,6 +273,7 @@ typedef struct et_ip_s {
struct in6_addr ipv6;
in_addr_t ipv4;
}address;
char str[INET6_ADDRSTRLEN+1];
}et_ip_t;
typedef struct et_ip_hdr_s {
......@@ -323,8 +323,6 @@ typedef struct et_scenario_s {
uint32_t registered_enb;
long enb_register_retry_timer_id;
pthread_mutex_t fsm_lock;
et_fsm_state_t fsm_state;
hash_table_t *hash_mme2association_id;
hash_table_t *hash_old_ue_mme_id2ue_mme_id;
......@@ -391,6 +389,7 @@ int et_s1ap_decode_pdu(S1AP_PDU_t * const pdu, s1ap_message * const message, con
void et_decode_s1ap(et_s1ap_t * const s1ap);
//-------------------------
int et_s1ap_eNB_compare_assoc_id( struct s1ap_eNB_mme_data_s *p1, struct s1ap_eNB_mme_data_s *p2);
uint32_t et_s1ap_generate_eNB_id(void);
uint16_t et_s1ap_eNB_fetch_add_global_cnx_id(void);
void et_s1ap_eNB_prepare_internal_data(void);
void et_s1ap_eNB_insert_new_instance(s1ap_eNB_instance_t *new_instance_p);
......@@ -436,6 +435,7 @@ int et_split_path ( char * pathP, char *** resP);
void et_display_node ( xmlNodePtr node, unsigned int indent);
void et_display_tree ( xmlNodePtr node, unsigned int indent);
char * et_ip2ip_str(const et_ip_t * const ip);
int et_compare_et_ip_to_net_ip_address(const et_ip_t * const ip, const net_ip_address_t * const net_ip);
int et_hex2data(unsigned char * const data, const unsigned char * const hexstring, const unsigned int len);
sctp_cid_t et_chunk_type_str2cid(const xmlChar * const chunk_type_str);
const char * const et_chunk_type_cid2str(const sctp_cid_t chunk_type);
......@@ -443,7 +443,7 @@ et_packet_action_t et_action_str2et_action_t(const xmlChar * const action);
void et_ip_str2et_ip(const xmlChar * const ip_str, et_ip_t * const ip);
void et_enb_config_init(const char const * lib_config_file_name_pP);
const Enb_properties_array_t *et_enb_config_get(void);
uint32_t et_eNB_app_register(const Enb_properties_array_t *enb_properties);
void et_eNB_app_register(const Enb_properties_array_t *enb_properties);
void *et_eNB_app_task(void *args_p);
int et_play_scenario(et_scenario_t* const scenario);
......
This diff is collapsed.
......@@ -36,6 +36,7 @@
*/
#include <stdio.h>
#include <sys/time.h>
#include <pthread.h>
#include "intertask_interface.h"
#include "platform_types.h"
......@@ -46,7 +47,9 @@
#include "timer.h"
//------------------------------------------------------------------------------
et_scenario_t *g_scenario = NULL;
et_scenario_t *g_scenario = NULL;
pthread_mutex_t g_fsm_lock = PTHREAD_MUTEX_INITIALIZER;
et_fsm_state_t g_fsm_state = ET_FSM_STATE_NULL;
//------------------------------------------------------------------------------
int timeval_subtract (struct timeval * const result, struct timeval * const a, struct timeval * const b)
{
......@@ -83,7 +86,7 @@ void et_scenario_wait_rx_packet(et_packet_t * const packet)
NULL, &packet->timer_id) < 0) {
AssertFatal(0, " Can not start waiting RX event timer\n");
}
g_scenario->fsm_state = ET_FSM_STATE_WAITING_EVENT;
g_fsm_state = ET_FSM_STATE_WAITING_EVENT;
packet->status = ET_PACKET_STATUS_SCHEDULED_FOR_RECEIVING;
}
//------------------------------------------------------------------------------
......@@ -102,7 +105,8 @@ void et_scenario_schedule_tx_packet(et_packet_t * const packet)
s1ap_eNB_instance = et_s1ap_eNB_get_instance(packet->enb_instance);
AssertFatal(NULL != s1ap_eNB_instance, "Cannot get s1ap_eNB_instance_t for eNB instance %d", packet->enb_instance);
g_scenario->fsm_state = ET_FSM_STATE_WAITING_EVENT;
LOG_D(ENB_APP, "%s\n", __FUNCTION__);
g_fsm_state = ET_FSM_STATE_WAITING_EVENT;
switch (packet->sctp_hdr.chunk_type) {
case SCTP_CID_DATA:
......@@ -124,7 +128,7 @@ void et_scenario_schedule_tx_packet(et_packet_t * const packet)
NULL, &packet->timer_id) < 0) {
AssertFatal(0, " Can not start TX event timer\n");
}
// Done g_scenario->fsm_state = ET_FSM_STATE_WAITING_TX_EVENT;
// Done g_fsm_state = ET_FSM_STATE_WAITING_TX_EVENT;
} else {
// send immediately
et_s1ap_eNB_itti_send_sctp_data_req(
......@@ -134,7 +138,7 @@ void et_scenario_schedule_tx_packet(et_packet_t * const packet)
packet->sctp_hdr.u.data_hdr.payload.binary_stream_allocated_size,
packet->sctp_hdr.u.data_hdr.stream);
packet->status = ET_PACKET_STATUS_SENT;
g_scenario->fsm_state = ET_FSM_STATE_RUNNING;
g_fsm_state = ET_FSM_STATE_RUNNING;
}
break;
case SCTP_CID_INIT:
......@@ -162,7 +166,7 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_running(et_event_t event)
default:
AssertFatal(0, "Case event %d not handled in ET_FSM_STATE_RUNNING", event.code);
}
pthread_mutex_unlock(&g_scenario->fsm_lock);
pthread_mutex_unlock(&g_fsm_lock);
return 0;
}
......@@ -188,14 +192,14 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_waiting(et_event_t event)
event.u.tx_timed_packet->sctp_hdr.u.data_hdr.payload.binary_stream_allocated_size,
event.u.tx_timed_packet->sctp_hdr.u.data_hdr.stream);
event.u.tx_timed_packet->status = ET_PACKET_STATUS_SENT;
g_scenario->fsm_state = ET_FSM_STATE_RUNNING;
g_fsm_state = ET_FSM_STATE_RUNNING;
break;
default:
AssertFatal(0, "Case event %d not handled in ET_FSM_STATE_WAITING", event.code);
}
pthread_mutex_unlock(&g_scenario->fsm_lock);
pthread_mutex_unlock(&g_fsm_lock);
return 0;
}
......@@ -215,8 +219,8 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_connecting_s1c(et_event_t even
// no init in this scenario, may be sub-scenario
if (g_scenario->next_packet->action == ET_PACKET_ACTION_S1C_SEND) {
et_scenario_schedule_tx_packet(g_scenario->next_packet);
pthread_mutex_unlock(&g_scenario->fsm_lock);
return g_scenario->fsm_state;
pthread_mutex_unlock(&g_fsm_lock);
return g_fsm_state;
} else if (g_scenario->next_packet->action == ET_PACKET_ACTION_S1C_RECEIVE) {
if (g_scenario->next_packet->status == ET_PACKET_STATUS_RECEIVED) {
g_scenario->last_rx_packet = g_scenario->next_packet;
......@@ -226,8 +230,8 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_connecting_s1c(et_event_t even
} else if (g_scenario->next_packet->status == ET_PACKET_STATUS_NONE) {
et_scenario_wait_rx_packet(g_scenario->next_packet);
pthread_mutex_unlock(&g_scenario->fsm_lock);
return g_scenario->fsm_state;
pthread_mutex_unlock(&g_fsm_lock);
return g_fsm_state;
} else {
AssertFatal(0, "Invalid packet status %d", g_scenario->next_packet->status);
}
......@@ -263,15 +267,15 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_connecting_s1c(et_event_t even
}
}
fprintf(stderr, "No Packet found in this scenario: %s\n", g_scenario->name);
g_scenario->fsm_state = ET_FSM_STATE_NULL;
pthread_mutex_unlock(&g_scenario->fsm_lock);
return g_scenario->fsm_state;
g_fsm_state = ET_FSM_STATE_NULL;
pthread_mutex_unlock(&g_fsm_lock);
return g_fsm_state;
break;
default:
AssertFatal(0, "Case event %d not handled in ET_FSM_STATE_CONNECTING_S1C", event.code);
}
pthread_mutex_unlock(&g_scenario->fsm_lock);
pthread_mutex_unlock(&g_fsm_lock);
return 0;
}
//------------------------------------------------------------------------------
......@@ -289,8 +293,8 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_null(et_event_t event)
// no init in this scenario, may be sub-scenario
if (g_scenario->next_packet->action == ET_PACKET_ACTION_S1C_SEND) {
et_scenario_schedule_tx_packet(g_scenario->next_packet);
pthread_mutex_unlock(&g_scenario->fsm_lock);
return g_scenario->fsm_state;
pthread_mutex_unlock(&g_fsm_lock);
return g_fsm_state;
} else if (g_scenario->next_packet->action == ET_PACKET_ACTION_S1C_RECEIVE) {
if (g_scenario->next_packet->status == ET_PACKET_STATUS_RECEIVED) {
g_scenario->last_rx_packet = g_scenario->next_packet;
......@@ -300,8 +304,8 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_null(et_event_t event)
} else if (g_scenario->next_packet->status == ET_PACKET_STATUS_NONE) {
et_scenario_wait_rx_packet(g_scenario->next_packet);
pthread_mutex_unlock(&g_scenario->fsm_lock);
return g_scenario->fsm_state;
pthread_mutex_unlock(&g_fsm_lock);
return g_fsm_state;
} else {
AssertFatal(0, "Invalid packet status %d", g_scenario->next_packet->status);
}
......@@ -317,10 +321,10 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_null(et_event_t event)
g_scenario->hash_mme2association_id = hashtable_create (256,NULL,NULL);
// Try to register each eNB
g_scenario->registered_enb = 0;
g_scenario->fsm_state = ET_FSM_STATE_CONNECTING_S1C;
g_scenario->register_enb_pending = et_eNB_app_register (g_scenario->enb_properties);
pthread_mutex_unlock(&g_scenario->fsm_lock);
return g_scenario->fsm_state;
g_fsm_state = ET_FSM_STATE_CONNECTING_S1C;
et_eNB_app_register (g_scenario->enb_properties);
pthread_mutex_unlock(&g_fsm_lock);
return g_fsm_state;
break;
case SCTP_CID_HEARTBEAT:
......@@ -348,9 +352,9 @@ et_fsm_state_t et_scenario_fsm_notify_event_state_null(et_event_t event)
}
}
fprintf(stderr, "No Useful packet found in this scenario: %s\n", g_scenario->name);
g_scenario->fsm_state = ET_FSM_STATE_NULL;
pthread_mutex_unlock(&g_scenario->fsm_lock);
return g_scenario->fsm_state;
g_fsm_state = ET_FSM_STATE_NULL;
pthread_mutex_unlock(&g_fsm_lock);
return g_fsm_state;
break;
default:
......@@ -364,15 +368,15 @@ et_fsm_state_t et_scenario_fsm_notify_event(et_event_t event)
{
AssertFatal((event.code >= ET_EVENT_START) && (event.code < ET_EVENT_END), "Unknown et_event_t.code %d", event.code);
pthread_mutex_lock(&g_scenario->fsm_lock);
switch (g_scenario->fsm_state){
pthread_mutex_lock(&g_fsm_lock);
switch (g_fsm_state){
case ET_FSM_STATE_NULL: return et_scenario_fsm_notify_event_state_null(event); break;
case ET_FSM_STATE_CONNECTING_S1C: return et_scenario_fsm_notify_event_state_connecting_s1c(event); break;
case ET_FSM_STATE_WAITING_EVENT: return et_scenario_fsm_notify_event_state_waiting(event); break;
case ET_FSM_STATE_RUNNING: return et_scenario_fsm_notify_event_state_running(event); break;
default:
AssertFatal(0, "Case fsm_state %d not handled", g_scenario->fsm_state);
AssertFatal(0, "Case fsm_state %d not handled", g_fsm_state);
}
pthread_mutex_unlock(&g_scenario->fsm_lock);
return g_scenario->fsm_state;
pthread_mutex_unlock(&g_fsm_lock);
return g_fsm_state;
}
......@@ -447,8 +447,6 @@ et_scenario_t* et_generate_scenario(
printf("scenario name: %s\n", xml_char);
scenario = calloc(1, sizeof(*scenario));
scenario->name = xml_char; // nodup nofree
scenario->fsm_state = ET_FSM_STATE_NULL;
pthread_mutex_init(&scenario->fsm_lock, NULL);
next_packet = &scenario->list_packet;
for (node = root->children; node != NULL; node = node->next) {
......
......@@ -308,28 +308,82 @@ void et_s1ap_update_assoc_id_of_packets(const int32_t assoc_id,
s1ap_eNB_mme_data_t * const mme_desc_p)
{
et_packet_t *packet = NULL;
struct in6_addr s1c_mme_ipv6 = IN6ADDR_ANY_INIT;
in_addr_t s1c_mme_ipv4 = INADDR_ANY;
struct in6_addr s1c_enb_ipv6 = IN6ADDR_ANY_INIT;
in_addr_t s1c_enb_ipv4 = INADDR_ANY;
int ret;
unsigned int old_enb_port = 0;
unsigned int old_mme_port = 0;
packet = g_scenario->next_packet;
S1AP_DEBUG("%s for SCTP association (%u)\n",__FUNCTION__,assoc_id);
packet = g_scenario->list_packet;
while (NULL != packet) {
switch (packet->sctp_hdr.chunk_type) {
case SCTP_CID_DATA :
if (g_scenario->next_packet->action == ET_PACKET_ACTION_S1C_SEND) {
// TODO compare addresses and ports
if (packet->ip_hdr.dst)
packet->sctp_hdr.dst_port == 0;
packet->sctp_hdr.src_port == 0;
} else if (g_scenario->next_packet->action == ET_PACKET_ACTION_S1C_RECEIVE) {
if (ET_PACKET_STATUS_NONE == packet->status) {
if (0 < old_mme_port) {
if (g_scenario->next_packet->action == ET_PACKET_ACTION_S1C_SEND) {
ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.dst, &mme_desc_p->mme_net_ip_address);
if (0 == ret) {
ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.src, &s1ap_eNB_instance->s1c_net_ip_address);
if (0 == ret) {
// same IP src, same IP dst
if ((packet->sctp_hdr.dst_port == old_mme_port) && (packet->sctp_hdr.src_port == old_enb_port)) {
packet->sctp_hdr.u.data_hdr.assoc_id = assoc_id;
S1AP_DEBUG("tPacket:\tnum %u | original frame number %u \n", packet->packet_number, packet->original_frame_number);
S1AP_DEBUG("\tUpdated assoc id: %u\n", assoc_id);
}
}
}
} else if (g_scenario->next_packet->action == ET_PACKET_ACTION_S1C_RECEIVE) {
ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.src, &mme_desc_p->mme_net_ip_address);
if (0 == ret) {
ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.dst, &s1ap_eNB_instance->s1c_net_ip_address);
if (0 == ret) {
// same IP src, same IP dst
if ((packet->sctp_hdr.src_port == old_mme_port) && (packet->sctp_hdr.dst_port == old_enb_port)) {
packet->sctp_hdr.u.data_hdr.assoc_id = assoc_id;
S1AP_DEBUG("tPacket:\tnum %u | original frame number %u \n", packet->packet_number, packet->original_frame_number);
S1AP_DEBUG("\tUpdated assoc id: %u\n", assoc_id);
}
}
}
}
}
}
break;
// Strong assumption
// in replayed scenario, the order of SCTP INIT packets is supposed to be the same as in the catched scenario
case SCTP_CID_INIT:
ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.dst, &mme_desc_p->mme_net_ip_address);
if (0 == ret) {
ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.src, &s1ap_eNB_instance->s1c_net_ip_address);
if (0 == ret) {
if (0 == old_enb_port) {
if (ET_PACKET_STATUS_NONE == packet->status) {
packet->status = ET_PACKET_STATUS_SENT;
old_enb_port = packet->sctp_hdr.src_port;
}
}
}
}
break;
case SCTP_CID_INIT_ACK:
ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.dst, &mme_desc_p->mme_net_ip_address);
if (0 == ret) {
ret = et_compare_et_ip_to_net_ip_address(&packet->ip_hdr.src, &s1ap_eNB_instance->s1c_net_ip_address);
if (0 == ret) {
if (old_enb_port == packet->sctp_hdr.dst_port) {
if (ET_PACKET_STATUS_NONE == packet->status) {
packet->status = ET_PACKET_STATUS_RECEIVED;
old_mme_port = packet->sctp_hdr.dst_port;
}
}
}
}
break;
case SCTP_CID_HEARTBEAT:
case SCTP_CID_HEARTBEAT_ACK:
case SCTP_CID_COOKIE_ECHO:
......@@ -384,12 +438,14 @@ void et_s1ap_handle_s1_setup_message(s1ap_eNB_mme_data_t *mme_desc_p, int sctp_s
if (mme_desc_p->s1ap_eNB_instance->s1ap_mme_pending_nb > 0) {
/* Decrease pending messages number */
mme_desc_p->s1ap_eNB_instance->s1ap_mme_pending_nb --;
mme_desc_p->s1ap_eNB_instance->s1ap_mme_associated_nb++;
}
et_s1ap_update_assoc_id_of_packets(mme_desc_p->assoc_id,
mme_desc_p->s1ap_eNB_instance,
mme_desc_p);
/* If there are no more pending messages, inform eNB app */
if (mme_desc_p->s1ap_eNB_instance->s1ap_mme_pending_nb == 0) {
MessageDef *message_p;
......@@ -484,6 +540,10 @@ void et_s1ap_eNB_handle_sctp_association_resp(instance_t instance, sctp_new_asso
return;
}
S1AP_DEBUG("Received successful result for SCTP association (%u), instance %d, cnx_id %u\n",
sctp_new_association_resp->sctp_state,
instance,
sctp_new_association_resp->ulp_cnx_id);
/* Update parameters */
s1ap_mme_data_p->assoc_id = sctp_new_association_resp->assoc_id;
s1ap_mme_data_p->in_streams = sctp_new_association_resp->in_streams;
......@@ -557,7 +617,7 @@ void *et_s1ap_eNB_task(void *arg)
if (TIMER_HAS_EXPIRED (received_msg).timer_id == g_scenario->enb_register_retry_timer_id) {
/* Restart the registration process */
g_scenario->registered_enb = 0;
g_scenario->register_enb_pending = et_eNB_app_register (g_scenario->enb_properties);
et_eNB_app_register (g_scenario->enb_properties);
}
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