set ns [new Simulator {\bfseries{}-multicast on}] # enable multicast routing; set group [{\bfseries{}Node allocaddr}] # allocate a multicast address; set node0 [$ns node] # create multicast capable nodes; set node1 [$ns node] $ns duplex-link $node0 $node1 1.5Mb 10ms DropTail set mproto DM # configure multicast protocol; set mrthandle [{\bfseries{}$ns mrtproto $mproto}] # all nodes will contain multicast protocol agents; set udp [new Agent/UDP] # create a source agent at node 0; $ns attach-agent $node0 $udp set src [new Application/Traffic/CBR] $src attach-agent $udp {\bfseries{}$udp set dst_addr_ $group} {\bfseries{}$udp set dst_port_ 0} set rcvr [new Agent/LossMonitor] # create a receiver agent at node 1; $ns attach-agent $node1 $rcvr $ns at 0.3 “{\bfseries{}$node1 join-group $rcvr $group}” # join the group at simulation time 0.3 (sec);
set ns [ new simulator ] set nf [ open main.nam w ] $ns namtrace-all $nf set tf [ open main.tr w ] $ns trace-all $tf proc finish{} { global ns nf tf $ns flush-trace close $nf cloe $tf exec nam pa1.nam & exit 0 } set n0[ $ns node ] set n2[ $ns node ] set n3[ $ns node ] $ns duplex-link $no $n2 200Mb 10ms DropTail $ns duplex-link $n2 $n3 2Mb 1000ms DropTail $ns queue-limit $no $n2 10 set udp0 [ new Agent/UDP ] $ns attach-agent $n0 $udp0 set cbr0 [ new Application/Traffic/CBR ] $cbr0 set packetSize_500 $cbr0 set interval_0.005 $cbr0 attach-agent $udp0 set null0 [ new Agent/Null ] $ns attach-agent $n3 $null0 $ns connect $udp0 $null0 $ns at 0.1 "$cbr0 start" $ns at 1.0 "finish" $ns run
puts "Hello World!" puts "Mansour"
set ns [new Simulator] #open a namtrace file set nf [open main.nam w] $ns namtrace-all $nf #open a trace file set nt [open main.tr w] $ns trace-all $nt #Define a 'finish' procedure proc finish {} { global ns nf nt $ns flush-trace close $nf close $nt exec nam p2.nam & exit 0 } #Create six nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set n4 [$ns node] set n5 [$ns node] #connect the nodes with two links $ns duplex-link $n0 $n1 1Mb 10ms DropTail $ns duplex-link $n2 $n1 1Mb 10ms DropTail $ns duplex-link $n3 $n1 1Mb 10ms DropTail $ns duplex-link $n4 $n1 1Mb 10ms DropTail $ns duplex-link $n5 $n1 1Mb 10ms DropTail #set queue length $ns queue-limit $n0 $n1 5 $ns queue-limit $n2 $n1 2 $ns queue-limit $n3 $n1 5 $ns queue-limit $n4 $n1 2 $ns queue-limit $n5 $n1 2 #Label the nodes $n0 label "ping0" $n1 label "Router" $n2 label "ping2" $n3 label "ping3" $n4 label "ping4" $n5 label "ping5" #color the flow $ns color 2 Blue $ns color 3 Red $ns color 4 Yellow $ns color 5 Green #Define a 'recv' function for the class 'Agent/Ping' Agent/Ping instproc recv {from rtt} { $self instvar node_ puts "node [$node_ id] received ping answer from \ $from with round-trip-time $rtt ms." } #create ping agents and attach them to the nodes set p0 [new Agent/Ping] $ns attach-agent $n0 $p0 $p0 set class_ 1 set p2 [new Agent/Ping] $ns attach-agent $n2 $p2 $p2 set class_ 2 set p3 [new Agent/Ping] $ns attach-agent $n3 $p3 $p3 set class_ 3 set p4 [new Agent/Ping] $ns attach-agent $n4 $p4 $p4 set class_ 4 set p5 [new Agent/Ping] $ns attach-agent $n5 $p5 $p5 set class_ 5 #connect the two agents $ns connect $p0 $p5 $ns connect $p4 $p5 proc SendPingPacket {} { global ns p0 p4 set intervalTime 0.001 set now [$ns now] $ns at [expr $now+$intervalTime] "$p0 send" $ns at [expr $now+$intervalTime] "$p4 send" $ns at [expr $now+$intervalTime] "SendPingPacket" } $ns at 0.1 "SendPingPacket" $ns at 2.0 "finish" $ns run
#!/usr/bin/tclsh if 0 { my first program in Tcl program Its very simple } puts "Hello World!"
Unable to open file!