Dear experts,

The scenario is this, 10 wireless nodes are connected to base station BS(0)
and another 10 wireless nodes are connected to base station BS(1). The 2
base stations (BS(0) and BS(1)) are connected by an intserv link. I am
trying to send packets from a wireless node to another wireless node through
base stations passing through the intserv link. I am using NOAH but I cant
get the packets through to the destination.Can anybody tell me where lies
the problem and teach me how to fix it as the packets can't reach the
destination(another wireless node), the trace file says RTR LOOP. Please
help me as soon as possible as it is very very urgent! Thank you very much.

ps: i attach my code and part of the trace.

*******************************************************************************************************
the trace
*******************************************************************************************************

+ 1.077391 0 1 sa_req 40 ------- 1 0.0.1.0 1.0.12.0 -1 0
- 1.077391 0 1 sa_req 40 ------- 1 0.0.1.0 1.0.12.0 -1 0
r 1.078423 0 1 sa_req 40 ------- 1 0.0.1.0 1.0.12.0 -1 0
+ 1.085227 1 0 sa_accept 60 ------- 1 1.0.12.0 0.0.1.0 -1 1
- 1.085227 1 0 sa_accept 60 ------- 1 1.0.12.0 0.0.1.0 -1 1
r 1.086275 1 0 sa_accept 60 ------- 1 1.0.12.0 0.0.1.0 -1 1
D 1.088106967 _2_ RTR LOOP 1 sa_conf 60 [13a 2 0 800] ------- [1:0 4194316:0
30 1]
+ 1.320025 0 1 sa_req 40 ------- 2 0.0.1.0 1.0.12.0 -1 2
- 1.320025 0 1 sa_req 40 ------- 2 0.0.1.0 1.0.12.0 -1 2
r 1.321057 0 1 sa_req 40 ------- 2 0.0.1.0 1.0.12.0 -1 2
+ 1.325325 1 0 sa_accept 60 ------- 2 1.0.12.0 0.0.1.0 -1 3
- 1.325325 1 0 sa_accept 60 ------- 2 1.0.12.0 0.0.1.0 -1 3
r 1.326373 1 0 sa_accept 60 ------- 2 1.0.12.0 0.0.1.0 -1 3
D 1.328265520 _2_ RTR LOOP 3 sa_conf 60 [13a 2 0 800] ------- [1:0 4194316:0
30 1]

* this pattern of trace keeps repeating itself

*******************************************************************************************************
the code
*******************************************************************************************************
# ===============================================================
#                              Options & Settings
# ===============================================================
set opt(chan)           Channel/WirelessChannel    ;# channel type
set opt(prop)           Propagation/TwoRayGround   ;# radio-propagation
model
set opt(netif)          Phy/WirelessPhy            ;# network interface type
set opt(mac)            Mac/802_11                 ;# MAC type
set opt(ifq)            Queue/DropTail/PriQueue    ;# interface queue type
set opt(ll)             LL                         ;# link layer type
set opt(ant)            Antenna/OmniAntenna        ;# antenna model
set opt(ifqlen)         50                         ;# max packet in ifq
set opt(nn)             20                          ;# number of mobilenodes

set opt(adhocRouting)   NOAH                       ;# routing protocol

set opt(cp)             ""                         ;# connection pattern
file
set opt(sc)     ""    ;# node movement file.

set opt(x)      1000                            ;# x coordinate of topology
set opt(y)      1000                            ;# y coordinate of topology
set opt(seed)   0.0                            ;# seed for random number
gen.
set opt(stop)   300                           ;# time to stop simulation

set num_wired_nodes      0
set num_bs_nodes         2

#-------------------------------------------------------------------------------

#                IntServ settings
#-------------------------------------------------------------------------------

#defaults
Queue/SimpleIntServ set qlimit1_ 160
Queue/SimpleIntServ set qlimit0_ 0
set S_ [expr 5e3]
set T_ 3
set utilization_ 0.95
set s_ [expr 2e-3]
set w_ [expr pow(2,-4)]
set epsilon_ 0.7
set simtime 3000
set meastime 1500
set srcno 1
set ADC MS
set EST TimeWindow
set trace_flow 1

#-------------------------------------------------------------------------------
#                           Flow settings
#-------------------------------------------------------------------------------

#Set pkt size and link bw
set psize 125
set bandwidth 10e6
set ptime [expr $psize*8.0/$bandwidth]

#set avg flowinterarrival time and holdtimes
set fint 0.4
set hold 300
set fvar [new RandomVariable/Exponential]
$fvar set avg_ $fint
set hvar [new RandomVariable/Exponential]
$hvar set avg_ $hold

#Use a diffent random variable for flow distribution
set myrng [new RNG]
#picked up an arbitrary predefined seed from rng.cc
$myrng seed 1973272912

