Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Actually run quic benches #56

Open
wants to merge 1 commit into
base: quic
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions golang/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/libp2p/go-libp2p v0.14.4
github.com/libp2p/go-libp2p-core v0.8.6
github.com/libp2p/go-libp2p-noise v0.2.0
github.com/libp2p/go-libp2p-quic-transport v0.10.0 // indirect
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I could not upgrade it to the newest version (0.15.0). Would you do that on your own?

github.com/libp2p/go-libp2p-yamux v0.5.4
github.com/multiformats/go-multiaddr v0.3.3
)
17 changes: 12 additions & 5 deletions golang/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"context"
"crypto/rand"
"flag"
"fmt"
"io"
Expand All @@ -15,7 +16,7 @@ import (
"github.com/libp2p/go-libp2p-core/peer"
"github.com/libp2p/go-libp2p-core/peerstore"
noise "github.com/libp2p/go-libp2p-noise"
yamux "github.com/libp2p/go-libp2p-yamux"
quic "github.com/libp2p/go-libp2p-quic-transport"
ma "github.com/multiformats/go-multiaddr"
)

Expand All @@ -29,14 +30,14 @@ func main() {
listenAddr := flag.String("listen-address", "", "")
fakeCryptoSeed := flag.Bool("fake-crypto-seed", false, "")
transportSecurity := flag.String(
"transport-security",
"tcp-transport-security",
"noise",
"Mechanism to secure transport, either 'noise' or 'plaintext'.",
)
flag.Parse()

if *listenAddr == "" {
*listenAddr = "/ip4/127.0.0.1/tcp/0"
*listenAddr = "/ip4/127.0.0.1/udp/0/quic"
}

var priv crypto.PrivKey
Expand All @@ -51,16 +52,22 @@ func main() {
panic(err)
}
} else {
priv, _, err = crypto.GenerateKeyPair(crypto.RSA, 2048)
priv, _, err = crypto.GenerateEd25519Key(rand.Reader)
if err != nil {
panic(err)
}
}

transport, err := quic.NewTransport(priv, nil, nil)
if err != nil {
panic(err)
}

opts := []libp2p.Option{
libp2p.ListenAddrStrings(*listenAddr),
libp2p.Identity(priv),
libp2p.Muxer("/yamux/1.0.0", yamux.DefaultTransport),
libp2p.Transport(transport),
//libp2p.Muxer("/yamux/1.0.0", yamux.DefaultTransport),
}

