.: MojoMesh :.
or, a HowTo: Mesh Network on a WRT54G using OLSRd


Please note that you have been redirected from the original URL, http://doctormojo.com/wrt54g/. Please take note of the new URL, http://www.sitkalug.org/mojomesh.php and update your bookmarks accordingly. The new URL is permanent. Thank you for coming!

Random Info

I love the WRT54G. Who couldn't, I guess.

So here's the lovely little mesh network package I put together. It uses the experimental build of OpenWRT as of around 4/18/2005, and the nifty little olsrd routing daemon from olsr.org. Some ash glue to stick it all together.

So....

I only used OpenWRT experimental 'cause my first WRT54Gs were version 
2.2.  Update:  I've got a G v1.1 going with experimental OpenWRT, and 
have created a separate script to set up the v1.1.

	I'm pretty sure that the G v2.2 script is for G v2.x, and the
	G v1.1 script is for G v1.x, but remember the dieffenbachia (below)
The br0 needs to be broken. The wifi_ variables need populated with good ad-hoc stuff. my glue does this, but you might want to read through it first to make sure you agree with what I've chosen to do. By downloading and using my glue you hereby indemnify me for any bricking that may happen to your router, dog, goldfish, dieffenbachia, or what-have-you. It's fairly strait forward and forces -you- to do the 'nvram commit' so I'm not the one whodunnit!

here's the nvram settings I modify for the purpose (Version 2.2 script shown):
	    nvram unset lan_ifnames
            nvram set lan_ifname=vlan0 # MUST BE vlan2 for G v1.1 router!!
            nvram set wifi_ifname=eth1 # MUST BE eth2 for G V1.1 router!
            nvram set wifi_proto=static
            nvram set wifi_ipaddr=$1
            nvram set wifi_netmask=$2
            nvram set wl0_mode=sta
            nvram set wl0_infra=0
            nvram set wl0_ssid=$3
            nvram set wl0_channel=$4
	    nvram set security_mode=wep
	    nvram set wl0_wep_bit=$5
	    nvram set wl0_key1=$6
	    nvram set wl0_key=1
	    nvram set wl0_closed=1
	    nvram set router_name=`nvram get wifi_ipaddr | sed 's/[^0-9]/-/g'`
	    nvram set wan_hostname=`nvram get router_name`
	    nvram set mm_map=$7
	    nvram set mm_x=$8
            nvram set mm_y=$9
	    echo "run nvram commit to save options, then reboot to enact them";
$1 is the IP of this box on the mesh net, ex. 10.43.24.19
$2 is the mask of this box on the mesh net, ex. 255.255.0.0
$3 is the ssid of the mesh network to join, ex. big_mesh
$4 is the channel of the mesh network to join, ex. 11
$5 is the number of bits in the wep key the mesh uses, ex. 64 or 128
$6 is the WEP key to use for the mesh network in HEX form.
Omit the '0x' from the beginning: 1234AB5678

Of course, all ips different, all other settings congruent.

Procedure

I need to confirm that this package works on a router with a factory-fresh nvram. I have _NOT_ confirmed that it does this yet. Apparently,the nvram in these routers can be blanked with the command "mtd erase nvram;reboot" -- Will update with the results of this when I can test it.

Install OpenWRT experimental.  Dunno if stable works.  I used the one mirrored here.
Install olsrd. I used the one mirrored here.
Install wl if you want better control over the wifi. I used the one mirrored here.
Install my glue. I'd do the following: cd / wget http://sitkalug.org/mm/mojomesh.tgz tar xvzf mojomesh.tgz rm mojomesh.tgz Run /bin/mm_init_v[VERSION].x where [VERSION] is 1 or 2 depending on your router revision, to set up the node's configuration files properly. Something like the following would work: mm_init_v2.x 10.11.UVW.XYZ 255.255.0.0 big_mesh 11 64 42DEADBEEF for a v2.2 router, or mm_init_v1.x 10.11.UVW.XYZ 255.255.0.0 big_mesh 11 64 42DEADBEEF for a v1.1 router.
where UVW and XYZ are random, unique numbers ranging from 1-254, inclusive.
This would join a network with a maximum of around 65 thousand hosts. Alter the IP and the netmask accordingly.

Example

An example setup for three nodes (two on v2.2 routers and one on a v1.1 router) would entail the following commands, each run on a different router:
mm_init_v2.x 10.11.12.1 255.255.255.0 small_mesh 11 64 1234AB5678; nvram commit; reboot
mm_init_v2.x 10.11.12.2 255.255.255.0 small_mesh 11 64 1234AB5678; nvram commit; reboot
mm_init_v1.x 10.11.12.3 255.255.255.0 small_mesh 11 64 1234AB5678; nvram commit; reboot

Notes

When OpenWRT boots, the /etc/init.d/S53olsrd script checks to see if there is a default route (gateway to the net). If there is, olsrd is configured to announce it. olsrd only runs on the wifi interface.

My firewall script isn't finished yet. And it allows access on the WAN interface ports 22 and 80 for configuratory purposes.

After installing my 'glue', a script is installed at /bin/mm_update - when run, this script will get the latest version of my mojomesh.tgz package from sitkalug.org, un-tar-gz it to the root directory. Beware, this will revert the following files, removing any changes you may have added:
/bin/mm_olsrd_protect
/bin/mm_init_v1.x
/bin/mm_init_v2.x
/bin/mm_neighbors_and_gateways
/bin/mm_status_update
/bin/mm_update
/etc/init.d/S45firewall
/etc/init.d/S43rdate
/etc/init.d/js.php
/etc/init.d/cnf
/etc/init.d/S45firewall2
/etc/init.d/S50telnet
/etc/init.d/S53olsrd
/etc/init.d/S98status
/etc/init.d/u
/etc/dnsmasq.conf
/etc/banner
/etc/resolv.conf
/etc/profile
/etc/olsrd.conf.gateway.v1.x
/etc/olsrd.conf.gateway.v2.x
/etc/olsrd.conf.node.v1.x
/etc/olsrd.conf.node.v2.x
/www/index.html

Also, I have instructed each router to resolve using granitecanyon's public name servers. Information can be found here.

If you have any questions or suggestions, you can reach me at moj@sitkalug.org -- you might put the word 'mesh' or something in the subject to make sure it doesn't get trashed...

Here's the last .dot file I requested from my mesh:

image last updated 08.07.2008 at 11:13 pm Alaska Time.

Oh, in case you were wondering, my web server thinks
this page was last modified on 10.14.2009 at 10:33 am Alaska Time.