Error In Vertical Handover Code

Hey,
I got some error when i execute the following code :
#check input parameters
Code:
if {$argc != 0} {

    puts ""

    puts "Wrong Number of Arguments! No arguments in this topology"

    puts ""

    exit (1)

}



global ns



#set debug output for components

Agent/ND set debug_ 1

Agent/MIH set debug_ 1

Agent/MIHUser/IFMNGMT/MIPV6/Handover/Handover1 set debug_ 1

Agent/MIHUser/IFMNGMT/MIPV6 set debug_ 1

Agent/MIHUser/IFMNGMT set debug_ 1

Mac/802_11 set debug_ 0

Mac/802_16 set debug_ 0



#define DEBUG parameters

set quiet 0



#defines ND attributes to fit the example

Agent/ND set maxRtrAdvInterval_ 1.0

Agent/ND set minRtrAdvInterval_ 0.5

Agent/ND set minDelayBetweenRA_ 0.5



#Handover

Agent/MIHUser/IFMNGMT/MIPV6/Handover/Handover1 set case_ 3



#defines ND: Neihbor discovery attributes to fit the example

Agent/ND set maxRtrAdvInterval_ 1.0

Agent/ND set minRtrAdvInterval_ 0.5

Agent/ND set minDelayBetweenRA_ 0.5



#defines function for flushing and closing files

proc finish {} {

    global ns f namtrace

    $ns flush-trace

    close $f

   
exec nam outtest.nam &
close $namtrace

    puts " Simulation ended."

    exit 0

}



# set global variables

set output_dir .



#create the simulator

set ns [new Simulator]

$ns use-newtrace



set opt(x)        2000               ;# X dimension of the topography

set opt(y)        2000               ;# Y dimension of the topography



#create the topography

set topo [new Topography]

$topo load_flatgrid $opt(x) $opt(y)





# create God

create-god 20  

puts ""



#Simulation process is written to the trace file

set f [open out.tr w]

$ns trace-all $f

set namfile [open outtest.nam w]

#$ns namtrace-all-wireless $namfile $opt(x) $opt(y)   

$ns namtrace-all-wireless $namfile 2000 2000



# set up for hierarchical routing (needed for routing over a basestation)

$ns node-config -addressType hierarchical

AddrParams set domain_num_  7                     ;# domain number

AddrParams set cluster_num_ {1 1 1 1 1 1 1}          ;# cluster number for each domain

AddrParams set nodes_num_   {6 6 6 6 6 6 6}          ;# number of nodes for each cluster      




# parameter for wireless nodes

set opt(chan)           Channel/WirelessChannel    ;# channel type for 802.11

set opt(prop)           Propagation/TwoRayGround   ;# radio-propagation model 802.11

set opt(netif)          Phy/WirelessPhy            ;# network interface type 802.11

set opt(mac)            Mac/802_11                 ;# MAC type 802.11

set opt(ifq)            Queue/DropTail/PriQueue    ;# interface queue type 802.11

set opt(ll)             LL                         ;# link layer type 802.11

set opt(ant)            Antenna/OmniAntenna        ;# antenna model 802.11

set opt(ifqlen)         50                         ;# max packet in ifq 802.11

set opt(adhocRouting)   DSDV                       ;# routing protocol 802.11

set opt(umtsRouting)    ""                         ;# routing for UMTS (to reset node config)

set opt(channel)        [new $opt(chan)]           ;# channel to be shared by all wireless nodes





#Rate at which the nodes start moving

set moveStart 10

set moveStop 130

#Speed of the mobile nodes (m/sec)

set moveSpeed 1



#origin of the MN

set X_src 40.0

set Y_src 100.0

set X_dst 160.0

set Y_dst 100.0





# creation of the Mobile Node (MutiFaceNodes). It MUST be done before the 802.11

$ns node-config  -multiIf ON                            ;#to create MultiFaceNode 

set multiFaceNode [$ns node 4.0.0] 

$ns node-config  -multiIf OFF                           ;#reset attribute

$ns at 0.05 "$multiFaceNode label "MN 5.0.0""

if {$quiet == 0} {

	puts "multiFaceNode(MN) has been created"

        puts ""

}



# creation of the Correspondant Node

set host0 [$ns node 1.0.1] ;# node id is 5

$ns at 0.05 "$host0 label "CN 1.0.1""

if {$quiet == 0} {

	puts "host(CN) has been created"

        puts ""

}



$ns set hsdschEnabled_ 1addr

$ns set hsdsch_rlc_set_ 0

$ns set hsdsch_rlc_nif_ 0



# configure RNC node

puts "________RNC Configuration________"

$ns node-config -UmtsNodeType rnc 

set rnc [$ns create-Umtsnode 0.0.0] ;

$ns at 0.05 "$rnc label "RNC 0.0.0""

if {$quiet == 0} {

	puts "RNC: tcl=$rnc; id=[$rnc id]; addr=[$rnc node-addr]"

	puts ""

}



# configure UMTS base station

puts "________UMTS Base Station Configuration________"

$ns node-config -UmtsNodeType bs \

		-downlinkBW 384kbs \

		-downlinkTTI 10ms \

		-uplinkBW 384kbs \

		-uplinkTTI 10ms \

	        -hs_downlinkTTI 2ms \

		-hs_downlinkBW 384kbs 



set bsUMTS [$ns create-Umtsnode 0.0.1] 

$ns at 0.05 "$bsUMTS label "UMTS_BS 0.0.0""

if {$quiet == 0} {

	puts "UMTS_Base_Station: tcl=$bsUMTS; id=[$bsUMTS id]; addr=[$bsUMTS node-addr]"

        puts ""

}



puts "----------------------------------------------"

puts ""

# connect RNC and base station

puts "Connecting RNC and Base Station..."

$ns setup-Iub $bsUMTS $rnc 622Mbit 622Mbit 15ms 15ms DummyDropTail 2000 color red



$ns node-config -UmtsNodeType ue \

		-baseStation $bsUMTS \

		-radioNetworkController $rnc

if {$quiet == 0} {

	puts "....Connecting successfully"

	puts ""

}

puts "----------------------------------------------"

puts ""

# creation of the wireless interface UMTS

set iface0 [$ns create-Umtsnode 0.0.2]

if {$quiet == 0} {

puts "iface0: tcl=$iface0; id=[$iface0 id]; addr=[$iface0 node-addr]"

puts "________iface0 created"

}



#define UMTS color 

$rnc color red

$bsUMTS color red


#define coverage area for 802.11 stations: 20m coverage, Freq: 2.4Ghz

Phy/WirelessPhy set Pt_ 0.025

Phy/WirelessPhy set freq_ 2412e+6

Phy/WirelessPhy set RXThresh_ 6.12277e-09

Phy/WirelessPhy set CSThresh_ [expr 0.9*[Phy/WirelessPhy set RXThresh_]]



# configure rate for 802.11

Mac/802_11 set basicRate_ 11Mb

Mac/802_11 set dataRate_ 11Mb

Mac/802_11 set bandwidth_ 11Mb



# configure Access Points

$ns node-config  -adhocRouting $opt(adhocRouting) \

                 -llType $opt(ll) \

                 -macType $opt(mac) \

                 -channel $opt(channel) \

                 -ifqType $opt(ifq) \

                 -ifqLen $opt(ifqlen) \

                 -antType $opt(ant) \

                 -propType $opt(prop)    \

                 -phyType $opt(netif) \

                 -topoInstance $topo \

                 -wiredRouting ON \

                 -agentTrace ON \

                 -routerTrace OFF \

                 -macTrace ON  \

                 -movementTrace OFF



