[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] TCL script for Alton only





	Hi Alton,

		I am sending the TCL script as an attachment. Even a 
single link between two nodes yields a 0 value for "pdrops_" at all 
times. I really appreciate your help. Thanks.

	Regards,
	  Vijay Chellappa.
#Create a simulator object
set ns [new Simulator]

#Open the trace file
set nf [open btp.tr w]
set tracefd [open vgraph.tr w]
set nq [open queue.tr w]
$ns namtrace-all $nf

#Define a 'finish' procedure
proc finish {} {
	global ns nf tracefd
	$ns flush-trace
	#close the trace file
	close $nf
	close $tracefd
#	exec nam btp.nam &
	exit 0
}	

#create two 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]



#Create links between the nodes
$ns duplex-link $n0 $n3 1Mb 100ms DropTail
$ns duplex-link $n1 $n3 1Mb 100ms DropTail
$ns duplex-link $n2 $n3 1Mb 100ms DropTail
$ns duplex-link $n3 $n4 0.5Mb 100ms DropTail
$ns duplex-link $n4 $n5 1Mb 100ms DropTail
$ns duplex-link $n4 $n6 1Mb 100ms DropTail

# $ns link $n3 $n4

Queue/DropTail set drop_front_ true

$ns queue-limit $n3 $n4 1

#Create a TCP agents and attach it to node n0, n1

set tcp_src1 [new Agent/TCP/Reno]

set tcp_src2 [new Agent/TCP/Reno]

set tcp_src3 [new Agent/TCP/Reno]

set tcp_snk5 [new Agent/TCPSink]

set tcp_snk6 [new Agent/TCPSink]

$ns attach-agent $n0 $tcp_src1
$ns attach-agent $n1 $tcp_src2
$ns attach-agent $n2 $tcp_src3

$ns attach-agent $n5 $tcp_snk5
$ns attach-agent $n6 $tcp_snk6

#Create FTP sources at the each node
set ftp1 [$tcp_src1 attach-source FTP]
set ftp2 [$tcp_src2 attach-source FTP]
set ftp3 [$tcp_src3 attach-source FTP]

#connect src and destination
$ns connect $tcp_src1 $tcp_snk5
$ns connect $tcp_src2 $tcp_snk5
$ns connect $tcp_src3 $tcp_snk6


$ns at 0.0 "$ftp1 start"
$ns at 0.0 "$ftp2 start"
$ns at 0.0 "$ftp3 start"


proc record {} {
	global ns tcp_src2 tracefd n3 n4 nq
	set ns [Simulator instance]
	set time 2.5
#	set vc [$tcp_src2 set cwnd_]
	$ns trace-queue $n3 $n4 $nq
	set qs [$ns monitor-queue $n3 $n4 ""]
	set qdrop [$qs set pdrops_]
	set now [$ns now]
	puts $tracefd "$now $qdrop"
	$ns at [expr $now+$time] "record"
}

$ns at 0.0 "record"


#Call the finish procedure after 5 seconds of simulation time
$ns at 50.0 "finish"

#Run the simulation
$ns run