if *transportSecurity == "noise" || *transportSecurity == "" {
Expand Down
46 changes: 23 additions & 23 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ trap "kill 0" EXIT
TcpTransportSecurityProtocols=( noise plaintext )

echo "# Start Rust and Golang servers."
./rust/target/release/server --private-key-pkcs8 rust/test.pk8 --listen-address /ip4/0.0.0.0/tcp/9992 > /dev/null 2>&1 &
./golang/go-libp2p-perf --fake-crypto-seed --listen-address /ip4/0.0.0.0/tcp/9993 --tcp-transport-security noise > /dev/null 2>&1 &
./golang/go-libp2p-perf --fake-crypto-seed --listen-address /ip4/0.0.0.0/tcp/9994 --tcp-transport-security plaintext > /dev/null 2>&1 &
./rust/target/release/server --private-key-pkcs8 rust/test.pk8 --listen-address /ip4/127.0.0.1/udp/9992/quic > /dev/null 2>&1 &
./golang/go-libp2p-perf --fake-crypto-seed --listen-address /ip4/0.0.0.0/udp/9993/quic --tcp-transport-security noise > /dev/null 2>&1 &
./golang/go-libp2p-perf --fake-crypto-seed --listen-address /ip4/0.0.0.0/udp/9994/quic --tcp-transport-security plaintext > /dev/null 2>&1 &

sleep 1

Expand All @@ -24,33 +24,33 @@ for Protocol in ${TcpTransportSecurityProtocols[*]}
do
echo
echo "## Transport security $Protocol"
./rust/target/release/client --server-address /ip4/127.0.0.1/tcp/9992 --tcp-transport-security $Protocol
./rust/target/release/client --server-address /ip4/127.0.0.1/udp/9992/quic --tcp-transport-security $Protocol
done

echo
echo "# Rust -> Golang"
echo
echo "## Transport security noise"
./rust/target/release/client --server-address /ip4/127.0.0.1/tcp/9993 --tcp-transport-security noise
echo
echo "## Transport security plaintext"
./rust/target/release/client --server-address /ip4/127.0.0.1/tcp/9994 --tcp-transport-security plaintext

echo
echo "# Golang -> Rust"
for Protocol in ${TcpTransportSecurityProtocols[*]}
do
echo
echo "## Transport security $Protocol"
./golang/go-libp2p-perf --server-address /ip4/127.0.0.1/tcp/9992/p2p/Qmcqq9TFaYbb94uwdER1BXyGfCFY4Bb1gKozxNyVvLvTSw --tcp-transport-security $Protocol
done
# echo
# echo "# Rust -> Golang"
# echo
# echo "## Transport security noise"
# ./rust/target/release/client --server-address /ip4/127.0.0.1/udp/9993/quic --tcp-transport-security noise
# echo
# echo "## Transport security plaintext"
# ./rust/target/release/client --server-address /ip4/127.0.0.1/udp/9994/quic --tcp-transport-security plaintext

# echo
# echo "# Golang -> Rust"
# for Protocol in ${TcpTransportSecurityProtocols[*]}
# do
# echo
# echo "## Transport security $Protocol"
# ./golang/go-libp2p-perf --server-address /ip4/127.0.0.1/tcp/9992/p2p/Qmcqq9TFaYbb94uwdER1BXyGfCFY4Bb1gKozxNyVvLvTSw --tcp-transport-security $Protocol
# done

echo
echo "# Golang -> Golang"
echo
echo "## Transport security noise"
./golang/go-libp2p-perf --server-address /ip4/127.0.0.1/tcp/9993/p2p/12D3KooWL3XJ9EMCyZvmmGXL2LMiVBtrVa2BuESsJiXkSj7333Jw --tcp-transport-security noise
./golang/go-libp2p-perf --server-address /ip4/127.0.0.1/udp/9993/quic/p2p/12D3KooWL3XJ9EMCyZvmmGXL2LMiVBtrVa2BuESsJiXkSj7333Jw --tcp-transport-security noise
echo
echo "## Transport security plaintext"
./golang/go-libp2p-perf --server-address /ip4/127.0.0.1/tcp/9994/p2p/12D3KooWL3XJ9EMCyZvmmGXL2LMiVBtrVa2BuESsJiXkSj7333Jw --tcp-transport-security plaintext
./golang/go-libp2p-perf --server-address /ip4/127.0.0.1/udp/9994/quic/p2p/12D3KooWL3XJ9EMCyZvmmGXL2LMiVBtrVa2BuESsJiXkSj7333Jw --tcp-transport-security plaintext

4 changes: 2 additions & 2 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ mod tests {
let key = identity::Keypair::generate_ed25519();
let local_peer_id = PeerId::from(key.public());

let transport = build_transport(key, TcpTransportSecurity::Plaintext).unwrap();
let transport = build_transport(key, TcpTransportSecurity::Plaintext, None).unwrap();
let perf = Perf::default();
Swarm::new(transport, perf, local_peer_id)
};
Expand All @@ -206,7 +206,7 @@ mod tests {
let key = identity::Keypair::generate_ed25519();
let local_peer_id = PeerId::from(key.public());

let transport = build_transport(key, TcpTransportSecurity::Plaintext).unwrap();
let transport = build_transport(key, TcpTransportSecurity::Plaintext, None).unwrap();
let perf = Perf::default();
Swarm::new(transport, perf, local_peer_id)
};
Expand Down