From ee9a752d7f2cb7ffcf55919459ac932023c4cb54 Mon Sep 17 00:00:00 2001 From: Isaac Shoebottom Date: Mon, 26 Feb 2024 07:23:13 -0400 Subject: [PATCH] Add net centric --- netcentric.py | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 netcentric.py diff --git a/netcentric.py b/netcentric.py new file mode 100644 index 0000000..8168565 --- /dev/null +++ b/netcentric.py @@ -0,0 +1,105 @@ +# Calculate internet checksum for any arbitrary length variable amount of binary numbers +def checksum(*args): + length = len(bin(args[0])) - 2 + result = 0 + for arg in args: + result += arg + if result > (2 ** length) - 1: + result = (result & ((2 ** length) - 1)) + 1 + return result ^ ((2 ** length) - 1) + + +def e2e_delay(P, L, N, R): + # P = propagation speed + # L = packet length + # N = number of packets + # R = transmission rate + return (P - 1) * (L / R) + N * (L / R) + + +def estimate_e2e_delay(PS, T): + # PS = packet size + # T = Throughput + return PS / T + + +def trans_delay(L, R): + # L = packet length + # R = transmission rate + return L / R + + +def prop_delay(P, L): + # P = propagation speed + # L = packet length + return P * L + + +def traffic_intensity(L, pps, R): + # L = packet length + # pps = packets per second + # R = transmission rate + return (L * pps) / R + + +def cs_time(N, F, U): + # N = Number of copies + # F = File size + # U = Server upload rate + return (N * F) / U + + +def cs_time_n_clients(N, F, U, D): + # N = Number of copies + # F = File size + # U = Server upload rate + # D = Client download rate + return max(cs_time(N, F, U), F / D) + + +def p2p_time(N, F, U, CD, D): + # N = Number of copies + # F = File size + # U = Server upload rate + # CU = Client upload rate + # D = Client download rate + return max((F / U), (N * F) / (U + (N * CD)), F / D) + + +def utilisation(L, R, RTT): + # L = packet length + # R = transmission rate + # RTT = round trip time + return (L / R) / (L / R + RTT) + + +def utilisation_pipeline(L, R, RTT, N): + # L = packet length + # R = transmission rate + # RTT = round trip time + # N = window size + return N / (1 + (RTT / (L / R))) + + +def print_byte_tables(): + print("Byte Conversion Table") + print("1 B = 8 bits") + print("kB = 1024 bytes") + print("MB = 1024 kB") + print("GB = 1024 MB") + print("TB = 1024 GB") + + +def man(): + print("checksum(0b, 0b,)") + print("e2e_delay(P, L, N, R)") + print("estimate_e2e_delay(PS, T)") + print("trans_delay(L, R)") + print("prop_delay(P, L)") + print("traffic_intensity(L, pps, R)") + print("cs_time(N, F, U)") + print("cs_time_n_clients(N, F, U, D)") + print("p2p_time(N, F, U, CD, D)") + print("utilisation(L, R, RTT)") + print("utilisation_pipeline(L, R, RTT, N)") + print("print_byte_tables()")