How I set up AODV with Openwrt on a Linksys WRT54G router (Dummy’s guide) {Part I}

August 11, 2006 at 1:37 am 13 comments

Note the keywords that I included in the title. This is an entirely TECHIE posting. 30 days worth of work condensed into one page.

This is really to help anyone, who’s looking for any sort of help to AODV on Openwrt on a WRT54G Version 4 /WRT54GL Linksys router. I am listing all my problems, or stuff encountered etc.
I have 2 methods. The first shows an inkling on how I did the cross-compilation from C code to Mips code. The second just shows how I did the ipkg thingy from the AODV-UU package that I found online. (For this second method, I am still trying to find a way to compile my own packages. Will put this in Part II when I figure out how. Or you guys can enlighten me)


Method 1: Following Krishna’s AODV Tutorial

Problems faced: The tutorial assumed that we know everything about Openwrt and Linux and stuff. I don’t, actually. I am a total noooooob. So let me list down the dummy’s step by step as much as I can to help anyone. Please cross reference with his Tutorial. His tutorial is really good! Just that I’m a noobie in need of more instructions. I wrote the steps in sync with his 4 steps.
1) He mentioned Firmware Installation.

I tried his stock firmware and I bricked my WRT54G Version 4 router. So please beware! Well, I managed to revive it by opening up the router and short circuiting pins 15 and 16. Check out this post on what I did to revive it. It’s doable! And I am still alive to tell the story!

So what I did was to download the buildroot (aka whiterussian or trunk). Apparently, we need to perform these details:

  1. Download and install this thingy called SVN. (You need to have it installed before you can get the buildroot codes) If I am not wrong, there are actually some details and some versions that you can download. I documented it on my previous computer but it died before I could save it. I will try to retrieve the info and update this site again. But the hint is, not all svn versions work.
  2. Check out the whiterussian version. Check out the trunk at your own risk. Apparently I did the trunk and realised that it couldn’t work for me. Irritating I tell you. Wasted like a week’s worth of time figuring out what happened.
  3. Build the firmware. You have to build it before you can get the toolchain/cross compiler. (Check FAQ on what do I mean by toolchain).
  4. So how do you build the firmware?

    In the openwrt directory (the top most level of your downloaded whiterussian/trunk)

    • “make menuconfig”
    • choose your options in the menu. I chose to put fping, tcpdump, sftp-server thingy (can’t remember the name)
    • Save and exit

    At this point, they would have done this config file (a config file is some sort of configuration file to aid the “make” process. And make simply means to make the software. Linux is kinda low-level, I figured) You don’t really have to bother about the config file, I couldn’t find it anyway, I just included it for an explanation here.

    The next step is to type “make”. This will make your software with all the options that you selected previously and stored in the config file.

    Note: The first make process will take a freaking long time. I took like 2-3 hours or so. Apparently they have to download all the funny programs required to compile the software. Be patient. Go play a game of hearts or something.

  5. The next step is to CHECK if your firmware/buildroot has been compiled and all your tools are in. I initially naively thought that my first make was fine and I stupidly used the wrong include folders (more about this later) and things like that. So how does one know if the firmware and hence buildroot has been compiled? I looked at a new “bin” folder and there were many firmware images there! (Unlike the first time when there was not even the bin folder)

Now that your firmware/buildroot is done, go ahead and flash your routers (Before that I restored to factory settings via the Linksys ORIGINAL firmware and uploaded my new firmware that I built {the corresponding firmware image in the bin folder} ), and you can move on with his second instructions!

2) Configuring the routers are the easy part. Just that I took over a day to configure them. Why so? Cause I used the wrong firmware and I set the wrong ip addresses. Correct me if I’m wrong, but in adhoc mode, your LAN address and wifi address better NOT be the same, or else you can’t ping out or receive pings from other connected nodes in the adhoc mode. Why? I don’t know. But through trial and error I discovered that.

Quicktip: If you realised that everything is set properly BUT something’s wrong, you still can’t ping. Check out your firewall. Do this: iptables -L <—- this lists out your firewall rules. This is something beyond what I know, I’m afterall a bimbo trying to do this aodv thingy. To edit right, you gotta do something like vi /etc/firewall.user. It will bring up the firewall file. This file contains the user defined rules. IE, your openwrt router will first load the normal default rules, then after that it will check this firewall.user and load whatever’s written there. If you can’t find where yours is located.. type find -name ‘firewall.user’. By the way, for some firmwares, apparently it’s a readonly file. So how now brown cow? I can’t remember the exact procedure but you have to copy the file to another name. Remove the readonly file. Copy back the file and edit it. That’s what I did.

Now that you’ve managed to get all your routers pinging without any aodv software on it. Move on to step 3!
3) Basically, I COULDN”T get the NIST to work. AODV-ST could be loaded BUT it hanged/rebooted my routers. What I did was used AODV-ST and his patch. But his patched had a slight problem, I tweaked the codes a little.

