From 2d55643dd9e98fe5913067c9e560b4598e0d654a Mon Sep 17 00:00:00 2001 From: Akilan Date: Fri, 30 May 2025 11:59:32 +0100 Subject: [PATCH 1/5] removed heavy WASM binary --- Simulation/simulation.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 Simulation/simulation.sh diff --git a/Simulation/simulation.sh b/Simulation/simulation.sh new file mode 100644 index 0000000..036fa95 --- /dev/null +++ b/Simulation/simulation.sh @@ -0,0 +1,39 @@ +# Spin up seperate P2PRC instances + +# Unset P2PRC +unset P2PRC + + +# Create P2PRC instances +# Parameters: +# 1. Number of nodes +P2PRC_instances() { + local rootPort + for (( counter=0; counter<$1; counter++ )); do + mkdir test-$counter/ + cd test-$counter/ + p2prc --dc + + # change port no + NEW_PORT=$(shuf -i 2000-65000 -n 1) + + if [ counter == 0 ]; then + rootPort = $NEW_PORT + fi + + echo $rootPort + + p2prc --arn --ip 0.0.0.0 --port $rootPort + + sed -i.bak "s/\"ServerPort\": \"[0-9]*\"/\"ServerPort\": \"$NEW_PORT\"/" "./config.json" + + p2prc --ls + + cd .. + done + + # remove all instances + rm -rf test-* +} + +P2PRC_instances 2 From a46ec3575c2ad4e2b316dbf7bb07e70928fa52f6 Mon Sep 17 00:00:00 2001 From: Akilan Date: Fri, 30 May 2025 16:23:39 +0100 Subject: [PATCH 2/5] Simulation base code --- Simulation/simulation.sh | 110 +++++++-- client/clientIPTable/Iptable.go | 318 ++++++++++++------------- config/config.go | 1 + config/generate/generate.go | 1 + config/generate/generateCertificate.go | 4 +- p2p/iptable.go | 12 + server/server.go | 1 + 7 files changed, 271 insertions(+), 176 deletions(-) diff --git a/Simulation/simulation.sh b/Simulation/simulation.sh index 036fa95..5dd43cd 100644 --- a/Simulation/simulation.sh +++ b/Simulation/simulation.sh @@ -1,39 +1,119 @@ -# Spin up seperate P2PRC instances - # Unset P2PRC unset P2PRC - # Create P2PRC instances # Parameters: # 1. Number of nodes P2PRC_instances() { - local rootPort + local rootPort="" for (( counter=0; counter<$1; counter++ )); do - mkdir test-$counter/ + mkdir test-$counter/ cd test-$counter/ - p2prc --dc - # change port no + # Generate a new random port NEW_PORT=$(shuf -i 2000-65000 -n 1) - if [ counter == 0 ]; then - rootPort = $NEW_PORT + # Initialize node + p2prc --dc + + # Save rootPort from the first node + if [[ $counter -eq 0 ]]; then + rootPort=$NEW_PORT fi - echo $rootPort + echo "Root port: $rootPort" + echo "This node's port: $NEW_PORT" - p2prc --arn --ip 0.0.0.0 --port $rootPort + # Set root port + p2prc --arn --ip 0.0.0.0 -p "$rootPort" + # add current node + p2prc --as 0.0.0.0 -p "$NEW_PORT" + + # Replace the ServerPort in config sed -i.bak "s/\"ServerPort\": \"[0-9]*\"/\"ServerPort\": \"$NEW_PORT\"/" "./config.json" + sed -i.bak "s/\"Test\": false/\"Test\": true/" "./config.json" + sed -i.bak "s/\"BehindNAT\": true/\"BehindNAT\": false/" "./config.json" + cat config.json + + # List services p2prc --ls cd .. - done + done - # remove all instances - rm -rf test-* + # remove all instances after testing (optional — might want to comment this during testing) + # rm -rf test-* } -P2PRC_instances 2 +# Arrays of process IDs +pids=() + +# Calls all the P2PRC instances created for testing +Start_all_instances() { + for (( counter=0; counter<$1; counter++ )); do + cd test-$counter/ + # Start P2PRC as background process + p2prc -s & + pids+=($!) + cd .. + done +} + +# Kills all P2PRC instances +Kill_all_instances() { + for pid in "${pids[@]}"; do + kill "$pid" + echo "Killed process $pid" + done +} + +# Removes all test files created +Remove_all_test_files() { + rm -rf test-* +} + +# List ip tables of all nodes started +IP_Tables_after_Started() { + for (( counter=0; counter<$1; counter++ )); do + cd test-$counter/ + p2prc --ls + cd .. + done +} + +Update_All_IP_Tables() { + for (( counter=0; counter<$1; counter++ )); do + cd test-$counter/ + p2prc --us + cd .. + done +} + + +# ---------------- Work flow test --------------- + +# Unset default P2PRC env path +unset P2PRC + +# Run with 2 nodes +P2PRC_instances 3 + +# Start instances +Start_all_instances 3 + +# Delay for instances to run +sleep 6 + +# update all instances ip table +#Update_All_IP_Tables 3 + +# List ip tables of nodes started +IP_Tables_after_Started 3 + +# Remove test files created +Remove_all_test_files + +# Kill all instances +Kill_all_instances diff --git a/client/clientIPTable/Iptable.go b/client/clientIPTable/Iptable.go index 204bbf0..6a56cd4 100644 --- a/client/clientIPTable/Iptable.go +++ b/client/clientIPTable/Iptable.go @@ -1,16 +1,16 @@ package clientIPTable import ( - "encoding/json" - "fmt" - "github.com/Akilan1999/p2p-rendering-computation/config" - "github.com/Akilan1999/p2p-rendering-computation/p2p" - "io" - "io/ioutil" - "mime/multipart" - "net/http" - "os" - "sync" + "encoding/json" + "fmt" + "github.com/Akilan1999/p2p-rendering-computation/config" + "github.com/Akilan1999/p2p-rendering-computation/p2p" + "io" + "io/ioutil" + "mime/multipart" + "net/http" + "os" + "sync" ) var mu sync.Mutex @@ -18,146 +18,146 @@ var mu sync.Mutex // UpdateIpTable Does the following to update it's IP table func UpdateIpTable(IpAddress string, serverPort string, wg *sync.WaitGroup) error { - config, err := config.ConfigInit(nil, nil) - if err != nil { - return err - } + config, err := config.ConfigInit(nil, nil) + if err != nil { + return err + } - client := http.Client{} + client := http.Client{} - var resp []byte + var resp []byte - version := p2p.Ip4or6(IpAddress) - if version == "version 6" { - resp, err = UploadMultipartFile(client, "http://["+IpAddress+"]:"+serverPort+"/IpTable", "json", config.IPTable) - if err != nil { - return err - } - } else { - resp, err = UploadMultipartFile(client, "http://"+IpAddress+":"+serverPort+"/IpTable", "json", config.IPTable) - if err != nil { - return err - } - } + version := p2p.Ip4or6(IpAddress) + if version == "version 6" { + resp, err = UploadMultipartFile(client, "http://["+IpAddress+"]:"+serverPort+"/IpTable", "json", config.IPTable) + if err != nil { + return err + } + } else { + resp, err = UploadMultipartFile(client, "http://"+IpAddress+":"+serverPort+"/IpTable", "json", config.IPTable) + if err != nil { + return err + } + } - if resp == nil { - return nil - } + if resp == nil { + return nil + } - //resp, err := SendPostRequest("http://"+IpAddress+":8088/IpTable", - // config.IPTable, - // "json") - // - //if err != nil { - // return err - //} + //resp, err := SendPostRequest("http://"+IpAddress+":8088/IpTable", + // config.IPTable, + // "json") + // + //if err != nil { + // return err + //} - var ipStruct p2p.IpAddresses - json.Unmarshal(resp, &ipStruct) + var ipStruct p2p.IpAddresses + json.Unmarshal(resp, &ipStruct) - // Updates IP table based on information provided - // by the server - if len(ipStruct.IpAddress) > 0 { - err = ipStruct.SpeedTestUpdatedIPTable() - if err != nil { - return err - } - } + // Updates IP table based on information provided + // by the server + if len(ipStruct.IpAddress) > 0 { + err = ipStruct.SpeedTestUpdatedIPTable() + if err != nil { + return err + } + } - // Not required to update IP table as speed test updates the IP Table - //err = ipStruct.WriteIpTable() - //if err != nil { - // return err - //} + // Not required to update IP table as speed test updates the IP Table + //err = ipStruct.WriteIpTable() + //if err != nil { + // return err + //} - wg.Done() + wg.Done() - return nil + return nil } // UpdateIpTableListClient updates IP tables (Default 3 hops) based on server information available // on the ip tables func UpdateIpTableListClient() error { - // Get config information - Config, err := config.ConfigInit(nil, nil) - if err != nil { - return err - } + // Get config information + Config, err := config.ConfigInit(nil, nil) + if err != nil { + return err + } - // Ensure that the IP Table has Node pingable - err = p2p.LocalSpeedTestIpTable() - if err != nil { - return err - } + // Ensure that the IP Table has Node pingable + err = p2p.LocalSpeedTestIpTable() + if err != nil { + return err + } - // IP addresses to not append to struct due to - // duplication + // IP addresses to not append to struct due to + // duplication - Addresses, err := p2p.ReadIpTable() - var DoNotRead p2p.IpAddresses + Addresses, err := p2p.ReadIpTable() + var DoNotRead p2p.IpAddresses - currentIPV4, err := p2p.CurrentPublicIP() - if err != nil { - return err - } + currentIPV4, err := p2p.CurrentPublicIP() + if err != nil { + return err + } - var w sync.WaitGroup + var w sync.WaitGroup - // Run loop 2 times - for i := 0; i < 2; i++ { - // Gets information from IP table - Addresses, err = p2p.ReadIpTable() - if err != nil { - return err - } + // Run loop 2 times + for i := 0; i < 2; i++ { + // Gets information from IP table + Addresses, err = p2p.ReadIpTable() + if err != nil { + return err + } - //DoNotRead.IpAddress = append(DoNotRead.IpAddress, PublicIP) + //DoNotRead.IpAddress = append(DoNotRead.IpAddress, PublicIP) - // Updates IP table based on server IP table - for j := range Addresses.IpAddress { + // Updates IP table based on server IP table + for j := range Addresses.IpAddress { - Exists := false - // If the address is local then add to the local list - if currentIPV4 == Addresses.IpAddress[j].Ipv4 && Addresses.IpAddress[j].ServerPort == Config.ServerPort { - Exists = true - } + Exists := false + // If the address is local then add to the local list + if currentIPV4 == Addresses.IpAddress[j].Ipv4 && Addresses.IpAddress[j].ServerPort == Config.ServerPort { + Exists = true + } - // Check if IP addresses is there in the struct DoNotRead - for k := range DoNotRead.IpAddress { - if (DoNotRead.IpAddress[k].Ipv4 == Addresses.IpAddress[j].Ipv4 && DoNotRead.IpAddress[k].ServerPort == Addresses.IpAddress[j].ServerPort) || (DoNotRead.IpAddress[k].Ipv6 != "" && Addresses.IpAddress[j].Ipv6 == DoNotRead.IpAddress[k].Ipv6) { - Exists = true - break - } - } + // Check if IP addresses is there in the struct DoNotRead + for k := range DoNotRead.IpAddress { + if (DoNotRead.IpAddress[k].Ipv4 == Addresses.IpAddress[j].Ipv4 && DoNotRead.IpAddress[k].ServerPort == Addresses.IpAddress[j].ServerPort) || (DoNotRead.IpAddress[k].Ipv6 != "" && Addresses.IpAddress[j].Ipv6 == DoNotRead.IpAddress[k].Ipv6) { + Exists = true + break + } + } - // If the struct exists then continues - if Exists { - continue - } + // If the struct exists then continues + if Exists { + continue + } - w.Add(1) - if Addresses.IpAddress[j].Ipv6 != "" { - go UpdateIpTable(Addresses.IpAddress[j].Ipv6, Addresses.IpAddress[j].ServerPort, &w) - } else if Addresses.IpAddress[j].Ipv4 != currentIPV4 { - go UpdateIpTable(Addresses.IpAddress[j].Ipv4, Addresses.IpAddress[j].ServerPort, &w) - } - w.Wait() + w.Add(1) + if Addresses.IpAddress[j].Ipv6 != "" { + go UpdateIpTable(Addresses.IpAddress[j].Ipv6, Addresses.IpAddress[j].ServerPort, &w) + } else if Addresses.IpAddress[j].Ipv4 != currentIPV4 { + go UpdateIpTable(Addresses.IpAddress[j].Ipv4, Addresses.IpAddress[j].ServerPort, &w) + } + w.Wait() - //Appends server1 IP address to variable DoNotRead - DoNotRead.IpAddress = append(DoNotRead.IpAddress, Addresses.IpAddress[j]) - } - } + //Appends server1 IP address to variable DoNotRead + DoNotRead.IpAddress = append(DoNotRead.IpAddress, Addresses.IpAddress[j]) + } + } - return nil + return nil } func RemoveOfflineNodes() error { - // Ensure that the IP Table has Node pingable - err := p2p.LocalSpeedTestIpTable() - if err != nil { - return err - } - return nil + // Ensure that the IP Table has Node pingable + err := p2p.LocalSpeedTestIpTable() + if err != nil { + return err + } + return nil } // SendPostRequest Sends a file as a @@ -207,58 +207,58 @@ func RemoveOfflineNodes() error { //} func UploadMultipartFile(client http.Client, uri, key, path string) ([]byte, error) { - body, writer := io.Pipe() + body, writer := io.Pipe() - req, err := http.NewRequest(http.MethodPost, uri, body) - if err != nil { - return nil, err - } + req, err := http.NewRequest(http.MethodPost, uri, body) + if err != nil { + return nil, err + } - mwriter := multipart.NewWriter(writer) - req.Header.Add("Content-Type", mwriter.FormDataContentType()) + mwriter := multipart.NewWriter(writer) + req.Header.Add("Content-Type", mwriter.FormDataContentType()) - errchan := make(chan error) + errchan := make(chan error) - go func() { - defer close(errchan) - defer writer.Close() - defer mwriter.Close() + go func() { + defer close(errchan) + defer writer.Close() + defer mwriter.Close() - w, err := mwriter.CreateFormFile(key, path) - if err != nil { - errchan <- err - return - } + w, err := mwriter.CreateFormFile(key, path) + if err != nil { + errchan <- err + return + } - in, err := os.Open(path) - if err != nil { - errchan <- err - return - } - defer in.Close() + in, err := os.Open(path) + if err != nil { + errchan <- err + return + } + defer in.Close() - if written, err := io.Copy(w, in); err != nil { - errchan <- fmt.Errorf("error copying %s (%d bytes written): %v", path, written, err) - return - } + if written, err := io.Copy(w, in); err != nil { + errchan <- fmt.Errorf("error copying %s (%d bytes written): %v", path, written, err) + return + } - if err := mwriter.Close(); err != nil { - errchan <- err - return - } - }() + if err := mwriter.Close(); err != nil { + errchan <- err + return + } + }() - resp, err := client.Do(req) - if err != nil { - return nil, err - } + resp, err := client.Do(req) + if err != nil { + return nil, err + } - content, err := ioutil.ReadAll(resp.Body) + content, err := ioutil.ReadAll(resp.Body) - if err != nil { - return nil, err - } + if err != nil { + return nil, err + } - return content, nil + return content, nil } diff --git a/config/config.go b/config/config.go index b05af12..76a41cf 100644 --- a/config/config.go +++ b/config/config.go @@ -38,6 +38,7 @@ type Config struct { KeyFile string BareMetal bool UnsafeMode bool + Test bool CustomConfig interface{} //NetworkInterface string //NetworkInterfaceIPV6Index int diff --git a/config/generate/generate.go b/config/generate/generate.go index 7d8228c..b6254f8 100644 --- a/config/generate/generate.go +++ b/config/generate/generate.go @@ -95,6 +95,7 @@ func SetDefaults(envName string, forceDefault bool, CustomConfig interface{}, No Defaults.PrivateKeyFile = defaultPath + "p2prc.privateKey" Defaults.BareMetal = false Defaults.UnsafeMode = false + Defaults.Test = false // Generate certificate files for SSL err = GenerateCertificate() diff --git a/config/generate/generateCertificate.go b/config/generate/generateCertificate.go index 3031777..456da12 100644 --- a/config/generate/generateCertificate.go +++ b/config/generate/generateCertificate.go @@ -16,7 +16,6 @@ import ( "crypto/x509" "crypto/x509/pkix" "encoding/pem" - "github.com/Akilan1999/p2p-rendering-computation/p2p" "log" "math/big" "net" @@ -54,7 +53,8 @@ func GenerateCertificate() error { //flag.Parse() - host, err = p2p.CurrentPublicIP() + //host, err = p2p.CurrentPublicIP() + host = "0.0.0.0" if err != nil { return err diff --git a/p2p/iptable.go b/p2p/iptable.go index 082ece2..d64e203 100644 --- a/p2p/iptable.go +++ b/p2p/iptable.go @@ -42,6 +42,8 @@ type IP struct { Query string } +var Test = false + // ReadIpTable Read data from Ip tables from json file func ReadIpTable() (*IpAddresses, error) { // Get Path from config @@ -178,6 +180,16 @@ func (table *IpAddresses) RemoveDuplicates() error { // CurrentPublicIP Get Current Public IP address func CurrentPublicIP() (string, error) { + // Get configs + Config, err := config.ConfigInit(nil, nil) + if err != nil { + return "", err + } + // If test mode is on then return local address + if Config.Test { + return "0.0.0.0", nil + } + req, err := http.Get("http://ip-api.com/json/") if err != nil { return "", err diff --git a/server/server.go b/server/server.go index 0e3ec1c..33063fe 100644 --- a/server/server.go +++ b/server/server.go @@ -312,6 +312,7 @@ func Server() (*gin.Engine, error) { if err != nil { fmt.Println(err) } + ProxyIpAddr.ServerPort = config.ServerPort ProxyIpAddr.Name = config.MachineName ProxyIpAddr.NAT = false From 02e58493f51ec31f35bd687e9dcb5d841b63c999 Mon Sep 17 00:00:00 2001 From: Akilan Date: Fri, 30 May 2025 17:09:36 +0100 Subject: [PATCH 3/5] added working version of simulator --- Simulation/simulation.sh | 25 +++++++++++++------------ client/clientIPTable/Iptable.go | 13 +++++++------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Simulation/simulation.sh b/Simulation/simulation.sh index 5dd43cd..eea9c74 100644 --- a/Simulation/simulation.sh +++ b/Simulation/simulation.sh @@ -57,6 +57,7 @@ Start_all_instances() { # Start P2PRC as background process p2prc -s & pids+=($!) + sleep 3 cd .. done } @@ -100,20 +101,20 @@ unset P2PRC # Run with 2 nodes P2PRC_instances 3 -# Start instances +## Start instances Start_all_instances 3 +# +## Delay for instances to run -# Delay for instances to run -sleep 6 - -# update all instances ip table -#Update_All_IP_Tables 3 - -# List ip tables of nodes started +# +## update all instances ip table +##Update_All_IP_Tables 3 +# +## List ip tables of nodes started IP_Tables_after_Started 3 - -# Remove test files created +# +## Remove test files created Remove_all_test_files - -# Kill all instances +# +## Kill all instances Kill_all_instances diff --git a/client/clientIPTable/Iptable.go b/client/clientIPTable/Iptable.go index 6a56cd4..6b6967a 100644 --- a/client/clientIPTable/Iptable.go +++ b/client/clientIPTable/Iptable.go @@ -118,7 +118,7 @@ func UpdateIpTableListClient() error { Exists := false // If the address is local then add to the local list - if currentIPV4 == Addresses.IpAddress[j].Ipv4 && Addresses.IpAddress[j].ServerPort == Config.ServerPort { + if (currentIPV4 == Addresses.IpAddress[j].Ipv4 && !Config.Test) && Addresses.IpAddress[j].ServerPort == Config.ServerPort { Exists = true } @@ -136,11 +136,12 @@ func UpdateIpTableListClient() error { } w.Add(1) - if Addresses.IpAddress[j].Ipv6 != "" { - go UpdateIpTable(Addresses.IpAddress[j].Ipv6, Addresses.IpAddress[j].ServerPort, &w) - } else if Addresses.IpAddress[j].Ipv4 != currentIPV4 { - go UpdateIpTable(Addresses.IpAddress[j].Ipv4, Addresses.IpAddress[j].ServerPort, &w) - } + //if Addresses.IpAddress[j].Ipv6 != "" { + // go UpdateIpTable(Addresses.IpAddress[j].Ipv6, Addresses.IpAddress[j].ServerPort, &w) + //} else if Addresses.IpAddress[j].Ipv4 != currentIPV4 { + // //go UpdateIpTable(Addresses.IpAddress[j].Ipv4, Addresses.IpAddress[j].ServerPort, &w) + //} + go UpdateIpTable(Addresses.IpAddress[j].Ipv4, Addresses.IpAddress[j].ServerPort, &w) w.Wait() //Appends server1 IP address to variable DoNotRead From 0e260cf8e49cf2baaccec7ae4ff8d3e9274093a7 Mon Sep 17 00:00:00 2001 From: Akilan Date: Fri, 30 May 2025 17:10:54 +0100 Subject: [PATCH 4/5] Made simulation simple --- Simulation/simulation.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Simulation/simulation.sh b/Simulation/simulation.sh index eea9c74..d42c2e9 100644 --- a/Simulation/simulation.sh +++ b/Simulation/simulation.sh @@ -103,18 +103,12 @@ P2PRC_instances 3 ## Start instances Start_all_instances 3 -# -## Delay for instances to run -# -## update all instances ip table -##Update_All_IP_Tables 3 -# ## List ip tables of nodes started IP_Tables_after_Started 3 # ## Remove test files created Remove_all_test_files -# + ## Kill all instances Kill_all_instances From 99c9c41528bfe0b2355530f8433ba12a185d418e Mon Sep 17 00:00:00 2001 From: Akilan Date: Fri, 30 May 2025 18:06:32 +0100 Subject: [PATCH 5/5] Documentation for Simulation added --- Docs/index.html | 265 +++++++++++++++++++++++++++++++----------------- Docs/index.org | 54 +++++++++- 2 files changed, 221 insertions(+), 98 deletions(-) diff --git a/Docs/index.html b/Docs/index.html index b66adba..624be17 100644 --- a/Docs/index.html +++ b/Docs/index.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + @@ -26,12 +26,12 @@