$fvar use-rng $myrng
$hvar use-rng $myrng

#-------------------------------------------------------------------------------
#                           Arguments for ADC
#-------------------------------------------------------------------------------

set i 0
while { $i < $argc } {
    set L [split [lindex $argv $i] =]
    if { [llength $L] == 2 } {
        set var [lindex $L 0]
        set val [lindex $L 1]
        set $var $val
    }
    incr i
}

set adc $ADC
set est $EST
puts "Using ADC: $adc EST: $est simtime: $simtime s"

ADC/MS set utilization_ [expr $utilization_]
ADC/ACTO set s_ [expr $s_]
ADC/ACTP set s_ [expr $s_]
ADC/HB set epsilon_ [expr $epsilon_]
Est/TimeWindow set T_ $T_
Est/ExpAvg set w_ [expr $w_]
Est set period_ [expr $S_*$ptime]


# ===============================================================
#                               Nodes
# ===============================================================

set ns [new Simulator]

set qt0  [open q_trace.tr w]
$ns trace-all $qt0

# set up for hierarchical routing
$ns node-config -addressType hierarchical

#Two Domains Configuration
AddrParams set domain_num_ 2           ;# number of domains
lappend cluster_num 1 1               ;# number of clusters in each domain
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel 11 11              ;# number of nodes in each cluster
AddrParams set nodes_num_ $eilastlevel ;# of each domain


# Create topography object
set topo   [new Topography]

# define topology
$topo load_flatgrid $opt(x) $opt(y)

# create God
create-god [expr $opt(nn) + $num_bs_nodes]



#-------------------------------------------------------------------------------

#                           Base Station
#-------------------------------------------------------------------------------

# configure for base-station node
$ns node-config -adhocRouting $opt(adhocRouting) \
                 -llType $opt(ll) \
                 -macType $opt(mac) \
                 -ifqType $opt(ifq) \
                 -ifqLen $opt(ifqlen) \
                 -antType $opt(ant) \
                 -propType $opt(prop) \
                 -phyType $opt(netif) \
                 -channelType $opt(chan) \
         -topoInstance $topo \
                 -wiredRouting ON \
         -agentTrace OFF \
                 -routerTrace OFF \
                 -macTrace OFF


# creating bs nodes
for {set i 0} {$i < $num_bs_nodes} {incr i} {
    set BS([expr $i]) [$ns node $i.0.0]
        puts "BS node $i created"
        $BS([expr $i]) random-motion 0
    $BS([expr $i]) set X_ [expr $i * 650.0 + 50.0]
    $BS([expr $i]) set Y_ 50.0
    $BS([expr $i]) set Z_ 0.0
}

#create links between wired and BS nodes
$ns duplex-intserv-link $BS(0) $BS(1) $bandwidth 1ms SimpleIntServ SALink
$adc $est CL
$BS(1) add-route $BS(0) $BS(1)


#Set up queue-monitor to measure link utilization and drop rates
set f [open out.tr w]
set qmon [$ns monitor-queue $BS(0) $BS(1) $f]
set l01 [$ns link $BS(0) $BS(1)]
$l01 set qBytesEstimate_ 0
$l01 set qPktsEstimate_ 0
$l01 set sampleInterval_ 0
$ns at $meastime "$l01 trace-util [expr $ptime*$S_] $f"

#-------------------------------------------------------------------------------

#                           Wireless nodes
#-------------------------------------------------------------------------------

#configure for mobilenodes
$ns node-config -wiredRouting OFF


for {set j 0} {$j < 10} {incr j} {
    set node_($j) [$ns node 0.0.[expr $j + 1]]
    $node_($j) random-motion 0        ;# disable random motion
    puts "wireless node $j created ..."
    $node_($j) base-station [AddrParams addr2id [$BS(0) node-addr]]
    $node_($j) set X_ 30.0
    $node_($j) set Y_ [expr $j + 45]
    $node_($j) set Z_ 0.0
}

for {set j 10} {$j < 20} {incr j} {
    set node_($j) [$ns node 1.0.[expr $j + 1]]
    $node_($j) random-motion 0        ;# disable random motion
    puts "wireless node $j created ..."
    $node_($j) base-station [AddrParams addr2id [$BS(1) node-addr]]
    $node_($j) set X_ 680.0
    $node_($j) set Y_ [expr $j + 35]
    $node_($j) set Z_ 0.0
}



# ===============================================================
#                               Agents
# ===============================================================


#create receiver agent
for {set i 10} {$i < 20} {incr i} {
set r($i) [new Agent/SAack]
$ns attach-agent $node_($i) $r($i)
}




proc show-simtime {} {
    global ns
    puts [$ns now]
    $ns at [expr [$ns now]+50.0] "show-simtime"
}