# configure Base station 802.11

set bstation802_11 [$ns node 3.0.0] ;

$ns at 0.05 "$bstation802_11 label "WLAN_BS 3.0.0""

if {$quiet == 0} {

	puts "WLAN Base Station_id =$bstation802_11"

}

$bstation802_11 set X_ 680.0

$bstation802_11 set Y_ 1000.0

$bstation802_11 set Z_ 0.0



# we need to set the BSS for the base station

set bstationMac [$bstation802_11 getMac 0]

set AP_ADDR_0 [$bstationMac id]

if {$quiet == 0} {

	puts "Basic Service Set_id for WAN_bstation =$AP_ADDR_0"

}

$bstationMac bss_id $AP_ADDR_0

$bstationMac enable-beacon

$bstationMac set-channel 1





# creation of the wireless interface 802.11

$ns node-config -wiredRouting OFF \

                -macTrace ON                

set iface1 [$ns node 3.0.1]                                        ;

$iface1 random-motion 0                                       ;# disable random motion

$iface1 base-station [AddrParams addr2id [$bstation802_11 node-addr]] ;#attach mn to basestation

$iface1 set X_ 480.0   ;# $iface1 set X_ $X_src

$iface1 set Y_ 1000.0  ;# $iface1 set Y_ $Y_src

$iface1 set Z_ 0.0



[$iface1 getMac 0] set-channel 1

if {$quiet == 0} {

puts "iface1: tcl=$iface1; id=[$iface1 id]; addr=[$iface1 node-addr]"           

puts "________iface1 created"

}

#define WLAN color 

$bstation802_11 color blue


#note: we put 16 on a different channel to avoid dealing with interferences

set opt(mac)            Mac/802_16

set opt(netif)          Phy/WirelessPhy/OFDM



#define coverage area for 802.16 stations:

Phy/WirelessPhy set Pt_ 0.025

Phy/WirelessPhy set RXThresh_ 2.025e-12

Phy/WirelessPhy set CSThresh_ [expr 0.9*[Phy/WirelessPhy set RXThresh_]]





$ns node-config  -adhocRouting $opt(adhocRouting) \

                 -llType $opt(ll) \

                 -macType $opt(mac) \

                 -channel $opt(channel) \

                 -ifqType $opt(ifq) \

                 -ifqLen $opt(ifqlen) \

                 -antType $opt(ant) \

                 -propType $opt(prop)    \

                 -phyType $opt(netif) \

                 -topoInstance $topo \

                 -wiredRouting ON \

                 -agentTrace ON \

                 -routerTrace OFF \

                 -macTrace ON  \

                 -movementTrace OFF



# configure Base station 802.16

set bstation802_16 [$ns node 4.0.0] ;

$ns at 0.05 "$bstation802_16 label "WIMAX_BS 4.0.0""

if {$quiet == 0} {

	puts "WIMAX Base Station_id =$bstation802_16"

}

$bstation802_16 random-motion 0

$bstation802_16 set X_ 1000

$bstation802_16 set Y_ 1000

$bstation802_16 set Z_ 0.0

puts "bstation802_16: tcl=$bstation802_16; id=[$bstation802_16 id]; addr=[$bstation802_16 node-addr]"



set clas [new SDUClassifier/Dest]

[$bstation802_16 set mac_(0)] add-classifier $clas



set bs_sched [new WimaxScheduler/BS]

[$bstation802_16 set mac_(0)] set-scheduler $bs_sched

[$bstation802_16 set mac_(0)] set-channel 1


# creation of the wireless interface 802.16

$ns node-config -wiredRouting OFF \

                -macTrace ON                

set iface2 [$ns node 4.0.1]                                        ;# node id is 12.   

$iface2 random-motion 0                                       ;# disable random motion

$iface2 base-station [AddrParams addr2id [$bstation802_16 node-addr]] ;#attach mn to basestation

$iface2 set X_ 480.0   ;# $iface1 set X_ $X_src

$iface2 set Y_ 1000.0  ;# $iface1 set Y_ $Y_src

$iface2 set Z_ 0.0

set clas [new SDUClassifier/Dest]

[$iface2 set mac_(0)] add-classifier $clas

set ss_sched [new WimaxScheduler/SS]

[$iface2 set mac_(0)] set-scheduler $ss_sched

[$iface2 set mac_(0)] set-channel 1

if {$quiet == 0} {

puts "iface2: tcl=$iface2; id=[$iface2 id]; addr=[$iface2 node-addr]"  

puts "________iface2 created"         

}



#define WIMAX color 

$bstation802_16 color green





# add interfaces to MultiFaceNode

$multiFaceNode add-interface-node $iface0

$multiFaceNode add-interface-node $iface1

$multiFaceNode add-interface-node $iface2



# define node movement. We start from outside the coverage, cross it and leave.

$ns at 20 "$iface0 setdest 1600.0 1000.0 3.0"

# define node movement. We start from outside the coverage, cross it and leave.

$ns at 20 "$iface1 setdest 1600.0 1000.0 3.0"

# define node movement. We start from outside the coverage, cross it and leave.

$ns at 20 "$iface2 setdest 1600.0 1000.0 3.0"

puts "----------------------------------------------"





#creation of backbones

set router0 [$ns node 1.0.0]

$ns at 0.05 "$router0 label "router0 1.0.0""

if {$quiet == 0} {

puts "router0: tcl=$router0; id=[$router0 id]; addr=[$router0 node-addr]"  

puts "________router0 created"         

}



set router1 [$ns node 2.0.0]

$ns at 0.05 "$router0 label "router1 2.0.0""

if {$quiet == 0} {

puts "router0: tcl=$router1; id=[$router1 id]; addr=[$router1 node-addr]"  

puts "________router1 created"         

puts ""

}






# topology Links..."

$ns duplex-link $rnc $router1 622Mbit 0.4ms DropTail 1000 color red

$ns trace-queue $rnc $router1 $f

$ns duplex-link $router1 $router0 100MBit 5ms DropTail 1000 

$ns trace-queue $router1 $router0 $f

$ns duplex-link $router0 $host0 100MBit 5ms DropTail 1000

$ns trace-queue $router0 $host0 $f

$rnc add-gateway $router1



# add link WLAN base station to backbone

$ns duplex-link $bstation802_11 $router1 100MBit 15ms DropTail 1000 color blue

$ns trace-queue $router1 $bstation802_11 $f



# add link WIMAX base station to backbone

$ns duplex-link $bstation802_16 $router1 100MBit 15ms DropTail 1000 color green

$ns trace-queue $router1 $bstation802_16 $f

if {$quiet == 0} {

	puts "....Connecting successfully"

	puts ""

}



#neighbor discovery module

# UMTS (Note: The ND module is on the rnc node NOT in the base station)

set nd_bsUMTS [$rnc install-nd]

$nd_bsUMTS set-router TRUE

$nd_bsUMTS router-lifetime 1800

$nd_bsUMTS enable-broadcast FALSE

$nd_bsUMTS add-ra-target 0.0.2 ; # adding ra-target (Router Advertisement)

				 # in UMTS there is no notion of broadcast.

				 # We fake it by sending unicast to a list of nodes

set nd_ue [$iface0 install-nd]



# WLAN

set nd_bs [$bstation802_11 install-nd]

$nd_bs set-router TRUE

$nd_bs router-lifetime 1800

set nd_mn [$iface1 install-nd]



# WIMAX

set nd_bs2 [$bstation802_16 install-nd]

$nd_bs2 set-router TRUE

$nd_bs2 router-lifetime 1800

set nd_mn2 [$iface2 install-nd]



# router1

set nd_router [$router1 install-nd]

$nd_router set-router TRUE

$nd_router router-lifetime 1800



# router0

set nd_router_0 [$router0 install-nd]

$nd_router_0 set-router TRUE

$nd_router_0 router-lifetime 1800

if {$quiet == 0} {

	puts "....Configuration successfully"

	puts ""

}

#mih module
# install interface manager into the Mobile Node (multi-interface node)

Agent/MIHUser/IFMNGMT/MIPV6/Handover/Handover1 set case_ 2

set handover [new Agent/MIHUser/IFMNGMT/MIPV6/Handover/Handover1]

$multiFaceNode install-ifmanager $handover



# adding handover module to the UMTS iface0

$nd_ue set-ifmanager $handover



# adding handover module to the WLAN iface1

$nd_mn set-ifmanager $handover

$handover nd_mac $nd_mn [$iface1 set mac_(0)] ;#to know how to send RS messages (Ready to sent)



# adding handover module to the WIMAX iface2

$nd_mn2 set-ifmanager $handover 

$handover nd_mac $nd_mn2 [$iface2 set mac_(0)] ;#to know how to send RS messages (Ready to sent)



# install interface manager into the Correspondant Node (host0)

set ifmgmt_cn [$host0 install-default-ifmanager]



# install MIH in multi-interface node

set mih [$multiFaceNode install-mih]



$handover connect-mih $mih ;#create connection between MIH and iface management





# install MIH on AP/BS

set mih_bs [$bstation802_11 install-mih]

set tmp_bs [$bstation802_11 set mac_(0)]

$tmp_bs mih $mih_bs

$mih_bs add-mac $tmp_bs



set mih_bs [$bstation802_16 install-mih]

set tmp_bs [$bstation802_16 set mac_(0)]

$tmp_bs mih $mih_bs

$mih_bs add-mac $tmp_bs

#traffic tcp between cn and multi interface

#Create a UDP agent

set udp_ [new Agent/UDP]

$udp_ set packetSize_ 1500

if {$quiet == 0} {

	puts "...UDP on node : $udp_"

}

# Create a CBR traffic source and attach it to udp

set cbr_ [new Application/Traffic/CBR]

$cbr_ set packetSize_ 500

$cbr_ set interval_ 0.2

$cbr_ attach-agent $udp_

if {$quiet == 0} {

	puts "...CBR created : $cbr_"

}

# Create the Null agent to sink traffic

set udp_test_sink [new Agent/Null]

$ns attach-agent $iface0 $udp_test_sink

$ns connect $udp_ $udp_test_sink

if {$quiet == 0} {

	puts "...TEST_SINK created : $udp_test_sink"

}

#host0 is transmitter    

$ns attach-agent $host0 $udp_

if {$quiet == 0} {

        puts ""

	puts "...Attachement Successfully"

}	

#Multiface node is receiver

$multiFaceNode attach-agent $udp_test_sink $iface0 ;#4

$handover add-flow $udp_test_sink $udp_ $iface0 1

if {$quiet == 0} {

	puts "...MN added flow"

}





# do registration in UMTS. This will create the MACs in UE and base stations

$ns node-config -llType UMTS/RLC/AM \

	-downlinkBW 384kbs \

	-uplinkBW 384kbs \

	-downlinkTTI 20ms \

	-uplinkTTI 20ms \

	-hs_downlinkTTI 2ms \

	-hs_downlinkBW 384kbs



if {$quiet == 0} {

	puts "Configuration UMTS Node..."

}



set dch0 [$ns create-dch $iface0 $udp_test_sink]

$ns attach-dch $iface0 $handover $dch0

$ns attach-dch $iface0 $nd_ue $dch0

if {$quiet == 0} {

	puts "...Attachement Successfully"

}



# Now we can register the MIH module with all the MACs

set tmp2 [$iface0 set mac_(2)] ;#in UMTS and using DCH the MAC to use is 2 (0 and 1 are for RACH and FACH)

$tmp2 mih $mih

$mih add-mac $tmp2	       ;#inform the MIH about the local MAC

set tmp2 [$iface1 set mac_(0)] ;#in 802.11 one interface is created

$tmp2 mih $mih

$mih add-mac $tmp2	       ;#inform the MIH about the local MAC

set tmp2 [$iface2 set mac_(0)] ;#in 802.16 one interface is created

$tmp2 mih $mih

$mih add-mac $tmp2             ;#inform the MIH about the local MAC

if {$quiet == 0} {

	puts "....Configuration finished successfully"

	puts ""

}



#Start the Application

$ns at 0.1 "$cbr_ start"

$ns at 4.0 "$cbr_ stop"

$ns at 5.0 "finish"

 

if {$quiet == 0} { 

puts " Simulation is running ... please wait ..." 

}
$ns run

