From 5468d7a7eb6b68fbdf8eed040ccf692dc663b7a4 Mon Sep 17 00:00:00 2001 From: emanuel Date: Tue, 30 May 2023 13:05:48 +0100 Subject: [PATCH] TPM log exchange time starting from tpm_pay() start --- src/tpm.c | 12 +++++++----- src/tpm.h | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/tpm.c b/src/tpm.c index 4a45536..6ac8301 100644 --- a/src/tpm.c +++ b/src/tpm.c @@ -85,6 +85,7 @@ int tpm_pay(tolling_info_t* info, void** security_socket, uint8_t* neighbour, ui pthread_mutex_lock(&tolling->lock); + tolling->station.obu.t_init = itss_ts_get(TIME_MICROSECONDS); tolling->station.obu.active = true; tolling->station.obu.nonce = rand() + 1; @@ -379,11 +380,12 @@ int tpm_pay(tolling_info_t* info, void** security_socket, uint8_t* neighbour, ui tolling->protocol.p == TOLLING_PROTOCOL_SIMPLE ? "TR.packet.btp" : "TR.packet.tcp"); // Retransmission + uint64_t now = itss_ts_get(TIME_MICROSECONDS); if (!tolling->station.obu.rt_on) { - tolling->station.obu.rt_init = itss_ts_get(TIME_MICROSECONDS); + tolling->station.obu.rt_init = now; tolling->station.obu.rt_on = true; } - tolling->station.obu.rt_t_trigger = itss_ts_get(TIME_MICROSECONDS); + tolling->station.obu.rt_t_trigger = now; // Logging if (facilities.logging.dbms) { @@ -1267,7 +1269,7 @@ int tpm_recv(TPM_t* tpm_rx, void** security_socket, uint8_t* neighbour, uint8_t* goto cleanup; } itss_time_lock(); - log_info("[tolling] entry.reply took %lld us", itss_ts_get(TIME_MICROSECONDS) - tolling->station.obu.rt_init); + log_info("[tolling] entry.reply took %lld us", itss_ts_get(TIME_MICROSECONDS) - tolling->station.obu.t_init); itss_time_unlock(); tolling->station.obu.rt_on = false; veh_handle_recv(tolling, tpm_rx, security_socket, facilities.tx_queue, neighbour, src_addr); @@ -1295,7 +1297,7 @@ int tpm_recv(TPM_t* tpm_rx, void** security_socket, uint8_t* neighbour, uint8_t* goto cleanup; } itss_time_lock(); - log_info("[tolling] exit.reply took %lld us", itss_ts_get(TIME_MICROSECONDS) - tolling->station.obu.rt_init); + log_info("[tolling] exit.reply took %lld us", itss_ts_get(TIME_MICROSECONDS) - tolling->station.obu.t_init); itss_time_unlock(); tolling->station.obu.rt_on = false; veh_handle_recv(tolling, tpm_rx, security_socket, facilities.tx_queue, neighbour, src_addr); @@ -1320,7 +1322,7 @@ int tpm_recv(TPM_t* tpm_rx, void** security_socket, uint8_t* neighbour, uint8_t* goto cleanup; } itss_time_lock(); - log_info("[tolling] single.reply took %lld us", itss_ts_get(TIME_MICROSECONDS) - tolling->station.obu.rt_init); + log_info("[tolling] single.reply took %lld us", itss_ts_get(TIME_MICROSECONDS) - tolling->station.obu.t_init); itss_time_unlock(); tolling->station.obu.rt_on = false; veh_handle_recv(tolling, tpm_rx, security_socket, facilities.tx_queue, neighbour, src_addr); diff --git a/src/tpm.h b/src/tpm.h index 5bb24ad..4c7cfda 100644 --- a/src/tpm.h +++ b/src/tpm.h @@ -85,6 +85,8 @@ typedef struct tolling { uint64_t tls_conn_id; TPM_t* entry_proof; + uint64_t t_init; + // Retransmission uint64_t rt_init; uint64_t rt_t_trigger;