#1706 - Got the core Node class build and working with ARP and the ability to ping another node. Added some basic tests in. Next job is to create the Node subclasses. Then move ARP and ICMP into a service that is used by all nodes.

This commit is contained in:
Chris McCarthy
2023-08-02 21:54:21 +01:00
parent 3660e27c15
commit 897dbdf10c
23 changed files with 879 additions and 309 deletions

View File

@@ -0,0 +1,27 @@
from typing import Union
def convert_bytes_to_megabits(B: Union[int, float]) -> float: # noqa - Keep it as B as this is how Bytes are expressed
"""
Convert Bytes (file size) to Megabits (data transfer).
:param B: The file size in Bytes.
:return: File bits to transfer in Megabits.
"""
if isinstance(B, int):
B = float(B)
bits = B * 8.0
return bits / 1024.0**2.0
def convert_megabits_to_bytes(Mbits: Union[int, float]) -> float: # noqa - The same for Mbits
"""
Convert Megabits (data transfer) to Bytes (file size).
:param Mbits bits to transfer in Megabits.
:return: The file size in Bytes.
"""
if isinstance(Mbits, int):
Mbits = float(Mbits)
bits = Mbits * 1024.0**2.0
return bits / 8