diff --git a/Docs/P2PImplementation.md b/Docs/P2PImplementation.md new file mode 100644 index 0000000..2b1132d --- /dev/null +++ b/Docs/P2PImplementation.md @@ -0,0 +1,48 @@ +# P2P Module Implementation +The peer to peer implementation was built from scratch. This is because other peer to peer +libraries were on the implementation of the Distributed hash table. At the current moment all +those heavy features are not needed because the objective is to search and list all possible servers +available. The limitation being that to be a part of the network the user has to know at least 1 +server and has to have DMZ enabled from the router if the user wants to act as a server out of the +users local network. The advantage of building from scratch makes the module super light and +possibility for custom functions and structs. The sub topics below will mention the +implementations of each functionality in depth. + +## IP Table +The ip table file is a json as the format with a list of servers ip addresses, latencies, downloads and +uploads speeds. The functions implemented include read +file, write file and remove duplicate IP addresses. The remove duplicate IP address function exists +because sometimes servers IP tables can have the same ip addresses as what the client has. The +path of the IP table json file is received from the configuration module. + +```json +{ + "ip_address": [ + { + "ipv4": "", + "latency": "", + "download": "", + "upload": "" + } + ] +} +``` + +## Speed Test +The speed test functions populate the fields which are latency, download, upload speed. Before the +speed test begins for each server IP address. The p2p module ensures that each server IP address +is pingable. If the server IP address is not pingable then it removes that IP address from the struct. + +### Latency +The latency is measured in milliseconds. The route /server_info is called from the +server and time it takes to provide a json response is recorded. + +### Download speed +The download speed is measured as (/