I wrote a new wireless route protocol and add it to ns2-2.30. Edit many
files according to AODV. 
      I also wrote a scenery script. it runs successful when i use AODV. but
when I change "AODV" to the name of my new protocol, it failed, the
information is followed:
      INITIALIZE THE LIST xListHead

    (_o17 cmd line 1)
    invoked from within
"_o17 cmd port-dmux _o26"
    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 "_o17" line 2)
    (SplitObject unknown line 2)
    invoked from within
"$agent port-dmux $dmux_"
    (procedure "_o14" line 11)
    (Node/MobileNode add-target-rtagent line 11)
    invoked from within
"$self add-target-rtagent $agent $port"
    (procedure "_o14" line 28)
    (Node/MobileNode add-target line 28)
    invoked from within
"$self add-target $agent $port"
    (procedure "_o14" line 15)
    (Node attach line 15)
    invoked from within
"$node attach $ragent [Node set rtagent_port_]"
    (procedure "_o3" line 78)
    (Simulator create-wireless-node line 78)
    invoked from within
"_o3 create-wireless-node"
    ("eval" body line 1)
    invoked from within
"eval $self create-wireless-node $args"
    (procedure "_o3" line 23)
    (Simulator node line 23)
    invoked from within
"$ns_ node"
    ("for" body line 2)
    invoked from within
"for {set i 0} {$i < $val(nn) } {incr i} {
                set node_($i) [$ns_ node]
                $node_($i) random-motion 0;
        }"
    (file "scene.tcl" line 64) 


*******************************************************
        And my script is :
   

# ======================================================================
# Define options
# ======================================================================
set val(chan)       Channel/WirelessChannel
set val(prop)       Propagation/TwoRayGround
set val(netif)      Phy/WirelessPhy
set val(mac)        Mac/802_11
set val(ifq)        Queue/DropTail/PriQueue
set val(ll)         LL
set val(ant)        Antenna/OmniAntenna

set val(x)          1200   ;# X dimension of the topography
set val(y)          1200   ;# Y dimension of the topography
set val(ifqlen)         50            ;# max packet in ifq
set val(seed)       0.0
set val(rp)         AODV
set val(nn)         50             ;# how many nodes are simulated
set val(cp)         "./cbr-50n-30c-1r-1s"
set val(sc)               "./scene-50n-0p-2m-400t-1200-1200"
set val(stop)     400

# ======================================================================
# Main Program
# ======================================================================

# Initialize Global Variables
set ns_ [new Simulator]
set tracefd [open aodv-scene.tr w]
$ns_ trace-all $tracefd

# set up topography
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)

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

#
# Create God
#
set god_ [create-god $val(nn)]

# Create the specified number of mobilenodes [$val(nn)] and "attach" them
# to the channel. 
# configure node
#set channel [new Channel/WirelessChannel]
#$channel set errorProbability_ 0.0

  $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) \
                         -channelType $val(chan) \
                         -topoInstance $topo \
                         -agentTrace ON \
                         -routerTrace ON\
                         -macTrace OFF \
                         -movementTrace OFF                     
                         
        for {set i 0} {$i < $val(nn) } {incr i} {
                set node_($i) [$ns_ node]       
                $node_($i) random-motion 0;     
        }

#
# Define node movement model
#
puts "Loading connection pattern..."
source $val(cp)

#
# Define traffic model
#
puts "Loading scenario file..."
source $val(sc)

# Define node initial position in nam

for {set i 0} {$i < $val(nn)} {incr i} {
    # 20 defines the node size in nam, must adjust it according to your
scenario
    # The function must be called after mobility model is defined

    $ns_ initial_node_pos $node_($i) 20
}

# Tell nodes when the simulation ends
for {set i 0} {$i < $val(nn) } {incr i} {
    $ns_ at $val(stop).0 "$node_($i) reset";
}

$ns_ at $val(stop).0 "stop"
$ns_ at $val(stop).01 "puts \"NS EXITING...\" ; $ns_ halt"

proc stop {} {
    global ns_ tracefd namtrace
    $ns_ flush-trace
    close $tracefd
    close $namtrace
    exit 0 
}

puts "Starting Simulation..."
$ns_ run

    

-- 
View this message in context: 
http://www.nabble.com/Help%3A-Problem-when-I-add-a-new-protocol-to-ns2-2.30-tf3537056.html#a9872996
Sent from the ns-users mailing list archive at Nabble.com.

Reply via email to