williampiat3 / ImprovingPSRemotePlay

This repository describes the making of a bridge VPN.
106 stars 1 forks source link

PS4 and PS5: Improving your PS remote play experience

Table of contents

Introduction

This guide will allow you to improve your experience of PS remote play, reduce the load of Sony's servers and tap into the world of raspberry pi while sitting on your couch and playing your PS4 or 5 from anywhere. Hooked already? Well, here's how to do it: As we were not able to find online the full explanation on how to solve this problem. My brother and I decided to note down the steps that allowed us to completely tackle some issues with the PS remote play. PlayStation gives an amazing feature to all its users by enabling them to play on their PlayStation from afar. My brother and I discovered this functionality during the quarantines in Europe for the Coronavirus. Thanks to it we were able to both play the PlayStation (not at the same time of course) while being physically separated. As we are both owners of the PS4 this is not in violation of the terms of use of the PS remote play.

To put it simple the remote play feature allows you to stream your PS4 on any device, your computer or phone for instance. As this is streaming, you don't need huge specs on the client devices (here are the ones for windows as an example), just a solid connection (15 Mb/s according to Sony's website). You can test your speed by making a speed test. Although this tool is incredible and useful, it has a few drawbacks:

When using it in your home network(ie same network as the PS4):

The problems arise when playing on a remote network:

Using our solution, we were able to make the remote play running at 720p all the time from afar without any connectivity issues with a safe encrypted connection. It requires to buy some equipment but it is not very expensive and we found for you the cheapest one.

Explanation of the solution:

Some of you might have guessed it from the beginning our goal here is to make the remote play locally even if you are located on another network, to bypass Sony's server (which they should be thankful as it reduces their load ;) ) and to connect your computer almost directly to the PS4 or 5. To achieve so we have to connect securely the device you are streaming on to the network of the PlayStation, and we will achieve this building a VPN server.

Here is a drawing explaining the principle of the solution:

We will offer you 2 solutions depending on your usage:

Price

Our solution is cheap, and it works on raspberry pi zero, 3 and 4 (so if you have one of these it works), meaning no subscription is needed in order to operate it (apart for your electricity subscription of course). And an idle raspberry pi 3 consumes 1.9 Watts which is less than a small lamp so it won't be much of an extra cost. The raspberry 3 and 4 can sustain multiple connexions on the VPN but come at a higher cost, on the other hand if there is only one person using the VPN then the pi zero solution is cheaper (half of the price approximatly) the configuration is a little bit trickier at the beginning as you need to ssh from the start on it but it is more efficient.

For the raspberry pi 3 and 4 you will need:

For the raspberry zero you will need:

If you are using the solution with the raspberry pi zero make sure to enable ssh (check paragraph 3.) right after burning the OS as you can't plug a keyboard on the pi zero if the ethernet dongle is on it

To help you in your choice, here is a small table summing up all use case we thought of. We hope this might help you in selecting the right raspberry pi:

use cases Pi zero v1.3
OpenVPN & Tailscale
Pi zero v1.3
Wireguard
Pi 3 & 4
All VPN
Psremote app
PS4 fat 540p low fps OK OK OK OK
PS4 fat 720p low fps OK OK OK Not stable
PS4 pro 720p low fps Not optimal OK OK disconnecting
PS4 fat 720p high fps Not optimal OK OK disconnecting
PS4 pro 1080p high fps Not working OK OK disconnecting*
PS5 1080p high fps Not working* OK OK OK*
PS5 and PS4 pro Not working* Not working* OK* Not possible*
Steam remote play Not working Not optimal OK -

*Test not performed, theorical result within our limited testing and comprehension

Equipment needed:

You will need:

If you don't feel like burning the OS yourself on the SD card, you can buy SD cards with the OS preinstalled as described here, no judgment here.

First steps that are common to all the solutions

Requirements before going to the next steps.

So at the end of these steps you are able to ssh on your raspberry that is connected to your network, and you have your raspberry IP, netmask, broadcast IP, router IP, public IP and PS IP. We will be supposing here that your public IP is not changing very often (in case you have a static IP, that's great). But in case for some reason your public IP changes regularly you'll have to subscribe to a DynDNS service to be able to connect every time to your home network. If it changes only when you reboot your router it's fine, you can go ahead and pretend you have a static IP (we will show you what to change if your public IP changed and it will just be changing one ip address in a configuration file)

Quick and dirty solution

Install a VPN server

This one is fast and might give you a taste of the improvement you can experience using the VPN but it doesn't completely support all the controller's keys on Windows, Linux users can enjoy full compatibility following this solution. We suggest 3 possible solutions:

You can follow our detailed guide to install an OpenVPN server or our guide to install a wireguard VPN server. They are straightforward and are both made using the piVPN script. The same behavior can be achieved using Tailscale but requires also some level of configuration.

In a nutshell: Wireguard is the most performant, Tailsale is the easiest to configure, OpenVPN is the most flexible.

We advise this quick and dirty solution just for testing the solution before implementing the second one since it lacks some of the features of the remote play. But if you really just care about having your VPN up and running with PS remote play app we suggest you to switch directly to the longer solution. However this way this connection works allowed us to understand how we could make our VPN work. This is why we left its conclusion here.

Connect to the PlayStation (try at least..)

Using the VPN you can connect remotly to your home network, now you can try to fire the PS remote play application but...

It doesn't work...

Yes, it doesn't work...

But you can actually detect the PlayStation if you run this command (it works on windows, Linux and Mac OS) ping **PS IP** you will be receiving packets meaning the PlayStation is accessible but the app doesn't reach it! (explanation here) But you know what does? Chiaki!

Install Chiaki

Chiaki is a free, open source, PS remote play client that you can download here. You also need your PSN account ID, not your login, not your email... Look, you just don't have it yet ;).

The Chiaki github is providing a python script for you to get it easily here, and if you don't know how to run a python script on your computer well you should! it really is an awesome language. If you really don't have and don't want python3 on your computer, the raspberry pi can run it for you : just run wget https://git.sr.ht/~thestr4ng3r/chiaki/tree/master/item/scripts/psn-account-id.py to get the script and run python3 psn-account-id.py... Some packages missing? sudo pip3 install requests ..... pip missing? sudo apt-get install python3-pip.

Ok now you should be fine running the script. It will open up a web page for logging you, copy past the link you get in your terminal and that's it your PSN account ID, note it down. Run the Chiaki executable enter your PSN account ID the PS IP and then it will prompt for a PIN code To register a PS4 with a PIN, it must be put into registration mode. To do this, on your PS4, simply go to: Settings -> Remote Play (ensure this is ticked) -> Add Device, it will give you a PIN code to enter on your PC and noooooooooooowwwwwwwww .... YOU ARE CONNECTED

Using Chiaki used to be constraining in many ways in it's version 1.3.0:

Now in it's version 2.1.1 fully compatible with PS5, the only noticable drawbacks are:

However it have a lots of advantages :

It is a great tool but the official application remains better if you are using a single PS and a DualShock (or DualSense) in my opinion.

Why is this not working with the PS remote play app

Well, it might be obvious for people used to VPNs but it wasn't for us so we had to investigate a little bit. Your LAN or local network is the network connecting all your machines to the web this is your router's job basically. The LAN cannot be seen from the outside. From anyone else on the internet, you are one device identified by your public IP that is the address of your router on the web.

On your LAN every device has a local address: a local IP (the PS IP or raspberry IP or router IP are local IPs) that are not visible from the outside but you can access them from within your network or with the VPN we just did.

How acts the VPN we just did? It creates a subnetwork in your network, meaning that the raspberry acts just like your web router: the raspberry gives to any device connected to the VPN access to your LAN and the web. That's why you can actually ping the PlayStation. However the PlayStation app can't reach it? Yes (and this was a conjuncture) the app looks for the PlayStation on the same network than the device running it meaning the subnetwork of the raspberry pi and not your LAN...

A solution could be to connect your PlayStation to the VPN but that is not feasible unless the connection of your PlayStation to the web is through a device that can use a VPN... And even though you will add an extra step of encryption, hence some extra lag, on your streaming experience that has already lag due to the fact that you are on remote.

So the other possibility is to have the VPN register you to the LAN and not create a subnetwork and this is called a Bridge VPN! However piVPN is not (for now) able to configure your raspberry to work in that mode so we will have to configure everything manually... Yes, this is the trickier and more complex operation but it is worth it!

Longer and more complex solution

So as described in the conclusion of the previous section the solution is to build a bridge VPN that will assign the remote computer to the LAN itself, not a subnetwork. The VPN is a little bit more complicated to configure but we will guide you through it.

Install a layer 2 VPN server and set up the client

If you performed the Quick and dirty solution, you'll have to uninstall piVPN on the raspberry by running the command: pivpn uninstall and select to uninstall all the dependencies, remove the port forwarding rule on your router (you'll have to put it back afterwards),enable ssh on your raspberry pi to be able to run commands on it from your computer and reboot it. As we performed the installation on raspberry pi 4 and zero we made two guides with very slight differences. However to make sure that you guys don't mix the two solution we made them in two different files.

Connect to your PlayStation locally remotely

Now that your VPN is on, that your client is ready and that you can connect to the VPN server, all you need to do is to fire the PS remote play app!!! maybe you'll have a pairing to make: To do this, on your PS4, simply go to: Settings -> Remote Play (ensure this is ticked) -> Add Device, it will give you a PIN code to enter on your PC And that's it folks a local remote play is on!!! With full compatibility with all keys, touchpad and so on. Chiaki has full compatibility on Ubuntu so if you have a linux machine you can also use this solution

Now you can increase the quality of your remote play as long as you connexion allows it. Feel free to test with and without the VPN: we saw drastic improvements

About this solution: what is this changing

Now any device connected to the VPN can be spotted on the LAN, if you go to your router's admin page (that you can also access on the remote computer with the VPN now) and check the devices connected you will note that a new device has appeared whose IP belongs to the range you gave in the configuration file of openVPN whereas in the previous solution your device was not visible as it was on a subnetwork.

Testing the connection

Once your setup is ready I advise you to use iperf3 to check the performance of your network through the VPN by using a remote wired network: the software is available on linux, windows and MacOS: therefore you can use it on all you machines to check the throuput:

On our networks we had the following throughput: VPN \ pi model Pi zero v1.3
+ usb dongle
Pi 3b
v1.2
Pi 4 (64bits)
local LAN 200 Mb/s 95 Mb/s 900 Mb/s
OpenVPN (Bridge) 11 Mb/s 61 Mb/s 80 Mb/s
Wireguard 25 Mb/s 80 Mb/s 86 Mb/s
Tailscale 10 Mb/s 86 Mb/s

The VPN drastically reduces the throughput compared to local play but this is the only way you can safely connect remotely to your local network. WireGuard appeards to be more optimized than OpenVPN as the gains on a pi zero are significant. Regarding pi 4 performances, internet providers in our country limit the bandwith for VPN therefore even with OpenVPN set up as bridge, we max out at this limit.

Throughput is one thing however when you are playing video games there is another metric that is terribly important, the latency. Of course you'll be playing from far away on your console, this means that this will introduce some delay between the time your are typing your commands and the time you will see them executed on the screen, this is kind of the unsolvable problem of remote play as it depends of the distance and the internet providers you have. You'll feel the difference as your inputs will be less responsive and it will be more difficult to have quick reflexes on any game so of course this is not ideal if you want to play competitive. But it does provide a good experience for casual play.

Conclusion

We don't believe that this solution harms Sony in any way: we give people the opportunity to play more on their consoles remotely and enabling friends to share a console where they might not have all the money to buy their own all of which is profitable to Sony. We made a huge ad of their remote play feature in this article and, you might have guessed it, we are definitely very fond of it.

In our minds this is a cheap solution to improve the quality and latency of your streaming feed, we wanted to enjoy ps4 games without having to buy a console both and this solution was a good answer to this problem, especially in quarantine times. It's also a good solution now: the PS5 being out and not everyone being able to afford it, you can share the price and the console with some of your friends and be coowners if you are ok with sharing the console.

At the time of the writing, we didn't test our solution on a PS5 but, as it involves the same protocols, we are confident that it can work (stay tuned!). Submit an issue if you are encountering a problem with the solution we will gladly help.

Other uses of this VPN

This VPN can also be used for other purposes: for building a LAN for playing with friends on PC, giving yourself access to your local network if you have a machine at home. I personnaly use it when working on projects with my friends so that we can code on the same machine.

You can also stream more efficiently Steam to a remote computer: if you are using steam remote play over the internet the computer that is streaming has quite an heavy load ass it has to decode the streaming flux coming from steam server: even if you are using the VPN the computer running the game will be sending the video flux to steam servers and that will be redirected to the streaming computer, by putting steam in offline mode on the computer running the game you will force the video flux to pass through the VPN directly and decrease the decoding load on the computer streaming the game: good to know if you are streaming from a potatoe.