ns: _o40 malicious: (_o40 cmd line 1) invoked from within "_o40 cmd malicious" invoked from within "catch "$self cmd $args" ret"

693 Views Asked by At

I am simulating Wireless Sensor Network Using NS2.35 and I get an error num_nodes is set 2 INITIALIZE THE LIST xListHead Starting Simulation... ns: _o40 malicious: (_o40 cmd line 1) invoked from within "_o40 cmd malicious" 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 "_o40" line 2) (SplitObject unknown line 2) invoked from within "o40 malicious" when i add $ns at 3.2 "[$node($id) set ragent]malicious"get this error. enter code here set val(chan) Channel/WirelessChannel ;#Channel Type set val(prop) Propagation/TwoRayGround ;# radio-propagation set val(netif) Phy/WirelessPhy ; set val(mac) Mac/802_11 ;# MAC type set val(ifq) Queue/DropTail/PriQueue ;# interface queue type set val(ll) LL ;# link layer type set val(ant) Antenna/OmniAntenna ;# antenna model set val(ifqlen) 50 ;# max packet in ifq set val(nn) 2 ;# number ofmobilenodes set val(rp) AODV ;# routing protocol set val(x) 500 set val(y) 500 set ns_ [new Simulator] set tracefd [open malicious.tr w] $ns_ trace-all $tracefd

set namtrace [open malicious.nam w]
$ns_ namtrace-all-wireless $namtrace $val(x) $val(y)

set topo       [new Topography]

$topo load_flatgrid $val(x) $val(y)
create-god $val(nn)
set chan_1_ [new $val(chan)]
set chan_2_ [new $val(chan)]
$ns_ node-config -adhocRouting $val(rp) \
        -llType $val(ll) \
        -macType $val(mac) \
        -ifqType $val(ifq) \
        -ifqLen $val(ifqlen) \
        -antType $val(ant) \
        -propType $val(prop) \
        -phyType $val(netif) \
        -topoInstance $topo \
        -agentTrace ON \
        -routerTrace ON \
        -macTrace ON \
        -movementTrace OFF \
        -channel $chan_1_ 

set node_(0) [$ns_ node]
set node_(1) [$ns_ node]
$ns_ at 1.0 "[$node_(1) set ragent_] malicious"
$node_(0) random-motion 0
$node_(1) random-motion 0

$node_(0) set X_ 5.0
$node_(0) set Y_ 2.0
$node_(0) set Z_ 0.0

$node_(1) set X_ 8.0
$node_(1) set Y_ 5.0
$node_(1) set Z_ 0.0

#
# Now produce some simple node movements
# Node_(1) starts to move towards node_(0)
#
$ns_ at 3.0 "$node_(1) setdest 50.0 40.0 25.0"
$ns_ at 3.0 "$node_(0) setdest 48.0 38.0 5.0"

# Node_(1) then starts to move away from node_(0)
$ns_ at 20.0 "$node_(1) setdest 490.0 480.0 30.0" 

# Setup traffic flow between nodes
# TCP connections between node_(0) and node_(1)

set tcp [new Agent/TCP]
$tcp set class_ 2
set sink [new Agent/TCPSink]
$ns_ attach-agent $node_(0) $tcp
$ns_ attach-agent $node_(1) $sink
$ns_ connect $tcp $sink
set ftp [new Application/FTP]
$ftp attach-agent $tcp
$ns_ at 3.0 "$ftp start" 

#
# Tell nodes when the simulation ends
#
for {set i 0} {$i < $val(nn) } {incr i} {
    $ns_ at 30.0 "$node_($i) reset";
}
$ns_ at 30.0 "stop"
$ns_ at 30.01 "puts \"NS EXITING...\" ; $ns_ halt"
proc stop {} {
    global ns_ tracefd nametrace
    $ns_ flush-trace
    close $tracefd
    exec nam malicious.nam &
    exit 0
}

puts "Starting Simulation..."
$ns_ run
1

There are 1 best solutions below

0
Knud Larsen On

Your above simulation ...

set val(chan) Channel/WirelessChannel ;#Channel Type 
set val(prop) Propagation/TwoRayGround ;# radio-propagation 
set val(netif) Phy/WirelessPhy ; 
set val(mac) Mac/802_11 ;# MAC type 
set val(ifq) Queue/DropTail/PriQueue ;# interface queue type 
set val(ll) LL ;# link layer type 
set val(ant) Antenna/OmniAntenna ;# antenna model 
set val(ifqlen) 50 ;# max packet in ifq 
set val(nn) 2 ;# number ofmobilenodes 
set val(rp) AODV ;# routing protocol 
set val(x) 500 
set val(y) 500 

set ns_ [new Simulator] 
set tracefd [open malicious.tr w] 
$ns_ trace-all $tracefd
.
.
.
$ns_ at 1.0 "[$node_(1) set ragent_] malicious"

... is very close to a copy of the classic "malicious.tcl" by Xuan Chen ( See aodv-malicious-examples-04.17.tar.gz https://drive.google.com/file/d/0B7S255p3kFXNRVBTU2JOUnpKclk/view?usp=sharing )

Xuan Chen, USC/ISI, July 21, 2000

# $ns_ at 0.0 "[$node_(1) set ragent_] malicious"
$ns_ at 0.0 "[$node_(1) set ragent_] hacker"

The error ...

ns: _o40 malicious: (_o40 cmd line 1)

... can happen in two occasions : 1. No "aodv-malicious" was added to your ns-2.35 . 2. The wrong definition is used : In the most used patch, aodv-malicious_ns235.patch malicious is set as hacker (in aodv.cc). Which means the setting in the simulation script must be ...

$ns_ at 1.0 "[$node_(1) set ragent_] hacker"

( Other reason for the error : You could simply be using a wrong copy of the executable 'ns' for your command $ ns malicious.tcl ).


Testing your file: $ ns235-malicious K2-malicious.tcl → The files malicious.nam 25.3kB, malicious.tr 15kB are created. NAM : An OK animation. "malicious.tr" : Packets are arriving → → $ awk -f tess-Packets.awk malicious.tr https://drive.google.com/file/d/1t9aU5p0m5RxGEaLaL04pjKWHTj59fG4P/view?usp=sharing → Top 25 awk scripts.


aodv-malicious_ns235.patch https://drive.google.com/file/d/0B7S255p3kFXNU0VNbUtIWlJpRk0/view?usp=sharing

All ~300 ns2 patches https://drive.google.com/drive/folders/0B7S255p3kFXNZ2lWZDBRSW40Q00?usp=sharing

All ~2500 simulations https://drive.google.com/drive/folders/0B7S255p3kFXNSmRYb2lGcDRUdWs?usp=sharing