I got this error:
can't read "Node_(10)": no such element in array
while executing
"return $Node_($id)"
(procedure "_o3" line 3)
(Simulator get-node-by-id line 3)
invoked from within
"$self get-node-by-id [lindex $L 1]"
(procedure "_o3" line 15)
(Simulator compute-hier-routes line 15)
invoked from within
"$self compute-hier-routes "
invoked from within
"if [Simulator hier-addr?] {
$self compute-hier-routes
} else {
$self compute-flat-routes
}"
(procedure "_o3" line 2)
(Simulator compute-routes line 2)
invoked from within
"[Simulator instance] compute-routes"
(procedure "Agent/rtProto/Static" line 2)
(Agent/rtProto/Static init-all line 2)
invoked from within
"Agent/rtProto/Static init-all"
invoked from within
"if [info exists rtprotos_] {
foreach proto [array names rtprotos_] {
eval Agent/rtProto/$proto init-all $rtprotos_($proto)
}
} else {
Agent/rtProto/St..."
(procedure "_o474" line 3)
(RouteLogic configure line 3)
invoked from within
"[$self get-routelogic] configure"
(procedure "_o3" line 5)
(Simulator run line 5)
invoked from within
"$ns run"
(file "test1.tcl" line 539)


How can I fix it???
Thanks in advance


Similar Content



Simulation Of Handoff B/w Umts And 802.11

Hello,I want to simulate seamless handoff b/w umts and 802.11,simulation works fine for one umts and one 802.11 base station but i want to simulate the senario of 3 802.11 base stations and one umts base station,when i add two 802.11 base stations,i got following error..
Please help me.

Simulation is running ... please wait ...
can't read "Node_(8)": no such element in array
while executing
"return $Node_($id)"
(procedure "_o3" line 3)
(Simulator get-node-by-id line 3)
invoked from within
"$self get-node-by-id [lindex $L 1]"
(procedure "_o3" line 15)
(Simulator compute-hier-routes line 15)
invoked from within
"$self compute-hier-routes "
invoked from within
"if [Simulator hier-addr?] {
$self compute-hier-routes
} else {
$self compute-flat-routes
}"
(procedure "_o3" line 2)
(Simulator compute-routes line 2)
invoked from within
"[Simulator instance] compute-routes"
(procedure "Agent/rtProto/Static" line 2)
(Agent/rtProto/Static init-all line 2)
invoked from within
"Agent/rtProto/Static init-all"
invoked from within
"if [info exists rtprotos_] {
foreach proto [array names rtprotos_] {
eval Agent/rtProto/$proto init-all $rtprotos_($proto)
}
} else {
Agent/rtProto/St..."
(procedure "_o343" line 3)
(RouteLogic configure line 3)
invoked from within
"[$self get-routelogic] configure"
(procedure "_o3" line 5)
(Simulator run line 5)
invoked from within
"$ns run"
(file "new.tcl" line 329)


CODE is...



#set debug attributes
Agent/ND set debug_ 1
Agent/MIH set debug_ 1
Agent/MIHUser/IFMNGMT/MIPV6/Handover/Simple set debug_ 1

# set global variables
set output_dir .

#create the simulator
set ns [new Simulator]
#$ns use-newtrace

#open file for trace
set f [open out1.tr w]
$ns trace-all $f

# set up for hierarchical routing (needed for routing over a basestation)
$ns node-config -addressType hierarchical
AddrParams set domain_num_ 6 ;# domain number
AddrParams set cluster_num_ {1 1 1 1 1 1} ;# cluster number for each domain
AddrParams set nodes_num_ {3 1 1 1 2 2} ;# number of nodes for each cluster

# configure UMTS.
# Note: The UMTS configuration MUST be done first otherwise it does not work
# furthermore, the node creation in UMTS MUST be as follow
# rnc, base station, and UE (User Equipment)
$ns set hsdschEnabled_ 1addr
$ns set hsdsch_rlc_set_ 0
$ns set hsdsch_rlc_nif_ 0

# configure RNC node
$ns node-config -UmtsNodeType rnc
set rnc [$ns create-Umtsnode 0.0.0] ;# node id is 0.
puts "rnc: tcl=$rnc; id=[$rnc id]; addr=[$rnc node-addr]"

# configure UMTS base station
$ns node-config -UmtsNodeType bs \
-downlinkBW 384kbs \
-downlinkTTI 10ms \
-uplinkBW 384kbs \
-uplinkTTI 10ms \
-hs_downlinkTTI 2ms \
-hs_downlinkBW 384kbs

set bsUMTS [$ns create-Umtsnode 0.0.1] ;# node id is 1
puts "bsUMTS: tcl=$bsUMTS; id=[$bsUMTS id]; addr=[$bsUMTS node-addr]"

# connect RNC and base station
$ns setup-Iub $bsUMTS $rnc 622Mbit 622Mbit 15ms 15ms DummyDropTail 2000

$ns node-config -UmtsNodeType ue \
-baseStation $bsUMTS \
-radioNetworkController $rnc

set iface0 [$ns create-Umtsnode 0.0.2] ;# node id is 2
puts "iface0(UMTS): tcl=$iface0; id=[$iface0 id]; addr=[$iface0 node-addr]"

# Node address for router0 and router1 are 3 and 4, respectively.
set cn [$ns node 1.0.0]
puts "cn: tcl=$cn; id=[$cn id]; addr=[$cn node-addr]"
set router1 [$ns node 2.0.0]
puts "router1: tcl=$router1; id=[$router1 id]; addr=[$router1 node-addr]"


# connect links
$ns duplex-link $rnc $router1 622Mbit 0.4ms DropTail 1000
$ns duplex-link $router1 $cn 100MBit 5ms DropTail 1000
$rnc add-gateway $router1

# creation of the MutiFaceNodes. It MUST be done before the 802.11
$ns node-config -multiIf ON ;#to create MultiFaceNode
set multiFaceNode [$ns node 5.0.0] ;# node id is 5
$ns node-config -multiIf OFF ;#reset attribute
puts "multiFaceNode: tcl=$multiFaceNode; id=[$multiFaceNode id]; addr=[$multiFaceNode node-addr]"

# parameter for wireless nodes
set opt(chan) Channel/WirelessChannel ;# channel type for 802.11
set opt(prop) Propagation/TwoRayGround ;# radio-propagation model 802.11
set opt(netif) Phy/WirelessPhy ;# network interface type 802.11
set opt(mac) Mac/802_11 ;# MAC type 802.11
set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type 802.11
set opt(ll) LL ;# link layer type 802.11
set opt(ant) Antenna/OmniAntenna ;# antenna model 802.11
set opt(ifqlen) 50 ;# max packet in ifq 802.11
set opt(adhocRouting) DSDV ;# routing protocol 802.11
set opt(umtsRouting) "" ;# routing for UMTS (to reset node config)

set opt(x) 800 ;# X dimension of the topography
set opt(y) 800 ;# Y dimension of the topography

# configure rate for 802.11
Mac/802_11 set basicRate_ 11Mb
Mac/802_11 set dataRate_ 11Mb
Mac/802_11 set bandwidth_ 11Mb

#create the topography
set topo [new Topography]
$topo load_flatgrid $opt(x) $opt(y)
#puts "Topology created"

# create God
create-god 10 ;# give the number of nodes


# configure Access Points
$ns node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-channel [new $opt(chan)] \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-topoInstance $topo \
-wiredRouting ON \
-agentTrace ON \
-routerTrace OFF \
-macTrace ON \
-movementTrace OFF


proc finish {} {
global ns f
$ns flush-trace
close $f
#exec nam mih.nam &
puts " Simulation ended."
exit 0
}

# configure Base station 802.11
set bstation1 [$ns node 3.0.0] ;
$bstation1 set X_ [expr 500.0]
$bstation1 set Y_ 300.0
$bstation1 set Z_ 0.0
puts "bstation802.11: tcl=$bstation1; id=[$bstation1 id]; addr=[$bstation1 node-addr]"
# we need to set the BSS for the base station
set bstationMac [$bstation1 getMac 0]
set AP_ADDR_0 [$bstationMac id]
puts "bss_id for bstation 1=$AP_ADDR_0"
$bstationMac bss_id $AP_ADDR_0
$bstationMac enable-beacon
$bstationMac set-channel 1

# creation of the wireless interface 802.11
$ns node-config -wiredRouting OFF \
-macTrace ON
set iface1 [$ns node 3.0.1] ;# node id is 7.
$iface1 random-motion 0 ;# disable random motion
$iface1 base-station [AddrParams addr2id [$bstation1 node-addr]] ;#attach mn to basestation
$iface1 set X_ 50.0
$iface1 set Y_ 200.0
$iface1 set Z_ 0.0
[$iface1 set mac_(0)] set-channel 1
# define node movement. We start from outside the coverage, cross it and leave.
$ns at 10 "$iface1 setdest 590.0 200.0 30.0"
puts "iface1: tcl=$iface1; id=[$iface1 id]; addr=[$iface1 node-addr]"


# configure Base station 802.11
set bstation2 [$ns node 4.0.0] ;
$bstation2 set X_ [expr 300.0]
$bstation2 set Y_ 300.0
$bstation2 set Z_ 0.0
puts "bstation802: tcl=$bstation2; id=[$bstation2 id]; addr=[$bstation2 node-addr]"
#we need to set the BSS for the base station
set bstationMac [$bstation2 getMac 0]
set AP_ADDR_0 [$bstationMac id]
puts "bss_id for bstation 2=$AP_ADDR_0"
$bstationMac bss_id $AP_ADDR_0
$bstationMac enable-beacon
$bstationMac set-channel 2
$iface1 base-station [AddrParams addr2id [$bstation2 node-addr]] ;#attach mn to basestation


# add link to backbone
$ns duplex-link $bstation1 $router1 100MBit 15ms DropTail 1000
$ns duplex-link $bstation2 $router1 100MBit 15ms DropTail 1000

# add interfaces to MultiFaceNode
$multiFaceNode add-interface-node $iface1
#$multiFaceNode add-interface-node $iface2
$multiFaceNode add-interface-node $iface0


# install ND modules

# take care of UMTS
# Note: The ND module is on the rnc node NOT in the base station
set nd_rncUMTS [$rnc install-nd]
$nd_rncUMTS set-router TRUE
$nd_rncUMTS router-lifetime 5
$nd_rncUMTS enable-broadcast FALSE
$nd_rncUMTS add-ra-target 0.0.2 ;#in UMTS there is no notion of broadcast.
#We fake it by sending unicast to a list of nodes
set nd_ue [$iface0 install-nd]

# now WLAN
set nd_bs1 [$bstation1 install-nd]
$nd_bs1 set-router TRUE
$nd_bs1 router-lifetime 7

set nd_bs2 [$bstation2 install-nd]
$nd_bs2 set-router TRUE
$nd_bs2 router-lifetime 7

set nd_mn1 [$iface1 install-nd]
#set nd_mn2 [$iface1 install-nd]

set nd_router [$router1 install-nd]
$nd_router set-router TRUE
$nd_router router-lifetime 5


# install interface manager into multi-interface node and CN
set handover [new Agent/MIHUser/IFMNGMT/MIPV6/Handover/Simple]
$multiFaceNode install-ifmanager $handover
$nd_mn1 set-ifmanager $handover
$handover nd_mac $nd_mn1 [$iface1 set mac_(0)] ;#to know how to send RS
#$nd_mn2 set-ifmanager $handover
#$handover nd_mac $nd_mn2 [$iface2 set mac_(0)] ;#to know how to send RS


set ifmgmt_cn [$cn install-default-ifmanager]

# install MIH in multi-interface node
set mih [$multiFaceNode install-mih]

$handover connect-mih $mih ;#create connection between MIH and iface management

# install MIH on AP
set mih_bs1 [$bstation1 install-mih]
set tmp_bs1 [$bstation1 set mac_(0)]
$tmp_bs1 mih $mih_bs1
$mih_bs1 add-mac $tmp_bs1

set mih_bs2 [$bstation2 install-mih]
set tmp_bs2 [$bstation2 set mac_(0)]
$tmp_bs2 mih $mih_bs2
$mih_bs2 add-mac $tmp_bs2

# create a TCP agent and attach it to multi-interface node
set tcp_(0) [new Agent/TCP/FullTcp]
# $ns attach-agent $iface0 $tcp_(0) ;# old command to attach to node
$multiFaceNode attach-agent $tcp_(0) $iface0 ;# new command: the interface is used for sending
set app_(0) [new Agent/Null] ;#we can use this or the next line

# create a TPC agent and attach it to router0
set tcp_(1) [new Agent/TCP/FullTcp]
$ns attach-agent $cn $tcp_(1)
set app_(1) [new Application/TcpApp $tcp_(1)] ;#activate this line if done created abot
puts "App1 id=$app_(1)"

#Create a CBR traffic source and attach it to tcp_(1)
set cbr_(0) [new Application/Traffic/CBR]
$cbr_(0) set packetSize_ 1000
$cbr_(0) set interval_ 0.5
$cbr_(0) attach-agent $tcp_(1)
$handover add-flow $tcp_(0) $tcp_(1) $iface0 1
$tcp_(0) listen
puts "tcp stream made from [$cn node-addr] and [$iface0 node-addr]"

# do registration in UMTS. This will create the MACs in UE and base stations
$ns node-config -llType UMTS/RLC/AM \
-downlinkBW 384kbs \
-uplinkBW 384kbs \
-downlinkTTI 20ms \
-uplinkTTI 20ms \
-hs_downlinkTTI 2ms \
-hs_downlinkBW 384kbs

# for the first HS-DCH, we must create. If any other, then use attach-dch
set dch0 [$ns create-dch $iface0 $tcp_(0)]
$ns attach-dch $iface0 $handover $dch0
$ns attach-dch $iface0 $nd_ue $dch0
puts "dch channel"

# Now we can register the MIH module with all the MACs
set tmp2 [$iface0 set mac_(2)] ;#in UMTS and using DCH the MAC to use is 2 (0 and 1 are for RACH and FACH)
$tmp2 mih $mih
$mih add-mac $tmp2 ;#inform the MIH about the local MAC
set tmp2 [$iface1 set mac_(0)] ;#in 802.11 one interface is created
$tmp2 mih $mih
$mih add-mac $tmp2 ;#inform the MIH about the local MAC



Application/TcpApp instproc recv {data} {
global ns
$ns trace-annotate "$self received data \"$data\""
puts "$self received data \"$data\" at [$ns now]"
}


$ns at 10 "$cbr_(0) start" ;#we should make sure we have UMTS link up before starting to send.

# set original status of interface. By default they are up..so to have a link up,
# we need to put them down first.
$ns at 0 "[eval $iface0 set mac_(2)] disconnect-link" ;#UMTS UE


# set the starting time for Router Advertisements
$ns at 3 "$nd_bs1 start-ra"
#$ns at 3 "$nd_bs2 start-ra"
#$ns at 3 "$nd_bs3 start-ra"
$ns at 1 "$nd_rncUMTS start-ra"
$ns at 1 "$nd_router start-ra"

$ns at 9 "[eval $iface0 set mac_(2)] connect-link" ;#umts link

$ns at 45 "finish"

puts " Simulation is running ... please wait ..."
$ns run

Ns2 Black Hole Attack Code Runing Problem

I installed ns2 using (sudo apt-get install ns2)
I hav code for black hole attack in aodv manet and while trying to run it on ns2 Im getting the fallowing error message
please tell me how to fix this..??

INITIALIZE THE LIST xListHead

(_o58 cmd line 1)
invoked from within
"_o58 cmd addr"
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 "_o58" line 2)
(SplitObject unknown line 2)
invoked from within
"_o58 addr"
("eval" body line 1)
invoked from within
"eval $node addr $args"
("default" arm line 2)
invoked from within
"switch -exact $routingAgent_ {
DSDV {
set ragent [$self create-dsdv-agent $node]
}
DSR {
$self at 0.0 "$node start-dsr"
}
AODV {
set ragent [$self cre..."
(procedure "_o3" line 14)
(Simulator create-wireless-node line 14)
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"
invoked from within
"set node_(2) [$ns node]"
(file "atk3.tcl" line 55)

URGENT HELP!!! GPSR Patch With Ns-2.34 Ubuntu 12.04

Hey guys
I have been trying to patch GPSR with ns-2.34.The operating system i am using is ubuntu 12.04.
I have made all the necessary changes required in the various files .

I have another version of ns (ns-2.35 ) too but it is in a different directory.
Everytime I run my tcl file an error keeps coming up.
I will be greatful if somebody can help me.This is very very URGENT.


(_o29 cmd line 1)
invoked from within
"_o29 cmd if-queue _o23"
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 "_o29" line 2)
(SplitObject unknown line 2)
invoked from within
"$agent if-queue [$self set ifq_(0)] "
(procedure "_o17" line 28)
(Node/MobileNode add-target line 28)
invoked from within
"$self add-target $agent $port"
(procedure "_o17" line 15)
(Node attach line 15)
invoked from within
"$node attach $ragent [Node set rtagent_port_]"
(procedure "create-gpsr-routing-agent" line 29)
invoked from within
"create-gpsr-routing-agent $node $id"
(procedure "gpsr-create-mobile-node" line 41)
invoked from within
"gpsr-create-mobile-node $i"
("for" body line 2)
invoked from within
"for {set i 0} {$i < $opt(nn) } {incr i} {
gpsr-create-mobile-node $i
}"

