Commit cc79d1a7 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Add another test to the testsuite that has some more interesting

events and some program agents.
parent 90ddc720
......@@ -24,3 +24,4 @@ fixed
vtypes
simplex
red
cbr
Test UDP and a TCP agent/CBR. Also throw in some events to start/stop
the trafgen.
source tb_compat.tcl
set ns [new Simulator]
#Create four nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
#Create links between the nodes
set link0 [$ns duplex-link $n0 $n2 100Mb 1ms DropTail]
set link1 [$ns duplex-link $n1 $n2 100Mb 1ms DropTail]
set link2 [$ns duplex-link $n3 $n2 100Mb 1ms DropTail]
#Create a UDP agent and attach it to node n0
set udp0 [new Agent/UDP]
#$udp0 set class_ 1
$ns attach-agent $n0 $udp0
# Create a CBR traffic source and attach it to udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0
#Create a TCP agent and attach it to node n1
set tcp0 [new Agent/TCP]
$ns attach-agent $n1 $tcp0
# Create a CBR traffic source and attach it to tcp0
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr1 attach-agent $tcp0
#Create a Null agent (a traffic sink) and attach it to node n3
set null0 [new Agent/Null]
$ns attach-agent $n3 $null0
#Create a TCPSINK agent (a traffic sink) and attach it to node n3
set null1 [new Agent/TCPSINK]
$ns attach-agent $n3 $null1
#Connect the traffic sources with the traffic sink
$ns connect $udp0 $null0
$ns connect $tcp0 $null1
# Create a program object and attach it to nodeA
set prog0 [$ns program]
$prog0 set node $n3
$prog0 set command "/bin/ls -lt >& /tmp/foo"
set prog1 [$ns program]
$prog1 set node $n3
$prog1 set command "/bin/sleep 60 >& /tmp/bar"
$ns at 1.0 "$cbr0 start"
$ns at 2.0 "$link0 down"
$ns at 4.0 "$link0 up"
$ns at 5.0 "$cbr0 stop"
$ns at 10.0 "$cbr1 start"
$ns at 11.0 "$cbr1 stop"
$ns at 20.0 "$prog0 start"
$ns at 21.0 "$prog0 stop"
$ns at 22.0 "$prog1 start"
$ns at 23.0 "$prog1 stop"
$ns at 30.0 "$link1 down"
$ns at 35.0 "$link1 up"
#Run the simulation
$ns run
tb_prerun("tbprerun",0);
tb_run("tbswapin",0);
tb_run("tbswapout",0);
tb_run("tbswapin",0);
tb_run("tbswapout",0);
tb_run("tbend",0);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment