Difference between revisions of "Mesh/WalkThrough"

4,067 bytes removed ,  17:15, 5 January 2016
Mesh Walkthrough - Updating to reflect all the new changes
(Mesh Walkthrough - Updating to reflect all the new changes)
Line 1: Line 1:
NOTE: This WalkThrough is somewhat outdated. We no longer use batman-adv. The instructions for flashing nodes are still fine for e.g. Ubiquiti devices but not the TP-Link devices we use as home nodes. We hope to update this walkthrough soon.'''
This a walkthrough for flashing a node with the sudomesh firmware and then configuring it with makenode. At the end of the walkthrough, you'll be able to plug in your router and join the mesh. The walkthrough assumes you're using a linux-ish (OSX should mostly work) OS and that you have [https://help.ubuntu.com/community/UsingTheTerminal basic knowledge of the terminal]. The basic idea of getting a node (router) on the mesh consists of flashing (copying files to [https://en.wikipedia.org/wiki/Flash_memory flash memory]) an operating system to the node and then using a software configurator finish setup .
 
This a walkthrough for flashing a node with an OpenWRT firmware and getting mesh-relevant packages installed. The walkthrough assumes you're using linux and that you have [https://help.ubuntu.com/community/UsingTheTerminal knowledge of the terminal]. The basic idea of getting a node (router) on the mesh consists of flashing (copying files to [https://en.wikipedia.org/wiki/Flash_memory flash memory]) an operating system to the node and installing additional drivers and packages. We use [https://openwrt.org/ OpenWRT] as the operating system on our embedded devices (routers), then connect to the node (via [https://en.wikipedia.org/wiki/Secure_Shell SSH]), install the related software and configure it. This operating system is meant to fit on a small amount (4MB) of flash memory.  


To build an OpenWRT image from scratch, visit this How To: [[Mesh/Build An OpenWRT Image]]
To build an OpenWRT image from scratch, visit this How To: [[Mesh/Build An OpenWRT Image]]
Line 7: Line 5:
= Build Environment =  
= Build Environment =  


The directions that follow assume you are runing a linux distro. Windows environments, see the instructions at the bottom of the page.
The directions that follow assume you are runing a linux-ish distro (OSX should work). Many of the quoted commands listed below may need `sudo` prepended to them. For the moment, Windows users will have to figure out some of these steps on their own. Sorry :/
 
== Install TFTP ==
verify that you have TFTP installed
    sudo apt-get update
    sudo apt-get install tftp
 
Mac Users will already have TFTP installed.
 
== Download the correct firmware ==
For the supported routers, please find the latest firmware here:
    http://build.sudomesh.org/latest_image/


=Installing OpenWRT=
=Installing OpenWRT=


There are four methods of [http://wiki.openwrt.org/doc/howto/generic.flashing flashing a router].
==Supported Hardware==
 
At the moment, we are supporting the following routers for home nodes:
Notes on choosing a router:  [[Mesh/Choosing_A_Router]]
* [https://wiki.openwrt.org/toh/tp-link/tl-wdr3500 TP-Link WDR3500] - [https://builds.sudomesh.org/builds/chaos_calmer/ar71xx/openwrt-ar71xx-generic-tl-wdr3500-v1-squashfs-factory.bin firmware image]
 
* [https://wiki.openwrt.org/toh/tp-link/tl-wdr3600 TP-Link WDR3600] - [https://builds.sudomesh.org/builds/chaos_calmer/ar71xx/openwrt-ar71xx-generic-tl-wdr3600-v1-squashfs-factory.bin firmware image]
Tested and working on:
* [https://wiki.openwrt.org/toh/tp-link/tl-wdr4300 TP-Link WDR4300] - [https://builds.sudomesh.org/builds/chaos_calmer/ar71xx/openwrt-ar71xx-generic-tl-wdr4300-v1-squashfs-factory.bin firmware image]
    *Bullet M5
* [https://wiki.openwrt.org/toh/wd/n600 Western Digital MyNet N600] - [https://builds.sudomesh.org/builds/chaos_calmer/ar71xx/openwrt-ar71xx-generic-mynet-n600-squashfs-factory.bin firmware image]
    *Bullet 2 HP
* [https://wiki.openwrt.org/toh/wd/n750 Western Digital MyNet N750] - [https://builds.sudomesh.org/builds/chaos_calmer/ar71xx/openwrt-ar71xx-generic-mynet-n750-squashfs-factory.bin firmware image]
    *Picostation 2 HP
 
==Step One: Reset the router==
===PicoStation===
  - Turn off the device
  - Press the reset button (near the ethernet port)
  - Turn on the device (by plugging in the ethernet w/ [http://en.wikipedia.org/wiki/Power_over_Ethernet POE])
  - Release the reset button after the lights blink red and orange. (the router will continue blinking until its flashed)
  - Ping 192.168.1.20. If it works, you're ready to upload an image.
 
===Bullet===
  - Press and hold the reset button while plugging in the powered ethernet cable.
  - Keep holding the reset button. Look at the LED above the power LED.
  - It will go from one green light, to two, the start flashing orange and red
  - Release the reset button when it turns on the second time.
 
The Bullet will now be running a TFTP server 192.168.1.20
 
==Step Two: Configure your IP address==
*Ensure that you have an IP address different from 192.168.1.20 and different from 192.168.1.1 in the 192.168.1.x range.
*You probably want to stop network-manager (not all distros use this, but Ubuntu does):
    sudo /etc/init.d/network-manager stop
*On most linux machines (assuming your ethernet interface is eth0) setting your ip address looks like this:
    sudo ifconfig eth0 192.168.1.12 netmask 255.255.255.0 up
 
==Step Three: Install OpenWRT on the router==
 
*Then do the following:
*: <code>$ tftp 192.168.1.20</code>
*: <code>tftp> binary</code>
*: <code>tftp> rexmt 1</code>
*: <code>tftp> timeout 60</code>
*: <code>tftp> trace</code>
*: <code>tftp> put <FIRMWARE>.bin</code>
 
The <FIRMWARE>.bin is the name of the firmware file you want to flash.
 
We are hosting custom firmwares for the supported routers [http://build.sudomesh.org/latest_image/ here] make sure you download the correct firmware for your model of router.
 
You will see a bunch of lines like this:
 
sent DATA <block=13468, 512 bytes>
received ACK <block=13468>
 
Once those lines stop coming, the router will take somewhere between 1 and 7 minutes to stop flashing its lights at you. DO NOT unplug or turn off the router until the bottom two green LEDs are solid for a minute. On the older routers the upgrade can take much longer than on the newer routers so be patient.
 
If you have a PicoStation running AirOS, you can use the following shell script to reflash it without needing to press the reset button:
#!/bin/sh -e
FIRMWARE=openwrt-atheros-ubnt2-pico2-squashfs.bin
#FIRMWARE='PicoStation2HP-v3.2.build3734.bin'
curl http://ubnt:ubnt@192.168.1.20/upgrade.cgi
curl -F fwfile=@"$FIRMWARE" http://ubnt:ubnt@192.168.1.20/upgrade.cgi
curl -F 'nil=nil' http://ubnt:ubnt@192.168.1.20/fwflash.cgi
echo "FLASHING IN PROGRESS - It will be complete when the system displays two solid green lights for ten seconds."
 
Note, that if you're flashing AirOS instead, at least the Bullet M5 series will remember setting between firmware upgrades and others may do so too. To reset username / password / ip address and other settings to factory default, first let the router boot, then press and hold the reset button until more lights come on and release. Wait for the factory reset to complete (a minute or two) and try to access 192.168.1.1 in a browser (ensure that your own IP is in the 192.168.1.x range). Note: This procedure seems to have no effect on the Bullet 2 HP, but works on the Bullet M5. It could be that the Bullet 2 HP does not persist settings across firmware upgrades, and so doesn't have the factory reset procedure.  When flashing AirOS on the PicoStation, only one green light will be on when the flash is complete.
 
==Windows Instructions==
 
from the directory where you stored the .bin file:
 
>tftp -i 192.168.1.20 PUT openwrt-atheros-ubnt2-squashfs.bin
 
Downloads within a minute, wait about 5 minutes to finish installing...
 
=Installing BATMAN=
 
For Bullet, first run the following commands to free up space:
  ssh root@192.168.1.1
  opkg remove --force-removal-of-dependent-packages remove luci*
  exit
 
 
== Online ==
 
Use these instructions if your router is connected to the internet:
 
  ssh root@192.168.1.1
  opkg update
  opkg install kmod-batman-adv
 
== Manually / Offline ==
 
If your router does not have internet connectivity when installing, then use these instructions.
 
Download these packages from:
 
    http://downloads.openwrt.org/<openwrt_version_name>/<openwrt_version_number>/<chipset_name>/<type>/packages
 
As of 7/31/13, download this: http://downloads.openwrt.org/attitude_adjustment/12.09/atheros/generic/packages/kmod-batman-adv_3.3.8%2b2012.3.0-3_atheros.ipk
 
and this: http://downloads.openwrt.org/attitude_adjustment/12.09/atheros/generic/packages/kmod-lib-crc16_3.3.8-1_atheros.ipk
 
Go to http://downloads.openwrt.org and browse to the correct directory. If there are multiple types, you probably want the 'generic' one, but check with the OpenWRT wiki page for your device to make sure.
 
These are the required packages:
 
kmod-batman-adv_<version>_<chipset>.ipk
kmod-lib-crc16_<version>_<chipset>.ipk
 
Use scp to copy them to the router:
 
scp kmod-*.ipk root@192.168.1.1:
 
Then ssh into the router and install them:
 
ssh root@192.168.1.1
opkg install kmod-*.ipk
 
=Configuring BATMAN=
These notes are valid for OpenWrt 12.09 (Attitude Adjustment), which uses BATMAN 2012.4.0. In newer versions, the version of BATMAN used is 2013.0.0 and the syntax for configuring BATMAN differs slightly. See [http://www.open-mesh.org/projects/batman-adv/wiki/Batman-adv-openwrt-config this page on open-mesh.org] for more info.
 
==Step One: Wireless Configuration ==
 
In /etc/config/wireless:
 
<pre>
config wifi-device 'radio0'
option type 'mac80211'
option hwmode '11g'
option channel '3'        # You may want another channel
option disabled '0'
option phy 'phy0'
 
# the interface where non-mesh nodes connect
config wifi-iface
option device 'radio0'
option ifname 'ap0'
option encryption 'none'
option network 'lan'
option mode 'ap'
option ssid 'sudomesh'  # You should change the ssid to be unique for dev purposes


# the mesh interface
==Images==
config wifi-iface
Sudomesh firmware images can be found here:
option device 'radio0'
[https://builds.sudomesh.org/builds/chaos_calmer/ar71xx/ https://builds.sudomesh.org/builds/chaos_calmer/ar71xx/]
option ifname 'adhoc0'
option encryption 'none'
option network 'mesh'
option mode 'adhoc'
option bssid 'CA:FE:C0:DE:F0:0D' # You should change this to be unique for development purposes, but for meshing this should be the same for all routers on the mesh
option ssid 'sudomesh-backchannel' # You should change the ssid to be unique for development purposes, but for meshing this should be the same for all routers on the mesh
</pre>


==Step Two: Network Configuration ==
Download the image according to your hardware. For example, if you have a Western Digital MyNet N600, download the image named: openwrt-ar71xx-generic-mynet-n750-squashfs-factory.bin, or use the links above


In /etc/config/network:
==Flashing==
There are different techniques for flashing each of the routers. Use the links above to the openwrt wiki and follow the instructions there to flash the router with the firmware you've downloaded.


<pre>
==Confirm Installation==
config interface 'loopback'
In order to confirm that the installation has proceeded correctly, use an ethernet cable to  connect your computer to the "internet/WAN" port of  your router and set your IP address to an address on the 172.22.0.0/24 subnet:
option ifname 'lo'
<code>$ ip addr add 172.22.0.9/24 dev IF_NAME</code>
option proto 'static'
(where IF_NAME is the name of your ethernet interface)
option ipaddr '127.0.0.1'
You ''may'' want to stop network-manager (not all distros use this, but Ubuntu does):
option netmask '255.0.0.0'
<code>$ /etc/init.d/network-manager stop</code>


# set up ethernet bridging between eth0 and bat0
You can also assign yourself the address via a network manager, both in linux and OSX.
# this means that packets can move between the ethernet port
# and the wifi mesh
<code>$ ssh root@172.22.0.1</code>
config interface 'lan'
option type 'bridge'
The default password will be: `meshtheplanet`
option proto 'static'
option ipaddr '10.42.10.11' # this should be a unique IP
option netmask '255.255.0.0'
option dns '208.67.222.222'
option gateway '192.168.1.1' # an internet gateway, not sure how to deal with multiple gateways yet
option ifname 'eth0 bat0'


# the mesh interface
You ''may'' need to restart the router, but be careful not to restart it while it's in the process of flashing.
config interface 'mesh'
option ifname 'adhoc0'
option proto 'none'
option mtu '1528'
</pre>


==Step Three: BATMAN Configuration ==


In /etc/config/batman-adv:
=Configuring=
These are the steps for configuring your newly flashed router. It will retrieve hardware information about the node, prompt you for a few config settings, and then query the meshnode database to get an available IP address and subnet.


<pre>
==Prerequisites==
config mesh 'bat0'
You'll need:
option interfaces 'adhoc0' # the interface for which to enable batman0
* A newish version of nodejs and npm. Follow the recommended instructions at [https://docs.npmjs.com/getting-started/installing-node npmjs.com].
option 'aggregated_ogms' # no idea what this means
* Git. In Debian based distros you can do: <code>$ apt-get install git</code>. For OSX you can probably use homebrew or your preferred package manager.
option 'ap_isolation' # no idea what this means
</pre>


==Step Four: System Configuration ==
==Setup==
Download [https://github.com/sudomesh/makenode makenode]. The easiest way to do this will likely be with git:
<code>$ git clone https://github.com/sudomesh/makenode.git</code>


In /etc/config/system you can set hostname and timezone. This is not strictly necessary for BATMAN to work, but it should be set correctly. The below timezone is correct for the Pacific U.S. timezone (PST). The naming convention for hostnames is: <router-model-name>-<some-unique-name-you-choose>
Then you need to install nodejs/npm packages:
<code>$ cd makenode</code>
<code>$ npm install</code>
<code>$ cp settings.js.example settings.js</code>


<pre>
The default settings in `settings.js` should suffice in most cases, but if you need to make changes, do them there.  
config system
option hostname tl-wr703n-foo
option timezone PST8PDT,M3.2.0,M11.1.0
</pre>


If you'd like to add your ssh key to the router, add it to the `configs/authorized_keys` file. You'll see that there are 3 other keys there for our developers. You can remove them if you'd like, but they're currently the only way we can provide remote support. During the alpha test phase we ask that you consider whether you are able to do diagnostics/debugging yourself before you remove them.


You may also have to turn off dnsmasq. (someone else can chime in if this contradicts their working knowledge)
==Running==
You should now be able to run makenode:
<code>$ ./makenode.js</code>


<pre>
Makenode will detect the hardware on the router and ask you to input some data about the node. Some notes:
/etc/init.d/dnsmasq disable
* Set the "txpower" to 20. This should be set in the code, but hasn't been just yet.
</pre>
* The password for the private ssid should be at least 8 characters or you will not be able to connect
* For info on what constitutes a valid hostname, see: [http://stackoverflow.com/questions/3523028/valid-characters-of-a-hostname valid characters of a hostname]
* The max downstream and upstream bandwidth are the maximum amount of bandwidth you want to share on the "peoplesopen.net" network. They are measured in kbps (kilobits per second), so if you'd like to share 10mbps (megabits per second), enter 10000. You may want to run a [http://www.dslreports.com/speedtest speed test] to find out how much bandwidth you have and determine how much you want to share.


==Step Five: Testing ==
==Step Five: Testing ==


You should see the 'sudomesh' and 'sudomesh-backchannel' wifi interfaces when running `sudo iwlist wlan0 scan`
You should see the 'peoplesopen.net' and 'pplsopen.net-node2node' wifi interfaces when running `sudo iwlist wlan0 scan` or when looking at available wifi networks.