set ns [new Simulator]
set n0 [$ns node]
set n1 [$ns node]
$ns color 1 red
$ns at 0.0 "$n0 label Host-1"
$ns at 0.0 "$n1 label Host-2"
set nf [open out.nam w]
$ns namtrace-all $nf
set f [open out.tr w]
$ns trace-all $f
$ns duplex-link $n0 $n1 1Mb 200ms DropTail
$ns duplex-link-op $n0 $n1 orient right
$ns queue-limit $n0 $n1 10
Agent/TCP set nam_tracevar_ true
set tcp [new Agent/TCP]
$tcp set windowInit_ 4
$tcp set maxcwnd_ 4
$tcp set fid_ 1
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n1 $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns add-agent-trace $tcp tcp
$ns monitor-agent-trace $tcp
$tcp tracevar cwnd_
$ns at 0.1 "$ftp start"
$ns at 3.0 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n1 $sink"
$ns at 3.0 "finish"
$ns at 0.0 "$ns trace-annotate \"Sliding Window with window size 4 (normal operation)\""
$ns at 0.52 "$ns trace-annotate \"Send Packet_0,1,2,3\""
$ns at 0.92 "$ns trace-annotate \"Receive Ack_0,1,2,3\""
$ns at 0.93 "$ns trace-annotate \"Send Packet_4,5,6,7\""
$ns at 1.32 "$ns trace-annotate \"Receive Ack_4,5,6,7\""
$ns at 1.33 "$ns trace-annotate \"Send Packet_8,9,10,11\""
$ns at 1.72 "$ns trace-annotate \"Receive Ack_8,9,10,11 \""
$ns at 1.73 "$ns trace-annotate \"Send Packet_12,13,14,15\""
$ns at 2.14 "$ns trace-annotate \"Receive Ack_12,13,14,15\""
$ns at 2.15 "$ns trace-annotate \"Send Packet_16,17,18,19\""
$ns at 2.55 "$ns trace-annotate \"Receive Ack_16,17,18,19\""
$ns at 2.56 "$ns trace-annotate \"Send Packet_20,21,22,23\""
$ns at 2.96 "$ns trace-annotate \"Receive Ack_20,21,22,23\""
$ns at 2.97 "$ns trace-annotate \"FTP stops\""
proc finish {} {
global ns
$ns flush-trace
exec nam out.nam &
exit 0
}
$ns run
set n0 [$ns node]
set n1 [$ns node]
$ns color 1 red
$ns at 0.0 "$n0 label Host-1"
$ns at 0.0 "$n1 label Host-2"
set nf [open out.nam w]
$ns namtrace-all $nf
set f [open out.tr w]
$ns trace-all $f
$ns duplex-link $n0 $n1 1Mb 200ms DropTail
$ns duplex-link-op $n0 $n1 orient right
$ns queue-limit $n0 $n1 10
Agent/TCP set nam_tracevar_ true
set tcp [new Agent/TCP]
$tcp set windowInit_ 4
$tcp set maxcwnd_ 4
$tcp set fid_ 1
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n1 $sink
$ns connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns add-agent-trace $tcp tcp
$ns monitor-agent-trace $tcp
$tcp tracevar cwnd_
$ns at 0.1 "$ftp start"
$ns at 3.0 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n1 $sink"
$ns at 3.0 "finish"
$ns at 0.0 "$ns trace-annotate \"Sliding Window with window size 4 (normal operation)\""
$ns at 0.52 "$ns trace-annotate \"Send Packet_0,1,2,3\""
$ns at 0.92 "$ns trace-annotate \"Receive Ack_0,1,2,3\""
$ns at 0.93 "$ns trace-annotate \"Send Packet_4,5,6,7\""
$ns at 1.32 "$ns trace-annotate \"Receive Ack_4,5,6,7\""
$ns at 1.33 "$ns trace-annotate \"Send Packet_8,9,10,11\""
$ns at 1.72 "$ns trace-annotate \"Receive Ack_8,9,10,11 \""
$ns at 1.73 "$ns trace-annotate \"Send Packet_12,13,14,15\""
$ns at 2.14 "$ns trace-annotate \"Receive Ack_12,13,14,15\""
$ns at 2.15 "$ns trace-annotate \"Send Packet_16,17,18,19\""
$ns at 2.55 "$ns trace-annotate \"Receive Ack_16,17,18,19\""
$ns at 2.56 "$ns trace-annotate \"Send Packet_20,21,22,23\""
$ns at 2.96 "$ns trace-annotate \"Receive Ack_20,21,22,23\""
$ns at 2.97 "$ns trace-annotate \"FTP stops\""
proc finish {} {
global ns
$ns flush-trace
exec nam out.nam &
exit 0
}
$ns run
No comments:
Post a Comment