Optimize the output of log and stat

This commit is contained in:
luwenpeng
2024-05-16 11:52:14 +08:00
parent 4c50a6dca7
commit 8d8a266f60
9 changed files with 120 additions and 51 deletions

View File

@@ -27,27 +27,27 @@ tcp_overload_evict_old_sess = 1 # 1: evict old session, 0: bypass new session
udp_overload_evict_old_sess = 1 # 1: evict old session, 0: bypass new session
# TCP timeout
tcp_init_timeout = 5000 # range: [1, 60000] (ms)
tcp_handshake_timeout = 5000 # range: [1, 60000] (ms)
tcp_data_timeout = 5000 # range: [1, 15999999000] (ms)
tcp_half_closed_timeout = 5000 # range: [1, 604800000] (ms)
tcp_time_wait_timeout = 5000 # range: [1, 600000] (ms)
tcp_discard_timeout = 10000 # range: [1, 15999999000] (ms)
tcp_unverified_rst_timeout = 5000 # range: [1, 600000] (ms)
tcp_init_timeout = 50 # range: [1, 60000] (ms)
tcp_handshake_timeout = 50 # range: [1, 60000] (ms)
tcp_data_timeout = 50 # range: [1, 15999999000] (ms)
tcp_half_closed_timeout = 50 # range: [1, 604800000] (ms)
tcp_time_wait_timeout = 50 # range: [1, 600000] (ms)
tcp_discard_timeout = 50 # range: [1, 15999999000] (ms)
tcp_unverified_rst_timeout = 50 # range: [1, 600000] (ms)
# UDP timeout
udp_data_timeout = 5000 # range: [1, 15999999000] (ms)
udp_discard_timeout = 5000 # range: [1, 15999999000] (ms)
udp_data_timeout = 50 # range: [1, 15999999000] (ms)
udp_discard_timeout = 50 # range: [1, 15999999000] (ms)
# duplicate packet filter
duplicated_packet_filter_enable = 1
duplicated_packet_filter_capacity = 1000000 # range: [1, 4294967295]
duplicated_packet_filter_timeout = 10000 # range: [1, 60000] (ms)
duplicated_packet_filter_timeout = 100 # range: [1, 60000] (ms)
duplicated_packet_filter_error_rate = 0.00001 # range: [0.0, 1.0]
# evicted session filter
evicted_session_filter_enable = 1
evicted_session_filter_capacity = 1000000 # range: [1, 4294967295]
evicted_session_filter_timeout = 10000 # range: [1, 60000] (ms)
evicted_session_filter_timeout = 100 # range: [1, 60000] (ms)
evicted_session_filter_error_rate = 0.00001 # range: [0.0, 1.0]
# TCP reassembly (Per direction)

View File

@@ -230,6 +230,17 @@ static int all_session_have_freed(void)
return 1;
}
static int all_stat_have_output(void)
{
static int count = 0;
if (runtime->stat_last_output_ts == stellar_get_monotonic_time_msec())
{
count++;
}
return count == 2;
}
static void usage(char *cmd)
{
printf("Usage: %s [options]\n\n", cmd);
@@ -449,8 +460,9 @@ int main(int argc, char **argv)
usleep(1000); // 1ms
// Only available in dump file mode, automatically exits when all sessions have been released
if (packet_io_wait_exit(runtime->packet_io) && all_session_have_freed())
if (packet_io_wait_exit(runtime->packet_io) && all_session_have_freed() && all_stat_have_output())
{
STELLAR_LOG_STATE("all sessions have been released and all stat have been output, notify threads to exit !!!");
ATOMIC_SET(&runtime->need_exit, 1);
}
}

View File

@@ -142,18 +142,21 @@ void packet_injector_test_frame_run(struct packet_injector_case *test)
char input_dir_abs_path[1024] = {0};
char output_dir_abs_path[1024] = {0};
char expect_dir_abs_path[1024] = {0};
char log_dir_abs_path[1024] = {0};
// absulute path
snprintf(config_file_abs_path, sizeof(config_file_abs_path), "%s/conf/stellar.toml", test->work_dir);
snprintf(input_dir_abs_path, sizeof(input_dir_abs_path), "%s/input/", test->work_dir);
snprintf(output_dir_abs_path, sizeof(output_dir_abs_path), "%s/output/", test->work_dir);
snprintf(expect_dir_abs_path, sizeof(expect_dir_abs_path), "%s/expect/", test->work_dir);
snprintf(log_dir_abs_path, sizeof(log_dir_abs_path), "%s/log/", test->work_dir);
// create directory
system_cmd("rm -rf %s", test->work_dir);
system_cmd("mkdir -p %s", input_dir_abs_path);
system_cmd("mkdir -p %s", output_dir_abs_path);
system_cmd("mkdir -p %s", expect_dir_abs_path);
system_cmd("mkdir -p %s", log_dir_abs_path);
// copy file to work directory
if (test->c2s_expect_pcap)