add support for periodic airplane mode simulation in srsUE

master
Andre Puschmann 5 years ago
parent 6c4e807141
commit 70ffe79b43

@ -57,6 +57,11 @@ typedef struct {
int usim_hex_limit;
} stack_log_args_t;
typedef struct {
int airplane_t_on_ms;
int airplane_t_off_ms;
} ue_sim_args_t;
typedef struct {
std::string type;
pcap_args_t pcap;
@ -67,6 +72,7 @@ typedef struct {
nas_args_t nas;
gw_args_t gw;
bool have_tti_time_stats;
ue_sim_args_t sim;
} stack_args_t;
class ue_stack_base

@ -132,10 +132,13 @@ private:
srslte::timer_handler* timers = nullptr;
srslte::timer_handler::unique_timer t3410; // started when attach request is sent, on expiry, start t3411
srslte::timer_handler::unique_timer t3411; // started when attach failed
srslte::timer_handler::unique_timer t3421; // started when detach request is sent
srslte::timer_handler::unique_timer reattach_timer; // started to trigger delayed re-attach
const uint32_t t3410_duration_ms = 15 * 1000; // 15s according to TS 24.301 Sec 10.2
const uint32_t t3411_duration_ms = 10 * 1000; // 10s according to TS 24.301 Sec 10.2
// Values according to TS 24.301 Sec 10.2
const uint32_t t3410_duration_ms = 15 * 1000; // 15s
const uint32_t t3411_duration_ms = 10 * 1000; // 10s
const uint32_t t3421_duration_ms = 1 * 1000; // 15s (here 1s to allow quick reattach)
const uint32_t reattach_timer_duration_ms = 2 * 1000; // 2s (arbitrarily chosen to delay re-attach)
// TS 23.003 Sec. 6.2.2 IMEISV's last two octets are Software Version Number (SVN)

@ -375,7 +375,16 @@ static int parse_args(all_args_t* args, int argc, char* argv[])
bpo::value<uint32_t>(&args->phy.nof_out_of_sync_events)->default_value(20),
"Number of PHY out-sync events before sending an out-sync event to RRC")
/* general options */
// UE simulation args
("sim.airplane_t_on_ms",
bpo::value<int>(&args->stack.sim.airplane_t_on_ms)->default_value(-1),
"On-time for airplane mode (in ms)")
("sim.airplane_t_off_ms",
bpo::value<int>(&args->stack.sim.airplane_t_off_ms)->default_value(-1),
"Off-time for airplane mode (in ms)")
/* general options */
("general.metrics_period_secs",
bpo::value<float>(&args->general.metrics_period_secs)->default_value(1.0),
"Periodicity for metrics in seconds")

@ -181,6 +181,15 @@ bool ue_stack_lte::switch_on()
if (running) {
pending_tasks.try_push(ue_queue_id,
[this]() { nas.start_attach_request(nullptr, srslte::establishment_cause_t::mo_data); });
// schedule airplane mode on command
if (args.sim.airplane_t_on_ms > 0) {
timers.defer_callback(args.sim.airplane_t_on_ms, [&]() {
// Enable air-plane mode
disable_data();
});
}
return true;
}
return false;
@ -210,13 +219,24 @@ bool ue_stack_lte::switch_off()
bool ue_stack_lte::enable_data()
{
// perform attach request
log.console("Turning off airplane mode.\n");
return switch_on();
}
bool ue_stack_lte::disable_data()
{
// generate detach request
return nas.detach_request(false);
log.console("Turning on airplane mode.\n");
int ret = nas.detach_request(false);
// schedule airplane mode off command
if (args.sim.airplane_t_off_ms > 0) {
timers.defer_callback(args.sim.airplane_t_off_ms, [&]() {
// Disable airplane mode again
enable_data();
});
}
return ret;
}
bool ue_stack_lte::get_metrics(stack_metrics_t* metrics)

@ -228,6 +228,7 @@ nas::nas(srslte::timer_handler* timers_) :
timers(timers_),
t3410(timers_->get_unique_timer()),
t3411(timers_->get_unique_timer()),
t3421(timers_->get_unique_timer()),
reattach_timer(timers_->get_unique_timer())
{
}
@ -281,9 +282,10 @@ void nas::init(usim_interface_nas* usim_, rrc_interface_nas* rrc_, gw_interface_
have_ctxt = true;
}
// Configure T3410 and T3411
// Configure timers
t3410.set(t3410_duration_ms, [this](uint32_t tid) { timer_expired(tid); });
t3411.set(t3411_duration_ms, [this](uint32_t tid) { timer_expired(tid); });
t3421.set(t3421_duration_ms, [this](uint32_t tid) { timer_expired(tid); });
reattach_timer.set(reattach_timer_duration_ms, [this](uint32_t tid) { timer_expired(tid); });
running = true;
@ -321,6 +323,11 @@ void nas::timer_expired(uint32_t timeout_id)
} else if (timeout_id == t3411.id()) {
nas_log->info("Timer T3411 expired: trying to attach again\n");
start_attach_request(nullptr, srslte::establishment_cause_t::mo_sig);
} else if (timeout_id == t3421.id()) {
nas_log->info("Timer T3421 expired: entering EMM_STATE_DEREGISTERED\n");
// TODO: TS 24.301 says to resend detach request but doesn't say how often before entering EMM_STATE_DEREGISTERED
// In order to allow reattaching the UE, we switch into EMM_STATE_DEREGISTERED straight
enter_emm_deregistered();
} else if (timeout_id == reattach_timer.id()) {
nas_log->info("Reattach timer expired: trying to attach again\n");
start_attach_request(nullptr, srslte::establishment_cause_t::mo_sig);
@ -1822,6 +1829,9 @@ void nas::send_detach_request(bool switch_off)
} else {
// we are expecting a response from the core
state = EMM_STATE_DEREGISTERED_INITIATED;
// start T3421
t3421.run();
}
if (rrc->is_connected()) {

@ -335,6 +335,21 @@ enable = false
#nof_in_sync_events = 10
#nof_out_of_sync_events = 20
#####################################################################
# Simulation configuration options
#
# The UE simulation supports turning on and off airplane mode in the UE.
# The actions are carried periodically until the UE is stopped.
#
# airplane_t_on_ms: Time to leave airplane mode turned on (in ms)
#
# airplane_t_off_ms: Time to leave airplane mode turned off (in ms)
#
#####################################################################
[sim]
#airplane_t_on_ms = -1
#airplane_t_off_ms = -1
#####################################################################
# General configuration options
#

Loading…
Cancel
Save