Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add [rntimatcher.gen] monitoring #13

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions scripts/visualize_rnti_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
DEFAULT_RESET_TIMESTAMPS = True
DEFAULT_FILTER_KEEP_REST = False
DEFAULT_EXPORT_PATH = './.export/'
DEFAULT_DIASHOW_KBPS = False

# RNTI Filterting
DCI_THRESHOLD = 0
EMPTY_DCI_RATIO_THRESHOLD = 0.99
SAMPLES_THRESHOLD = 5

MAX_TOTAL_UL_FACTOR = 100.0
MAX_TOTAL_UL_FACTOR = 200.0
MIN_TOTAL_UL_FACTOR = 0.005 # x% of the expected UL traffic
MAX_UL_PER_DCI_THRESHOLD = 5_000_000
MIN_OCCURENCES_FACTOR = 0.005
Expand Down Expand Up @@ -397,8 +398,12 @@ def __init__(self, ax, data: list, settings):

def plot(self):
self.ax.clear()
df_kbps = self.data[self.index].filtered_df.resample('1s').median().mul(8 / 1_000)
plot_df(plot_pandas_line, df_kbps, axes=self.ax)
df = self.data[self.index].filtered_df
print_info(f"Highest DCI count RNTI: {df.count().idxmax()}")
if self.settings.kbps:
df = df.resample('1s').sum().mul(8).div(1000)

plot_df(DEFAULT_DIASHOW_PLOT_TYPE_CHOICES[self.settings.plot_type], df, axes=self.ax)

def check_data(self, file_index) -> bool:
if isinstance(self.data[file_index], FilteredRecording):
Expand Down Expand Up @@ -550,7 +555,7 @@ def export(settings):
filtered_data = filter_dataset(settings, raw_recording)

df = move_column_to_front(filtered_data.filtered_df, '11985')
df_kbps = df.resample('1s').median().mul(8 / 1_000)
df_kbps = df.resample('1s').sum().mul(8).div(1000)

# Replace the first directory and change the file extension
os.makedirs(os.path.dirname(export_base_path), exist_ok=True)
Expand Down Expand Up @@ -674,6 +679,12 @@ def plot_pandas_hist(ax, df):
ax.set_ylabel('Frequency')
# ax.set_title('Histogram of UL Bytes')

DEFAULT_DIASHOW_PLOT_TYPE = 'scatter'
DEFAULT_DIASHOW_PLOT_TYPE_CHOICES = {
'scatter': plot_pandas_scatter,
'line': plot_pandas_line,
'hist': plot_pandas_hist,
}

def plot_basic_filtered(settings, recording):

Expand Down Expand Up @@ -758,6 +769,15 @@ def plot_basic_filtered(settings, recording):
type=bool,
default=DEFAULT_PLOT_FILTERED,
help='Display filtered RNTIs in the plot (default: {DEFAULT_PLOT_FILTERED})')
parser_diashow.add_argument('--kbps',
type=bool,
default=DEFAULT_DIASHOW_KBPS,
help='Resample to kbps (default: {DEFAULT_DIASHOW_KBPS})')
parser_diashow.add_argument('--plot-type',
type=str,
choices=list(DEFAULT_DIASHOW_PLOT_TYPE_CHOICES.keys()),
default=DEFAULT_DIASHOW_PLOT_TYPE,
help='The type of the plot (default: {DEFAULT_DIASHOW_PLOT_TYPE})')

# standardize subcommand
parser_standardize = subparsers.add_parser('standardize', help='Run standardize mode')
Expand Down
33 changes: 29 additions & 4 deletions src/logic/rnti_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub const MATCHING_UL_BYTES_UPPER_BOUND_FACTOR: f64 = 4.0;
pub const TIME_MS_TO_US_FACTOR: u64 = 1000;
pub const COLLECT_DCI_MAX_TIMESTAMP_DELTA_US: u64 = 50000;

pub const BASIC_FILTER_MAX_TOTAL_UL_FACTOR: f64 = 100.0;
pub const BASIC_FILTER_MAX_TOTAL_UL_FACTOR: f64 = 200.0;
pub const BASIC_FILTER_MIN_TOTAL_UL_FACTOR: f64 = 0.005;
pub const BASIC_FILTER_MAX_UL_PER_DCI: u64 = 5_000_000;
pub const BASIC_FILTER_MIN_OCCURENCES_FACTOR: f64 = 0.005;
Expand Down Expand Up @@ -405,6 +405,8 @@ fn run_traffic_generator(
determine_process_id()
));

let mut last_timemstamp_us: Option<u64> = None;

loop {
match check_rx_state(&rx_local_gen_state) {
Ok(Some(new_state)) => gen_state = new_state,
Expand All @@ -424,7 +426,7 @@ fn run_traffic_generator(
break;
}
LocalGeneratorState::SendPattern(ref destination, ref mut pattern) => {
match gen_handle_send_pattern(&socket, destination, pattern) {
match gen_handle_send_pattern(&socket, destination, pattern, &mut last_timemstamp_us) {
Ok(Some(_)) => { /* stay in the state and keep sending */ },
Ok(None) => gen_state = LocalGeneratorState::PatternSent,
Err(e) => {
Expand All @@ -435,6 +437,7 @@ fn run_traffic_generator(
}
LocalGeneratorState::PatternSent => {
print_info("[rntimatcher.gen] Finished sending pattern!");
last_timemstamp_us = None;
gen_state = LocalGeneratorState::Idle
}
}
Expand Down Expand Up @@ -468,11 +471,33 @@ fn gen_handle_send_pattern(
socket: &UdpSocket,
destination: &str,
pattern: &mut TrafficPattern,
last_sent_timemstamp_us: &mut Option<u64>,
) -> Result<Option<()>> {
match pattern.messages.pop_front() {
Some(msg) => {
thread::sleep(Duration::from_millis(msg.time_ms as u64));
let sleep_us: u64;

let now_us = chrono::Utc::now().timestamp_micros() as u64;
if let Some(ref mut timestamp_us) = last_sent_timemstamp_us {
/* Determine time delta and adapt sleeping time */
let delta = now_us - *timestamp_us;
if delta > msg.time_ms as u64 * TIME_MS_TO_US_FACTOR {
print_info(&format!("[rntimatcher.gen] sending time interval exceeded by: {:?}us", delta));
sleep_us = msg.time_ms as u64 * TIME_MS_TO_US_FACTOR;
} else {
sleep_us = (msg.time_ms as u64 * TIME_MS_TO_US_FACTOR) - delta;
}
} else {
/* First packet, just sleep and send */
sleep_us = msg.time_ms as u64 * TIME_MS_TO_US_FACTOR;
}

thread::sleep(Duration::from_micros(sleep_us));

*last_sent_timemstamp_us = Some(chrono::Utc::now().timestamp_micros() as u64);

socket.send_to(&msg.payload, destination)?;

Ok(Some(()))
}
None => Ok(None)
Expand Down Expand Up @@ -603,7 +628,7 @@ impl TrafficCollection {
/* ZERO MEDIAN */
.filter(|(_, ue_traffic)| {
match ue_traffic.feature_ul_bytes_median_mean_variance() {
Ok((median, _, _)) if median <= 0.0 => true,
Ok((median, _, _)) if median > 0.0 => true,
_ => {
stats.zero_ul_median += 1;
false
Expand Down
Loading
Loading