Network Considerations
This section will help you understand how Moonbeam interacts with your network, performs speed tests and latency measurements, and how these factors affect your streaming experience.
Sunshine Availability Check
Moonbeam’s Sunshine availability check requires open communication on port 47989. This port is used for both TCP and UDP traffic. When setting up your network or configuring firewalls, ensure that this port is open between your client device (where Moonbeam is running) and your host PC (where Sunshine is installed). Failure to have this port open may result in Moonbeam being unable to detect Sunshine, even if it’s running correctly on the host.
Using VPNs for Remote Access
If you want to access your home network remotely without setting up port forwarding on your router, using a VPN (Virtual Private Network) can be an excellent solution. This method provides a secure way to connect to your home network from anywhere, allowing you to use Moonbeam for remote streaming.
Tailscale
Tailscale is a user-friendly VPN that uses the WireGuard protocol. It’s known for its ease of use and quick setup process.
Key Features:
- Auto-configuring mesh network
- End-to-end encryption
- Works across different networks and firewalls
ZeroTier
ZeroTier is another excellent option that creates a virtual network over the internet, allowing your devices to communicate as if they were on the same local network.
Key Features:
- Software-defined networking
- Peer-to-peer connection when possible
- Centralized management of network access
Setting Up VPN
- Choose either Tailscale or ZeroTier and install it on both your home streaming PC and your remote device.
- Set up your VPN network following the provider’s instructions.
- Ensure both your home PC and remote device are connected to the same VPN network.
- Use Moonbeam to connect to your home PC using its VPN IP address instead of your public IP.
Speed Tests
Moonbeam uses network speed tests to determine the optimal streaming settings for your current network conditions. These tests are crucial for providing you with the best possible streaming experience.
How Moonbeam Performs Speed Tests
-
Initialization: When you start a Moonbeam streaming session, it first checks if a speed test is necessary.
-
Connection to Host: Moonbeam attempts to connect to your streaming host (the computer running Sunshine) with the
iperf3
tool over port 31347# to perform a brief speed test. -
Result Analysis: The speed test results are analyzed to determine the available bandwidth.
-
Settings Optimization: Based on the speed test results, Moonbeam adjusts streaming parameters such as resolution, FPS, and bitrate.
Interpreting Speed Test Results
Moonbeam categorizes your network speed into different tiers, which influence the streaming settings:
- High Speed (30+ Mbps): Allows for high resolution and high FPS streaming.
- Medium Speed (15-30 Mbps): May require some compromises in resolution or FPS.
- Low Speed (< 15 Mbps): Will prioritize a smooth experience over high resolution.
Speed Test Failures
If Moonbeam fails to perform a speed test, it will:
- Log a warning message.
- Fall back to using estimated bitrate based on your chosen resolution and FPS.
Troubleshooting
-
Check if
iperf3
is running on your host machine: -
If it’s not running, start it manually:
-
Ensure your firewall allows traffic on port 31347.
Bitrate
Benchmarking Scenarios
To find the optimal bitrate settings for your games and network conditions, you can simulate different network speeds using the tc
(traffic control) tool on Linux. This allows you to test how your game streaming performs under various bandwidth limitations.
-
Start by limiting your network bandwidth to 2 Mbps (replace
<WIFI>
with your actual interface name): -
Launch your game with Moonbeam and observe the streaming quality:
-
Gradually increase the bandwidth limit to test higher bitrate scenarios:
-
Test your games at different bandwidth levels (e.g., 2 Mbps, 5 Mbps, 10 Mbps) to understand how they perform:
-
When you’re done testing, remove the bandwidth limitation:
Latency
Moonbeam incorporates latency measurements to fine-tune the resolution and FPS settings.
Impact of Latency
Latency affects various aspects of the connection to the host:
-
Input Responsiveness: Higher latency means a longer delay between your actions and seeing the results on screen.
-
Frame Rate: Moonbeam may adjust the target frame rate based on latency to maintain smooth playback.
-
Video Quality: In some cases, Moonbeam might reduce video quality to maintain responsiveness in high-latency situations.
-
Audio Sync: High latency can cause audio and video to become out of sync.
How Moonbeam Measures Latency
Moonbeam uses a simple method to measure latency:
-
Ping Test: Moonbeam sends a series of ICMP echo requests (pings) to your streaming host.
-
Sample Collection: It collects multiple samples to ensure accuracy.
-
Average Calculation: The average round-trip time is calculated from these samples.
-
Result Interpretation: This average is then used as the latency measurement for optimization calculations.
Benchmarking Scenarios
To simulate different network conditions, you can use the tc
(traffic control) tool on Linux. This allows you to artificially introduce latency and test how your games and applications perform under various conditions.
-
Start by adding a 200ms delay to your network interface (replace
<WIFI>
with your actual interface name): -
Launch (and play) your game with Moonbeam and observe the performance:
-
Gradually decrease the latency to test lower latency scenarios:
-
When you’re done testing, remove the artificial delay:
By starting with a high latency and gradually decreasing it, you can find the highest latency at which each game remains playable. This can help you determine which games are suitable for different network conditions.
Best Practices
-
Network Quality:
Your network quality significantly impacts latency. Consider these factors:
- Physical distance to the host
- Network congestion
- Wi-Fi vs. Ethernet connection
-
Network Router: Ensure your router is configured for gaming, with QoS (Quality of Service) settings prioritizing your gaming devices if available.
-
Game-Specific Tuning
Adjust based on the type of game:
- For fast-paced, competitive games (e.g., FPS, fighting games), set a lower max latency.
- For slower-paced games (e.g., strategy, RPGs), you can likely tolerate higher latency. Here are some additional steps you can take to minimize latency:
-
Use a Wired Connection: Whenever possible, use Ethernet instead of Wi-Fi on both the host and client devices.
-
Close Bandwidth-Heavy Applications: On both host and client, close applications that might be using significant bandwidth (e.g., file synchronization services, video streaming).
-
Consider Host Hardware: On the host PC, using a hardware encoder (like NVENC on NVIDIA GPUs) can help reduce encoding latency.