Commit 64df39d1 authored by gauthier's avatar gauthier

Sync

parent ed268454
This diff is collapsed.
......@@ -89,6 +89,15 @@
#define ENB_CONFIG_STRING_ENB_PORT_FOR_S1U "ENB_PORT_FOR_S1U"
typedef struct shift_packet_s {
unsigned int frame_number;
int shift_seconds;
int shift_microseconds;
int single; // only this packet
struct shift_packet_s *next;
} shift_packet_t;
typedef struct mme_ip_address_s {
unsigned ipv4:1;
unsigned ipv6:1;
......@@ -445,6 +454,10 @@ int et_generate_xml_scenario(
const char const * enb_config_filename,
char const * tsml_out_scenario_filename);
//-------------------------
void timeval_add (struct timeval * const result, const struct timeval * const a, const struct timeval * const b);
int timeval_subtract (struct timeval * const result, struct timeval * const a, struct timeval * const b);
void et_scenario_wait_rx_packet(et_packet_t * const packet);
void et_scenario_schedule_tx_packet(et_packet_t * const packet);
et_fsm_state_t et_scenario_fsm_notify_event_state_running(et_event_t event);
et_fsm_state_t et_scenario_fsm_notify_event_state_waiting_tx(et_event_t event);
et_fsm_state_t et_scenario_fsm_notify_event_state_waiting_rx(et_event_t event);
......@@ -458,7 +471,7 @@ void et_parse_sctp_init_chunk(xmlDocPtr doc, const xmlNode const *sctp_node, sct
void et_parse_sctp_init_ack_chunk(xmlDocPtr doc, const xmlNode const *sctp_node, sctp_initackhdr_t * const sctp_hdr);
void et_parse_sctp(xmlDocPtr doc, const xmlNode const *sctp_node, et_sctp_hdr_t * const sctp_hdr);
et_packet_t* et_parse_xml_packet(xmlDocPtr doc, xmlNodePtr node);
et_scenario_t* et_generate_scenario(const char * const et_scenario_filename );
et_scenario_t* et_generate_scenario(const char * const et_scenario_filename);
//-------------------------
asn_comp_rval_t * et_s1ap_ies_is_matching(const S1AP_PDU_PR present, s1ap_message * const m1, s1ap_message * const m2, const uint32_t constraints);
void update_xpath_node_mme_ue_s1ap_id(et_s1ap_t * const s1ap, xmlNode *node, const S1ap_MME_UE_S1AP_ID_t new_id);
......@@ -471,6 +484,7 @@ asn_comp_rval_t * et_sctp_is_matching(et_sctp_hdr_t * const sctp1, et_sctp_hdr_t
void et_print_hex_octets(const unsigned char * const byte_stream, const unsigned long int num);
int et_is_file_exists ( const char const * file_nameP, const char const *file_roleP);
int et_strip_extension( char *in_filename);
void et_get_shift_arg( char * line_argument, shift_packet_t * const shift);
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);
......@@ -486,6 +500,6 @@ void et_enb_config_init(const char const * lib_config_file_name_pP);
const Enb_properties_array_t *et_enb_config_get(void);
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);
int et_play_scenario(et_scenario_t* const scenario, const struct shift_packet_s *shifts);
#endif /* PLAY_SCENARIO_H_ */
......@@ -54,37 +54,36 @@ pthread_mutex_t g_fsm_lock = PTHREAD_MUTEX_INITIALIZER;
et_fsm_state_t g_fsm_state = ET_FSM_STATE_NULL;
uint32_t g_constraints = ET_BIT_MASK_MATCH_SCTP_STREAM | ET_BIT_MASK_MATCH_SCTP_SSN;
//------------------------------------------------------------------------------
int timeval_subtract (struct timeval * const result, struct timeval * const a, struct timeval * const b)
// it is assumed that if a time is negative tv_sec and tv_usec are both negative
void timeval_add (struct timeval * const result, const struct timeval * const a, const struct timeval * const b)
{
struct timeval b2;
int nsec = 0;
b2.tv_sec = b->tv_sec;
b2.tv_usec = b->tv_usec;
/* Perform the carry for the later subtraction by updating y. */
if (a->tv_usec < b2.tv_usec) {
nsec = (b2.tv_usec - a->tv_usec) / 1000000 + 1;
b2.tv_usec -= 1000000 * nsec;
b2.tv_sec += nsec;
AssertFatal(((a->tv_sec <= 0) && (a->tv_usec <= 0)) || ((a->tv_sec >= 0) && (a->tv_usec >= 0)), " Bad time format arg a\n");
AssertFatal(((b->tv_sec <= 0) && (b->tv_usec <= 0)) || ((b->tv_sec >= 0) && (b->tv_usec >= 0)), " Bad time format arg b\n");
// may happen overflows but were are not dealing with very large timings
long long int r = a->tv_usec + b->tv_usec + (a->tv_sec + b->tv_sec) * 1000000;
result->tv_sec = r / (long long int)1000000;
result->tv_usec = r % (long long int)1000000;
if ((result != a) && (result != b)) {
LOG_D(ENB_APP, "timeval_add(%ld.%06d, %ld.%06d)=%ld.%06d\n", a->tv_sec, a->tv_usec, b->tv_sec, b->tv_usec, result->tv_sec, result->tv_usec);
}
if (a->tv_usec - b2.tv_usec > 1000000) {
nsec = (a->tv_usec - b2.tv_usec) / 1000000;
b2.tv_usec += 1000000 * nsec;
b2.tv_sec -= nsec;
}
/* Compute the time remaining to wait.
tv_usec is certainly positive. */
result->tv_sec = a->tv_sec - b2.tv_sec;
result->tv_usec = a->tv_usec - b2.tv_usec;
}
//------------------------------------------------------------------------------
// it is assumed that if a time is negative tv_sec and tv_usec are both negative
int timeval_subtract (struct timeval * const result, struct timeval * const a, struct timeval * const b)
{
AssertFatal(((a->tv_sec <= 0) && (a->tv_usec <= 0)) || ((a->tv_sec >= 0) && (a->tv_usec >= 0)), " Bad time format arg a\n");
AssertFatal(((b->tv_sec <= 0) && (b->tv_usec <= 0)) || ((b->tv_sec >= 0) && (b->tv_usec >= 0)), " Bad time format arg b\n");
// may happen overflows but were are not dealing with very large timings
long long int r = a->tv_usec - b->tv_usec + (a->tv_sec - b->tv_sec) * 1000000;
result->tv_sec = r / (long long int)1000000;
result->tv_usec = r % (long long int)1000000;
if ((result != a) && (result != b)) {
LOG_D(ENB_APP, "timeval_subtract(%ld.%06d, %ld.%06d)=%ld.%06d\n", a->tv_sec, a->tv_usec, b->tv_sec, b->tv_usec, result->tv_sec, result->tv_usec);
return a->tv_sec < b2.tv_sec;
}
return result->tv_sec < 0;
}
//------------------------------------------------------------------------------
void et_scenario_wait_rx_packet(et_packet_t * const packet)
{
......@@ -137,10 +136,9 @@ void et_scenario_schedule_tx_packet(et_packet_t * const packet)
}
if ((0 < we_are_too_early) && (0 == g_max_speed)){
// set timer
if (offset.tv_sec < 0) offset.tv_sec = -offset.tv_sec;
if (offset.tv_usec < 0) {
offset.tv_usec = offset.tv_usec + 1000000;
offset.tv_sec -= 1;
if (offset.tv_sec < 0) {
offset.tv_sec = -offset.tv_sec;
offset.tv_usec = -offset.tv_usec;
}
LOG_D(ENB_APP, "Send packet num %u original frame number %u in %ld.%06d sec\n",
......
......@@ -62,7 +62,7 @@ extern Enb_properties_array_t g_enb_properties;
//------------------------------------------------------------------------------
void et_parse_s1ap(xmlDocPtr doc, const xmlNode const *s1ap_node, et_s1ap_t * const s1ap)
{
xmlNode *cur_node = NULL;
xmlNodePtr cur_node = NULL;
xmlChar *xml_char = NULL;
xmlChar *xml_char2 = NULL;
unsigned int size = 0;
......@@ -329,7 +329,36 @@ void et_parse_sctp(xmlDocPtr doc, const xmlNode const *sctp_node, et_sctp_hdr_t
}
}
//------------------------------------------------------------------------------
et_packet_t* et_parse_xml_packet(xmlDocPtr doc, xmlNodePtr node) {
void et_packet_shift_timing(et_packet_t * const packet, const struct timeval * const shift)
{
timeval_add(&packet->time_relative_to_first_packet, &packet->time_relative_to_first_packet, shift);
AssertFatal((packet->time_relative_to_first_packet.tv_sec >= 0) && (packet->time_relative_to_first_packet.tv_usec >= 0),
"Bad timing result time_relative_to_first_packet=%d.%d packet num %u, original frame number %u",
packet->time_relative_to_first_packet.tv_sec,
packet->time_relative_to_first_packet.tv_usec,
packet->packet_number,
packet->original_frame_number);
timeval_add(&packet->time_relative_to_last_received_packet, &packet->time_relative_to_last_received_packet, shift);
AssertFatal((packet->time_relative_to_last_received_packet.tv_sec >= 0) && (packet->time_relative_to_last_received_packet.tv_usec >= 0),
"Bad timing result time_relative_to_last_received_packet=%d.%d packet num %u, original frame number %u",
packet->time_relative_to_last_received_packet.tv_sec,
packet->time_relative_to_last_received_packet.tv_usec,
packet->packet_number,
packet->original_frame_number);
timeval_add(&packet->time_relative_to_last_sent_packet, &packet->time_relative_to_last_sent_packet, shift);
AssertFatal((packet->time_relative_to_last_sent_packet.tv_sec >= 0) && (packet->time_relative_to_last_sent_packet.tv_usec >= 0),
"Bad timing result time_relative_to_last_sent_packet=%d.%d packet num %u, original frame number %u",
packet->time_relative_to_last_sent_packet.tv_sec,
packet->time_relative_to_last_sent_packet.tv_usec,
packet->packet_number,
packet->original_frame_number);
}
//------------------------------------------------------------------------------
et_packet_t* et_parse_xml_packet(xmlDocPtr doc, xmlNodePtr node)
{
et_packet_t *packet = NULL;
xmlNode *cur_node = NULL;
......@@ -343,6 +372,7 @@ et_packet_t* et_parse_xml_packet(xmlDocPtr doc, xmlNodePtr node) {
static char first_received_packet = 1;
static unsigned int packet_number = 1;
if (NULL != node) {
packet = calloc(1, sizeof(*packet));
......@@ -441,7 +471,7 @@ et_packet_t* et_parse_xml_packet(xmlDocPtr doc, xmlNodePtr node) {
}
//------------------------------------------------------------------------------
et_scenario_t* et_generate_scenario(
const char * const tsml_out_scenario_filename )
const char * const tsml_out_scenario_filename)
{
xmlDocPtr doc = NULL;
xmlNodePtr root = NULL;
......
......@@ -68,7 +68,6 @@ int et_s1ap_eNB_compare_assoc_id(
if (p1->cnx_id < p2->cnx_id) {
return -1;
}
if (p1->cnx_id > p2->cnx_id) {
return 1;
}
......@@ -76,7 +75,6 @@ int et_s1ap_eNB_compare_assoc_id(
if (p1->assoc_id < p2->assoc_id) {
return -1;
}
if (p1->assoc_id > p2->assoc_id) {
return 1;
}
......
......@@ -586,7 +586,6 @@ int et_s1ap_update_mme_ue_s1ap_id(et_packet_t * const packet, const S1ap_MME_UE_
{
xmlNode *cur_node = NULL;
xmlChar xpath_expression[ET_XPATH_EXPRESSION_MAX_LENGTH];
int ret = 0;
xmlDocPtr doc = NULL;
......
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