Skip to content

Commit

Permalink
Add downloader thread
Browse files Browse the repository at this point in the history
* Add DownloadConfig containing rtt and rnti_share_type
* Add messaging between downloader and model
* Add parse entries for download config
* Add sockopt_get_tcp_info to determine RTT
* Log DownloadFinish in .logs/download/*.jsonl

Introduce scenario parameter

Set the scenario to choose between

* TrackUeAndEstimateTransportCapacity
* TrackCellDciOnly
* PerformMeasurement
  • Loading branch information
bastian-src committed Jul 23, 2024
1 parent 06ffdb9 commit 9fc5f1e
Show file tree
Hide file tree
Showing 8 changed files with 655 additions and 33 deletions.
23 changes: 19 additions & 4 deletions src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use arrow::datatypes::{DataType, Field, Fields, Schema};
use arrow::ipc::writer::FileWriter;
use arrow::record_batch::RecordBatch;

use crate::logic::downloader::DownloadFinishParameters;
use crate::logic::model_handler::LogMetric;
use crate::logic::rnti_matcher::TrafficCollection;
use crate::ngscope::types::NgScopeRntiDci;
Expand All @@ -37,8 +38,7 @@ const LOGGER_RELATIVE_PATH_INFO: &str = "stdout/";
const LOGGER_RELATIVE_PATH_DCI: &str = "dci/";
const LOGGER_RELATIVE_PATH_RNTI_MATCHING: &str = "rnti_matching/";
const LOGGER_RELATIVE_PATH_METRIC: &str = "metric/";
// TODO: Implement saving measurements data
// const LOGGER_RELATIVE_PATH_MEASUREMENT: &str = "measurements/";
const LOGGER_RELATIVE_PATH_DOWNLOAD: &str = "download/";

#[derive(Clone, Debug, PartialEq)]
pub enum LoggerState {
Expand Down Expand Up @@ -100,8 +100,8 @@ pub enum LogMessage {
RntiMatchingTrafficCollection(Box<TrafficCollection>),
/// Model Metric
Metric(Box<LogMetric>),
// Measurement transmission data (RTT)
// LogDataTransmission(Box<NgScopeCellDci>),
/// Measurement transmission data (RTT)
DownloadStatistics(Box<DownloadFinishParameters>),
}

/*
Expand Down Expand Up @@ -241,6 +241,10 @@ pub fn log_dci(dcis: Vec<NgScopeCellDci>) -> Result<()> {
Logger::queue_log_message(LogMessage::NgScopeDci(dcis))
}

pub fn log_download(download: DownloadFinishParameters) -> Result<()> {
Logger::queue_log_message(LogMessage::DownloadStatistics(Box::new(download)))
}

#[allow(unknown_lints)]
pub fn get_logger() -> &'static mut Lazy<Logger> {
static mut GLOBAL_LOGGER: Lazy<Logger> = Lazy::new(|| {
Expand Down Expand Up @@ -339,6 +343,7 @@ impl LogMessage {
LogMessage::NgScopeDci(_) => "ngscope dci",
LogMessage::RntiMatchingTrafficCollection(_) => "rnti traffic collection",
LogMessage::Metric(_) => "metric",
LogMessage::DownloadStatistics(_) => "download",
}
.to_string()
}
Expand Down Expand Up @@ -372,6 +377,12 @@ impl LogMessage {
LOGGER_RELATIVE_PATH_RNTI_MATCHING, run_timestamp_formatted
)
}
LogMessage::DownloadStatistics(_) => {
format!(
"{}run_{}_download.jsonl",
LOGGER_RELATIVE_PATH_DOWNLOAD, run_timestamp_formatted
)
}
};
format!("{}{}", base_dir, message_type_file_path)
}
Expand All @@ -392,6 +403,10 @@ impl LogMessage {
let json_string = serde_json::to_string(metric)?;
writeln!(file, "{}", json_string)?;
}
LogMessage::DownloadStatistics(download) => {
let json_string = serde_json::to_string(download)?;
writeln!(file, "{}", json_string)?;
}
}
file.flush()?;
Ok(())
Expand Down
Loading

0 comments on commit 9fc5f1e

Please sign in to comment.