void update_aodv_neigh_metric(u_int32_t ip, int metric1, int metric2) {
aodv_neigh *tmp_neigh = NULL;
tmp_neigh = find_aodv_neigh(ip);

if (metric1 * metric2 > 100) {
#ifdef DEBUG
printk(KERN_INFO “Why is metric – %d to %s greater than 100.\n”, metric, inet_ntoa(ip));
metric1 = metric2 = 10;
if(tmp_neigh != NULL) {
if ((metric1*metric2) == 0) { //this portion was buggy in his patch

tmp_neigh->link_metric = DEFAULT_LINK_METRIC;
} else {
tmp_neigh->link_metric = compute_rel_for_linksys(metric1) * compute_rel_for_linksys(metric2) * 10;
// tmp_neigh->link_metric = (int) ((100.0/(float)metric) * (float)1000);


Just copy the above in place of his suggested portion on update_aodv_neigh_metric.

Then now comes the INTERESTING Part.

The cross compilation.

Problems faced: No matter what I did, all the codes keep hanging my router. I spent 1-2 weeks trying to figure out then I realised that we might have to compile against the sources from the Linksys GPL itself. I did it and it worked!

Let me explain:

Krishna said to modify the Makefile of the AODV directory.

There are 3 lines to be added.

Go look for the CC, LD and KPATH in the Makefile and edit them.

Type: find -name “mipsel-linux-gcc” and find -name “mipsel-linux-ld“. Whatever comes out that is contained within a build_mipsel directory, just copy the entire thingy into the CC and LD, respectively.

As for the KPATH. This is where your GPL sources from Linksys comes in. If I’m not wrong, you have to cross compile with reference to the “environment” that the Linksys routers were developed in, so that the code can better run, perhaps? I don’t know really πŸ˜› I got this hint from scouring through forums.

So how now brown cow again?

  1. Download your GPL code. This link only contains the GPL for WRT54GL. Don’t be lazy, go search a little bit around the Linksys website for your exact GPL code. I use this for my WRT54G version 4 and they work fine though.
  2. gzip -d yourgzipfile.gzip (this creates a tar file)
  3. tar -xvf yourtarfile.tar
  4. Go back to your make file and put in the KPATH:= <your-tar-directory>/release/src/linux/linux/include (tweak a little bit if you can’t get it right. Always use the find -name “*” where * can be linux/include or whatever to help you navigate around)

Once you’ve done all these, do a “make”. A successful make entails some welcome/hi/successful message at the end of the make. You should see an aodv-st.o there!

4) Run aodv-st.o by typing: insmod aodv-st.o use_dev=eth1 network_ip=x.x.x.x/ where x is whatever you named for your router’s wireless interface.

How do you know if it’s running? Type lsmod. If aodv-st is in, then yeah! To stop the module, type rmmod aodv-st

For lazy people who want to have a start up script to start the aodv the moment it switches on.. Here’s mine:

1)    Copy aodv-st.o into /aodv-st-patched
2)    cd /etc/init.d
3)    vi S60aodv
/sbin/insmod /aodv-st-patched/aodv-st.o use_dev=eth1 network_ip=
{network ip depends on the node. If it is 4 then use}
4)    chmod a+x S60aodv

Presto. Everything should work beautifully.Except that I have this “AODV: Error with SIOCSIWSPY: -22” that I can’t solve. But AODV-ST works just fine.

Type route to see your routing tables. πŸ™‚


1) What the hell is a toolchain? What is Buildroot? What cross compile?

I might be wrong about this.. but I figured that a toolchain/buildroot is needed to compile the C code into something readable by the Linksys router. Think about it this way, our computers have an architecture, usually called x86. C code has to be compiled into an x86 object file so that our computers (which are built on x86) can UNDERSTAND the codes. This is the same for our routers. Routers are actually built on the MIPS architecture. So naturally we need to translate (in other words compile) the C code to MIPS object file so that the routers can understand, right?

But, alas, one problem exists, our normal compilers don’t compile directly to MIPS object files (cause we are x86 computers right, naturally everything is compiled to x86 form.) So we have to cross compile from C code to x86 and use a special cross compiler that compiles x86 to MIPS code. I am not sure if this is the exact process, but think of it as a black box. In to it you input a C code —> The cross compilation process –> MIPS object file! Whee!

2) What do you mean by bricked the router?

From what I understand, it means that you uploaded some faulty firmware and your router cannot boot up anymore.. hence functioning like a brick. Thus the term “bricked”.


I spent nearly 2 hours typing this out. I hope it will really remove frustrations and help people get their asses moving and reduce production time from one month to one week!

The bimbotic geek signing off.

By the way, if you need help or you simply wanna know me, you can email me at at gmail dot com πŸ™‚

Entry filed under: Openwrt, Technology.

My first two dreams after POS Memory stuff on WRT54G and Openwrt

