Wednesday, 4 December 2013

How to install NO Ad-Hoc Routing Agent (NOAH) in NS-2.34

NO Ad-Hoc Routing Agent (NOAH)

NOAH is a wireless routing agent that (in contrast to DSDV, DSR, ...) only supports direct communication between wireless nodes or between base stations and mobile nodes in case Mobile IP is used. This allows to simulate scenarios where multi-hop wireless routing is undesired. NOAH does not send any routing related packets.

  • It has been updated to work with ns-2.26 - ns-2.30 and with non-Mobile IP scenarios. (For older versions of ns-2, take a look at but this version does not contain the bugfixes for non-Mobile IP scenarios.)
  • Further update to allow static multi-hop routes. The routes can be set up using the routing command which takes as parameters the number of destinations and then as many tuples of destination and next hop address. The following example sets up static routing for a line of nodes:
    # setup static routing for line of nodes
    for {set i 0} {$i < $val(nn) } {incr i} {
        set cmd "[$node_($i) set ragent_] routing $val(nn)"
        for {set to 0} {$to < $val(nn) } {incr to} {
     if {$to < $i} {
         set hop [expr $i - 1]
     } elseif {$to > $i} {
         set hop [expr $i + 1]
     } else {
         set hop $i
     set cmd "$cmd $to $hop"
        eval $cmd
Step-by-step installation instructions for ns-2.34
add noah/noah.o \ to OBJ_CC and tcl/mobility/noah.tcl \ to NS_TCL_LIB
Note: make sure there is no space after "\"
add noah.h and to a new subdirectory noah/
Create directory in the folder ns-2.34
add noah.tcl to tcl/mobility/
in  line 197: add source ../mobility/noah.tcl
in 634: add
            NOAH {
                   set ragent [$self create-noah-agent $node]
line 778: add
Simulator instproc create-noah-agent { node } {
    # Create a noah routing agent for this node
    set ragent [new Agent/NOAH]

    ## setup address (supports hier-addr) for noah agent
    ## and mobilenode
    set addr [$node node-addr]

    $ragent addr $addr
    $ragent node $node

    if [Simulator set mobile_ip_] {
        $ragent port-dmux [$node demux]
    $node addr $addr
    $node set ragent_ $ragent
    return $ragent
Open terminal and go to the directory ns-2.34 and type follow commands
make clean

If everything went then you have successfully installed NOAH routing protocol. 

Possible errors
Makefile:13: *** commands commence before first target.  Stop.

The reason of this error is due to the possible space after “\” in these lines noah/noah.o \ or tcl/mobility/noah.tcl \
Make sure u leave no space after “\”

Thursday, 14 February 2013

bash unexpected end of file problem

bash unexpected end of file problem

Other day I was working for my research in Ubuntu and I needed to automate a process. I decide to write a bash script but my while loop was not working at all. Any condition and loop I wrote, it gave me a unexpected end of file error. I try to google for more than an hour but nothing was helpful. Even though my syntax seems to be correct but the terminal was giving me same error again and again. I was not able to figure out what was causing the error but, finally I was able to solve it.

There are several reasons for throwing this error when working with the bash script and mostly its due to syntax error. But, sometimes even  though every syntax is correct, you may still get this error and those times are really frustrating. It took me more than 2 hours to figure out the problem.

I figure our the cause of this problem. It is due to the line ending used by various OS. I figure out that when we save our file in gedit (ubuntu), it has 3 line ending options as,
1. Unix/linux
2. Mac
3. Windows.

By default, windows is selected as line ending, and if its the case then how much you write the correct syntax, bash will not run and give you the unexpected end of file error.

Just use the line ending as unix/linux and your bash script should work well this time. I hope this simple information is helpful.

Thank you and have a nice day...