Problem In Running Codes Of TORA

Hi,
I am new in linux. I have following problem while running the codes of TORA in ns-2.35 in ubuntu.Can you please help me?


num_nodes is set 6
INITIALIZE THE LIST xListHead

(_o22 cmd line 1)
invoked from within
"_o22 cmd port-dmux _o37"
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 "_o22" line 2)
(SplitObject unknown line 2)
invoked from within
"$agent port-dmux $dmux_"
(procedure "_o19" line 11)
(Node/MobileNode add-target-rtagent line 11)
invoked from within
"$self add-target-rtagent $agent $port"
(procedure "_o19" line 28)
(Node/MobileNode add-target line 28)
invoked from within
"$self add-target $agent $port"
(procedure "_o19" line 15)
(Node attach line 15)
invoked from within
"$node attach $ragent [Node set rtagent_port_]"
(procedure "_o3" line 85)
(Simulator create-wireless-node line 85)
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"
invoked from within
"set n(0) [$ns node]"
(file "tora2.tcl" line 115)

Error In Umts Verical Handover Wih Wlan

Hey,
please find attached the code
I got this error :
can't read "mac_(0)": no such variable
while executing
"subst $[subst $var]"
(procedure "_o112" line 5)
(SplitObject set line 5)
invoked from within
"$iface2 set mac_(0)"
invoked from within
"set tmp2 [$iface2 set mac_(0)] "
(file "umts.tcl" line 319)