13 Comments Add your own

  • 1. Luke  |  July 20, 2007 at 4:37 am

    Nice work! I wrote the AODV code that Krishna used on his WRT54G and I am friends with the UU guys. Cool to see this stuff getting out there.

  • 2. thimerosa  |  July 20, 2007 at 5:09 pm

    Hi Luke!

    Thought that I should contribute to the spirit of open-source and share with the community what I have too πŸ™‚

    It’s a great honor to meet someone who wrote those codes!

    Thanks for dropping by!

  • 3. JJ  |  September 10, 2007 at 6:14 pm

    HI! I am a NUS student doing my FYP this year! So that makes me kind of like your “xue di”, right?? So here I was, looking for tutorials on the implementation of AODV protocol and I stumbled onto your site. I’m trying to to setup AODV-UU on an Ubuntu linux, I’m really a noob in all of this. I got questions and I need answers. I really need your help!! So here it goes:
    1) I know this sound stupid, (on a MANET and all) but can AODV be set up on a wired LAN environment? The readme file that comes with AODV-UU says that it is possible, but it did not give any hints any further on how to do so.

    2) Let’s say I’ve got AODV set up, how do I know what are the nodes that are connected to me?

    More to come. Thanks in advance!

  • 4. nagarajan  |  February 8, 2008 at 11:00 pm


    I flashed the openwrt-wrt54g-2.4-squashfs.bin firmware compiled using kamikaze_7.09. But am not able to configure the wireless interface parameters as mentioned in krishna’s tutorial. I could not find “infra” parameter in wireless configuration file thereby am not able to set the ad-hoc mode. Do i need to include any patches to get the complete wireless parameters?? Please let me know the procedure and the version you followed with openwrt. Your help in this regard is greatly appreciated.

    Looking forward your reply

    Thanks and regards,

  • 5. UI RISE: VAST: Hardware Linksys Wrt54g  |  October 26, 2008 at 2:48 am

    […] AODV Setup Guide 1 […]

  • 6. abghassen  |  August 25, 2009 at 5:58 pm

    I have compiled aodv-st and i generated the aodv.o
    but i dont know what i run aodv-st and send him into device

    Heeeeeeeeeeelp please,


  • 7. thimerosa  |  August 29, 2009 at 12:06 am

    Hmm what problem are you facing?

    Is the aodv-st in the router?

    I haven’t touched this stuff for the longest time ever but I’ll try to help in any way that I can.

  • 8. harish  |  October 30, 2009 at 8:41 pm

    hey i need the code for s-aodv plz if any one has then do send me on my email id
    thanks in advance

  • 9. aztroboy  |  June 3, 2010 at 12:52 pm

    Hi! This guide is indeed very useful. Thanks a lot! I just build and installed aodv-st into a WRT54GL and a WRT54G-TM routers

    Now, I happen to have this particular problem: I got two routers: (also a gateway with a public address on vlan0) and (mesh router, eth1 only).

    Now, if I, for example, try pinging from (1 hop to gateway to a public address (for example it prompts:
    ping: sendto: Network is unreachable.

    Any ideas? The firewall is set to accept anywhere.

  • 10. thimerosa  |  June 3, 2010 at 2:48 pm

    Haven’t touched these router stuff for a while…. but if I were to trouble shoot, I would take a look at the trace routes and check where the ping packets drop.

    For your firewall rules, are they set to forward packets too? Cause sometimes the dns packets from the initial ping might not be forwarded back to the router cause of the rules. You need to check.

    Also, ping to a couple of public addresses, not all public addresses allow pings to them so the error message, “network is unreachable” might be there.

    Hope this helps πŸ™‚

  • 11. Kayode Oki  |  April 9, 2012 at 6:42 pm

    Good day,
    My name is Kayode a student at the University of Zululand
    I’m setting up a Wireless Mesh network indoor testbed, using both
    OLSR and AODV as my routing protocol. I’m done with OLSR part, but the
    AODV part is not compiling. I followed your post and some other forum posts, but all proof abortive. I’m using WRT54GL v1.1 router with Openwrt whiterussian 0.9 version as my firmware. I’ve tried to compile using Ubuntu 6.06, 9.10 and 11.04 but none of them work. I’ve also tried to use image builder and SDK, yet none of them work. Please can anyone
    send me the aodv-st.o that you generated when you run the code so that I can try it om my routers too or if you know any other ways through which I can be able to Set up AODV on my WRT54GL v1.1, kindly send them to me.
    I’m seriously running out of time for the project, please any help you can render will be highly appreciated.

    Thanks and do have a great day.

  • 12. Kian  |  August 30, 2013 at 8:28 pm

    Hello I am so grateful I found your website, I really found you by accident,
    while I was researching on Google for something
    else, Nonetheless I am here now and would just like to
    say thanks a lot for a marvelous post and a all round enjoyable blog (I also
    love the theme/design), I don’t have time to read it all at the moment but I have book-marked
    it and also included your RSS feeds, so when I have time I will be back to read a great deal more,
    Please do keep up the excellent work.

  • 13. netgear dgn2200 100nas  |  March 19, 2017 at 5:48 pm

    Wow, amazing blog format! How lengthy have you ever been blogging for?
    you make running a blog look easy. The whole glance of your site is excellent, let alone the content material!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed

August 2006

Recent Posts

Blog Stats

  • 35,229 hits

%d bloggers like this: