[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

I have very strange problem with DV.



Hello, may be somebody knows what is the problem with my script.

When link between nodes n(1) and n(3) goes up at 1.0, there are no changes in routing of packets and they keep circulating in the loop between nodes n(0), n(1) and n(2). However, if I change bandwidth of channel n(1)-n(2) to 1Mb or to 500Kb, then everything will be Ok, it will start to use the new channel. I tested this script on NS 2.1b5 under Linux RedHat 6.0.

-------------------------------------------------------------------------------------

set ns [new Simulator]

Node set multiPath_ 1

$ns namtrace-all [open dv_test.nam w]
$ns trace-all [open dv_test.tr w]

for {set i 0} {$i < 17} {incr i} {
     set n($i) [$ns node]
}

$ns rtproto DV
Agent/rtProto/DV set preference_ 90

$ns color 0 Red
$ns color 1 Blue
$ns color 2 Green
$ns color 3 Yellow

$ns duplex-link $n(0) $n(1) 1Mb 10ms DropTail
$ns duplex-link-op $n(0) $n(1) orient right-up
$ns duplex-link $n(0) $n(2) 1Mb 10ms DropTail
$ns duplex-link-op $n(0) $n(2) orient right-down

$ns duplex-link $n(1) $n(2) 600kb 10ms DropTail

$ns duplex-link-op $n(1) $n(2) orient down
$ns duplex-link $n(1) $n(3) 1Mb 10ms DropTail
$ns duplex-link-op $n(1) $n(3) orient right-down
$ns duplex-link $n(2) $n(3) 1Mb 10ms DropTail
$ns duplex-link-op $n(2) $n(3) orient right-up
$ns duplex-link $n(3) $n(4) 1Mb 10ms DropTail
$ns duplex-link-op $n(3) $n(4) orient right

set orien "right"

for {set j 1} {$j <4} {incr j} {
 $ns duplex-link $n([expr $j*4]) $n([expr $j*4+1]) 1Mb 10ms DropTail
 $ns duplex-link-op $n([expr $j*4]) $n([expr $j*4+1]) orient down
 if { $orien == "left" } {
  set orien "right"
 } else {
  set orien "left"
 }
 for {set i 1} {$i <4} {incr i} {
  $ns duplex-link $n([expr $j*4+$i]) $n([expr $j*4+$i+1]) 1Mb 10ms DropTail
  $ns duplex-link-op $n([expr $j*4+$i]) $n([expr $j*4+$i+1]) orient $orien
 }
}

$ns queue-limit $n(0) $n(1) 3
$ns queue-limit $n(1) $n(0) 3
$ns queue-limit $n(0) $n(2) 3
$ns queue-limit $n(2) $n(0) 3
$ns queue-limit $n(1) $n(2) 3
$ns queue-limit $n(2) $n(1) 3
$ns queue-limit $n(1) $n(3) 3
$ns queue-limit $n(2) $n(3) 3

$ns duplex-link-op $n(0) $n(1) queuePos 1
$ns duplex-link-op $n(1) $n(0) queuePos 1
$ns duplex-link-op $n(0) $n(2) queuePos 1
$ns duplex-link-op $n(2) $n(0) queuePos 1
$ns duplex-link-op $n(1) $n(2) queuePos 1
$ns duplex-link-op $n(2) $n(1) queuePos 1
$ns duplex-link-op $n(1) $n(3) queuePos 1
$ns duplex-link-op $n(2) $n(3) queuePos 1

$ns cost $n(1) $n(2) 2
$ns cost $n(2) $n(1) 2
$ns cost $n(2) $n(3) 10
$ns cost $n(3) $n(2) 10

set cbr0 [new Agent/CBR]
$ns attach-agent $n(0) $cbr0
$cbr0 set packetSize_ 200
$cbr0 set interval_ 0.005
$cbr0 set random_ 1
$cbr0 set fid_ 1

set cbr1 [new Agent/CBR]
$ns attach-agent $n(1) $cbr1
$cbr1 set packetSize_ 200
$cbr1 set interval_ 0.005
$cbr1 set random_ 1
$cbr1 set fid_ 2

set cbr2 [new Agent/CBR]
$ns attach-agent $n(2) $cbr2
$cbr2 set packetSize_ 200
$cbr2 set interval_ 0.005
$cbr2 set random_ 1
$cbr2 set fid_ 3

set lmonitor0_16 [new Agent/LossMonitor]
$ns attach-agent $n(16) $lmonitor0_16

set lmonitor1_16 [new Agent/LossMonitor]
$ns attach-agent $n(16) $lmonitor1_16

set lmonitor2_16 [new Agent/LossMonitor]
$ns attach-agent $n(16) $lmonitor2_16

$ns connect $cbr0 $lmonitor0_16
$ns connect $cbr1 $lmonitor1_16
$ns connect $cbr2 $lmonitor2_16

$ns at 0.2 "$cbr0 start"
$ns at 0.2 "$cbr1 start"
$ns at 0.2 "$cbr2 start"

$ns rtmodel-at 0.4 down $n(2) $n(3)
$ns at 0.69 "$ns set-animation-rate 0.1ms"
$ns rtmodel-at 0.7 down $n(1) $n(3)
$ns at 0.74 "$ns set-animation-rate 1ms"
$ns at 0.99 "$ns set-animation-rate 0.1ms"
$ns rtmodel-at 1.0 up $n(1) $n(3)
$ns at 1.04 "$ns set-animation-rate 1ms"
$ns at 1.29 "$ns set-animation-rate 0.1ms"
$ns rtmodel-at 1.3 up $n(2) $n(3)
$ns at 1.34 "$ns set-animation-rate 1ms"

$ns at 1.6 "$cbr0 stop"
$ns at 1.6 "$cbr1 stop"
$ns at 1.6 "$cbr2 stop"

$ns at 2.0 "finish"

proc finish {} {
 global ns lmonitor0_16 lmonitor1_16 lmonitor2_16
 puts "Transmition from node0 to node16 by using DV"
 puts "Number of packets lost: [$lmonitor0_16 set nlost_] (including [expr [$lmonitor0_16 set expected_]-[$lmonitor0_16 set npkts_]] information packets)"
 puts "Number of packets received: [$lmonitor0_16 set npkts_]"
 puts "The expected sequence number of the next packet: [$lmonitor0_16 set expected_]"
 puts "Time at which the last packet was received: [$lmonitor0_16 set lastPktTime_]"
 puts "Number of bytes received: [$lmonitor0_16 set bytes_]"
 puts "-------------------------------------------"
 puts "Transmition from node1 to node16 by using DV"
 puts "Number of packets lost: [$lmonitor1_16 set nlost_] (including [expr [$lmonitor1_16 set expected_]-[$lmonitor1_16 set npkts_]] information packets)"
 puts "Number of packets received: [$lmonitor1_16 set npkts_]"
 puts "The expected sequence number of the next packet: [$lmonitor1_16 set expected_]"
 puts "Time at which the last packet was received: [$lmonitor1_16 set lastPktTime_]"
 puts "Number of bytes received: [$lmonitor1_16 set bytes_]"
 puts "-------------------------------------------"
 puts "Transmition from node2 to node16 by using DV"
 puts "Number of packets lost: [$lmonitor2_16 set nlost_] (including [expr [$lmonitor2_16 set expected_]-[$lmonitor2_16 set npkts_]] information packets)"
 puts "Number of packets received: [$lmonitor2_16 set npkts_]"
 puts "The expected sequence number of the next packet: [$lmonitor2_16 set expected_]"
 puts "Time at which the last packet was received: [$lmonitor2_16 set lastPktTime_]"
 puts "Number of bytes received: [$lmonitor2_16 set bytes_]"
 $ns flush-trace
 puts "running nam..."
 exec nam dv_test.nam
 exit 0
}

$ns at 0.0 "$ns set-animation-rate 1ms"
$ns run

-------------------------------------------------------------------------------------

Thank you for your assistance, Best Regards,
Sergey Balandin