Table of Contents

-
+

Colored-On-Light-Image.png

-
-

1. Guide through video

+
+

1. Guide through video

-
-

1.0.1. The video below shows the setup and usage of P2PRC.

+
+

1.0.1. The video below shows the setup and usage of P2PRC.

-
+

maxresdefault.jpg

-
@@ -259,7 +265,7 @@ Go API to create and interact with the containers. to install docker GPU

-
+
 // Do ensure that the docker command does not need sudo to run
 sudo chmod 666 /var/run/docker.sock
 
@@ -273,7 +279,7 @@ To set up the internal dependencies and build the entire go code into a single binary

-
+
 make
 
@@ -285,7 +291,7 @@ To set up P2PRC on Windows, simply run this batch file. Make sure you are not in admin mode when running this.

-
+
 .\install.bat
 
@@ -295,7 +301,7 @@ are not in admin mode when running this.

3.2.4. Add appropriate paths to .bashrc

-
+
 export P2PRC=/<PATH>/p2p-rendering-computation
 export PATH=/<PATH>/p2p-rendering-computation:${PATH}
 
@@ -304,14 +310,14 @@ export PATH=/<PATH>/p2p-rendering-computation:${PATH}

3.2.5. Test if binary works

-
+
 p2prc --help
 
  1. Output:
    -
    +
     NAME:
        p2p-rendering-computation - p2p cli application to create and access VMs in other servers
     
    @@ -373,7 +379,7 @@ GLOBAL OPTIONS:
     

    4.0.1. Start as a server

    -
    +
     p2prc -s 
     
    @@ -381,7 +387,7 @@ p2prc -s

    4.0.2. View server Specification

    -
    +
     p2prc --specs=<ip address>
     
    @@ -393,7 +399,7 @@ p2prc --specs=<ip address> use the --gpu if you know the other machine has a gpu.

    -
    +
     p2prc --touch=<server ip address> -p <number of ports> --gpu
     
    @@ -405,7 +411,7 @@ p2prc --touch=<server ip address> -p <number of ports> --gpu The docker id is present in the output where you create a container

    -
    +
     p2prc --rm=<server ip address> --id=<docker container id> 
     
    @@ -413,7 +419,7 @@ p2prc --rm=<server ip address> --id=<docker container id>

    4.0.5. Adding servers to ip table

    -
    +
     p2prc --as=<server ip address you want to add> 
     
    @@ -421,7 +427,7 @@ p2prc --as=<server ip address you want to add>

    4.0.6. Update ip table

    -
    +
     p2prc --us 
     
    @@ -429,7 +435,7 @@ p2prc --us

    4.0.7. List Servers

    -
    +
     p2prc --ls 
     
    @@ -437,7 +443,7 @@ p2prc --ls

    4.0.8. View Network interfaces

    -
    +
     p2prc --ni
     
    @@ -445,7 +451,7 @@ p2prc --ni

    4.0.9. Viewing Containers created Client side

    -
    +
     p2prc --tc
     
    @@ -453,7 +459,7 @@ p2prc --tc

    4.0.10. Running plugin

    -
    +
     p2prc --plugin <plugin name> --id <container id or group id>
     
    @@ -461,7 +467,7 @@ p2prc --plugin <plugin name> --id <container id or group id>

    4.0.11. Create group

    -
    +
     p2prc --cgroup
     
    @@ -469,7 +475,7 @@ p2prc --cgroup

    4.0.12. Add container to group

    -
    +
     p2prc --group <group id> --id <container id>
     
    @@ -477,7 +483,7 @@ p2prc --group <group id> --id <container id>

    4.0.13. View groups

    -
    +
     p2prc --groups
     
    @@ -485,7 +491,7 @@ p2prc --groups

    4.0.14. View specific group

    -
    +
     p2prc --group <group id>
     
    @@ -493,7 +499,7 @@ p2prc --group <group id>

    4.0.15. Delete container from group

    -
    +
     p2prc --rmcgroup --group <group id> --id <container id> 
     
    @@ -501,7 +507,7 @@ p2prc --rmcgroup --group <group id> --id <container id>

    4.0.16. Delete entire group

    -
    +
     p2prc --rmgroup <group id>
     
    @@ -509,7 +515,7 @@ p2prc --rmgroup <group id>

    4.0.17. Pulling plugin from a remote repo

    -
    +
     p2prc --pp <repo link>
     
    @@ -517,7 +523,7 @@ p2prc --pp <repo link>

    4.0.18. Deleting plugin from the plugin directory

    -
    +
     p2prc --rp <plugin name> 
     
    @@ -525,28 +531,28 @@ p2prc --rp <plugin name>

    4.0.19. Added custom metadata about the current node

    -
    +
     p2prc --amd "custom metadata"
     
    -
    -

    4.0.20. MapPort and link to domain name

    +
    +

    4.0.20. MapPort and link to domain name

    Allows to expose remote ports from a machine in the P2P network.

    -
    +
     p2prc --mp <port no to map> --dn <domain name to link Mapped port against>
     
      -
    1. MapPort in remote machine
      +
    2. MapPort in remote machine

      This is to ensure ports on remote machines on the P2PRC can be easily opened.

      -
      +
       p2prc --mp <port no to map> --dn <domain name to link Mapped port against> --ra <remote server address>
       
      @@ -555,15 +561,15 @@ p2prc --mp <port no to map> --dn <domain name to link Mapped port again
    -
    -

    4.0.21. Add root node

    +
    +

    4.0.21. Add root node

    Adds a root node to P2RRC and overwrites all other nodes in the ip table. To be only added before the network is started and with the intention of a fresh instance.

    -
    +
     p2prc --arn --ip <root node ip address> -p <root node port no>
     
    @@ -674,7 +680,7 @@ from the TURN server. The flow below describes the workflow.
  2. Call /FRPPort
  3. -
    +
     http://<turn server ip>:<server port no>/FRPport
     
    @@ -763,7 +769,7 @@ p2prc.h p2prc.so Below are a sample set of commands to open the bindings implementation.

    -
    +
     # run
     cd Bindings/
     # list files
    @@ -851,7 +857,7 @@ that convert a go object to JSON string initially and converts it to
     
  4. A Pseudo code to refer to the common function implementation shape could be represented as:
    -
    +
     func <Function name> (output *C.char) {
           <response>,<error> := <P2PRC function name>(<parameters if needed>)
           if <error> != nil {
    @@ -869,8 +875,8 @@ func <Function name> (output *C.char) {
     

    6.3. Current languages supported

    -
    -

    6.3.1. Python

    +
    +

    6.3.1. Python

      @@ -907,8 +913,8 @@ called from other programming languages.
    -
    -

    6.3.2. Haskell

    +
    +

    6.3.2. Haskell

    P2PRC officially supports Haskell bindings and will further support @@ -943,18 +949,28 @@ configuration file was generated using JSON format.

    {
    - "MachineName": "pc-74-120.customer.ask4.lan",
    + "MachineName": "Akilans-MacBook-Pro.local-975261X",
      "IPTable": "/Users/akilan/Documents/p2p-rendering-computation/p2p/iptable/ip_table.json",
      "DockerContainers": "/Users/akilan/Documents/p2p-rendering-computation/server/docker/containers/",
      "DefaultDockerFile": "/Users/akilan/Documents/p2p-rendering-computation/server/docker/containers/docker-ubuntu-sshd/",
    + "DockerRunLogs": "/tmp/",
      "SpeedTestFile": "/Users/akilan/Documents/p2p-rendering-computation/p2p/50.bin",
      "IPV6Address": "",
      "PluginPath": "/Users/akilan/Documents/p2p-rendering-computation/plugin/deploy",
      "TrackContainersPath": "/Users/akilan/Documents/p2p-rendering-computation/client/trackcontainers/trackcontainers.json",
      "ServerPort": "8088",
    + "ProxyPort": "",
      "GroupTrackContainersPath": "/Users/akilan/Documents/p2p-rendering-computation/client/trackcontainers/grouptrackcontainers.json",
    - "FRPServerPort": "True",
    - "BehindNAT": "True",
    + "FRPServerPort": true,
    + "BehindNAT": true,
    + "IPTableKey": "QH3yQrGRe2X4",
    + "PublicKeyFile": "/Users/akilan/Documents/p2p-rendering-computation/p2prc.publicKey",
    + "PrivateKeyFile": "/Users/akilan/Documents/p2p-rendering-computation/p2prc.privateKey",
    + "PemFile": "/Users/akilan/Documents/p2p-rendering-computation/cert.pem",
    + "KeyFile": "/Users/akilan/Documents/p2p-rendering-computation/key.pem",
    + "BareMetal": false,
    + "UnsafeMode": false,
    + "Test": false,
      "CustomConfig": null
     }
     
    @@ -1020,7 +1036,7 @@ from the TURN server. The flow below describes the workflow.
  5. Call /FRPPort
  6. -
    +
     http://<turn server ip>:<server port no>/FRPport
     
    @@ -1051,14 +1067,73 @@ func main() {
    -
    -

    11. Blog posts

    +
    +

    11. Simulation

    +

    +The simulation library is a really simple library to locally +run serveral instances of P2PRC to test the functionality +of sending information through the network and particularly +the Node discovery mechanism. There are current 5 commands +which can be used as shown below: +

    -
    -

    11.1. Self host within 5 minutes any program

    +
    +

    11.1. Command

      +
    • P2PRC instances "number of instances" : Starts p2prc processes +based on the number of number instances provided. This includes +creating temporary folders with independent IPTables.
    • +
    • Start all instances "number of instances": Starts the P2PRC instances +created. This function enters into the instance directory and runs +```p2prc -s &``` with a delay for approximately 3 seconds. This allows +each independent created node to learn about each other.
    • +
    • IP Tables after Started number of instances": Prints the IPTable of +each independant node.
    • +
    • Remove all test files: Removes all test files created which needed for +testing the generated P2PRC instances.
    • +
    • Kill all instances: Kills all the background P2PRC instances created.
    • +
    +
    +
    +
    +

    11.2. Sample bash instructions

    +
    +
    +
    # Unset default P2PRC env path
    +unset P2PRC
    +
    +# Run with 2 nodes
    +P2PRC_instances 3
    +
    +# Start instances
    +Start_all_instances 3
    +
    +# List ip tables of nodes started
    +IP_Tables_after_Started 3
    +
    +# Remove test files created
    +Remove_all_test_files
    +
    +# Kill all instances
    +Kill_all_instances
    +
    +
    +

    +Source code: https://github.com/Akilan1999/p2p-rendering-computation/blob/master/Simulation/simulation.sh +

    +
    +
    +
    +
    +

    12. Blog posts

    +
    +
    +
    +

    12.1. Self host within 5 minutes any program

    +
    + @@ -1068,7 +1143,7 @@ func main() {
  7. Video tutorial:
  8. -
    +

    maxresdefault.jpg

    @@ -1078,9 +1153,9 @@ This is a fun expirement for anyone to try to quickly run a server and quickly do a map port and domain name mapping in a single command.

    -
    -

    11.1.1. 1. Find a program you want to run

    -
    +
    +

    12.1.1. 1. Find a program you want to run

    +

    Let's try to setup a really easy program (Let's do with Linkwarden with docker compose :) ). This is under the assumption you have docker @@ -1088,8 +1163,8 @@ compose installed on your local machine.

      -
    1. Let's run Linkwarden using docker compose and P2PRC
      -
      +
    2. Let's run Linkwarden using docker compose and P2PRC
      +
    -
    -

    12. Ideas for future potencial features

    -
    +
    +

    13. Ideas for future potencial features

    +

    Consists of personal loideas for the future of P2PRC. At moment only has main contributors writiing to this.

    -
    -

    12.1. To support hetrogenous set of Nodes that cannot run P2PRC

    -
    +
    +

    13.1. To support hetrogenous set of Nodes that cannot run P2PRC

    +

    This stems from a personal issue I have when doing research on CheriBSD kernel. For my research I am using the ARM morello @@ -1202,9 +1277,9 @@ and would introduce a new layer fault tolerance within a local network nodes.

    -
    -

    12.1.1. Assumptions:

    -
    +
    +

    13.1.1. Assumptions:

    +
    • I have a Morello board that cannot run P2PRC
    • The Morello has a local IP address (ex: 192.168.0.10)
    • @@ -1216,9 +1291,9 @@ as well look into custom tasks into the hetrogenous hardware.
    -
    -

    12.1.2. Set of interesting possible:

    -
    +
    +

    13.1.2. Set of interesting possible:

    +

    We build a cool set possibilities before and use this to build up the implementation plan. @@ -1234,9 +1309,9 @@ weight hypervisors.

-
-

12.1.3. Implementation

-
+
+

13.1.3. Implementation

+
  • To use implementations similar to socat to ensure we can bind address of local nodes to a node running P2PRC and the node running P2PRC can do a local map port.
  • @@ -1249,7 +1324,7 @@ other nodes can access the Morello board who have permission access.
-
+

P2PRCRemoteNodes.png

Figure 1: Implementation idea (To be improved upon)

@@ -1261,7 +1336,7 @@ other nodes can access the Morello board who have permission access.

Author: Akilan

-

Created: 2025-04-28 Mon 23:14

+

Created: 2025-05-30 Fri 18:05

Validate

diff --git a/Docs/index.org b/Docs/index.org index 265680e..98e79c5 100644 --- a/Docs/index.org +++ b/Docs/index.org @@ -690,18 +690,28 @@ configuration file was generated using JSON format. #+begin_src json { - "MachineName": "pc-74-120.customer.ask4.lan", + "MachineName": "Akilans-MacBook-Pro.local-975261X", "IPTable": "/Users/akilan/Documents/p2p-rendering-computation/p2p/iptable/ip_table.json", "DockerContainers": "/Users/akilan/Documents/p2p-rendering-computation/server/docker/containers/", "DefaultDockerFile": "/Users/akilan/Documents/p2p-rendering-computation/server/docker/containers/docker-ubuntu-sshd/", + "DockerRunLogs": "/tmp/", "SpeedTestFile": "/Users/akilan/Documents/p2p-rendering-computation/p2p/50.bin", "IPV6Address": "", "PluginPath": "/Users/akilan/Documents/p2p-rendering-computation/plugin/deploy", "TrackContainersPath": "/Users/akilan/Documents/p2p-rendering-computation/client/trackcontainers/trackcontainers.json", "ServerPort": "8088", + "ProxyPort": "", "GroupTrackContainersPath": "/Users/akilan/Documents/p2p-rendering-computation/client/trackcontainers/grouptrackcontainers.json", - "FRPServerPort": "True", - "BehindNAT": "True", + "FRPServerPort": true, + "BehindNAT": true, + "IPTableKey": "QH3yQrGRe2X4", + "PublicKeyFile": "/Users/akilan/Documents/p2p-rendering-computation/p2prc.publicKey", + "PrivateKeyFile": "/Users/akilan/Documents/p2p-rendering-computation/p2prc.privateKey", + "PemFile": "/Users/akilan/Documents/p2p-rendering-computation/cert.pem", + "KeyFile": "/Users/akilan/Documents/p2p-rendering-computation/key.pem", + "BareMetal": false, + "UnsafeMode": false, + "Test": false, "CustomConfig": null } #+end_src @@ -783,10 +793,48 @@ func main() { } } #+end_src +* Simulation +The simulation library is a really simple library to locally +run serveral instances of P2PRC to test the functionality +of sending information through the network and particularly +the Node discovery mechanism. There are current 5 commands +which can be used as shown below: +** Command +- ***P2PRC instances "number of instances"*** : Starts p2prc processes + based on the number of number instances provided. This includes + creating temporary folders with independent IPTables. +- ***Start all instances "number of instances"***: Starts the P2PRC instances + created. This function enters into the instance directory and runs + ```p2prc -s &``` with a delay for approximately 3 seconds. This allows + each independent created node to learn about each other. +- ***IP Tables after Started number of instances"***: Prints the IPTable of + each independant node. +- ***Remove all test files***: Removes all test files created which needed for + testing the generated P2PRC instances. +- ***Kill all instances***: Kills all the background P2PRC instances created. +** Sample bash instructions +#+begin_src bash +# Unset default P2PRC env path +unset P2PRC +# Run with 2 nodes +P2PRC_instances 3 +# Start instances +Start_all_instances 3 + +# List ip tables of nodes started +IP_Tables_after_Started 3 + +# Remove test files created +Remove_all_test_files + +# Kill all instances +Kill_all_instances +#+end_src +Source code: https://github.com/Akilan1999/p2p-rendering-computation/blob/master/Simulation/simulation.sh * Blog posts ** Self host within 5 minutes any program