Difference between revisions of "Mesh/WalkThrough"

From Sudo Room
Jump to navigation Jump to search
(added flashing methods)
Line 43: Line 43:
*: <code>$ make menuconfig</code>
*: <code>$ make menuconfig</code>
*Configure the firmware (needs it's own article)
*Configure the firmware (needs it's own article)
*: ''Kernel Modules > Network Support > kmod-ipsec''


=Installing OpenWRT=
=Installing OpenWRT=

Revision as of 17:12, 1 December 2013

The following walk through assumes you're using linux and knowledge of terminal. The basic idea of getting a node (router) on the mesh consists of flashing (copying files to the flash) an operating system to node and installing additional drivers and packages. We use OpenWRT as the operating system on our embedded devices (routers), then connect to the node (via SSH) and install mesh the related software and configure it. This operating system is meant to fit on small amount (4MB) of flash memory.

Building an OpenWRT image

If you already have a image of the operating system (firmware), then you can skip this step. If your router has the stock software, then you'll probably have to use a factory image, which has information in the header which allows you to install it. Otherwise, you'll be using a sysupgrade image (trx image).

Step One: Install Buildroot

The Buildroot is software which will creates your firmware. The Buildroot has feeds associated with it that allow you to add more to your firmware. The feeds are comparable to repositories in linux. There's a full guide at OpenWRT, this is a shorter version.

  • Install svn and git.
    $ sudo apt-get install subversion build-essential
    $ sudo apt-get install git-core
  • Make a new directory and download the Buildroot.
    $ mkdir ~/openwrt
    $ cd ~/openwrt
    $ git clone git://git.openwrt.org/openwrt.git
  • Update Buildroot and install feeds.
    $ cd ~/openwrt/openwrtt
    $ ./scripts/feeds update -a
    $ ./scripts/feeds install -a (if you want to install all feeds)
  • Update and Install the Buildroot dependencies
    $ make defconfig (build list of dependencies)
    $ make prereq (install dependencies)

If you're still missing software, then you'll have to manually install it.

Step Two: Install Feeds

There are other feeds than the standard that you may want to be available to Buildroot. These are the suggested feeds for nodes:

  • Find the drivers for your device
    Determine drivers for your router based on the chipset (ex. Atheros AR9331)
    The open source driver for this example is Ath9k. (all drivers for linux)
  • Install the driver feed
    $ ./scripts/feeds install <PACKAGENAME> (ex. kmod-ath9k)

Other feeds for OpenWRT.

Step Three: Build the Firmware

  • Run the Buildroot
    $ make menuconfig
  • Configure the firmware (needs it's own article)
    Kernel Modules > Network Support > kmod-ipsec

Installing OpenWRT

There are four methods to flashing a router.

Tested and working on:

   *Bullet M5
   *Bullet 2 HP
   *Picostation 2 HP 

Step One: Reset the router

  • 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:
    $ tftp 192.168.1.20
    $ binary
    $ rexmt 1
    $ timeout 60
    $ trace
    $ tftp> put <FIRMWARE>.bin

The <FIRMWARE>.bin is the name of the firmware file you want to flash.

Assuming you want to run Attitude Adjustment, the correct firmwares for tested routers are:

Bullet M5: http://downloads.openwrt.org/attitude_adjustment/12.09/atheros/generic/openwrt-ar71xx-generic-ubnt-airrouter-squashfs-factory.bin
Bullet 2 HP: http://downloads.openwrt.org/attitude_adjustment/12.09/atheros/generic/openwrt-atheros-ubnt2-squashfs.bin
Picostation 2 HP: http://downloads.openwrt.org/attitude_adjustment/12.09/atheros/generic/openwrt-atheros-ubnt2-pico2-squashfs.bin

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 it presents two adjacent green LEDs and has done so for 10+ seconds. 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 this page on open-mesh.org for more info.

Step One: Wireless Configuration

In /etc/config/wireless:

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
config wifi-iface
	option device 'radio0'
	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

Write some of this stuff down for reference later! You might need it!

Step Two: Network Configuration

In /etc/config/network:

config interface 'loopback'
	option ifname 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

# set up ethernet bridging between eth0 and bat0
# this means that packets can move between the ethernet port
# and the wifi mesh
config interface 'lan'
	option type 'bridge'
	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
config interface 'mesh'
	option ifname 'adhoc0'
	option proto 'none'
	option mtu '1528'

Step Three: BATMAN Configuration

In /etc/config/batman-adv:

config mesh 'bat0'
	option interfaces 'adhoc0' # the interface for which to enable batman0
	option 'aggregated_ogms' # no idea what this means
	option 'ap_isolation' # no idea what this means

Step Four: System Configuration

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. The naming convention for hostnames is: <router-model-name>-<some-unique-name-you-choose>

config system
	option hostname	tl-wr703n-foo
	option timezone	PST8PDT,M3.2.0,M11.1.0


You may also have to turn off dnsmasq. (someone else can chime in if this contradicts their working knowledge)

/etc/init.d/dnsmasq disable

Step Five: Testing

You should see the 'sudomesh' and 'sudomesh-backchannel' wifi interfaces when running `sudo iwlist wlan0 scan`