delay.ns 2.83 KB
Newer Older
1 2 3 4 5 6
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2004 University of Utah and the Flux Group.
# All rights reserved.
#

7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
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]

tb-set-node-os $n0 FBSD43-STD
tb-set-node-os $n1 FBSD43-STD
tb-set-node-os $n2 FBSD43-STD

#Create links between the nodes
set link0 [$ns duplex-link $n0 $n2 100Mb 1ms DropTail]
set link1 [$ns duplex-link $n1 $n2 100Mb 1ms RED]
set link2 [$ns duplex-link $n3 $n2 100Mb 1ms DropTail]

# Get the queue object for the n1/n2 link and modify its RED params.
set queue0 [[$ns link $n1 $n2] queue]
$queue0 set gentle_ 1
$queue0 set queue-in-bytes_ 0
$queue0 set limit_ 40
$queue0 set maxthresh_ 35
$queue0 set thresh_ 25
$queue0 set linterm_ 20
$queue0 set q_weight_ 0.004


#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 UDP agent and attach it to node n1
set udp1 [new Agent/UDP]
#$udp1 set class_ 2
$ns attach-agent $n1 $udp1

# Create a CBR traffic source and attach it to udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$cbr1 attach-agent $udp1

#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 Null agent (a traffic sink) and attach it to node n3
set null1 [new Agent/Null]
$ns attach-agent $n3 $null1

#Connect the traffic sources with the traffic sink
$ns connect $udp0 $null0  
$ns connect $udp1 $null1

tb-set-ip-interface $n0 $n2 192.168.2.2
tb-set-ip-interface $n2 $n0 192.168.2.3
tb-set-ip-interface $n1 $n2 192.168.3.2
tb-set-ip-interface $n2 $n1 192.168.3.3
tb-set-ip-interface $n3 $n2 192.168.1.2
tb-set-ip-interface $n2 $n3 192.168.1.3


#tb-set-node-startup $n0 /users/abhijeet/ping0 
#tb-set-node-startup $n1 /users/abhijeet/ping1 

$ns at 0.00001 "$cbr0 start"
$ns at 0.00300 "$cbr0 set packetSize_ 64"
$ns at 0.00300 "$cbr0 set interval_ 128"
$ns at 0.00300 "$cbr0 set rate_ 15Mbps"
$ns at 0.00500 "$cbr0 stop"
$ns at 2.0 "$link0 down"
$ns at 4.0 "$link1 down"
$ns at 6.0 "$link0 up"
$ns at 8.0 "$link1 up"
$ns at 12.0 "$link0 delay 300ms"
$ns at 12.0 "$link1 delay 300ms"
$ns at 13.0 "$link0 bandwidth 1Mb duplex"
$ns at 13.0 "$link1 bandwidth 1Mb duplex"
$ns at 15.0 "$link0 bandwidth 100Mb duplex"
$ns at 15.0 "$link1 bandwidth 100Mb duplex"
$ns at 15.0 "$link0 delay 1ms"
$ns at 15.0 "$link1 delay 1ms"

$ns at 20    "$queue0 set thresh_ 5 ; $queue0 set linterm_ 10"
$ns at 25    "$queue0 set maxthresh_ 30 ; $queue0 set q_weight_ 0.5"
$ns at 30    "$queue0 set queue-in-bytes_ 0"
$ns at 35    "$queue0 set limit_ 30"


#Run the simulation
$ns run