Commit 717a8f5e authored by Pietro Fezzardi's avatar Pietro Fezzardi

arch-sim: new simulator diagnostics and config

diagnostics:

For testing purposes we can't just read the ofm value
printed out by the slave, because that's only the offset
perceived by the slave and can be wrong. We need instead to
print out the offset obtained subtracting the real time of
the master from the real time of the slave.
To print out the ofm we use the "ext" flag of pp_diag.
The ofm is printed only when the slave gets a
DelayResp message from the master.
A new tool to strip ofm out of simulator log is provided

config:

now the max number of simulated ptp iterations can be configured.
previously one could set the number of seconds to simulate.
this is not possible anymore.
parent 459ea68f
......@@ -54,7 +54,7 @@ void sim_main_loop(struct pp_globals *ppg)
delay_ns = run_all_state_machines(ppg) * 1000LL * 1000LL;
while (data->duration_ns >= 0) {
while (data->sim_iter_n <= data->sim_iter_max) {
/*
* If Ebest was changed in previous loop, run best
* master clock before checking for new packets, which
......
......@@ -58,7 +58,8 @@ struct sim_pending_pkt {
struct sim_ppg_arch_data {
int n_pending;
struct sim_pending_pkt pending[64];
int64_t duration_ns;
int64_t sim_iter_max;
int64_t sim_iter_n;
};
static inline struct sim_ppg_arch_data *SIM_PPG_ARCH(struct pp_globals *ppg)
......
......@@ -110,11 +110,10 @@ static int f_jit(int lineno, struct pp_globals *ppg,
return 0;
}
static int f_duration(int lineno, struct pp_globals *ppg,
static int f_iter(int lineno, struct pp_globals *ppg,
union pp_cfg_arg *arg)
{
SIM_PPG_ARCH(ppg)->duration_ns = arg->ts.tv_nsec +
arg->ts.tv_sec * (long long)PP_NSEC_PER_SEC;
SIM_PPG_ARCH(ppg)->sim_iter_max = arg->i;
return 0;
}
......@@ -129,7 +128,7 @@ struct pp_argline pp_arch_arglines[] = {
{f_jit, "sim_jit_ns", ARG_INT},
{f_fwd_jit, "sim_fwd_jit_ns", ARG_INT},
{f_bckwd_jit, "sim_bckwd_jit_ns", ARG_INT},
{f_duration, "sim_duration_sec", ARG_TIME},
{f_iter, "sim_iter_max", ARG_TIME},
{}
};
......
......@@ -121,7 +121,7 @@ int main(int argc, char **argv)
sim_set_global_DS(pp_sim_get_master(ppg));
pp_config_string(ppg, strdup("port SIM_MASTER; iface MASTER;"
"proto udp; role master;"
"sim_duration_sec 3600;" // one hour
"sim_iter_max 10000;"
"sim_init_master_time .9;"));
/* parse commandline for configuration options */
......
......@@ -48,7 +48,6 @@ static char *fmt_TI(TimeInternal *t)
return s;
}
/* Called by slave and uncalib when we have t1 and t2 */
void pp_servo_got_sync(struct pp_instance *ppi)
{
......
......@@ -78,6 +78,9 @@ static int sim_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
ssize_t ret;
struct msghdr msg;
struct iovec vec[1];
int64_t master_ns, slave_ns;
struct pp_globals *ppg = GLBS(ppi);
struct sim_ppg_arch_data *data = SIM_PPG_ARCH(ppg);
union {
struct cmsghdr cm;
......@@ -117,6 +120,14 @@ static int sim_recv_msg(struct pp_instance *ppi, int fd, void *pkt, int len,
/* This is not really hw... */
pp_diag(ppi, time, 2, "recv stamp: %i.%09i (%s)\n",
(int)t->seconds, (int)t->nanoseconds, "user");
/* If we got a DelayResponse print out the offset from master */
if (((*(Enumeration4 *) (pkt + 0)) & 0x0F) == PPM_DELAY_RESP) {
master_ns = SIM_PPI_ARCH(INST(ppg, SIM_MASTER))->time.current_ns;
slave_ns = SIM_PPI_ARCH(INST(ppg, SIM_SLAVE))->time.current_ns;
pp_diag(ppi, ext, 1, "Real ofm %lli\n",
(long long)slave_ns - master_ns);
data->sim_iter_n++;
}
return ret;
}
......
......@@ -27,7 +27,7 @@ int sim_fast_forward_ns(struct pp_globals *ppg, int64_t ff_ns)
t_inst->current_ns += tmp + (t_inst->freq_ppm_servo) *
tmp / 1000 / 1000 / 1000;
}
pp_diag(0, time, 1, "%s: %li ns\n", __func__, (long)ff_ns);
pp_diag(0, ext, 2, "%s: %lli ns\n", __func__, (long long)ff_ns);
struct sim_pending_pkt *pkt;
struct sim_ppg_arch_data *data = SIM_PPG_ARCH(ppg);
......@@ -43,7 +43,6 @@ int sim_fast_forward_ns(struct pp_globals *ppg, int64_t ff_ns)
}
}
data->duration_ns -= ff_ns;
return 0;
}
......
#!/bin/bash
# Warning! you neet to run with -d 000001 debug flags in order to use this
# strip utility with success. otherwise you will get some junk lines in the
# middle which will not be thrown away
if [ $# != 1 ]; then
echo "Usage: $0 inputfile";
exit 1;
fi
grep "Real" $1 | \
sed 's/diag-extension-[0-9]-SLAVE: Real ofm//g'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment