Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Sap id: 60003230300

Department of Information Technology

COURSE CODE: DJ19ITL404 DATE: 9/03/24


COURSE NAME: Computer Networks CLASS: S. Y. B.Tech
Name: ISHA PATEL Roll no: I193

Experiment No. 3

1.
set a 24 set b 15 puts $a puts $b
puts " The value of a = $a" puts
"The value of b = $b" puts "The
value of a+b= $a + $b"

2.

set a 24 set
b
15 puts $a puts $b puts " the
value of a= $a" puts " the
value of b= $b" puts " the
value of a+b= $a+$b" set c
[expr $a+$b] puts " the value
of c= $c" set d [expr [expr
$b-$a] * $c]
puts " the value of d= $d"
Sap id: 60003230300

puts -nonewline "enter value of a "


flush stdout gets stdin a
puts -nonewline "enter value of b "
flush stdout gets stdin b

puts " the value of a= $a" puts


" the value of b= $b"

set c [expr $a+$b]

puts " the value of c= $c"

3.
proc display {} { puts "Welcome to STTP Organized by JDIET Yavatmal"
} display

4.

proc add {x y} { set z


[expr $x + $y] puts " the
value of z= $z"
} add 40
80

5.
proc print { k } { for {set i 0 } {$i <
Sap id: 60003230300
$k } { incr i} { puts "node_{$i}
\t n$i" puts "n$i $k"
} } print
1

6.

set test [ open file.txt w] puts


$test "Welcome to Nagpur"

7,8,9.
set ns [new Simulator]

set tr [ open out.tr w]


$ns trace-all $tr

set namtr [open out.nam w] $ns


namtrace-all $namtr

set n0 [$ns node] set n1


[$ns node] set n2
[$ns node] set n3
[$ns node]

$ns duplex-link $n0 $n1 10Mb 5ms DropTail


$ns duplex-link $n2 $n0 10Mb 5ms DropTail
$ns duplex-link $n3 $n0 10Mb 5ms DropTail
Sap id: 60003230300
$ns duplex-link-op $n0 $n1 orient right
$ns duplex-link-op $n0 $n2 orient left-up $ns duplex-link-op $n0 $n3 orient left-down set udp0 [new
Agent/UDP] $ns attach-agent $n3 $udp0

set null0 [new Agent/Null] $ns attach-agent


$n1 $null0

set udp1 [new Agent/UDP] $ns


attach-agent $n2 $udp1

set null1 [new Agent/Null] $ns attach-agent


$n3 $null1

$ns connect $udp0 $null0


$ns connect $udp1 $null1

set cbr0 [new Application/Traffic/CBR] set


cbr1 [new Application/Traffic/CBR]

$udp0 set fid_ 1


$ns color 1 blue

$udp1 set fid_ 2


$ns color 2 red

$cbr0 attach-agent $udp0


$cbr1 attach-agent $udp1

$ns at 1.0 "$cbr0 start"


$ns at 1.5 "$cbr1 start"

$ns at 5.0 "$cbr0 stop"


$ns at 5.0 "$cbr1 stop"

$ns at 5.0 "$ns halt"


$ns run
Sap id: 60003230300

8
Sap id: 60003220127

set ns [new Simulator] set tr


[ open out.tr w] $ns traceall
$tr set namtr [open out.nam
w] $ns namtraceall $namtr
set n0 [$ns node] set n1 [$ns
node] set n2 [$ns node] set
n3 [$ns node] set n4 [$ns
node] set n5
[$ns node]
$ns duplex-link $n0 $n1 10Mb 5ms DropTail
Sap id: 60003220127
$ns duplex-link $n1 $n2 10Mb 5ms DropTail
$ns duplex-link $n1 $n3 10Mb 5ms DropTail
$ns duplex-link $n2 $n4 10Mb 5ms DropTail
$ns duplex-link $n3 $n4 10Mb 5ms DropTail
$ns duplex-link $n4 $n5 10Mb 5ms DropTail
$ns duplex-link-op $n0 $n1 orient right
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n1 $n3 orient right-down
$ns duplex-link-op $n2 $n4 orient right-down
$ns duplex-link-op $n3 $n4 orient right-up
$ns duplex-link-op $n4 $n5 orient right set
udp0 [new Agent/UDP] $ns attach-agent
$n0 $udp0 set null0 [new Agent/Null] $ns
attach-agent $n3 $null0 set udp1 [new
Agent/UDP] $ns attach-agent $n2 $udp1
set null1 [new Agent/Null]
$ns attach-agent $n5 $null1
$udp0 set fid_ 1
$ns color 1 blue
$udp1 set fid_ 2
$ns color 2 red
$ns connect $udp0 $null0 $ns connect
$udp1 $null1 set cbr0 [new
Application/Traffic/CBR] set cbr1 [new
Application/Traffic/CBR] $cbr0 attachagent
$udp0
$cbr1 attach-agent $udp1
$ns at 2.0 "$cbr0 start"
$ns at 3.0 "$cbr1 start"
$ns at 8.0 "$cbr0 stop"
$ns at 7.0 "$cbr1 stop"
$ns at 10.0 "$ns halt"
$ns ru
Sap id: 60003220127

You might also like