3. Implement an
Ethernet LAN using n nodes and set multiple traffic nodes and plot congestion
window for different source / destination.
set ns [new Simulator]
set nf [open "lab3.nam" w]
$ns namtrace-all $nf
set tf [open "lab3.tr" w]
$ns trace-all $tf
set n0 [$ns node]
$n0 label "src1"
$n0 color "magenta"
set n1 [$ns node]
$n1 color "red"
set n2 [$ns node]
$n2 label "src2"
$n2 color "magenta"
set n4 [$ns node]
$n4 color "red"
set n3 [$ns node]
$n3 label "dest2"
$n3 color "blue"
set n5 [$ns node]
$n5 label "dest1"
$n5 color "blue"
$ns make-lan "$n0 $n1 $n2 $n3 $n4" 100Mb 10ms LL Queue/DropTail Mac/802_3
$ns duplex-link $n4 $n5 100Mb 10ms DropTail
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
$ftp0 set packetSize_ 1000
$ftp0 set interval_ 0.005
set Sink0 [new Agent/TCPSink]
$ns attach-agent $n5 $Sink0
$ns connect $tcp0 $Sink0
set tcp1 [new Agent/TCP]
$ns attach-agent $n2 $tcp1
set ftp1 [ new Application/FTP]
$ftp1 attach-agent $tcp1
$ftp1 set packetSize_ 10000
$ftp1 set interval_ 0.0005
set Sink1 [new Agent/TCPSink]
$ns attach-agent $n3 $Sink1
$ns connect $tcp1 $Sink1
set file0 [open "file0.tr" w]
$tcp0 attach $file0
set file1 [open "file1.tr" w]
$tcp1 attach $file1
$tcp0 trace cwnd_
$tcp1 trace cwnd_
proc finish { } {
global ns nf tf
$ns flush-trace
close $nf
close $tf
exec nam lab3.nam &
exit 0
}
$ns at 0.1 "$ftp0 start"
$ns at 0.5 "$ftp0 stop"
$ns at 0.8 "$ftp0 start"
$ns at 0.9 "$ftp1 start"
$ns at 1.1 "$ftp1 stop"
$ns at 1.5 "$ftp0 stop"
$ns at 1.8 "$ftp1 start"
$ns at 2.2 "$ftp1 stop"
$ns at 2.9 "finish"
$ns run
set nf [open "lab3.nam" w]
$ns namtrace-all $nf
set tf [open "lab3.tr" w]
$ns trace-all $tf
set n0 [$ns node]
$n0 label "src1"
$n0 color "magenta"
set n1 [$ns node]
$n1 color "red"
set n2 [$ns node]
$n2 label "src2"
$n2 color "magenta"
set n4 [$ns node]
$n4 color "red"
set n3 [$ns node]
$n3 label "dest2"
$n3 color "blue"
set n5 [$ns node]
$n5 label "dest1"
$n5 color "blue"
$ns make-lan "$n0 $n1 $n2 $n3 $n4" 100Mb 10ms LL Queue/DropTail Mac/802_3
$ns duplex-link $n4 $n5 100Mb 10ms DropTail
set tcp0 [new Agent/TCP]
$ns attach-agent $n0 $tcp0
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
$ftp0 set packetSize_ 1000
$ftp0 set interval_ 0.005
set Sink0 [new Agent/TCPSink]
$ns attach-agent $n5 $Sink0
$ns connect $tcp0 $Sink0
set tcp1 [new Agent/TCP]
$ns attach-agent $n2 $tcp1
set ftp1 [ new Application/FTP]
$ftp1 attach-agent $tcp1
$ftp1 set packetSize_ 10000
$ftp1 set interval_ 0.0005
set Sink1 [new Agent/TCPSink]
$ns attach-agent $n3 $Sink1
$ns connect $tcp1 $Sink1
set file0 [open "file0.tr" w]
$tcp0 attach $file0
set file1 [open "file1.tr" w]
$tcp1 attach $file1
$tcp0 trace cwnd_
$tcp1 trace cwnd_
proc finish { } {
global ns nf tf
$ns flush-trace
close $nf
close $tf
exec nam lab3.nam &
exit 0
}
$ns at 0.1 "$ftp0 start"
$ns at 0.5 "$ftp0 stop"
$ns at 0.8 "$ftp0 start"
$ns at 0.9 "$ftp1 start"
$ns at 1.1 "$ftp1 stop"
$ns at 1.5 "$ftp0 stop"
$ns at 1.8 "$ftp1 start"
$ns at 2.2 "$ftp1 stop"
$ns at 2.9 "finish"
$ns run
AWK file
(Open a new editor using “gedit command” and write awk file and save with
“.awk” extension)
cwnd:-
means congestion window
BEGIN{
}
{
if($6 == "cwnd_")
{
printf("%f\t%f\n",$1,$7);
}
}
END{
}
}
{
if($6 == "cwnd_")
{
printf("%f\t%f\n",$1,$7);
}
}
END{
}
No comments:
Post a Comment