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

[ns] problem with Error Modelling.




Dear Seniors,
	I'm trying to simulate a multicast network with error
modelling. Please find the corresponding code below. The problems is ...
When i run the simulation without any error modelling, it is running quite
well. But when i run the simulation with error modelling all the packets
are being dropped at the source node itself. It would be nice if someone
help me in this regard.

Thanks in Advance,

Regards,
Mahesh.



_______________________________________________________________________________

set ns [new Simulator -multicast on]
Simulator instproc duplex-link-cost-prob {node1 node2 bw delay qtype {c 1}} {
    $self duplex-link $node1 $node2 $bw $delay $qtype
    [$self link $node1 $node2] cost $c
    [$self link $node2 $node1] cost $c

	#error modelling.......

    set em [new ErrorModel]
    $em unit pkt
    $em drop-target [new Agent/Null]
    $em set rate_ $c
    $self at 0.2 "$self link-lossmodel $em $node1 $node2"

    #error modelling.......
    set em [new ErrorModel]
    $em unit pkt
    $em drop-target [new Agent/Null]
    $em set rate_ $c
    $self at 0.2 "$self link-lossmodel $em $node2 $node1"

}



set f [open out.tr w]
$ns trace-all $f
$ns namtrace-all [open out.nam w]

$ns color 1 red
# prune/graft packets
$ns color 30 purple
$ns color 31 bisque
set i 0
 while {$i < 11} {
set n($i) [$ns node]
set i [expr $i+1]
}

#Code for creating the nodes...

set i 0
$ns duplex-link-cost-prob $n($n0) $n($n1) 1.5Mb 10ms DropTail 0.2  
$ns duplex-link-cost-prob $n($n0) $n($n2) 1.5Mb 10ms DropTail 1 
			...
			...
 
DM set CacheMissMode dvmrp
set mproto CtrMcast

set mrthandle [$ns mrtproto $mproto {}]
set group($n0) [Node allocaddr]
set group($n1) [Node allocaddr]

#cbr agent 0 being created here.

set udp($n0) [new Agent/UDP]
#node 0 is the sending agent of UDP packets at CBR
$ns attach-agent $n($n0) $udp($n0)
$udp($n0) set dst_addr_ $group($n0)
$udp($n0) set dst_port_ 0
set cbr($n0) [new Application/Traffic/CBR]
$cbr($n0) attach-agent $udp($n0)

set rcvr($n0) [new Agent/LossMonitor]
#node 10 is the receiver agent.
set i 1
while {$i < 11} {
    $ns attach-agent $n($i) $rcvr($n0)
    $ns at 1.0 "$n($i) join-group $rcvr($n0) $group($n0)"
    set i [expr $i+1]
}

set rcvr($n1) [new Agent/LossMonitor]

$ns at 0.2 "$cbr($n0) start"
#$ns at 0.3 "$cbr($n1) start"

#$ns at 1.001 "$cbr($n0) stop"
#$ns at 1.1 "$cbr1 start"

$ns at 5.0 "finish"

proc finish {} {
	global ns
	$ns flush-trace

	puts "running nam..."
	exec nam out.nam &
	exit 0
}

$ns run