#pragma once #ifdef __cplusplus extern "C" { #endif #include "list.h" #include "tuple.h" #include "uthash.h" #include "timeout.h" #include "packet_def.h" #include "stellar/session.h" #include "tcp_reassembly.h" #define EX_DATA_MAX_COUNT 4 // output format: "${src_addr}:${src_port}-${dst_addr}:${dst_port}-${ip_proto}-${domain}" // output max len: (46 + 1 + 5) + 1 + (46 + 1 + 5) + 1 + 1 + 1 + 20 = 129 #define TUPLE6_STR_SIZE 130 struct tcp_half { struct tcp_reassembly *assembler; struct tcp_segment in_order; // current packet in order segment uint32_t in_order_ref; // reference count of current packet in order segment uint32_t seq; // current packet sequence number uint32_t ack; // current packet ack number uint16_t len; // current packet payload length uint8_t flags; // current packet flags uint32_t isn; // current direction initial sequence number uint8_t history; // current direction received flags }; /* * sizeof(struct session) > 1024 bytes * max thread number = 128 * per thread max tcp session number = 50000 * per thread max udp session number = 50000 * * session memory usage = 128 * (50000 + 50000) * 1024 = 13107200000 bytes = 12.2 GB */ struct session { uint64_t id; uint64_t stats[MAX_FLOW_DIRECTION][MAX_STAT]; uint64_t timestamps[MAX_TIMESTAMP]; // realtime seconds struct tcp_half tcp_halfs[MAX_FLOW_DIRECTION]; struct timeout timeout; struct list_head lru; struct list_head free; struct list_head evicte; UT_hash_handle hh1; UT_hash_handle hh2; UT_hash_handle hh3; struct tuple6 tuple; char tuple_str[TUPLE6_STR_SIZE]; struct sids sids[MAX_FLOW_DIRECTION]; struct route_ctx route_ctx[MAX_FLOW_DIRECTION]; const struct packet *first_pkt[MAX_FLOW_DIRECTION]; const struct packet *curr_pkt; void *ex_data[EX_DATA_MAX_COUNT]; void *user_data; int is_symmetric; int dup; enum session_direction sess_dir; enum flow_direction tuple_dir; enum flow_direction flow_dir; enum session_type type; enum session_state state; enum closing_reason reason; struct session_manager *mgr; struct session_manager_stat *mgr_stat; }; #ifdef __cplusplus } #endif