Professional Documents
Culture Documents
#In the following network, the host named Annie is transmitting data
over a reliable, connection-oriented communication to the host named
Peter at a rate of 0.1Mbps in 1000 bytes long packets. The shortest
path algorithm is followed for routing and a sliding window protocol
with a window size of 8 is used for a reliable data transfer.It has
been found that the queue of the link host3-host4 goes down to zero
at 2.5 sec and comes up to 50 again at 3.0 sec.
#At the same time the host named Robin is transmitting data to the
host named Juliet over a reliable, connection-oriented communication
at a rate of 0.1Mbps in 1000 bytes long packets. The shortest path
algorithm is followed for routing and a simple stop and wait protocol
is used for a reliable data transfer. It has been found that the
queue of the link host4-host3 goes down to zero at 4.5 sec and comes
up to 50 again at 5.0 sec. The above-said transmissions exist totally
for 10.0 secs.
#Set the queue size of all links to 50 packets. Orient the nodes as
shown in the figure. Set labels for transmitting nodes as Annie and
Robin and receiving nodes as Peter and Juliet as shown in the figure.
Set label for each link indicating its bandwidth, and delay as shown
in the figure. Set the shape of the transmitting and receiving nodes
to hexagon and box, and color, to red and blue, respectively. Set the
color of the traffic flow from Annie to Peter to red and that from
Robin to Juliet to blue. Set nam and .tr tracings. Analyze the .tr
trace file to get details on dropped packets during this transmission
scenario.
#create new simulator object
set ns [new Simulator]
#set nam and .tr tracings
set nf [open Q55.nam w]
$ns namtrace-all $nf
set tf [open Q55.tr w]
$ns trace-all $tf
#finish procedure
proc finish {} {
global ns nf tf
$ns flush-trace
close $nf
close $tf
exec nam Q55.nam &
exit 0
}
#add nodes
for {set i 0} {$i<8} {incr i} {
set n($i) [$ns node]
}
#set node parameters
$n(0) shape hexagon
$n(0) color red
$ns at 0.0 "$n(0) label \"Annie\""
$n(7) shape box
$n(7) color blue
$ns at 0.0 "$n(7) label \"Peter\""
$n(5) shape hexagon
$n(5) color red
$ns at 0.0 "$n(5) label \"Robin\""
at
at
at
at
0.0
0.0
0.0
0.0
"$n(1)
"$n(3)
"$n(4)
"$n(6)
#add links
$ns duplex-link
$ns duplex-link
$ns duplex-link
$ns duplex-link
$ns duplex-link
$ns duplex-link
$ns duplex-link
label
label
label
label
$n(0)
$n(1)
$n(2)
$n(3)
$n(4)
$n(4)
$n(4)
\"host1\""
\"host3\""
\"host4\""
\"host6\""
$n(3)
$n(3)
$n(3)
$n(4)
$n(5)
$n(6)
$n(7)
1Mb
1Mb
1Mb
1Mb
1Mb
1Mb
1Mb
100ms
100ms
100ms
100ms
100ms
100ms
100ms
$n(3)
$n(3)
$n(3)
$n(4)
$n(5)
$n(6)
$n(7)
orient
orient
orient
orient
orient
orient
orient
$ns
$ns
$ns
$ns
$ns
$ns
$ns
$n(3)
$n(3)
$n(3)
$n(4)
$n(5)
$n(6)
$n(7)
label
label
label
label
label
label
label
duplex-link-op
duplex-link-op
duplex-link-op
duplex-link-op
duplex-link-op
duplex-link-op
duplex-link-op
$n(0)
$n(1)
$n(2)
$n(3)
$n(4)
$n(4)
$n(4)
DropTail
DropTail
DropTail
DropTail
DropTail
DropTail
DropTail
right-down
right
right-up
right
right-up
right
right-down
"\
"\
"\
"\
"\
"\
"\
1Mb,100ms"
1Mb,100ms"
1Mb,100ms"
1Mb,100ms"
1Mb,100ms"
1Mb,100ms"
1Mb,100ms"
#add traffics
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
set ftp5 [new Application/FTP]
$ftp5 attach-agent $tcp5
#set traffic parameters
$ftp0 set rate_ 0.1Mb
$ftp0 set packetSize_ 1000
$ftp5 set rate_ 0.1Mb
$ftp5 set packetSize_ 1000
#insert network
$ns at 2.5 "$ns
$ns at 3.0 "$ns
$ns at 4.5 "$ns
$ns at 5.0 "$ns
dynamics
queue-limit
queue-limit
queue-limit
queue-limit
$n(3)
$n(3)
$n(4)
$n(4)
$n(4)
$n(4)
$n(3)
$n(3)
0"
50"
0"
50"