can anyone help to solve the error??

Error:: "wrong # Args: Should Be "set VarName ?newValue?" " While Running TCL Script

I m learning Tcl and write short code. After running code i got same error repeatedly and not able to find mistake,,,i wrote it as it is from a tutorial. here is the code below

set ns [new Simulator]

set f1 [open out.nam w] #open nam file out.nam
$ns namtrace-all $f1

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


set n1 [$ns node] # 3 nodes defined
set n2 [$ns node]
set n3 [$ns node]

set duplex-link $n1 $n2 10mb 10ms Droptail
set duplex-link $n2 $n3 10mb 10ms DropTail
set duplex-link $n3 $n1 10mb 10ms DropTail

set udp1 [new Agent/UDP] #UDP agent attached to node n1
$ns attach-agent $n1 $udp1

set cbr1 [new Application/traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 0.005
$ns attach-agent cbr1 udp1

set null1 [new Aggent/Null]
$ns attach-agent $n2 $null1


$ns connect $udp1 $null1

$ns at 0.5 "$cbr0 start"
$ns at 4.5 "$cbr0 stop"


$ns at 12.0 "finish"

$ns run



ERROR:wrong # args: should be "set varName ?newValue?"
while executing
"set f1 [open out.nam w] #open nam file out.nam"
(file "11.tcl" line 19)

Tcl Ns2 (not Running)

#======================================================================
# Define options
#======================================================================
set val(chan) Channel/WirelessChannel ;# channel type
set val(prop) Propagation/TwoRayGround ;# radio-propagation model
set val(netif) Phy/WirelessPhy ;# network interface type
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(rp) DumbAgent ;# routing protocol
set val(start) 0.0
set val(tr) "trace"
set val(X) 100
set val(Y) 100T
set val(UPDpacketsize) 65536
set val(RTSThreshold) 65536
set val(ShortRetryLimit) 4
set val(LongRetryLimit) 4
set val(CWmin) 16
set val(CWmax) 1024
set val(SlotTime) 0.000009
set val(SIFS) 0.000016
set rng [new RNG]
set val(nn) 0
$rng seed 0
set ss [$rng next-random]
puts "random number for ns is: $ss"
set opt(seed) $ss
#the cbr_scenario.tcl defines the traffic flows and the stations’ positions
# Get default options
#source phyrate_cbr-default_options.tcl
#Ken Chan Advisor: Prof Melody MohCS298 Report, Spring 2009 May 03, 2009 39
# Station position
puts "---------------------------------------------------------------------"
for {set i 1} {$i < $val(nn)+1 } {incr i 1} {
$node_([expr $i-1]) set X_ [expr $val(X)-$i]
$node_([expr $i-1]) set Y_ [expr $val(Y)-$i]
$node_([expr $i-1]) set Z_ 0.0
}
puts "---------------------------------------------------------------------"
# Flow from this station to all the others
puts "---------------------------------------------------------------------"
set flowid 0

# only one flow
set i 0
set udp($flowid) [new Agent/UDP]
set null($flowid) [new Agent/Null]
#$ns_ attach-agent $node_($i) $udp($flowid)
#$ns_ attach-agent $node_([expr ($i+1) % $val(nn)]) $null($flowid)
#$ns_ connect $udp($flowid) $null($flowid)
set cbr($flowid) [new Application/Traffic/CBR]
$cbr($flowid) attach-agent $udp($flowid)
#$ns_ at [expr $val(start)+[expr $i / 1000]] "$cbr($flowid) start"
#$ns_ at [expr $val(start)+ $i]] "$cbr($flowid) start"
set flowid [expr $flowid + 1]
# multi flows
for {set i 0} {$i < $val(nn) } {incr i 1} {
set udp($flowid) [new Agent/UDP]
set null($flowid) [new Agent/Null]
$ns_ attach-agent $node_($i) $udp($flowid)
$ns_ attach-agent $node_([expr ($i+1) % $val(nn)]) $null($flowid)
$ns_ connect $udp($flowid) $null($flowid)
set cbr($flowid) [new Application/Traffic/CBR]
$cbr($flowid) attach-agent $udp($flowid)
$ns_ at [expr $val(start)+[expr $i / 1000]] "$cbr($flowid) start"
$ns_ at [expr $val(start)+ $i]] "$cbr($flowid) start"
$ns_ at $val(start) "$cbr($flowid) start"
set flowid [expr $flowid + 1]
}
puts "---------------------------------------------------------------------"
# the cbr.tcl defines the core of the cbr simulations and the record of nam graphand .tr trace file, following are parts of the files and explanations Ken Chan #CS298 Report, Spring 2009 May 03, 2009 40
#======================================================================
# Define options
#======================================================================
#source phyrate_cbr-default_options.tcl
#----------------------------------------------------------------------------
set val(nn) 10 ;##fixed node number for testing CBR traffic
set val(ifqlen) 10 ;# max packet in ifq
set val(Sq_LIMIT) 10
set val(run) 5.0
#-----------------------------------------------------------------------
set val(BER) 0
set val(PktSize) 1024
set val(FRAMELEN) 65535
set val(fgLEN) 8192
set val(DELAY) 0.0 ;# duration of delay timer, change to 0.0 instead of using argument 4
set val(temp) 144 ;# datarate
set val(appFERReq) 0.10
set val(trafficload) 0.5
set val(turnOnAFS) 1
set val(dataRate) $val(temp)Mb
set val(basicRate) 6.0Mb ;#changed to 6.0MB
set val(CBRrate) {expr [$val(temp)/$val(nn)*$val(trafficload)]}
puts "CBRrate for each station = $val(CBRrate)"
#-----------------------------------------------------------------------
set val(percentage) 0.03 ;#for calculating the percentage with more than 30ms
set val(OrigPktSize) 1024
#----------------------------------------------------------------------------
Mac/802_11 set fgLEN_ $val(fgLEN)
Mac/802_11 set BER_ $val(BER)
Mac/802_11 set Sq_LIMIT_ $val(Sq_LIMIT) ;# number of fragments
Mac/802_11 set peakDelay_ 0.0
Mac/802_11 set percentage_ $val(percentage)
Mac/802_11 set appFERReq_ $val(appFERReq) ;#for setting applicationFERRequirement
#Mac/802_11 set PLCPDataRate_ $val(PLCPRate)
set val(avoidARP) 0.0
set val(stop) [expr $val(start)+$val(avoidARP)+$val(run)]
#-------------------------------------------------------------------------------- Ken Chan Advisor: Prof Melody Moh CS298 Report, Spring 2009 May 03, 2009 41$val(fgLEN)//////////////////////////
puts "----------------------------------------------------------------"
puts "BER PktSize AMPDU_Frame_Size AMSDU_Frame_Size DataRate(Mbps) App_FER_Req Trafficload TurnOnAFS"
puts "$val(BER) $val(PktSize) $val(FRAMELEN) $val(dataRate) $val(appFERReq) $val(trafficload) $val(turnOnAFS)"
puts "----------------------------------------------------------------"

