首页 > 解决方案 > 当将节点的随机运动设置为 0 时会出现错误:“调用类 $cls 时出错:$args”$...”

问题描述

这是一个有线网络,row*col数量为nodes. 由于它是静态的,我试图将其设置random-motion0。但是当我运行时,ns wired.tcl 3 3 5 0.01我得到以下错误。这里的cmd参数是

ns<filename> <no of rows> <no of col> <links> <cbr_interval>

      (_o10 cmd line 1)
        invoked from within
    "_o10 cmd random-motion 0"
        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 "_o10" line 2)
        (SplitObject unknown line 2)
        invoked from within
    "$node_($i) random-motion 0"
        ("for" body line 3)
        invoked from within
    "for {set i 0} {$i < [expr $num_row*$num_col]} {incr i} {
        set node_($i) [$ns node]
        $node_($i) random-motion 0
    }"
        (file "rough.tcl" line 34)

我正在跑步ubuntu-18.04ns-allinone-2.35这是wired.tcl文件

    set ns [new Simulator]
    $ns multicast
    set start_time 0.5
    set cbr_interval [lindex $argv 3]
    set num_row [lindex $argv 0]
    set num_col [lindex $argv 1]
    set x_dim 100
    set y_dim 100
    set grid 0

    set k 6
    set num_random_flow [lindex $argv 2]

    set traceFile [open wired.tr w]
    $ns trace-all $traceFile

    set nf [open out.nam w]
    $ns namtrace-all $nf

    #create-god [expr $num_row * $num_col ]

    proc  finish {} \
    {
        puts "finishing simulation"
        global ns nf traceFile
        $ns flush-trace
        close $traceFile
        close $nf
        #exec nam out.nam &
        exit 0
    }

    puts "start node creation"
    for {set i 0} {$i < [expr $num_row*$num_col]} {incr i} {
        set node_($i) [$ns node]
        $node_($i) random-motion 0; #problem
    }


    $ns at 5.0 "finish"
    puts "starting simulation"
    $ns run

标签: ns2

解决方案


推荐阅读