diff --git a/pq-tls-benchmark-framework/emulation-exp/code/kex/scripts/queries.py b/pq-tls-benchmark-framework/emulation-exp/code/kex/scripts/queries.py index 46ca25fea8aa60753a62cc46db5bb0b430bfdb12..92424b4838434402567a72f610df8275bce900d3 100644 --- a/pq-tls-benchmark-framework/emulation-exp/code/kex/scripts/queries.py +++ b/pq-tls-benchmark-framework/emulation-exp/code/kex/scripts/queries.py @@ -12,7 +12,7 @@ def main(): data = pd.read_feather(f"{FEATHERS_DIR}/data.feather") # data = pd.read_feather(f"{FEATHERS_DIR}/data_run_20241028.feather") - p_no_one_sec_delay() + loss_calculations() # static_scenario_statistical_analysis(data) # median_of_all_static_runs_per_algorithm(data) # stats_of_qtl95_of_packetloss(data) @@ -23,11 +23,11 @@ def main(): # print_kem_ids() -def p_no_one_sec_delay(): +def loss_calculations(): udp_packets_df = pd.read_feather("feathers/udp_packets.feather") df = ap.get_packets_sent_by_node(udp_packets_df) - print("\n\n No one second delay") + print("\n\n Loss calculations") df = df.drop(columns=["length_public_key", "length_ciphertext"]) # print(df) df["cic"] = df["client_sent_packets_with_crypto_count"] - 1 @@ -39,9 +39,25 @@ def p_no_one_sec_delay(): ] ) + # p_noOneSec does not make sense if cic or sic is bigger than 10 -> look thesis df = df.query("cic <= 10 and sic <= 10") - def calc_p(cic, sic, l): + def calc_p_no_loss(cic, sic, l): + """ + Calculates the probability p_noLoss. + + Args: + cic: client initial count. + sic: server initial count. + l: loss probability. + + Returns: + p_noLoss as defined in the thesis. + """ + + return (1 - l) ** (cic + sic) + + def calc_p_no_one_sec_delay(cic, sic, l): """ Calculates the probability p_noOneSec. @@ -65,15 +81,40 @@ def p_no_one_sec_delay(): return term1 + term2 - # print(df) + def calc_l_for_no_loss_p(cic, sic, p): + """ + Calculates the loss probability l for a p_noLoss of 0.95. + + Args: + cic: client initial count. + sic: server initial count. + p: probability. + + Returns: + l as defined in the thesis. + """ + + return 1 - (p ** (1 / (cic + sic))) for l in [0.01, 0.05, 0.10, 0.20]: + df[f"p_noLoss_{l}"] = df.apply( + lambda row: calc_p_no_loss(row["cic"], row["sic"], l), axis=1 + ) df[f"p_noOneSec_{l}"] = df.apply( - lambda row: calc_p(row["cic"], row["sic"], l), axis=1 + lambda row: calc_p_no_one_sec_delay(row["cic"], row["sic"], l), axis=1 ) + df["l_for_noLoss_p50"] = df.apply( + lambda row: calc_l_for_no_loss_p(row["cic"], row["sic"], 0.50), axis=1 + ) + df["l_for_noLoss_p95"] = df.apply( + lambda row: calc_l_for_no_loss_p(row["cic"], row["sic"], 0.95), axis=1 + ) + print(df) + return df + def static_scenario_statistical_analysis(data): ldata = data