proc create-source {node rcvr starttime  i} {
    global ns hold hvar
    set a [new Agent/SA]
    $ns attach-agent $node $a

    $a set fid_ $i

    $ns connect $a $rcvr

    set exp1 [new Application/Traffic/Exponential]
    #changed the packetSize_ from 125 to 500 for more reject action
    $exp1 set packetSize_ 500
    #changed the burst_time_ from 20.0 to 2000.0 for longer burst hence
longer queues
    $exp1 set burst_time_ [expr 2000.0/64]
    $exp1 set idle_time_ 325ms
    $exp1 set rate_ 64k


    #set up (r,b)
    $a set rate_ 64k
    $a set bucket_ 1
    $a attach-traffic $exp1
    $a set lifetime_ [$hvar value]
    $ns at $starttime "$a start"
    $a instvar trafgen_
    set trafgen_ $exp1

}


# ===============================================================
#                           Added this : Queue Size
# ===============================================================


proc queue-size { } {
global ns qmon
$ns instvar link_
$qmon instvar parrivals_ pdepartures_ pdrops_
set queue_size [expr $parrivals_-$pdepartures_-$pdrops_]
return $queue_size
#set q_ [$link_(0:1) sample-queue-size]
#puts $q_
#return $q_
}

# ===============================================================
#                                   Procs
# ===============================================================
proc finish { file } {
    global f r psize bandwidth simtime meastime qmon

    $qmon instvar pdrops_ pdepartures_ bdepartures_
    set utlzn [expr $bdepartures_*8.0/($bandwidth*($simtime-$meastime))]
    set d [expr $pdrops_*1.0/($pdrops_+ $pdepartures_)]
    puts "Drops : $d Utilization : $utlzn"
    if [ info exists f ] {
        close $f
    }
    set output [ open temp.rands w ]
    puts $output "TitleText: $file"
        puts $f "Device: Postscript"

    exec rm -f temp.p1 temp.p2
        exec awk {
        {
            print $1,$2
        }
    } out.tr > temp.p1
        exec awk {
        {
            print $1,$3
        }
    } out.tr > temp.p2


    puts $output [format "\n\"Estimate"]
    exec cat temp.p1 >@ $output
    puts $output [format "\n\"Actual Utilzn"]
        exec cat temp.p2 >@ $output
    flush $f
        close $f

#    exec rm -f temp.p1 temp.p2
#        exec xgraph -bb -tk -m -x time -y bandwidth -ly [expr
$bandwidth/2.0],$bandwidth -lx [expr 2/3.0*$simtime],[expr
2/3.0*$simtime+100.0] temp.rands &
        exec xgraph -bb -tk -m -x time -y bandwidth -lx [expr
2/3.0*$simtime],[expr 2/3.0*$simtime+100.0] temp.rands &

#    exec rm -f out.tr
    exit 0
}

#Helper function to schedule stop time for the new flow
Agent/SA instproc sched-stop { decision } {
    global hold simtime ns trace_flow
    $self instvar node_ lifetime_

    if { $decision == 1 } {
        set leavetime [expr [$ns now] + $lifetime_]
        $ns at [expr [$ns now] + $lifetime_] "$self stop;\
                if { $trace_flow } { \
            puts \"Flow [$self set fid_] left @ $leavetime\" \
        }; \
            $ns detach-agent $node_ $self; \
            delete [$self set trafgen_]; delete $self"
    } else {
        set leavetime [$ns now]
        $ns at-now "if { $trace_flow } { \
            puts \"Flow [$self set fid_] left @ $leavetime\"\
        }; \
            $ns detach-agent $node_ $self; \
            delete [$self set trafgen_]; delete $self"
    }
}

# ===============================================================
#                Event Scheduling
# ===============================================================

#proc to create a source and schedule another one after a time from
#expo dist
proc sched-source { node receiver } {
    global srcno ns fint hold fvar trace_flow

    create-source $node $receiver [$ns now]  $srcno
    if { $trace_flow } {
        puts "Flow $srcno started @ [$ns now]"
    }
    incr srcno

    #generate another startime
    set starttime [expr [$ns now]+[$fvar value]]
    $ns at $starttime "sched-source $node $receiver"
}

#Sched the first flow
set starttime  [expr $srcno + double([ns-random] % 10000000) / 1e7]
puts "Start time $starttime"



for {set i 0} {$i < 10} {incr i} {
$ns at [expr $starttime * $i] "sched-source $node_($i) $r([expr $i+10])"
}




$ns at [expr $simtime] "finish $f"

$ns at $meastime "$qmon set bdepartures_ 0;$qmon set bdrops_ 0"

$ns at 0.0 "show-simtime"
puts "Running simulation...."
$ns run

Reply via email to