NS-2.27 and Leach

Wednesday, July 21, 2004

Problem:
The current MTE code somehow is not able to get the DATA to the basestation.  I can clearly see that it sends the data to the next hop BS, but the basestation has no message that it received the message.

Wanderings:
Wondering if the mac address is wrong, and it needs to be a $MAC_BROADCAST, but apparently not.

Solution:
no idea.

Tuesday, July 13, 2004

Problem:
The mte (dsdv or dsr) code won't run, because it's dependent on the variable $bs. however, $bs is only set in /mit/uAMPS/sim/uamps.tcl, which is sourced in leach.tcl. When leach.tcl is not being used, uamps.tcl is never run. However, one should not be able to just take it out and source it in wireless-leach.tcl, since it requires $opt(spreading)

Solution:
The MTE does run now, for whatever reason, but dsdv and dsr doesn't.  mte does source uamps.tcl, but the other two don't.  That's ok, I just need mte.

Problem:
The sample leach script is actually defunct when it comes to being able to switch between mte, dsdv, dsr, leach-c, etc. Trying to get leach to work again, but I get this:

96: Current cluster-head is 66, code is 1, dist is 22
97: Current cluster-head is 66, code is 1, dist is 13
98: Current cluster-head is 66, code is 1, dist is 25
ns: _o217 send_now 0xffffffff 1 8 16 139.0 1: wrong # args: should be "_o217 self class proc mac_dst link_dst type msg data_size dist code"
(Application/LEACH send_now line 1)
invoked from within
"_o217 send_now 0xffffffff 1 8 16 139.0 1"


It looks like some interface is different. I didn't get this error before, and I don't know where it's coming from.

Wading:
Apparently, the offending piece of code is only at once place:

Application/LEACH instproc send_now {mac_dst link_dst type msg data_size dist code} {

called by:

$ns_ at [$ns_ now] "$self send_now $mac_dst $link_dst $type $msg $data_size $dist $code"

After running the code with it printing out the parameters it was passing, in one instance, $link_dst became null for some reason, and that's why tcl thought there was an invalid number of arguments.

Solution:

8: Current cluster-head is 8, code is 1, dist is 139.0
9: Current cluster-head is , code is 1, dist is 0
10: Current cluster-head is 50, code is 2, dist is 29


Looking at node #9 in the snippet above, it ends up that the clusterheads weren't sending the ADV_CH (advertise clusterhead) message loud enough so that some nodes weren't able to hear it. Thus, they did not select a clusterhead and thus, there was no link destination for the messages they were sending.

Either the density of the nodes is too low, or that the power is too low.

printing out the clusterhead choices, it seems like there are some that are missing:

node 7 CH = 48
node 7 choice = 52 37 97 70 77 92 67 2
node 7 CH = 77
node 7 choice = 52 37 97 70 77 92 67 2
7: Current cluster-head is 77, code is 5, dist is 10
node 8 CH = 48
node 8 choice = {} 52 37 97 70 77 92 67 2
node 8 CH =
node 8 choice = {} 52 37 97 70 77 92 67 2
8: Current cluster-head is , code is 1, dist is 0
node 9 CH = 36
node 9 choice = {} {} {} {} {} 52 37 97 70 77 92 67 2
node 9 CH =
node 9 choice = {} {} {} {} {} 52 37 97 70 77 92 67 2
9: Current cluster-head is , code is 1, dist is 0


CH 53 received data (8 , 28.98289012430514) from 8 at 29.015228248610278
9 rcvd ADV_CH from at 29.031284241486009
9 clusterchoice: {}
CH 75 received data (25 , 29.013674076469229) from 25 at 29.046012152938452


It ends up that these nodes are somehow getting phantom blank messages during data transfer phase from node zero when node zero never sent them in the first place. I guess I can assume that it's somewhere in the code, but when I grep for the command, I can only find one stance calling send.

chungw1@CHUNGW1-WD1 ~/ns-allinone-2.27/ns-2.27
$ grep 'send .* .* $ADV_CH' *
mit/uAMPS/ns-leach.tcl: $self send $mac_dst $link_dst $ADV_CH $msg $datasize $opt(max_dist) $code_
mit/uAMPS/ns-leach.tcl~: $self send $mac_dst $link_dst $ADV_CH $msg $datasize $opt(max_dist) $code_


Fix:

I'll assume it's some weird glitch in ns that sends phantom messages, and will just proceed to make the receive function a bit smarter and just ignore all blank and anonymous messages.

I changed

puts "$nodeID rcvd ADV_CH from $chID at [$ns_ now]"
set clusterChoices_ [lappend clusterChoices_ $msg]
set clusterDist_ [lappend clusterDist_ [[$self agent] set distEst_]]


to

# if statement is a patch to deal with phantom ADV_CH messages
if {$msg != ""} {
puts "$nodeID rcvd ADV_CH from $chID at [$ns_ now]"
set clusterChoices_ [lappend clusterChoices_ $msg]
set clusterDist_ [lappend clusterDist_ [[$self agent] set distEst_]]
} else {
puts "$nodeID rcvd PHANTOM ADV_CH <$chID, $msg> at [$ns_ now]"
}


A weakness in the current clusterhead based algorithm is that it depends on a somewhat uniform sensor field to create the network topology.

Saturday, May 01, 2004

dst_ is deprecated

Problem:
Warning dst_ is no longer being supported in NS. dst_ 0xffffffff
Use dst_addr_ and dst_port_ instead


Fix:
I replaced:

[$self agent] set dst_ $mac_dst

with this:

[$self agent] set dst_addr_ $mac_dst

Port is assumed to be zero.

Hella yeah it's running!

hella yeah, the leach code is running now. It's complaining about a depracated function, but I'll fix that later.

data_ doesn't exist

Problem:
Tcl files don't run cuz when it asks for the data for the base station app code, it complains that there's not $data_

Fix:
Freaking, the number of nodes is set to 101, and that can't be changed to 5, the way I had it. number of nodes passed in must be 101 for now. don't know intricacies of what you'd need to do to change the base station's stuff.

Does ns-packet.tcl need to have changes?

Observation:
'tcl/lib/ns-packet.tcl' format has changed. now you can specify which protocols to load.

"# By default, ns includes ALL packet headers of ALL protocols in ns in
# EVERY packet in your simulation. This is a LOT, and will increase as more
# protocols are added into ns. For "packet-intensive" simulations, this could
# be a huge overhead."
......
# NOTICE THAT ADD-PACKET-HEADER{} MUST GO BEFORE THE SIMULATOR IS CREATED.
#
# To include only a specific set of headers in your simulation, e.g., AODV
# and ARP, follow this pattern:
#
# remove-all-packet-headers
# add-packet-header AODV ARP
# ...
# set ns [new Simulator]


Missing class variable RCALinkLayer::avoidReordering_ and RCALinkLayer::debug_

Problem:
The creation of nodes is missing a variable that the program needs.

Creating sensor nodes...
0 _o12 _o13 RCALinkLayer Mac/Sensor Queue/DropTail 100 Phy/WirelessPhy Antenna/OmniAntenna _o14 {} {} {}
warning: no class variable RCALinkLayer::avoidReordering_

see tcl-object.tcl in tclcl for info about this warning.

warning: no class variable RCALinkLayer::debug_


Observation:
Looking in tcl-object.tcl, I found the following comments:

# warn if a class variable not defined
# this is in a separate method so user can nop it
#
# In ns, this error happens for several possible reasons:
#
# 1. you bound a variable in C but didn't initialize it in tcl
# To fix: put initialization code in tcl/lib/ns-default.tcl
# (and make sure that this code ends up compiled into your
# version of ns!)
#
# 2. You bound it in C and think you initialized it in Tcl,
# but there's an error in your class hierarchy
# (for example, the Tcl hierarchy name given in
# the XxxClass declaration in C++
# doesn't match the name used in the Tcl initialization).
#
# 3. you invoked something which assumed that something else had
# been built (for example, doing "new Node" without having
# first done "new Simulator")
# To fix: do new Simulator (or whatever).
#
# 4. You created a split object from C++ (with new)
# rather than from Tcl.
# Nitin Vaidya found this problem
# and suggested working around it either by avoiding
# binding the variable or invoking tcl to create the object.
# See the discussion at
# http://www-mash.cs.berkeley.edu/dist/archive/ns-users/9808/
# for more details.


After grepping for it, I found the following note in Changes.html

[Sally Floyd]
Thu Mar 27 2003
Adding avoidReordering_ to DelayLink, set to true to avoid reordering when changing link bandwidth or delay. The code was contributed by Andrei Gurtov, and the validation test is in ./test-all-links in the directory tcl/test. The default is for avoidReordering_ to be false, for no change in past behavior.


Fix:
I added the default settings for RCALinklayer in tcl/lib/ns-default.tcl

# for MIT_uAMPS LEACH protocol
RCALinkLayer set avoidReordering_ false
RCALinkLayer set debug_ false


under the section for "Wireless simulation support"

need to recompile after making the change.

Wednesday, April 28, 2004

proc add-interface changed its signature

Problem:
The tcl code complains that the wrong number of arguments was inserted:

0 _o12 _o13 RCALinkLayer Mac/Sensor Queue/DropTail 100 Phy/WirelessPhy Antenna/OmniAntenna # _o5 {} {} {}
wrong # args: should be "_o17 self class proc channel pmodel lltype mactype qtype qlen iftype anttype topo inerrproc outerrproc fecproc"
(Object next line 1)
invoked from within
"_o17 next _o12 _o13 RCALinkLayer Mac/Sensor Queue/DropTail 100 Phy/WirelessPhy Antenna/OmniAntenna # _o5 {} {} {}"
("eval" body line 1)
invoked from within
"eval $self next $args"
(procedure "_o17" line 15)
(MobileNode/ResourceAwareNode add-interface line 15)
invoked from within
"$node add-interface $chan $prop $opt(ll) $opt(mac) $opt(ifq) $opt(ifqlen) $opt(netif) $opt(ant) # $ns_ "" "" """
(procedure "leach-create-mobile-node" line 54)
invoked from within
"leach-create-mobile-node $i"
invoked from within
"if { [string compare $opt(rp) "dsr"] == 0} {
for {set i 0} {$i < $opt(nn) } {incr i} {
dsr-create-mobile-node $i
}
} elseif { [string compare $op..."
(file "./wireless-leach.tcl" line 246)


This is because the Node/MobileNode procedure add-interface in file tcl/lib/ns-mobilenode.tcl is different since 2.1b5. The documentation hasn't been keeping up either. The old signature is:

Node/MobileNode instproc add-interface { channel pmodel lltype mactype qtype qlen iftype anttype}

The new signature is:

Node/MobileNode instproc add-interface { channel pmodel lltype mactype qtype qlen iftype anttype topo inerrproc outerrproc fecproc}

As you can see, there are four extra arguments tacked on the end, but I have no idea what those argument are, much less their type. I'm guessing it's a topology object, some incoming error procedure, an outgoing error procedure, and a forward error correction procedure.

Fix:
I grepped for 'proc channel':

gen/ns_tcl.cc:Simulator instproc channel {val} {$self set channel_ $val}\ngen/ns_tcl.cc:Simulator instproc channelType {val} {$self set channelType_ $val}\nBinary file gen/ns_tcl.o matches
Binary file ns.exe matches
tcl/lib/ns-lib.tcl:Simulator instproc channel {val} {$self set channel_ $val}
tcl/lib/ns-lib.tcl:Simulator instproc channelType {val} {$self set channelType_ $val}


Which makes me guess that since the only object that has a channel procedure is simulator, I assume $topo takes a Simulator object. There is a Topography object in ns2. It makes more sense that this is what you pass in. I'll have to check if it has a channel procedure though.

Looking at the code within proc add-interface, I noticed the following lines were added:

if {$inerrproc != ""} {
set inerr_($t) [$inerrproc]
}
set outerr_($t) ""
if {$outerrproc != ""} {
set outerr_($t) [$outerrproc]
}
set fec_($t) ""
if {$fecproc != ""} {
set fec_($t) [$fecproc]
}


So I assume that I can pass in nothing and leach will still work, since it didn't need it before. Therefore, in mit/uAMPS/sims/uamps.tcl, I changed

$node add-interface $chan $prop $opt(ll) $opt(mac) $opt(ifq) $opt(ifqlen) $opt(netif) $opt(ant)

into:

$node add-interface $chan $prop $opt(ll) $opt(mac) $opt(ifq) $opt(ifqlen) $opt(netif) $opt(ant) $ns_$topo "" "" ""

Tuesday, April 27, 2004

Looking for TDMAschedule.*.txt

Problem:
The rest of the tcl scripts that she wrote for leach has some directory pointing problems. Those are easily fixable. However, the script, uamps.tcl, asks for "TDMAschedule.*.txt", which I have no idea where to find them.

Fix:
They were being deleted if they existed, not being created. Error in the syntax of the catch statement.

catch "eval exec rm [glob $opt(dirname)/TDMAschedule.*.txt]"

changes to:

catch {eval exec rm [glob $opt(dirname)/TDMAschedule.*.txt]}

This way, the eval statement is treated as an argument into catch, so that it doesn't error out.

Tuesday, April 20, 2004

sample-wireless-script failed

Problem:
The execution of the tcl script (wireless-leach.tcl--formerly wireless.tcl) to validate LEACH is failing. Somehow, nodes aren't being defined.

Fix:
"sample_leach_script" was originally written as a sh file. Need to convert to bash file.

set alg = leach

changes to:

alg = "leach"

etc, for the variable instanciations.

Monday, April 19, 2004

Some validation tests failed

Problem:
The following validation files filed after compilation:

./test-all-full ./test-all-wireless-shadowing ./test-all-wireless-lan-aodv ./test-all-wireless-tdma ./test-all-wireless-gridkeeper ./test-all-wireless-diffusion ./test-all-wireless-lan-newnode ./test-all-WLtutorial ./test-all-energy ./test-all-diffusion3 ./test-all-tagged-trace ./test-all-smac

Explaination:
The validation failed because the tcl script could not recognize the new MIT-uAMPS variables added into wireless-phy.cc. Therefore, no output was generated for the test, and thus the test failed. I don't think that it's THAT important to get these validations tests up and running, since the tests weren't designed for MIT-uAMPS in the first place.