Robonomics-2018 Day 1
Mesh Networks & IPFS PubSub
Resources
- Alexander Krupenkin blog post
- Robonomics Day-1 Follow-Up
- Robonomics 2018: network resources spreadsheet
Prerequisites
All job has been done on Ubuntu 18.04.1 LTS
All scripts presuming working folder is ~/dev/aira/
Mesh Networks
Stack is: B.A.T.M.A.N + CJDNS + IPFS
- B.A.T.M.A.N builds virtual Ethernet network
- CJDNS builds routing over Ethernet network
- IPFS works on top of these two above
Purposes:
- Setup a mesh network
- Chat through IPFS PubSub
- Download a film from IPFS
Step-by-Step Guide
- (Re-)Plugin your WiFi dongle (if you use it, though you can just use your notebook's WiFi interface)
- Turn OFF the WiFi manager and start B.A.T.M.A.N. Run the wifi.sh script:
#!/bin/bash iwconfig wlx503eaa70c460 mode ad-hoc iwconfig wlx503eaa70c460 essid fftlt-ibss iwconfig wlx503eaa70c460 ap 62:C2:3A:86:A6:EE iwconfig wlx503eaa70c460 channel 3 modprobe batman_adv batctl if add wlx503eaa70c460 ifconfig wlx503eaa70c460 up
replace wlx503eaa70c460 to your inteface here
-
Check B.A.T.M.A.N connectivity
$ sudo batctl n
-
(run once after the install) Configure CJDNS
$ cd cjdns $ ./cjdroute --genconf >> cjdroute.conf
-
Turn CJDNS up
$ sudo ./cjdroute < cjdroute.conf
- Sometimes you'll need to restart the CJDNS for troubleshooting. To do this, kill the process and start it again:
$ sudo pkill cjdroute
$ sudo ./cjdroute < cjdroute.conf
- Check CJDNS connectivity
$ ./tools/peerStats
- Start IPFS daemon if not started yet
ipfs daemon --enable-pubsub-experiment
- You can check if IPFS daemon runing with
$ ipfs id
Error: api not running
It is not running if you get an Error
- Connect to certain IPFS nodes of our network (and set it to do this each time on startup)
ipfs swarm connect "/ip6/fca2:d099:c448:8666:e3f1:f39e:aad0:ea07/tcp/4001/ipfs/QmZbznJh9bAGDptdiRYcrLN4cM8h9D2jwSCTgrKRj3KayE" ;
ipfs bootstrap add /ip6/fca2:d099:c448:8666:e3f1:f39e:aad0:ea07/tcp/4001/ipfs/QmZbznJh9bAGDptdiRYcrLN4cM8h9D2jwSCTgrKRj3KayE ;
ipfs bootstrap add /ip6/fc52:735:525b:7aa:3450:3b0b:e03f:6d1f/tcp/4001/ipfs/QmZB2JPt8bhkQbBnjpwzdgaqZMmJupx85R7r9f1e5stmKs
- Check the nodes you are connected to
$ ipfs swarm peers
- Subscribe to certain IPFS channel
ipfs pubsub sub --discover airalab-mesh
Publish a message to the channel
ipfs pubsub pub airalab-mesh " F.CK THE GOVERNER\! "
- Share your file through the IPFS
$ ipfs add film.mkv
added QmWfHXfnQbxwqJoPnyRqSBndHR8EgWwyMAyF4FSaF1MEZx film.mkv
you can publish the hash to the IPFS pubsub, to let your mates to download the film 13. You can download the file from IPFS knowing its hash by
$ ipfs get QmWfHXfnQbxwqJoPnyRqSBndHR8EgWwyMAyF4FSaF1MEZx
Troubleshooting
Problem 1. Connection problems
Sometimes you could loose the connection to other nodes. This could be because of dongle channel sets back to wrong one. Or, more tricky case, the network just can loose connectivity between sub-networks.
To resolve these issues:
- Check WiFi dongle channel
$ iwconfig
You should see something like Frequency=2.422 GHz on dongle's interface, which means it is on the channel 3. Of you see 2.412 GHz instead, this means you dropped back to channel 1. If so, go to 2.
-
Re-Plug the dongle and repeat the steps starting from the step 1.
-
To connect sub-network, take the ip of any node from other sub-network and use
ipfs swarm connect <node>
to resore connectivity
Problem 2. File downloading is tooooo sloooow
Well, the dongles we used were very slow. And moreover the more nodes the mesh networks has, the faster it works. Hence, try to
- Use your notebook WiFi instead of the dongle
- Encourage your mates to join the mesh network
- Well, you can use the CJDNS on top of usual WiFi local network instead of mesh network
More Tools & Tricks
- yrd - CJDNS debugging tool
To set a WiFi connection from shell
Sometimes you probably would like to google something in the middle of the process. To not get crazy while switching your Wlan interface between mesh network and your internet provider router, you could use the WiFi dongle for the former and the notebook wlan interface for the latter. For that, use something like this
$ ip a
$ wpa_supplicant -i wlp3s0 -c wpa.conf
$ sudo rfkill list
$ sudo rfkill unblock all
$ sudo wpa_supplicant -i wlp3s0 -c wpa.conf