Skip to content
Snippets Groups Projects
Commit 7d8a1c12 authored by Bartolomeo Berend Müller's avatar Bartolomeo Berend Müller
Browse files

Added loss calcs

parent f1bfc78a
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ def main(): ...@@ -12,7 +12,7 @@ def main():
data = pd.read_feather(f"{FEATHERS_DIR}/data.feather") data = pd.read_feather(f"{FEATHERS_DIR}/data.feather")
# data = pd.read_feather(f"{FEATHERS_DIR}/data_run_20241028.feather") # data = pd.read_feather(f"{FEATHERS_DIR}/data_run_20241028.feather")
p_no_one_sec_delay() loss_calculations()
# static_scenario_statistical_analysis(data) # static_scenario_statistical_analysis(data)
# median_of_all_static_runs_per_algorithm(data) # median_of_all_static_runs_per_algorithm(data)
# stats_of_qtl95_of_packetloss(data) # stats_of_qtl95_of_packetloss(data)
...@@ -23,11 +23,11 @@ def main(): ...@@ -23,11 +23,11 @@ def main():
# print_kem_ids() # print_kem_ids()
def p_no_one_sec_delay(): def loss_calculations():
udp_packets_df = pd.read_feather("feathers/udp_packets.feather") udp_packets_df = pd.read_feather("feathers/udp_packets.feather")
df = ap.get_packets_sent_by_node(udp_packets_df) 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"]) df = df.drop(columns=["length_public_key", "length_ciphertext"])
# print(df) # print(df)
df["cic"] = df["client_sent_packets_with_crypto_count"] - 1 df["cic"] = df["client_sent_packets_with_crypto_count"] - 1
...@@ -39,9 +39,25 @@ def p_no_one_sec_delay(): ...@@ -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") 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. Calculates the probability p_noOneSec.
...@@ -65,15 +81,40 @@ def p_no_one_sec_delay(): ...@@ -65,15 +81,40 @@ def p_no_one_sec_delay():
return term1 + term2 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]: 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( 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) print(df)
return df
def static_scenario_statistical_analysis(data): def static_scenario_statistical_analysis(data):
ldata = data ldata = data
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment