0% found this document useful (0 votes)
46 views7 pages

EXP

RFSD lab manual

Uploaded by

Kumar ji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views7 pages

EXP

RFSD lab manual

Uploaded by

Kumar ji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

EXP :-1(a)

#===================================
# Simulation parameters setup
#===================================
set val(stop) 10.0 ;# time of simulation end
#===================================
# Initialization
#===================================
#Create a ns simulator
set ns [new Simulator]
#Open the NS trace file
set tracefile [open ftp.tr w]
$ns trace-all $tracefile
#Open the NAM trace file
set namfile [open ftp.nam w]
$ns namtrace-all $namfile
#===================================
# Nodes Definition
#===================================
#Create 5 nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
#===================================
# Links Definition
#===================================
#Createlinks between nodes
$ns duplex-link $n0 $n4 100.0Mb 10ms DropTail
$ns queue-limit $n0 $n4 50
$ns duplex-link $n1 $n4 100.0Mb 10ms DropTail
$ns queue-limit $n1 $n4 50
$ns duplex-link $n2 $n4 100.0Mb 10ms DropTail
$ns queue-limit $n2 $n4 50
$ns duplex-link $n3 $n4 100.0Mb 10ms DropTail
$ns queue-limit $n3 $n4 50
$ns duplex-link $n3 $n0 100.0Mb 10ms DropTail
$ns queue-limit $n3 $n0 50
# Agents Definition
#===================================
#Setup a UDP connection
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set sink1 [new Agent/TCPSink]
$ns attach-agent $n2 $sink1
$ns connect $tcp0 $sink1
#Setup a UDP connection
set udp1 [new Agent/UDP]
$ns attach-agent $n1 $udp1
set null3 [new Agent/Null]
$ns attach-agent $n3 $null3
$ns connect $udp1 $null3
$udp1 set packetSize_ 1500
#===================================
# Applications Definition
#===================================
#Setup a FTP Application over TCP connection
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp0
$ns at 1.0 "$ftp1 start"
$ns at 10.0 "$ftp1 stop"
#Setup a Telnet Application over UDP connection
set telnet0 [new Application/Telnet]
$telnet0 set interval_ 0.001
$telnet0 attach-agent $udp1
$ns at 1.0 "$telnet0 start"
$ns at 10.0 "$telnet0 stop"
#$ns at 10.0 "$cbr1 stop"
$telnet0 set type_ Telnet
# Termination #=
#Define a 'finish' procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam out. nam &
exit 0
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run
EXP:-2
set val(stop) 10.0 ; # time of simulation end
#Create a ns simulator
set ns [new Simulator]
#Open the NS trace file
set nr [open queue_red.tr w]
$ns trace-all $nr
#Open the NAM trace file
set nf [open queue_red.nam w]
$ns namtrace-all $nf
#Create 7 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]
set n6 [$ns node]
$ns duplex-link $n0 $n3 100.0Mb 10ms RED
$ns queue-limit $n0 $n3 50
$ns duplex-link $n4 $n1 100.0Mb 10ms RED
$ns queue-limit $n4 $n1 50
$ns duplex-link $n6 $n5 100.0Mb 10ms RED
$ns queue-limit $n6 $n5 50
$ns duplex-link $n4 $n6 100.0Mb 10ms RED
$ns queue-limit $n4 $n6 50
$ns duplex-link $n5 $n2 100.0Mb 10ms RED
$ns queue-limit $n5 $n2 50
$ns duplex-link $n0 $n2 100.0Mb 10ms RED
$ns queue-limit $n0 $n2 50
$ns duplex-link $n2 $n1 100.0Mb 10ms RED
$ns queue-limit $n2 $n1 50
$ns duplex-link $n1 $n5 100.0Mb 10ms RED
$ns queue-limit $n1 $n5 50
$ns duplex-link $n3 $n4 100.0Mb 10ms RED
$ns queue-limit $n3 $n4 50
$ns duplex-link $n3 $n1 100.0Mb 10ms RED
$ns queue-limit $n3 $n1 50
#Give node position (for NAM)
$ns duplex-link-op $n0 $n3 orient right-up
$ns duplex-link-op $n4 $n1 orient left-down
$ns duplex-link-op $n6 $n5 orient left-down
$ns duplex-link-op $n4 $n6 orient right-down
$ns duplex-link-op $n5 $n2 orient left
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n2 $n1 orient right-up
$ns duplex-link-op $n1 $n5 orient right-down
$ns duplex-link-op $n3 $n4 orient right
$ns duplex-link-op $n3 $n1 orient right-down
#Setup a TCP connection
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set sink2 [new Agent/TCPSink]
$ns attach-agent $n4 $sink2
$ns connect $tcp0 $sink2
$tcp0 set packetSize_ 1500
#Setup a TCP/FullTcp/Tahoe connection
set tcp1 [new Agent/TCP]
$ns attach-agent $n2 $tcp1
set sink3 [new Agent/TCPSink]
$ns attach-agent $n6 $sink3
$ns connect $tcp1 $sink3
$tcp1 set packetSize_ 1500
#Setup a FTP Application over TCP connection
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
$ns at 1.0 "$ftp0 start"
$ns at 10.0 "$ftp0 stop"
#Setup a FTP Application over TCP/FullTcp/Tahoe connection
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
$ns at 1.0 "$ftp1 start"
$ns at 10.0 "$ftp1 stop"
#Define a 'finish' procedure
proc finish { } {
global ns nr nf
$ns flush-trace
close $nr
close $nf
exec nam queue_red.nam &
exit 0
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run
EXP:-3
set val(stop) 10.5
#Create a ns simulator
set ns [new Simulator]
#Open the NS trace file
set tracefile [open httpex.tr w]
$ns trace-all $tracefile
#Open the NAM trace file
set namfile [open httpex.nam w]
$ns namtrace-all $namfile
#Create 6 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]
#Createlinks between nodes
$ns duplex-link $n0 $n2 100.0Mb 10ms SFQ
$ns queue-limit $n0 $n2 50
$ns duplex-link $n3 $n2 100.0Mb 10ms SFQ
$ns queue-limit $n3 $n2 50
$ns duplex-link $n1 $n2 100.0Mb 10ms SFQ
$ns queue-limit $n1 $n2 50
$ns duplex-link $n3 $n4 100.0Mb 10ms SFQ
$ns queue-limit $n3 $n4 50
$ns duplex-link $n3 $n5 100.0Mb 10ms SFQ
$ns queue-limit $n3 $n5 50
#Give node position (for NAM)
$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n3 $n2 orient left
$ns duplex-link-op $n1 $n2 orient right-up
$ns duplex-link-op $n3 $n4 orient right-up
$ns duplex-link-op $n3 $n5 orient right-down
#Setup a TCP connection
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set sink3 [new Agent/TCPSink]
$ns attach-agent $n5 $sink3
$ns connect $tcp0 $sink3
$tcp0 set packetSize_ 1500
#Setup a TCP connection
set tcp1 [new Agent/TCP]
$ns attach-agent $n4 $tcp1
set sink2 [new Agent/TCPSink]
$ns attach-agent $n1 $sink2
$ns connect $tcp1 $sink2
$tcp1 set packetSize_ 1500
#Setup a UDP connection
set udp4 [new Agent/UDP]
$ns attach-agent $n2 $udp4
set null5 [new Agent/Null]
$ns attach-agent $n5 $null5
$ns connect $udp4 $null5
$udp4 set packetSize_ 48
#Setup a FTP Application over TCP connection
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
$ns at 1.0 "$ftp0 start"
$ns at 10.0 "$ftp0 stop"
#Setup a FTP Application over TCP connection
set ftp1 [new Application/FTP]
$ftp1 attach-agent $tcp1
$ns at 1.0 "$ftp1 start"
$ns at 10.0 "$ftp1 stop"
#Setup a CBR Application over UDP connection
set cbr2 [new Application/Traffic/CBR]
$cbr2 attach-agent $udp4
$cbr2 set packetSize_ 48
$cbr2 set interval_ 50ms
$cbr2 set random_ null
$ns at 1.0 "$cbr2 start"
$ns at 10.0 "$cbr2 stop"
#Define a 'finish' procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam httpex.nam &
exit 0
}
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "finish"
$ns at $val(stop) "puts \"done\" ; $ns halt"
$ns run
Exp:-04(FUND1)Two nodes
#Create a simulator object
set ns [new Simulator]
#Open the nam trace file
set tr [open "out.tr" w]
$ns trace-all $tr
set nf [open out.nam w]
$ns namtrace-all $nf
#Define a 'finish' procedure
proc finish {} {
global ns nf tr
$ns flush-trace
#Close the trace file
close $nf
close $tr
#Execute nam on the trace file
exec nam out.nam &
exit 0
}
#Create two nodes
set n0 [$ns node]
$n0 shape box
$n0 color green
set n1 [$ns node]
$n1 color red
#Create a duplex link between the nodes
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"
#Run the simulation
$ns run
Exp:-5(fund2)
#Create a simulator object
set ns [new Simulator]
#Open the nam trace file
set tr [open "out.tr" w]
$ns trace-all $tr
set nf [open out.nam w]
$ns namtrace-all $nf
#Create two nodes
set n0 [$ns node]
$n0 shape box
$n0 color green
set n1 [$ns node]
$n1 color red
#Create a duplex link between the nodes
$ns duplex-link $n0 $n1 2Mb 4ms DropTail
set tcp1 [new Agent/TCP]
set sink [new Agent/TCPSink]
$ns attach-agent $n0 $tcp1
$ns attach-agent $n1 $sink
$ns connect $tcp1 $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp1
#Define a 'finish' procedure
proc finish {} {
global ns nf tr
$ns flush-trace
#Close the trace file
close $nf
close $tr
#Execute nam on the trace file
exec nam out.nam &
exit 0
}
#Call the finish procedure after 5 seconds of simulation time
$ns at 0.1 "$ftp start"
$ns at 2.0 "$ftp stop"
$ns at 2.1 "finish"
#Run the simulation
$ns run

You might also like