#--------------------------------------------------------------------------------
# PHY MIB
#--------------------------------------------------------------------------------
Phy/WirelessPhy set CPThresh_ 20000.0 ;#capture threshold (db)
Phy/WirelessPhy set Pt_ 0.2818 ;#for 250m range
#--------------------------------------------------------------------------------
# MAC MIB
#--------------------------------------------------------------------------------
Mac/802_11 set PktSize_ $val(PktSize)
Mac/802_11 set basicRate_ $val(basicRate)
Mac/802_11 set dataRate_ $val(dataRate)
Mac/802_11 set CWMin_ $val(CWmin)
Mac/802_11 set CWMax_ $val(CWmax)
Mac/802_11 set SlotTime_ $val(SlotTime)
Mac/802_11 set SIFS_ $val(SIFS)
Mac/802_11 set RTSThreshold_ $val(RTSThreshold)
Mac/802_11 set ShortRetryLimit_ $val(ShortRetryLimit)
Mac/802_11 set LongRetryLimit_ $val(LongRetryLimit)
Mac/802_11 set STANUM_ $val(nn)
Mac/802_11 set THRind_ 0.0
Mac/802_11 set SizeOfAllFrame_ 0
Mac/802_11 set totalDelay_ 0.0
Mac/802_11 set percentageDelay_ 0.0
Mac/802_11 set recvNumber_ 0
Mac/802_11 set DELAY_ $val(DELAY)
Mac/802_11 set FRAMELEN_ $val(FRAMELEN)
Mac/802_11 set turnOnAFS_ $val(turnOnAFS)
#--------------------------------------------------------------------------------
# Antenna settings
#--------------------------------------------------------------------------------
# unity gain, omni-directional antennas
# set up the antennas to be centered in the node and 1.5 meters above it
Antenna/OmniAntenna set X_ 1
Antenna/OmniAntenna set Y_ 1
Antenna/OmniAntenna set Z_ 1.5
Antenna/OmniAntenna set Gt_ 1.0
Antenna/OmniAntenna set Gr_ 1.0

# Application Characteristics
Agent/CBR set sport_ 0
Agent/CBR set dport_ 0
Application/Traffic/CBR set rate_ $val(CBRrate)
Application/Traffic/CBR set packetSize_ $val(PktSize) ;#bytes
Agent/UDP set packetSize_ $val(UPDpacketsize) ;#bytes
Agent/Null set sport_ 0
Agent/Null set dport_ 0
# LL
LL set mindelay_ 0us
LL set delay_ 0us
LL set bandwidth_ 0 ;# not used
LL set off_prune_ 0 ;# not used
LL set off_CtrMcast_ 0 ;# not used
LL set debug_ false
#======================================================================
# Global Procedures
#======================================================================
#remove-all-packet-headers
#remove-packet-header AODV ARP IMEP IPinIP IVS LDP MPLS MIP Ping PGM PGM_SPM PGM_NAK NV Smac Pushback TORA TFRC_ACK TFRC ;# original

#remove-packet-header IMEP IPinIP IVS LDP MPLS MIP Ping PGM PGM_SPMPGM_NAK NV Smac Pushback TORA TFRC_ACK TFRC
#add-packet-header Common IP Mac TCP LL CtrMcast
# new ns
#------------------------------------------------------------------------
remove-all-packet-headers
add-packet-header Common IP Mac LL CtrMcast
set ns_ [new Simulator]
$ns_ use-newtrace ;# change to use another trace
# CMU trace format, trace if needed
set tracefd [open $val(tr).cmu.all w]
$ns_ trace-all $tracefd
puts "second times"
proc hello {} {
puts "hello"
}
# open the tr trace file and the nam graph Ken Chan Advisor: Prof Melody Moh
set f [open final_out.tr w]
#$ns trace-all $f
## set nam trace for graph generation
##/////enable namtrace if needed
set namtrace [open phyrate_cbr.nam w]
$ns_ namtrace-all-wireless $namtrace $val(X) $val(Y)
set f0 [open bandwidth_node1.tr w]
set f1 [open npkts_node1.tr w]
## open throughput, average delay and peak delay and fairness or percentage delay if needed here
set f_throughput [open throughput_dcf.tr w]
set f_averagedelay [open averagedelay__dcf.tr w]
set f_peakdelay [open peakdelay_dcf.tr w]
set f_data [open phyrate_cbr_data_$val(temp).tr a]
ns-random 0 ;# may not be useful
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(X) $val(Y)
# Create God
create-god $val(nn)
## need to get the wireless channel value first
set wirelesschan [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) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace ON
#-channel $val(chan) ;# wireless channel
#-agentTrace OFF \ ;# should be set to ON for nam trace Ken Chan Advisor: Prof
#-routerTrace OFF \
#-macTrace OFF \
#-movementTrace OFF
#------------------------------------------------------------------------
##Need to do sth here .........
# Create node
#------------------------------------------------------------------------
for {set i 0} {$i < $val(nn) } {incr i} {
# assign dst address in TCL because I do not use ARP pkts
LL set macDA_ [expr [expr $i+1] % $val(nn)]
LL set dataDA_ [expr [expr $i+1] % $val(nn)]
if { $i == 0 } {
LL set tcpAckDA_ [expr $val(nn) - 1 ]
} else {
LL set tcpAckDA_ [expr $i-1]
}

set node_($i) [$ns_ node]
$node_($i) random-motion 0 ;# disable random motion
$ns_ initial_node_pos $node_($i) 30 ;# define the initial position of bility
#$node_($i) set SlotTime_
}

