#################################################################### # # # < QoS over (G)MPLS with Traffic Preemption > # # # #################################################################### set ns [new Simulator] set na [open test-crlsp.tr w] #set nf [open test-crlsp.nam w] set fAF11 [open AF11 w] set fAF21 [open AF21 w] set fAF31 [open AF31 w] set fEF [open EF w] set TpktAF11 0 set TpktAF21 0 set TpktAF31 0 set TpktEF 0 proc record {} { global fAF11 fAF21 fAF31 fEF AF11sink AF21sink AF31sink EFsink TpktAF11 TpktAF21 TpktAF31 TpktEF set ns [Simulator instance] # Set the time after which the procedure should be called again # set time 1.0 # set time 0.045 # # How many bytes have been received by the traffic sink? # set bwAF11 [$AF11sink set bytes_] set bwAF21 [$AF21sink set bytes_] set bwAF31 [$AF31sink set bytes_] set bwEF [$EFsink set bytes_] # Get the current time # set now [$ns now] 88 # Calculate the bandwidth (in MBit/s) and write it to the file # puts $fAF11 "$now [expr $bwAF11/$time*8/1000000]" puts $fAF21 "$now [expr $bwAF21/$time*8/1000000]" puts $fAF31 "$now [expr $bwAF31/$time*8/1000000]" puts $fEF "$now [expr $bwEF/$time*8/1000000]" # Reset the bytes_ values on the traffic sink # $AF11sink set bytes_ 0 $AF21sink set bytes_ 0 $AF31sink set bytes_ 0 $EFsink set bytes_ 0 set pktAF11 [expr $bwAF11 / 200] set TpktAF11 [expr $TpktAF11 + $pktAF11] set pktAF21 [expr $bwAF21 / 200] set TpktAF21 [expr $TpktAF21 + $pktAF21] set pktAF31 [expr $bwAF31 / 200] set TpktAF31 [expr $TpktAF31 + $pktAF31] set pktEF [expr $bwEF / 200] set TpktEF [expr $TpktEF + $pktEF] # Re-schedule the procedure # $ns at [expr $now+$time] "record" } proc recv-pkts {} { global TpktAF11 TpktAF21 TpktAF31 TpktEF puts "The packet number of AF11 : $TpktAF11" puts "The packet number of AF21 : $TpktAF21" puts "The packet number of AF31 : $TpktAF31" puts "The packet number of EF : $TpktEF" } proc attach-expoo-traffic { node sink size burst idle rate } { global ns set source [new Agent/CBR/UDP] $ns attach-agent $node $source set traffic [new Traffic/Expoo] $traffic set packet-size $size $traffic set burst-time $burst 89 $traffic set idle-time $idle $traffic set rate $rate $source attach-traffic $traffic $ns connect $source $sink return $source } $ns trace-all $na # $ns namtrace-all $nf # proc finish {} { global ns na nf fAF11 fAF21 fAF31 fEF $ns flush-trace close $na #close $nf close $fAF11 close $fAF21 close $fAF31 close $fEF recv-pkts # exec nam test-crlsp.nam & # exec xgraph -m AF11 AF21 AF31 EF -geometry 800x400 & exit 0 } # make nodes & MPLSnodes # set Node0 [$ns node] set LSR1 [$ns mpls-node] set LSR2 [$ns mpls-node] set LSR3 [$ns mpls-node] set Node4 [$ns node] # make links $ns duplex-link $Node0 $LSR1 2Mb 10ms DropTail $ns duplex-link $LSR1 $LSR2 1Mb 10ms CBQ $ns duplex-link $LSR2 $LSR3 1Mb 10ms CBQ $ns duplex-link $LSR3 $Node4 1Mb 10ms DropTail 90 $ns duplex-link-op $LSR1 $LSR2 queuePos 0.8 # configure ldp agents on all mpls nodes # $ns configure-ldp-on-all-mpls-nodes #--------------------------------|-------|-------------|------------|-----|----------|--------------|# # configure-cbq-for-AF11S |{qlim|cbq_qtype |okborrow|bw |maxidle |extradelay} |# #--------------------------------|-------|-------------|------------|-----|----------|--------------|# $ns cfg-cbq-for-AF11S 10 DropTail 1 0.1 auto 0 $ns cfg-cbq-for-AF21S 10 DropTail 1 0.05 auto 0 $ns cfg-cbq-for-RTS 10 DropTail 0 0.8 auto 0 $ns cfg-cbq-for-STS 10 DropTail 1 0.05 auto 0 $ns bind-flowid-to-AF11S 100 $ns bind-flowid-to-AF11S 200 $ns bind-flowid-to-AF11S 300 $ns bind-flowid-to-AF11S 400 $ns bind-ldp-to-STS # set ldp-message clolr # $ns ldp-request-color blue $ns ldp-mapping-color red $ns ldp-withdraw-color magenta $ns ldp-release-color orange $ns ldp-notification-color yellow # $LSR2 trace-mpls # # $LSR3 trace-mpls # # set ldp events # # $ns enable-control-driven # #$ns enable-data-driven #$ns enable-on-demand #$ns enable-ordered-control 91 # Create a traffic sink and attach it to the node Node4 # set AF11sink [new Agent/LossMonitor] $ns attach-agent $Node4 $AF11sink $AF11sink clear set AF21sink [new Agent/LossMonitor] $ns attach-agent $Node4 $AF21sink $AF21sink clear set AF31sink [new Agent/LossMonitor] $ns attach-agent $Node4 $AF31sink $AF31sink clear set EFsink [new Agent/LossMonitor] $ns attach-agent $Node4 $EFsink $EFsink clear # Create a traffic source # set AF11 [attach-expoo-traffic $Node0 $AF11sink 200 0 0 250k] $AF11 set fid_ 100 $ns color 100 red set AF21 [attach-expoo-traffic $Node0 $AF21sink 200 0 0 250k] $AF21 set fid_ 200 $ns color 200 blue set AF31 [attach-expoo-traffic $Node0 $AF31sink 200 0 0 350k] $AF31 set fid_ 300 $ns color 300 yellow set EF [attach-expoo-traffic $Node0 $EFsink 200 0 0 450k] $EF set fid_ 400 $ns color 400 black proc notify-erlsp-setup {node lspid} { set ns [Simulator instance] puts "[$ns now] nodeid=[$node id] : lspid=$lspid" set module [$node get-module "MPLS"] if {[$node id] == 1} { switch $lspid { 92 1000 { $module bind-flow-erlsp 4 100 $lspid } 1100 { $module bind-flow-erlsp 4 200 $lspid $module set-flow-prio 4 200 1 } 1200 { $module bind-flow-erlsp 4 300 $lspid } 1300 { $module bind-flow-erlsp 4 400 $lspid } default { puts "error" exit 1 } } } } proc notify-erlsp-fail {node status lspid tr} { puts "nodeid=[$node id] : status=$status lspid=$lspid tr=$tr" } # set MPLS modules # for {set i 1} {$i < 4} {incr i} { set a LSR$i set m [eval $$a get-module "MPLS"] eval set LSRmpls$i $m } $ns at 0.0 "record" $ns at 0.1 "$LSRmpls1 setup-erlsp 3 1_2_3 1000" $ns at 0.1 "$LSRmpls1 setup-erlsp 3 1_2_3 1100" #----------------------------------------------|-----|--|-----|--------|-------|-------|-------|---|# #RtModule/MPLS instproc #setupcrlsp|{fec|er|lspid|TRate|BSize|PSize|SPrio|HPrio}|# #----------------------------------------------|-----|--|-----|--------|-------|-------|-------|------|# $ns at 0.1 "$LSRmpls1 setup-crlsp 3 1_2_3 1200 350K 400B 200B 7 3" 93 $ns at 1.0 "$AF11 start" $ns at 1.0 "$AF21 start" $ns at 1.0 "$AF31 start" #----------------------------------------------|-----|--|-----|--------|-------|-------|-------|-------- |# # RtModule/MPLS instproc setupcrlsp|{ fec|er|lspid|TRate|BSize|PSize|SPrio|HPrio}|# #----------------------------------------------|-----|--|-----|--------|-------|-------|-------|-------- |# $ns at 10.0 "$LSRmpls1 setup-crlsp 3 1_2_3 1300 450K 400B 200B 7 3" $ns at 11.0 "$EF start" $ns at 30.0 "$EF stop" $ns at 31.0 "$LSRmpls1 send-crldp-release-msg 1300" $ns at 40.0 "$AF11 stop" $ns at 40.0 "$AF21 stop" $ns at 40.0 "$AF31 stop" $ns at 43.0 "finish" $ns run ### Local Variables: ### mode: tcl ### tcl-indent-level: 8 ### tcl-default-application: ns ### End: