As you may know from our whitepaper — RightMesh uses the concept of a superpeer. This node is one which acts as a relay between one geographically separate mesh and another. This device should be run on a computer that has a fast, stable connection to the Internet. For the purpose of this article, let’s assume an AWS instance, but it could also be a computer at your house with the correct ports open (In this case UDP port 40000).
The most minimalist superpeer possible is provided [https://github.com/RightMesh/Superpeer](https://github.com/RightMesh/Superpeer)
All this java app does it start up a RightMesh node waiting for Internet sharing devices to connect to it. It acts a hole-punching and relaying device so that phones behind NAT and firewalls can reach each other.
Let’s assume we’re starting from scratch. Sign-up for an AWS account.
<center>![file](/uploads/image-1599623951398.png)<br/> The AWS screen after creating a new account</center>
Select `EC2` and then `launch instance`. Next select `Ubuntu Server 16.04 LTS (HVM)`, `SSD Volume Type`.
<center> ![file](/uploads/image-1599624009847.png) <br/> Select the Ubuntu server option under “free-tier eligible”
<br/> Select the “Free-Tier” option and click Review and Launch
You may wish to edit the storage amount (it defaults to 8GB — but I think you can get up to 20 or 30GB with free tier).
You should also edit the security groups to add an inbound UDP port exception for port `40000`:
<center> ![file](/uploads/image-1599624089366.png) </center>
Lastly, you’ll want to create an ssh keypair — it should popup when you click review (otherwise you won’t have access to the instance when you start). Save the key into your ~/.ssh directory. Then launch the instance.
You’ll want to change the permissions on the .pem file:
chmod 400 <insert-your-pem>.pem
Then you can ssh into the server. By default the username is ubuntu when you setup a Ubuntu server instance.
ssh -i <insert-your-pem>.pem ubuntu@<insert-server-ip>
You can see the server IP from the instances page:
Now that you are ssh’d into the server, install some of the things required to build the superpeer:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
Next, you can clone the git repo for the superpeer. You’ll also need to add your credentials from `developer.rightmesh.io` into the build.gradle file:
git clone https://github.com/RightMesh/Superpeer
After you’ve updated your credentials, you should be able to build the superpeer:
Then to run it use:
In your apps on the phones, you can now use the superpeer you just created with the function call mm.setSuperPeer(“`<insert your superpeer ip>`”);The superpeer will be used to relay data packets between geographically separate meshes (for instance, one mesh in Canada and one in Bangladesh).
With this superpeer, all phones which are provided Internet by connecting the two meshes via the Superpeer would be doing so for free, but we will be releasing a version soon which can use Ethereum tokens to allow the devices sharing their Internet connection to set a price in tokens.
[Originally posted on medium on November 29, 2017](https://medium.com/@compscidr/setting-up-a-rightmesh-superpeer-a5c4a433b238).