LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-29-2015, 02:45 PM   #1
najat
Member
 
Registered: Apr 2015
Posts: 58
Blog Entries: 1

Rep: Reputation: Disabled
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

Last edited by najat; 04-30-2015 at 03:41 AM.
 
Old 04-30-2015, 12:42 AM   #2
najat
Member
 
Registered: Apr 2015
Posts: 58
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
Please,Could anyone help me
 
Old 04-30-2015, 03:07 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016 CentOS6.9 CentOS7.3 + 50+ other Linux OS, for test only.
Posts: 16,683

Rep: Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284
Yes, you can start with editing post #1 to CODE Tags : [code]code text[/code]

Editing post #1 : That's the 'Edit' button in post #1.

You will also have to replace the wrecked text with the real code.
And no lines ##################### with 300 characters, please.


-
 
Old 04-30-2015, 03:41 AM   #4
najat
Member
 
Registered: Apr 2015
Posts: 58
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
I modified the post.How can i solve this error
 
Old 04-30-2015, 04:10 AM   #5
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016 CentOS6.9 CentOS7.3 + 50+ other Linux OS, for test only.
Posts: 16,683

Rep: Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284
Error output also goes into CODE Tags: [code]error text[/code]
! And no colors, please. Color is for a single word !


There is still some syntax errors / invisible characters? in the post #1 code:

Code:
[knudfl@localhost najat]$ ns-nist-pmipv6 Second-MIH-najat.tcl 
num_nodes is set 20

extra characters after close-quote
    while executing
"$ns at 0.05 "$multiFaceNode label "MN 5.0.0""

if {$quiet == 0} {

        puts "multiFaceNode(MN) has been created"

        puts ""

}



# creation of the..."
    (file "Second-MIH-najat.tcl" line 221)
 
Old 04-30-2015, 04:24 AM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016 CentOS6.9 CentOS7.3 + 50+ other Linux OS, for test only.
Posts: 16,683

Rep: Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284
? May be you can upload your own file copy to e.g. 'Google Docs' ?

.... I.e. when you are sure that you have the most perfect file you can make.
? Could it be some Windows characters that causes the error shown in post #5 ?
And I cannot fix it, even with : $ dos2unix Second-MIH-najat.tcl


-
 
Old 04-30-2015, 04:45 AM   #7
najat
Member
 
Registered: Apr 2015
Posts: 58
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
this is the new code :
Code:



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)

puts "________Topology created________"



# 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      



#Configure Wireless parameters

# 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 ""

}

#Configure UMTS

$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 ""

}





# 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



# 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

#Configure WLAN

puts "________WLAN Configuration________"

#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

#Configure WIMAX

#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

#Configure Multiface Node

puts "________Mobile Node Configuration________"



# 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"



#Configure Routers

#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 ""

}



#ADD Links

puts "Adding 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

if {$quiet == 0} {

	puts "....Configuration successfully"

	puts ""

}

#create traffic: TCP application between CN and Multi interface node

#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"

 $ns run
 
Old 04-30-2015, 05:14 AM   #8
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016 CentOS6.9 CentOS7.3 + 50+ other Linux OS, for test only.
Posts: 16,683

Rep: Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284
Re #7.

Some improvement, but ...
Code:
[knudfl@localhost najat]$ ns-nist-pmipv6 Third-mih_najat.tcl 
________Topology created________
num_nodes is set 20

multiFaceNode(MN) has been created

host(CN) has been created
                                                                              
________RNC Configuration________                                             
RNC: tcl=_o41; id=2; addr=0.0.0                                               
                                                                              
________UMTS Base Station Configuration________                               
invalid command name "-downlinkBW"                                            
    while executing                                                           
"-downlinkBW 384kbs \                                                         
"                                                                             
    (file "Third-mih_najat.tcl" line 269)
 
Old 04-30-2015, 05:48 AM   #9
najat
Member
 
Registered: Apr 2015
Posts: 58
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
I don't get this error when i simulate?
What can i do to fix this error
I couldn't attch the tcl file

Last edited by najat; 04-30-2015 at 05:55 AM.
 
Old 04-30-2015, 06:09 AM   #10
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016 CentOS6.9 CentOS7.3 + 50+ other Linux OS, for test only.
Posts: 16,683

Rep: Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284
Re #9.

Do as asked. Don't try copy / pasting your code. Upload the file.

LQ attachments : That's the "paper clip tool" in the 'Advanced Editor'.
Attach the file as unique-name.tcl.txt .


Uploading : Google Docs, Mediafire, filedropper, wikisend.com, etc. etc.


-
 
Old 04-30-2015, 06:44 AM   #11
najat
Member
 
Registered: Apr 2015
Posts: 58
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
I've attached the file.
Attached Files
File Type: txt test1.txt (16.2 KB, 26 views)
 
Old 04-30-2015, 08:45 AM   #12
najat
Member
 
Registered: Apr 2015
Posts: 58
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
Does the attached file work?
 
Old 04-30-2015, 10:14 AM   #13
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016 CentOS6.9 CentOS7.3 + 50+ other Linux OS, for test only.
Posts: 16,683

Rep: Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284Reputation: 3284
Re #11.

"All" students working with ns2 will create a file by name test.tcl or test1.tcl.
Hence the request for using a unique name for the attachment.

Tcl files should be recognizable as "file.tcl" by all readers.
Therefore a tcl example must have suffix .tcl.txt


And no, I cannot trace why "node 10" is named "Node_(10)" instead of the usual "node_(10)".
Or if you really are creating 11 nodes.


-
 
Old 04-30-2015, 12:05 PM   #14
najat
Member
 
Registered: Apr 2015
Posts: 58
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
Dear kundulf,
I cannot found the error.
I'm not understanding what do i write wrong
My file is a tcl file but when i upload i make txt file
 
Old 05-01-2015, 02:18 AM   #15
najat
Member
 
Registered: Apr 2015
Posts: 58
Blog Entries: 1

Original Poster
Rep: Reputation: Disabled
Please can someone help me
 
  


Reply

Tags
ns2


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Vertical handover between wimax and wifi code najat Linux - Newbie 3 01-14-2016 07:26 AM
[SOLVED] vertical histogram on C giving segmentation error.. CeroZilch Programming 3 10-03-2014 03:02 AM
want tcl script for vertical handover between wifi and UMTS ........ npkshirsagar Linux - Software 1 11-16-2011 03:48 AM
Need vertical scroll code for 3 column web page Dafydd Programming 3 06-20-2011 11:36 AM
vertical scroll in code view. oskar LQ Suggestions & Feedback 4 09-28-2008 02:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration