set ns [new Simulator]

#Open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf

#Open the Trace file
set tf [open out.tr w]
$ns trace-all $tf

#Define a 'finish' procedure
proc finish {} {
        global ns nf tf
        $ns flush-trace
        #Close the trace file
        close $nf
        #Close the Trace file
        close $tf
        #Execute nam on the trace file
        exec nam out.nam &
        exit 0
}

#set ip nodes and mpls nodes

set node0 [$ns node]
set node1 [$ns node]
$ns node-config -MPLS ON
set LSR2  [$ns mpls-node]
$ns node-config -MPLS ON
set LSR3  [$ns mpls-node]
$ns node-config -MPLS ON
set LSR4  [$ns mpls-node]
$ns node-config -MPLS ON
set LSR5  [$ns mpls-node]
$ns node-config -MPLS ON
set LSR6  [$ns mpls-node]
$ns node-config -MPLS ON
set LSR7  [$ns mpls-node]
$ns node-config -MPLS ON
set LSR8  [$ns mpls-node]
$ns node-config -MPLS OFF
set node9 [$ns node]
set node10 [$ns node]



#connect nodes

$ns duplex-link $node0 $LSR2 1Mb 10ms DropTail
$ns duplex-link $node1 $LSR3 1Mb 10ms DropTail
$ns duplex-link $LSR2  $LSR3 1Mb 10ms DropTail
$ns duplex-link $LSR3  $LSR4 1Mb 10ms DropTail
$ns duplex-link $LSR4  $LSR8 1Mb 10ms DropTail
$ns duplex-link $LSR2  $LSR5 1Mb 10ms DropTail
$ns duplex-link $LSR5  $LSR6 1Mb 10ms DropTail
$ns duplex-link $LSR5  $LSR4 1Mb 10ms DropTail
$ns duplex-link $LSR6  $LSR7 1Mb 10ms DropTail
$ns duplex-link $LSR6  $LSR8 1Mb 10ms DropTail
$ns duplex-link $LSR7  $LSR8 1Mb 10ms DropTail
$ns duplex-link $LSR7  $node9   1Mb 10ms DropTail
$ns duplex-link $LSR8  $node10  1Mb 10ms DropTail


$ns duplex-link-op $node0 $LSR2 orient right
$ns duplex-link-op $node1 $LSR3 orient right
$ns duplex-link-op $LSR2  $LSR3 orient down
$ns duplex-link-op $LSR3  $LSR4 orient right
$ns duplex-link-op $LSR4  $LSR8 orient right
$ns duplex-link-op $LSR2  $LSR5 orient right
$ns duplex-link-op $LSR5  $LSR6 orient right
$ns duplex-link-op $LSR5  $LSR4 orient down
$ns duplex-link-op $LSR6  $LSR7 orient
right-down
$ns duplex-link-op $LSR6  $LSR8 orient down
$ns duplex-link-op $LSR7  $LSR8 orient left-down
$ns duplex-link-op $LSR7  $node9 orient right
$ns duplex-link-op $LSR8  $node10 orient right



# Adjust loop length to address all LSRs (MPLS nodes).

for {set i 2} {$i < 9} {incr i} {
    for {set j [expr $i+1]} {$j < 9} {incr j} {
         set a LSR$i
         set b LSR$j
         eval $ns LDP-peer $$a $$b
    }
}

[$LSR2 get-module "MPLS"] enable-control-driven
[$LSR3 get-module "MPLS"] enable-control-driven
[$LSR4 get-module "MPLS"] enable-control-driven
[$LSR5 get-module "MPLS"] enable-control-driven
[$LSR6 get-module "MPLS"] enable-control-driven
[$LSR7 get-module "MPLS"] enable-control-driven
[$LSR8 get-module "MPLS"] enable-control-driven


$ns configure-ldp-on-all-mpls-nodes
$ns enable-control-driven

$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





set udp0 [new Agent/UDP]
$ns attach-agent $node0 $udp0
set cbr0 [new Application/Traffic/CBR]
$cbr0 attach-agent $udp0

set udp1 [new Agent/UDP]
$ns attach-agent $node1 $udp1
$udp1 set class_ 1
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1

set null0 [new Agent/Null]
$ns attach-agent $node9 $null0

set null1 [new Agent/Null]
$ns attach-agent $node10 $null1

$ns connect $udp0 $null0
$ns connect $udp1 $null1

$ns at 0.1 "$cbr0 start"
$ns at 0.1 "$cbr1 start"

set tcp [new Agent/TCP]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $node0 $tcp
$ns attach-agent $node9 $sink
$ns connect $tcp $sink

set tcp [new Agent/TCP]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns attach-agent $node1 $tcp
$ns attach-agent $node10 $sink
$ns connect $tcp $sink


#connect src and dst
#$ns connect $node0 $node9
#$ns connect $node1 $node10

$ns at 0.1 "$node0 start"
$ns at 0.1 "$node1 start"

$ns at 0.2 "[$LSR7 get-module MPLS] ldp-trigger-by-withdraw     9 -1"
$ns at 0.2 "[$LSR8 get-module MPLS] ldp-trigger-by-withdraw     10 -1"

$ns at 0.3 "[$LSR2 get-module MPLS] flow-aggregation            9 -1 6 -1"
$ns at 0.3 "[$LSR2 get-module MPLS] flow-aggregation            10 -1 6 -1"
$ns at 0.5 "[$LSR6 get-module MPLS] ldp-trigger-by-withdraw     6 -1"
$ns at 0.7 "$node1 stop"

$ns at 0.7 "$LSR2 make-explicit-route                          7
5_4_8_6_7    3000"
$ns at 0.9 "$LSR2 flow-erlsp-install                           9 -1 3000"
$ns at 1.1 "$LSR2 ldp-trigger-by-release                           3000"
$ns at 1.2  "$LSR4 make-explicit-route                        8  4_5_6_8
3500"
$ns at 1.3  "$LSR2 make-explicit-route                        7 2_3_4_3500_7
3600"
$ns at 1.4  "$LSR2 flow-erlsp-install                         9  -1 3600"
$ns at 1.6  "$LSR2 ldp-trigger-by-release                      3600"
$ns at 1.7  "$LSR4 ldp-trigger-by-release                      3500"
$ns at 1.8 "$LSR2 enable-data-driven"
$ns at 2.0 "$node0 stop"


$ns run
    (_o3 cmd line 1)
    invoked from within
"_o3 cmd configure-ldp-on-all-mpls-nodes"
    invoked from within
"catch "$self cmd $args" ret"
    invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
    (procedure "_o3" line 2)
    (SplitObject unknown line 2)
    invoked from within
"$ns configure-ldp-on-all-mpls-nodes"
    (file "label.tcl" line 101)

Reply via email to