Browse Source

Merge pull request #720 from paullouisageneau/change-stun-turn

Change STUN and TURN servers in tests
Paul-Louis Ageneau 2 years ago
parent
commit
6e11c3dd0a

+ 14 - 14
examples/client-benchmark/README.md

@@ -3,7 +3,7 @@
 This directory contains a native client to open Data Channels with WebSocket signaling using libdatachannel and benchmark functionalities. It offers three functionalities;
 - Benchmark: Bi-directional data transfer benchmark (Also supports One-Way testing)
 - Constant Throughput Set: Send desired amount of data per second
-- Multiple Data Channel: Create desired amount of data channel 
+- Multiple Data Channel: Create desired amount of data channel
 
 ## Start Signaling Server
 - Start one of the signaling server from the examples folder. For example start  `signaling-server-nodejs` like;
@@ -19,13 +19,13 @@ Start 2 applications by using example calls below. Then copy one of the client's
 
 ### Benchmark for 300 seconds
 
-> `./client-benchmark -d 300` 
+> `./client-benchmark -d 300`
 
 Example Output (Offering Peer's Output);
 ```bash
-Stun server is stun:stun.l.google.com:19302
+STUN server is stun:stun.l.google.com:19302
 The local ID is: H1E3
-Url is ws://localhost:8000/H1E3
+URL is ws://localhost:8000/H1E3
 Waiting for signaling to be connected...
 2021-04-10 19:51:31.319 INFO  [16449] [rtc::impl::TcpTransport::connect@163] Connected to localhost:8000
 2021-04-10 19:51:31.319 INFO  [16449] [rtc::impl::TcpTransport::runLoop@331] TCP connected
@@ -113,17 +113,17 @@ Stats# Received Total: 655 MB   Sent Total: 558 MB   RTT: 13 ms
 ### Benchmark for 300 seconds (Only Send, One Way)
 
 Start first peer as;
-> `./client-benchmark -d 300 -o` 
+> `./client-benchmark -d 300 -o`
 
 Start second peer as;
-> `./client-benchmark -d 300` 
+> `./client-benchmark -d 300`
 
 Example Output (Offering Peer's Output);
 ```bash
 Not Sending data. (One way benchmark).
-Stun server is stun:stun.l.google.com:19302
+STUN server is stun:stun.l.google.com:19302
 The local ID is: 7EaP
-Url is ws://localhost:8000/7EaP
+URL is ws://localhost:8000/7EaP
 Waiting for signaling to be connected...
 2021-04-10 19:54:36.857 INFO  [16632] [rtc::impl::TcpTransport::connect@163] Connected to localhost:8000
 2021-04-10 19:54:36.857 INFO  [16632] [rtc::impl::TcpTransport::runLoop@331] TCP connected
@@ -210,13 +210,13 @@ Stats# Received Total: 1362 MB   Sent Total: 0 MB   RTT: 2 ms
 
 ### Constant Throughput Set 8000 byte, for 300 seconds, send buffer 10000 byte
 
-> `./client-benchmark -p -d 300 -r 8000 -b 10000` 
+> `./client-benchmark -p -d 300 -r 8000 -b 10000`
 
 Example Output (Offering Peer's Output);
 ```bash
-Stun server is stun:stun.l.google.com:19302
+STUN server is stun:stun.l.google.com:19302
 The local ID is: 5zkC
-Url is ws://localhost:8000/5zkC
+URL is ws://localhost:8000/5zkC
 Waiting for signaling to be connected...
 2021-04-10 19:52:49.788 INFO  [16530] [rtc::impl::TcpTransport::connect@163] Connected to localhost:8000
 2021-04-10 19:52:49.788 INFO  [16530] [rtc::impl::TcpTransport::runLoop@331] TCP connected
@@ -303,13 +303,13 @@ Stats# Received Total: 122 MB   Sent Total: 122 MB   RTT: 0 ms
 
 ### Constant Throughput Set 8000 byte, for 300 seconds, send buffer 10000 byte, 5 Data Channel
 
-> `./client-benchmark -p -d 300 -r 8000 -b 10000 -c 5` 
+> `./client-benchmark -p -d 300 -r 8000 -b 10000 -c 5`
 
 Example Output (Offering Peer's Output);
 ```bash
-Stun server is stun:stun.l.google.com:19302
+STUN server is stun:stun.l.google.com:19302
 The local ID is: QZ46
-Url is ws://localhost:8000/QZ46
+URL is ws://localhost:8000/QZ46
 Waiting for signaling to be connected...
 2021-04-10 19:57:28.562 INFO  [17117] [rtc::impl::TcpTransport::connect@163] Connected to localhost:8000
 2021-04-10 19:57:28.562 INFO  [17117] [rtc::impl::TcpTransport::runLoop@331] TCP connected

+ 2 - 2
examples/client-benchmark/parse_cl.cpp

@@ -190,9 +190,9 @@ libdatachannel client implementing WebRTC Data Channels with WebSocket signaling
    [ -n ] [ --noStun ] (type=FLAG)\n\
           Do NOT use a stun server (overrides -s and -t).\n\
    [ -s ] [ --stunServer ] (type=STRING, default=stun.l.google.com)\n\
-          Stun server URL or IP address.\n\
+          STUN server URL or IP address.\n\
    [ -t ] [ --stunPort ] (type=INTEGER, range=0...65535, default=19302)\n\
-          Stun server port.\n\
+          STUN server port.\n\
    [ -w ] [ --webSocketServer ] (type=STRING, default=localhost)\n\
           Web socket server URL or IP address.\n\
    [ -x ] [ --webSocketPort ] (type=INTEGER, range=0...65535, default=8000)\n\

+ 2 - 2
examples/client/parse_cl.cpp

@@ -151,9 +151,9 @@ libdatachannel client implementing WebRTC Data Channels with WebSocket signaling
    [ -n ] [ --noStun ] (type=FLAG)\n\
           Do NOT use a stun server (overrides -s and -t).\n\
    [ -s ] [ --stunServer ] (type=STRING, default=stun.l.google.com)\n\
-          Stun server URL or IP address.\n\
+          STUN server URL or IP address.\n\
    [ -t ] [ --stunPort ] (type=INTEGER, range=0...65535, default=19302)\n\
-          Stun server port.\n\
+          STUN server port.\n\
    [ -w ] [ --webSocketServer ] (type=STRING, default=localhost)\n\
           Web socket server URL or IP address.\n\
    [ -x ] [ --webSocketPort ] (type=INTEGER, range=0...65535, default=8000)\n\

+ 2 - 2
examples/streamer/main.cpp

@@ -159,7 +159,7 @@ int main(int argc, char **argv) try {
 
     Configuration config;
     string stunServer = "stun:stun.l.google.com:19302";
-    cout << "Stun server is " << stunServer << endl;
+    cout << "STUN server is " << stunServer << endl;
     config.iceServers.emplace_back(stunServer);
     config.disableAutoNegotiation = true;
 
@@ -185,7 +185,7 @@ int main(int argc, char **argv) try {
     });
 
     const string url = "ws://" + ip_address + ":" + to_string(port) + "/" + localId;
-    cout << "Url is " << url << endl;
+    cout << "URL is " << url << endl;
     ws->open(url);
 
     cout << "Waiting for signaling to be connected..." << endl;

+ 1 - 2
test/capi_connectivity.cpp

@@ -200,8 +200,7 @@ int test_capi_connectivity_main() {
 	}
 
 	// STUN server example (not necessary to connect locally)
-	// Please do not use outside of libdatachannel tests
-	const char *iceServers[1] = {"stun:stun.ageneau.net:3478"};
+	const char *iceServers[1] = {"stun:stun.l.google.com:19302"};
 
 	// Create peer 1
 	rtcConfiguration config1;

+ 2 - 4
test/connectivity.cpp

@@ -36,8 +36,7 @@ void test_connectivity() {
 
 	Configuration config1;
 	// STUN server example (not necessary to connect locally)
-	// Please do not use outside of libdatachannel tests
-	config1.iceServers.emplace_back("stun:stun.ageneau.net:3478");
+	config1.iceServers.emplace_back("stun:stun.l.google.com:19302");
 	// Custom MTU example
 	config1.mtu = 1500;
 	// Custom max message size
@@ -47,8 +46,7 @@ void test_connectivity() {
 
 	Configuration config2;
 	// STUN server example (not necessary to connect locally)
-	// Please do not use outside of libdatachannel tests
-	config2.iceServers.emplace_back("stun:stun.ageneau.net:3478");
+	config2.iceServers.emplace_back("stun:stun.l.google.com:19302");
 	// Custom MTU example
 	config2.mtu = 1500;
 	// Custom max message size

+ 13 - 31
test/turn_connectivity.cpp

@@ -35,24 +35,16 @@ void test_turn_connectivity() {
 	Configuration config1;
 	config1.iceTransportPolicy = TransportPolicy::Relay; // force relay
 
-	// STUN server example (not necessary, just here for testing)
-	// Please do not use outside of libdatachannel tests
-	config1.iceServers.emplace_back("stun:stun.ageneau.net:3478");
-	// TURN server example
-	// Please do not use outside of libdatachannel tests
-	config1.iceServers.emplace_back("turn:datachannel_test:[email protected]:3478");
+	// TURN server example (use your own server in production)
+	config1.iceServers.emplace_back(
+	    "turn:openrelayproject:[email protected]:80");
 
 	PeerConnection pc1(config1);
 
 	Configuration config2;
-	config2.iceTransportPolicy = TransportPolicy::Relay; // force relay
 
-	// STUN server example (not necessary, just here for testing)
-	// Please do not use outside of libdatachannel tests
-	config1.iceServers.emplace_back("stun:stun.ageneau.net:3478");
-	// TURN server example (note that the reserved special character '@' is percent-encoded)
-	// Please do not use outside of libdatachannel tests
-	config2.iceServers.emplace_back("turn:datachannel_test_speci%40l:[email protected]:3478");
+	// STUN server example (use your own server in production)
+	config2.iceServers.emplace_back("stun:openrelay.metered.ca:80");
 
 	PeerConnection pc2(config2);
 
@@ -82,6 +74,10 @@ void test_turn_connectivity() {
 	});
 
 	pc2.onLocalCandidate([&pc1](Candidate candidate) {
+		// Filter server reflexive candidates
+		if (candidate.type() != rtc::Candidate::Type::ServerReflexive)
+			return;
+
 		cout << "Candidate 2: " << candidate << endl;
 		pc1.addRemoteCandidate(string(candidate));
 	});
@@ -130,10 +126,7 @@ void test_turn_connectivity() {
 		dc1->send("Hello from 1");
 	});
 
-
-	dc1->onClosed([]() {
-		cout << "DataChannel 1: Closed" << endl;
-	});
+	dc1->onClosed([]() { cout << "DataChannel 1: Closed" << endl; });
 
 	dc1->onMessage([](const variant<binary, string> &message) {
 		if (holds_alternative<string>(message)) {
@@ -165,21 +158,12 @@ void test_turn_connectivity() {
 
 	Candidate local, remote;
 	if (!pc1.getSelectedCandidatePair(&local, &remote))
-		throw runtime_error("getSelectedCabndidatePair failed");
+		throw runtime_error("getSelectedCandidatePair failed");
 
 	cout << "Local candidate 1:  " << local << endl;
 	cout << "Remote candidate 1: " << remote << endl;
 
-	if (local.type() != Candidate::Type::Relayed || remote.type() != Candidate::Type::Relayed)
-		throw runtime_error("Connection is not relayed as expected");
-
-	if (!pc2.getSelectedCandidatePair(&local, &remote))
-		throw runtime_error("getSelectedCabndidatePair failed");
-
-	cout << "Local candidate 2:  " << local << endl;
-	cout << "Remote candidate 2: " << remote << endl;
-
-	if (local.type() != Candidate::Type::Relayed || remote.type() != Candidate::Type::Relayed)
+	if (local.type() != Candidate::Type::Relayed)
 		throw runtime_error("Connection is not relayed as expected");
 
 	// Try to open a second data channel with another label
@@ -216,9 +200,7 @@ void test_turn_connectivity() {
 		second1->send("Second hello from 1");
 	});
 
-	second1->onClosed([]() {
-		cout << "Second DataChannel 1: Closed" << endl;
-	});
+	second1->onClosed([]() { cout << "Second DataChannel 1: Closed" << endl; });
 
 	second1->onMessage([](const variant<binary, string> &message) {
 		if (holds_alternative<string>(message)) {