#---------------------------------------------------------------------
#source phyrate_cbr-scenario.tcl
# Station position
# Station position
#set phydatarate $var(dataRate)
#put "$var(dataRate)"
###for setting the first line
proc stop {} { global ns_ val node_ temp_delay tracefd f_data
#namtrace
#f_throughput f_averagedelay f_peakdelay
$ns_ flush-trace ; #flush the trace file

#exec xgraph cwnd_tcp1.tr
#exec xgraph pkt_received_at_node1.tr
#set sum 0.0
#set squaresum 0.0
#set peakDelay 0.0

set f_throughput [open "phyrate_cbr_throughput_ampdu.tr" "a"]
#Ken Chan Advisor:
set f_a_delay [open "phyrate_cbr_average_delay_ampdu.tr" "a"]
set f_p_delay [open "phyrate_cbr_peak_delay_ampdu.tr" "a"]
set f_fairness [open "phyrate_cbr_fairness_ampdu.tr" "a"]
set f_percentage_delay [open "phyrate_cbr_percentage_delay_ampdu.tr" "a"]
#omit BER and TrafficLoad, put $val(dataRate) in the front of file, to get result for BER and TL
$val(BER) $val(PktSize) $val(FRAMELEN)
$val(fgLEN) $val(dataRate) $val(appFERReq) $val(trafficload) $val(turnOnAFS)
set f_data [open phyrate_cbr_data_$val(dataRate)_$val(PktSize)_$val(FRAMELEN)_$val(fgLEN)_$val( appFERReq)_$val(turnOnAFS).tr a]
set f_data [open phyrate_cbr_data_Optimal_vs_Adaptive.tr a]
set f_data [open phyrate_cbr_data_BER_vs_AMSDUSize.tr a]
set f_data [open phyrate_cbr_data_test.tr a]

for {set i 0} {$i < $val(nn) } {incr i} {
set mac [$node_($i) getMac 0] ;## get the current mac instance
set throughput($i) [$mac set THRind_]
set totalDelay [$mac set totalDelay_]
set recvNumber [$mac set recvNumber_]
set temp_delay [$mac set peakDelay_]
set totalBER [$mac set totalBER_] ;## for caluculating actual BER increase with TL
set totalBERCounter [$mac set totalBERCounter_]
set averageActualFER [$mac set averageActualFER_]
set averageActualBER [$mac set averageActualBER_]
set peakDelay [expr $peakDelay + $temp_delay]
set percentageDelay [$mac set percentageDelay_] ;## for caluculating percentage delay, percentage is set to MAC previously
set numExceed30ms [$mac set numExceed30ms_]
puts "peak Delay=$temp_delay"

set sum [expr $sum + $throughput($i)]
set squaresum [expr $squaresum+[expr $throughput($i)*$throughput($i)]]
}
##need to move forward
set nominator [expr $sum*$sum]
set denominator [expr $val(nn)*$squaresum]
set fairness [expr $nominator/$denominator]
##for tracing performance in .tr file
set systhroughput [expr $sum/$val(stop)]
set a_delay [expr $totalDelay/$recvNumber]
set a_actual_BER [expr $totalBER/$totalBERCounter] ;## for calculating the average actual BER.
set p_delay [expr $peakDelay/$val(nn)]
set percentageDelay [expr $percentageDelay]


puts "numExceed30ms/recvNumber = $numExceed30ms/$recvNumber"
puts $f_throughput "$val(temp) $systhroughput" ;## temp is data rate
puts $f_a_delay "$val(temp) $a_delay"
puts $f_p_delay "$val(temp) $p_delay"
puts $f_fairness "$val(temp) $fairness"
puts $f_percentage_delay "$val(temp) $percentageDelay $val(percentage)"
# for calculating the actual BER with increase of Traffic Load.
# should remove column 3 $a_actual_BER
puts $f_data "$systhroughput $a_delay $a_actual_BER $p_delay
$percentageDelay $averageActualBER $averageActualFER $val(BER)
$val(OrigPktSize) $val(FRAMELEN) $val(fgLEN) $val(dataRate)
$val(appFERReq) $val(trafficload) $val(turnOnAFS)
$val(percentage)"


puts "The system throughput = [expr $sum/$val(stop)]"
puts -nonewline $f_throughput "[string range [expr $sum/$val(stop)] 0 6] "
puts "The average delay = [expr $totalDelay/$recvNumber]"
puts "The peak delay = [expr $peakDelay/$val(nn)]"
puts "The Percentage delay of $val(percentage) = $percentageDelay"
puts "The fairness = $fairness"
puts "The average actual BER = $averageActualBER"
puts "The average actual FER = $averageActualFER "

close $f_data
close $tracefd
puts -nonewline $f_a_delay "[string range [expr $totalDelay/$recvNumber] 0 6] "
puts -nonewline $f_p_delay "[string range [expr $peakDelay/$val(nn)] 0 6] "
puts -nonewline $f_fairness "[string range $fairness 0 6] "
close $f_throughput
close $f_a_delay
close $f_p_delay
close $f_fairness

close $namtrace

close $f_throughput
close $f_averagedelay
close $f_peakdelay
##exec nam graph
exec nam -r 5m phyrate_cbr.nam &
exit 0
}
# Tell nodes when the simulation ends
#-----------------------------------------------------------------------
$ns_ at $val(stop) "stop"
$ns_ at $val(stop)+1 "$ns_ halt"

# Run ns...
#-----------------------------------------------------------------------
$ns_ run

How To Patch GPSR Routing Protocol To Ns-2.35

Hi,
I have patched GPSR to ns-2.35 using keliu' code. It works fine with given tcl file. I need to move nodes according to mine own mobility scenario and compare them to AODV protocol.
I have two problems
1. I don't understand what this command in gpsr.tcl file means Code:
proc gpsr-create-mobile-node { id args } {
         .........................	
if [info exists opt(energy)] {
	$node addenergymodel [new $opt(energy) $node 10 0.5 0.2]}
         .............

What are these figures (0.5, 0.2), are these energy consumed in reception and transmission or some thing else.

Secondly I want move mobile node created using proc defined in gpsr.tcl file according to my own mobility plan e.g. Code:
 $ns_ at 0.000000000000 "$node_(0) setdest 144.816950690450 20.073824649527 0.324133202939"
$ns_ at 0.000000000000 "$node_(1) setdest 93.957720171475 192.140808646867 1.452613500562"
$ns_ at 12.158688172971 "$node_(23) setdest 113.137798368154 39.443538618334 0.902003496971"
$ns_ at 14.805074599534 "$node_(2) setdest 152.227654369397 20.766089279052 1.742469780423"

But when I run simulation it gives error like this:[QUOTE]Load complete...
Starting Simulation...
ns: _o18 setdest 144.816950690450 20.073824649527 0.324133202939:
(_o18 cmd line 1)
invoked from within
"_o18 cmd setdest 144.816950690450 20.073824649527 0.324133202939"
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 "_o18" line 2)
(SplitObject unknown line 2)
invoked from within
"_o18 setdest 144.816950690450 20.073824649527 0.324133202939"
[\QUOTE]
Urgent help is needed please

Problem With Creating Malicious Node For OLSR In Ubuntu 14.10 With Ns 2.35

Experts,


I need your help to create malicious nodes for OLSR routing protocol. I completly patch OSLR in ns 2.35 in ubuntu 14.10 (32-bit) and its working but when I am try to create any malcious node by defining it "Malicious" or "hacker" it show me an error and not running that .tcl file.

for an example.

$ns_ at 0.0 "[$node_(8) set ragent_] hacker "
$ns_ at 0.0 "[$node_(14) set ragent_] hacker "
$ns_ at 0.0 "[$node_(20) set ragent_] hacker "
$ns_ at 0.0 "[$node_(26) set ragent_] hacker "



Help me to solve this problem.
I searched over internet but couldn't find any solution.

Help me to solve this.

Thank you.

After Install Gpsr, Test The Perimeter Mode , It Has Throw "Wrong The Other Node"

hello there!
the common communication between nodes is fine, but when i want to test the perimeter mode it has throw the error "Wrong the other node", it seems that it couldn't find its next hop node.
i trace the code as show below
Code:
int
GPSRNeighbors::intersect(nsaddr_t theother, double sx, double sy,
			 double dx, double dy){
  //line 1 (x1,y1)--(x2,y2) is the segment
  //line 2 (x3,y3)--(x4,y4) is the xD 
  struct gpsr_neighbor *other = getnb(theother);

  if(other==NULL){
    printf("Wrong the other node\n");
    exit(1);
  }


  ****************

struct gpsr_neighbor*
GPSRNeighbors::getnb(nsaddr_t nid){
  struct gpsr_neighbor *temp = head_;
  while(temp){
    if(temp->id_ == nid){
      if((GPSR_CURRENT - temp->ts_) < DEFAULT_GPSR_TIMEOUT)
	return temp;
      else {
	delnb(temp); //if this entry expire, delete it and return NULL
	return NULL;
      }
      return temp;
    }
    temp = temp->next_;
  }
  return NULL;
}

the simulation scene was shown in the attachment.
when i make node 0 send packet to node 1, the error will occur.
would somebody know how to solve it?
thank you for your time!