Xin chào ! Nếu đây là lần đầu tiên bạn đến với diễn đàn, xin vui lòng danh ra một phút bấm vào đây để đăng kí và tham gia thảo luận cùng VnPro.

Announcement

Collapse
No announcement yet.

Xin giúp đỡ lỗi GMPLS trên NS2

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Xin giúp đỡ lỗi GMPLS trên NS2



    set ns [new Simulator]
    set na [open GMPLS.tr w]
    set nf [open GMPLS.nam w]
    $ns trace-all $na
    $ns namtrace-all $nf
    set f0 [open s0.tr w]
    set f1 [open s1.tr w]
    set f2 [open s2.tr w]
    set f3 [open s3.tr w]
    set f4 [open s4.tr w]
    set lambda1 [open lambda1.tr w]
    set lambda2 [open lambda2.tr w]
    set lambda3 [open lambda3.tr w]

    global ns nf tf f0 f1
    close $f0
    close $f1
    close $f2
    close $f3
    close $f4
    exec xgraph lambda1.tr lambda2.tr lambda3.tr &

    proc finish {} {
    global ns na nf f0 f1 f2 f3 f4 lambda1 lambda2 lambda3 fs
    $ns flush-trace
    close $na
    close $nf
    close $f0
    close $f1
    close $f2
    close $f3
    close $f4
    close $lambda1
    close $lambda2
    close $lambda3
    exec xgraph -m s0.tr s1.tr s2.tr s3.tr s4.tr -
    geometry 1000x600 -t "Throughput" -x "secs" -y "Mbps" &
    exec xgraph -m lambda1.tr lambda2.tr lambda3.tr -
    geometry 1000x600 -t "Lambda Utilization" -x "secs" -y
    "Percentage %" &
    exec nam GMPLS.nam &
    exit 0
    }
    set BW 2Mb

    proc attach-expoo-traffic {node sink size burst idle rate}
    {
    set ns [Simulator instance]
    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
    $traffic set idle-time $idle
    $traffic set rate $rate


    $source attach-traffic $traffic
    $ns connect $source $sink
    return $source
    }


    ################################################## #########
    #Define a procedure which periodically records the bandwidth received by the traffic sink sink0 and writes it to the file f0.

    proc record {} {
    global sink0 sink1 sink2 sink3 sink4 f1 f2 f3 f4

    set ns [Simulator instance]

    #set the time after which the procedure should be called again
    set time 0.065

    #How many bytes have been received by the traffic sink?
    set bw0 [$sink0 set bytes_]
    set bw1 [$sink1 set bytes_]
    set bw2 [$sink2 set bytes_]
    set bw3 [$sink3 set bytes_]
    set bw4 [$sink4 set bytes_]


    #Get the current time
    set now [$ns now]


    #Calculate the bandwidth (in Mbit/s) and write it to the file

    puts $f0 "$now [expr $bw0/$time*8/1000000]"
    puts $f1 "$now [expr $bw1/$time*8/1000000]"
    puts $f2 "$now [expr $bw2/$time*8/1000000]"
    puts $f3 "$now [expr $bw3/$time*8/1000000]"
    puts $f4 "$now [expr $bw4/$time*8/1000000]"

    #Reset the bytes_ values on the traffic sink
    $sink0 set bytes_0
    $sink1 set bytes_0
    $sink2 set bytes_0
    $sink3 set bytes_0
    $sink4 set bytes_0

    #Re-scheduler the procedure
    $ns at [expr $now+$time] "record"
    }

    #Routing protocol
    $ns rtproto DV
    #############################
    # make nodes & MPLSnodes #
    ############################

    set node0 [$ns node]
    set node1 [$ns node]
    set node2 [$ns node]
    set node3 [$ns node]
    set node4 [$ns node]

    set LSR5 [$ns mpls-node]
    set LSR6 [$ns mpls-node]
    set LSR7 [$ns mpls-node]
    set LSR8 [$ns mpls-node]
    set LSR9 [$ns mpls-node]

    set node10 [$ns node]
    set node11 [$ns node]
    set node12 [$ns node]
    set node13 [$ns node]
    set node14 [$ns node]

    ####################################
    # make Link #
    ####################################

    $ns duplex-link $node0 $LSR5 3Mb 10ms DropTail
    $ns duplex-link $node1 $LSR5 3Mb 10ms DropTail
    $ns duplex-link $node2 $LSR5 3Mb 10ms DropTail
    $ns duplex-link $node3 $LSR5 3Mb 10ms DropTail
    $ns duplex-link $node4 $LSR5 3Mb 10ms DropTail

    $ns duplex-link $LSR5 $LSR6 5Mb 10ms CBQ
    $ns duplex-link $LSR5 $LSR7 5Mb 10ms CBQ
    $ns duplex-link $LSR5 $LSR8 5Mb 10ms CBQ
    $ns duplex-link $LSR6 $LSR9 5Mb 10ms CBQ
    $ns duplex-link $LSR7 $LSR9 5Mb 10ms CBQ
    $ns duplex-link $LSR8 $LSR9 5Mb 10ms CBQ

    $ns duplex-link $LSR9 $node10 3Mb 10ms DropTail
    $ns duplex-link $LSR9 $node11 3Mb 10ms DropTail
    $ns duplex-link $LSR9 $node12 3Mb 10ms DropTail
    $ns duplex-link $LSR9 $node13 3Mb 10ms DropTail
    $ns duplex-link $LSR9 $node14 3Mb 10ms DropTail

    ###########################################
    # Configure Ldp agents on all Mpls node #
    ###########################################

    $ns configure-ldp-on-all-mpls-nodes

    #configure-cbq-for-SBTS {qlim cbq_qtype okborrow bw maxidle extradelay}
    $ns cfg-cbq-for-SBTS 2000 DropTail 0 0.1 auto 0
    $ns cfg-cbq-for-SBTS 2000 DropTail 0 0.05 auto 0
    $ns cfg-cbq-for-SBTS 2000 DropTail 0 0.8 auto 0
    $ns cfg-cbq-for-SBTS 2000 DropTail 0 0.05 auto 0

    $ns bind-flowid-to-SBTS 0
    $ns bind-flowid-to-SBTS 100
    $ns bind-flowid-to-SBTS 200
    $ns bind-flowid-to-SBTS 300
    $ns bind-flowid-to-SBTS 400
    $ns bind-flowid-to-SBTS 500

    $ns bind-ldp-to-STS

    ####################################
    # set ldp-message colour #
    ####################################

    $ns ldp-request-color blue
    $ns ldp-mapping-color red
    $ns ldp-withdraw-color magenta
    $ns ldp-release-color orange
    $ns ldp-notification-color green

    $ns collect-resource-info 4

    ################################################## #######
    # Create a traffic sink and attach it to the destination#
    # node $ Traffic Source #
    ################################################## #######

    set sink0 [new Agent/LossMonitor]
    $ns attach-agent $node10 $sink0
    $sink0 clear

    #Create a traffic source
    set src0 [attach-expoo-traffic $node0 $sink0 200 0 0 $BW]
    $src0 set fid_ 100
    $ns color 100 orange

    #Create a traffic sink and attach it to the node node11
    set sink1 [new Agent/LossMonitor]
    $ns attach-agent $node11 $sink1
    $sink1 clear

    #Create a traffic source
    set src1 [attach-expoo-traffic $node1 $sink1 200 0 0 $BW]
    $srcl set fid_ 200
    $ns color 200 magenta

    #Create a traffic sink and attach it to the node node12
    set sink2 [new Agent/LossMonitor]
    $ns attach-agent $node12 $sink2
    $sink2 clear

    #Create a traffic source
    set scr2 [attach-expoo-traffic $node2 $sink2 1500 0.5 0.2 3M]
    $src2 set fid_ 300
    $ns color 300 blue

    #Create a traffic sink and attach it to the node node13
    set sink3 [new Agent/LossMonitor]
    $ns attach-agent $node13 $sink3
    $sink3 clear

    #Create a traffic source
    set scr3 [attach-expoo-traffic $node3 $sink3 200 0 0 $BW]
    $src3 set fid_ 400
    $ns color 400 cyan

    #Create a traffic sink and attach it to the node node14
    set sink4 [new Agent/LossMonitor]
    $ns attach-agent $node14 $sink4
    $sink4 clear

    #Create a traffic source
    set scr4 [attach-expoo-traffic $node4 $sink4 200 0 0 $BW]
    $src4 set fid_ 500
    $ns color 500 purple

    ###############################################
    # Monitor Queue #
    ###############################################

    #-----------------------------------------------------
    #monitor for lambda1
    #-----------------------------------------------------

    set qfile1 [$ns monitor-queue $LSR5 $LSR6 [open queue1.tr w] 0.1]
    [$ns link $LSR5 $LSR6] queue-sample-timeout;

    proc record1 {} {
    global ns qfilel LSR5 LSR6 lambda1
    set time 0.1
    set now [$ns now]

    $qfile1 instvar barrivals_ parrivals_ pdepartures_
    bdrops_ bdepartures_ pdrops_

    puts $lambda1 "$now [expr ($barrivals_-$bdrops_)/$time*8/1000000/5*100]"
    set barrivals_ 0
    set bdrops_ 0

    $ns at [expr $now+$time] "record1"
    }

    #-------------------------------------
    # Monitor for lambda2
    #-------------------------------------

    set qfile2 [$ns monitor-queue $LSR5 $LSR7 [open queue2.tr w] 0.1]
    [$ns link $LSR5 $LSR7] queue-sample-timeout;

    proc record2 {} {
    global ns qfile1 LSR5 LSR7 lambda2
    set time 0.1
    set now [$ns now]

    $qfile1 instvar barrivals_ parrivals_ pdepartures_
    bdrops_ bdepartures_ pdrops_

    puts $lambdal "$now [expr ($barrivals_-$bdrops_)/$time*8/1000000/5*100]"
    set barrivals_ 0
    set bdrops_ 0

    $ns at [expr $now+$time] "record2"
    }

    #-------------------------------------
    #monitor for lambda3
    #-------------------------------------

    set qfile3 [$ns monitor-queue $LSR5 $LSR8 [open queue3.tr w] 0.1]
    [$ns link $LSR5 $LSR8] queue-sample-timeout;

    proc record3 {} {
    global ns qfilel LSR5 LSR8 lambda3
    set time 0.1
    set now [$ns now]

    $qfile1 instvar barrivals_ parrivals_ pdepartures_
    bdrops_ bdepartures_ pdrops_

    puts $lambda3 "$now [expr ($barrivals_-$bdrops_)/$time*8/1000000/5*100]"
    set barrivals_ 0
    set bdrops_ 0

    $ns at [expr $now+$time] "record3"
    }
    ################################################## ######

    pro nofify-erlsp-setup {node lspid } {
    global src0 src1 src2 src3 src4

    set module [$node get-module "MPLS"]
    set time 0.1
    #set now [$ns now]

    set ns [Simulator instance]

    if{[$node id] ==5} {
    puts " The CR-LSP of lspid $lspid has been just established at [$ns now]"
    switch $lspid {
    1100 { $module bind-flow-erlsp 10 100 $lspid
    $src0 start
    }
    1200 { $module bind-flow-erlsp 11 200 $lspid
    $scr1 start
    }
    1300 { $module bind-flow-erlsp 12 300 $lspid
    $scr2 start
    }
    1400 { $module bind-flow-erlsp 13 400 $lspid
    $scr3 start
    }
    1500 { $module bind-flow-erlsp 14 500 $lspid
    $scr4 start
    }
    default {
    #puts "error"
    #exit 1
    }
    }
    }
    }

    proc notify-erlsp-fail {node status lspid tr} {

    put "nodeid=[$node id]: status=$status lspip=$lspid
    tr=$tr"
    }
    #-------------

    proc constraint-based-routing {lspid sLSR dLSRid bw } {
    set sLSRmodule [$sLSR get-module "MPLS"]
    set er [$sLSRmodule constraint-based-routing $dLSRid $bw]
    if {$er !=-1}{
    puts "--> the result of constraint-based routing for lspid $lspid : Explicit Route=$er"
    $sLSRmodule setup-crlsp $dLSPid $er $lspid $bw 400B 200B 7 3
    } else {
    put "--> the result of constraint-based routing for lspid $lspid : Explicit Route= No path"
    }
    }
    #---------------------------

    $node0 label "s0"
    $node1 label "s1"
    $node2 label "s2"
    $node3 label "s3"
    $node4 label "s4"

    $LSR5 label "GLSR1"
    $LSR9 label "GLSR2"

    $node10 label "D0"
    $node11 label "D1"
    $node12 label "D2"
    $node13 label "D3"
    $node14 label "D4"

    $ns at 0.0 "record"
    $ns at 0.0 "record1"

    $ns at 0.0 "record2"

    $ns at 0.0 "record3"

    $ns at 0.0 "constraint-based-routing 1100 $LSR5 9 2M"
    $ns at 0.2 "constraint-based-routing 1200 $LSR5 9 2M"
    $ns at 0.4 "constraint-based-routing 1300 $LSR5 9 2M"
    $ns at 0.5 "constraint-based-routing 1400 $LSR5 9 2M"
    $ns at 0.6 "constraint-based-routing 1500 $LSR5 9 2M"

    $ns at 3.1 "record"
    $ns at 3.1 "finish"

    $ns run

    -----------------------------------------------------

    Mình chạy file .tcl xong nó báo lỗi như vậy, mình đã fix nhiều lần nhưng vẫn ko dc, nhờ các bạn chỉ giúp lỗi fix. Mình gần tới thời gian nộp luận văn rồi, mà còn demo chưa được. Bạn nào biết xin chỉ hướng giải quyết giúp mình. Thanks !!!

    Code gmpls: http://www.mediafire.com/?bag8wbr28xuf4bm
    Last edited by cena; 22-09-2011, 03:08 AM.

  • #2
    Bạn đã làm về GMPLS rồi có tài liệu gì không share cho mình với. Thanks !
    mail: longtran214@gmail.com

    Comment

    Working...
    X