Ошибка программы NS2: не отображается переменная класса - PullRequest
2 голосов
/ 20 января 2020

Моя программа показывает эту ошибку:

warning: no class variable LanRouter::debug_

        see tcl-object.tcl in tclcl for info about this warning.

--- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) ---
        _o12: no target for slot -1
        _o12 type: Classifier/Hash/Dest
content dump:
classifier _o12
        0 offset
        0 shift
        1073741823 mask
        1 slots
                slot 0: _o139 (Classifier/Port)
        -1 default

Я дал 2 часа на написание этой программы, пожалуйста, помогите мне найти решение, Моя программа приведена ниже :

set ns [new Simulator]

$ns color 1 Blue
$ns color 2 Red

set tracefile1 [open out.tr w]
set winfile [open winfile w]
$ns trace-all $tracefile1

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

proc finish {} {
    global ns tracefile1 namfile
    $ns flush-trace
    close $tracefile1
    close $namfile
    exec nam out.nam &
    exit 0
    }

set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]
$n1 color Red
$n1 shape box

$ns duplex-link $n0 $n2 2Mb 10ms DropTail
$ns duplex-link $n1 $n2 2Mb 10ms DropTail
$ns simplex-link $n2 $n3 0.3Mb 100ms DropTail
$ns simplex-link $n3 $n2 0.3Mb 100ms DropTail
set lan [$ns newLan "$n3 $n4 $n5" 0.5Mb 40ms LL Queue/DropTail MAC/Csma/Cd Channel]

$ns duplex-link-op $n0 $n2 orient right-down
$ns duplex-link-op $n1 $n2 orient right-up
$ns simplex-link-op $n2 $n3 orient right
$ns simplex-link-op $n3 $n2 orient left

$ns queue-limit $n2 $n3 20

set tcp [new Agent/TCP/Newreno]
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink/DelAck]
$ns attach-agent $n4 $sink
$tcp set fid_ 1
$tcp set packet_size_ 552

set ftp [new Application/FTP]
$ftp attach-agent $tcp

set udp [new Agent/UDP]
$ns attach-agent $n1 $udp
set null [new Agent/Null]
$ns attach-agent $n5 $null
$ns connect $udp $null
$udp set fid_ 2

set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr  set type_ CBR
$cbr set packet_size_ 1000
$cbr set rate_ 0.01Mb
$cbr set random_ false

$ns at 0.1 "$cbr start"
$ns at 1.0 "$ftp start"
$ns at 124.0 "$ftp stop"
$ns at 125.0 "$cbr stop"
proc plotWindow {tcpSource file} {
    global ns
    set time 0.1
    set now [$ns now]
    set cwnd [$tcpSource set cwnd_]
    puts $file "$now $cwnd"
     $ns at [expr $now + $time] "plotWindow $tcpSource $file"
    }

$ns at 0.1 "plotWindow $tcp $winfile"
$ns at 125.0 "finish"
$ns run

Я перепробовал все, что могло бы решить проблему, поэтому, наконец, я должен прийти сюда, чтобы найти решение, поэтому, если у кого-то есть решение, пожалуйста! Помоги мне. Спасибо тебе!

1 Ответ

1 голос
/ 21 января 2020

--- Classfier :: no-slot {} обработчик по умолчанию

Ваш файл близок к копии https://github.com/dnlove/ammac-ns2/blob/master/duy/tcl/csma.tcl: этот оригинал " amma c Файл Csma.Cd "работает нормально.

Ваш файл: в разделе" TCP-соединение "отсутствует строка: $ns connect $tcp $sink

set tcp [new Agent/TCP/Newreno]
$ns attach-agent $n0 $tcp
set sink [new Agent/TCPSink/DelAck]
$ns attach-agent $n4 $sink
$ns connect $tcp $sink      ;# added .........
$tcp set fid_ 1
$tcp set packet_size_ 552

.... Тогда ваш файл работает нормально.

Если вы хотите избежать предупреждения: no class variable LanRouter::debug_, добавьте это в пустую строку 2: LanRouter set debug_ 0 (Предупреждение не является ошибкой, это просто текстовое сообщение.)

...