if you can't download it, here it is :
if {$argc != 0} { puts "" puts "Wrong Number of Arguments! No arguments in this topology" puts "" exit (1) } global ns proc finish {} { global ns f f0 f1 f2 f01 f11 f21 namfile $ns flush-trace close $f close $f0 close $f1 close $f2 close $f01 close $f11 close $f21 close $namfile puts " Simulation ended." exec xgraph throughput.tr throughput1.tr -geometry 800x400 & exec xgraph loss.tr loss1.tr -geometry 800x400 & exec xgraph delay.tr delay1.tr -geometry 800x400 exit 0 } set output_dir . set ns [new Simulator] $ns use-newtrace $ns color 1 Blue $ns color 2 Red set f [open out.tr w] $ns trace-all $f set namfile [open out1.nam w] $ns namtrace-all-wireless $namfile 800 800 #Open the output files set f0 [open throughput.tr w] set f1 [open loss.tr w] set f2 [open delay.tr w] #Open the output files set f01 [open throughput1.tr w] set f11 [open loss1.tr w] set f21 [open delay1.tr w] # UMTS $ns set hsdschEnabled_ 1addr $ns set hsdsch_rlc_set_ 0 $ns set hsdsch_rlc_nif_ 0 # (needed for routing over a basestation) $ns node-config -addressType hierarchical AddrParams set domain_num_ 7 AddrParams set cluster_num_ {1 1 1 1 1 1 1} AddrParams set nodes_num_ {5 1 1 1 3 1 1} #RNC puts "##############################################################" puts "***********************Now, Creating RNC**********************" $ns node-config -UmtsNodeType rnc set RNC [$ns create-Umtsnode 0.0.0] ;# node id is 0. $ns at 0.00 "$RNC label \"RNC 0.0.0\"" $RNC set X_ 200 $RNC set Y_ 100 $RNC set Z_ 0 puts "RNC $RNC" puts "***********************Completed successfully*****************" puts "##############################################################" puts "" puts "" # 配置UMTS基站 puts "##############################################################" puts "***********************Now, Creating BS**********************" $ns node-config -UmtsNodeType bs \ -downlinkBW 384kbs \ -downlinkTTI 10ms \ -uplinkBW 384kbs \ -uplinkTTI 10ms \ -hs_downlinkTTI 2ms \ -hs_downlinkBW 384kbs set BS [$ns create-Umtsnode 0.0.1] ;# node id is 1 $ns at 0.00 "$BS label \"BSumts 0.0.1\"" $BS set X_ 100 $BS set Y_ 100 $BS set Z_ 0 puts "BS $BS" puts "***********************Completed successfully*****************" puts "##############################################################" puts "" puts "" # BS __ RNC puts "##############################################################" puts "***********************Now, Connecting RNC and BS*************" $ns setup-Iub $BS $RNC 622Mbit 622Mbit 15ms 15ms DummyDropTail 2000 puts "***********************Completed successfully*****************" puts "##############################################################" puts "" puts "" #创建UMTS无线节点 puts "##############################################################" puts "******Now, Creating UMTS UE(us as MultiFaceNode's NIC)*******" $ns node-config -UmtsNodeType ue \ -baseStation $BS \ -radioNetworkController $RNC #UMTS_UE0 set UMTS_UE0 [$ns create-Umtsnode 0.0.2] ;# node id is 2 $ns at 0.00 "$UMTS_UE0 label \"umts_ue0 0.0.2\"" $UMTS_UE0 set Y_ 50 $UMTS_UE0 set X_ 100 $UMTS_UE0 set Z_ 0 set UMTS_UE0_id [$UMTS_UE0 id] puts "UMTS_UE0 created $UMTS_UE0_id" puts "***********************Completed successfully*****************" puts "##############################################################" puts "" puts "" #SGSN GGSN。 Node id for SGSN0 and GGSN0 are 4 and 5, respectively. puts "##############################################################" puts "***********************Now, Creating GGSN and SGSN************" set SGSN [$ns node 1.0.0] $ns at 0.00 "$SGSN label \"SGSN 1.0.0\"" set SGSN_id [$SGSN id] puts "SGSN $SGSN" puts "SGSN_id $SGSN_id" $SGSN set X_ 300 $SGSN set Y_ 100 $SGSN set Z_ 0 puts "***********************Completed successfully*****************" puts "##############################################################" puts "" puts "" puts "##############################################################" puts "***********************Now, Creating CN_host1 and CN_host2****" set CN_host0 [$ns node 3.0.0] $ns at 0.00 "$CN_host0 label \"CN0 3.0.0\"" $CN_host0 set X_ 500 $CN_host0 set Y_ 100 $CN_host0 set Z_ 0 puts "CN_host0 $CN_host0" set CN_host0_id [$CN_host0 id] puts "CN_host0_id $CN_host0_id" puts "finished" puts "" # do the connections in the UMTS part puts "Connecting RNC SGSN GGSN CN_host0 CN host1" $ns duplex-link $RNC $SGSN 622Mbit 0.4ms DropTail 1000 $ns duplex-link $SGSN $CN_host0 10MBit 15ms DropTail 1000 $RNC add-gateway $SGSN # puts "2 Creating UE" puts "" $ns node-config -multiIf ON ;#to create MultiFaceNode set UE0 [$ns node 5.0.0] $ns at 0.00 "$UE0 label \"multifacenode\"" $UE0 set X_ 100 $UE0 set Y_ 100 $UE0 set Z_ 0 set UE0_id [$UE0 id] puts "UE0 $UE0_id" $ns node-config -multiIf OFF ;#reset attribute puts "***********************Completed successfully*****************" puts "##############################################################" puts "" puts "" #WLAN puts "##############################################################" puts "***********************Now, Creating WLAN*********************" # 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) 1000 ;# X dimension of the topography set opt(y) 1000 ;# Y dimension of the topography # WLAN 11Mb Mac/802_11 set basicRate_ 11Mb Mac/802_11 set dataRate_ 11Mb Mac/802_11 set bandwidth_ 11Mb Mac/802_11 set client_lifetime_ 10 ;#increase since iface 2 is not sending traffic for some time puts "1 Creating topology" puts "" set topo [new Topography] $topo load_flatgrid $opt(x) $opt(y) puts "Topology created" puts "" # create God set god [create-god 12] ;# give the number of nodes $god set-dist 1 2 1 $god set-dist 0 2 2 $god set-dist 0 1 1 set god [God instance] puts "finished" puts "" #AP puts "3 Creating AP" puts "" puts "coverge:20m" 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 [new $opt(chan)] \ -ifqType $opt(ifq) \ -ifqLen $opt(ifqlen) \ -antType $opt(ant) \ -propType $opt(prop) \ -phyType $opt(netif) \ -topoInstance $topo \ -wiredRouting ON \ -agentTrace OFF\ -routerTrace OFF \ -macTrace ON \ -movementTrace OFF # configure Base station 802.11 set AP0 [$ns node 4.0.0] $ns at 0.00 "$AP0 label \"AP0 4.0.0\"" set AP0_id [$AP0 id] puts "AP0_id $AP0_id" $AP0 set X_ [expr 200] $AP0 set Y_ 50.0 $AP0 set Z_ 0.0 [$AP0 set mac_(0)] bss_id [[$AP0 set mac_(0)] id] [$AP0 set mac_(0)] enable-beacon [$AP0 set mac_(0)] set-channel 1 puts "AP0 created" # configure Base station 802.11 set AP1 [$ns node 2.0.0] $ns at 0.00 "$AP1 label \"AP1 2.0.0\"" set AP1_id [$AP1 id] puts "AP1_id $AP1_id" $AP1 set X_ [expr 550] $AP1 set Y_ 50.0 $AP1 set Z_ 0.0 [$AP1 set mac_(0)] bss_id [[$AP1 set mac_(0)] id] [$AP1 set mac_(0)] enable-beacon [$AP1 set mac_(0)] set-channel 1 puts "AP1 created" # creation of the wireless interface 802.11 puts "5 Creating 2 WLAN interfaces" puts "" $ns node-config -wiredRouting OFF \ -macTrace ON # interface wlan 0 set WLAN_UE0 [$ns node 4.0.1] $ns at 0.00 "$WLAN_UE0 label \"wlan_ue0_interface 4.0.1\"" ;# create the node with given @. $WLAN_UE0 random-motion 0 set WLAN_UE0_id [$WLAN_UE0 id] puts "WLAN_UE0_id $WLAN_UE0_id connect to AP0" ;# disable random motion $WLAN_UE0 base-station [AddrParams addr2id [$AP0 node-addr]] ;#attach mn to basestation $WLAN_UE0 set X_ [expr 200.0] $WLAN_UE0 set Y_ 50.0 $WLAN_UE0 set Z_ 0.0 [$WLAN_UE0 set mac_(0)] set-channel 1 $ns at 0.0 "$WLAN_UE0 setdest 750.0 100.0 50.0" #interface wlan 1 set WLAN_UE1 [$ns node 2.0.1] $ns at 0.00 "$WLAN_UE1 label \"wlan_ue1_interface 2.0.1\"" ;# create the node with given @. $WLAN_UE1 random-motion 0 set WLAN_UE1_id [$WLAN_UE1 id] puts "WLAN_UE1_id $WLAN_UE1_id connect to AP1" ;# disable random motion $WLAN_UE1 base-station [AddrParams addr2id [$AP1 node-addr]] ;#attach mn to basestation $WLAN_UE1 set X_ [expr 250.0] $WLAN_UE1 set Y_ 50.0 $WLAN_UE1 set Z_ 0.0 [$WLAN_UE1 set mac_(0)] set-channel 1 $ns at 0.0 "$WLAN_UE1 setdest 850.0 100.0 50.0" # add link to backbone puts "5 Connecting AP0 to RNC and Connecting AP1 to SGSN" puts "" $ns duplex-link $AP0 $RNC 10MBit 15ms DropTail 1000 $ns duplex-link $AP1 $SGSN 10MBit 15ms DropTail 1000 # add interfaces to MultiFaceNode $UE0 add-interface-node $WLAN_UE1 $UE0 add-interface-node $WLAN_UE0 $UE0 add-interface-node $UMTS_UE0 puts "***********************Completed successfully*****************" puts "##############################################################" puts "" puts "" # create a TCP agent and attach it to multi-interface node puts "##############################################################" puts "***************Generating traffic: using TcpApp***************" puts "" puts "1 Generating traffic between CN_host0 and mutilFacenNode0" set udp(0) [new Agent/UDP] $UE0 attach-agent $udp(0) $UMTS_UE0 ;# new command: the interface is used for sending set null(0) [new Agent/LossMonitor] $ns attach-agent $CN_host0 $null(0) $ns connect $udp(0) $null(0) set cbr(0) [new Application/Traffic/CBR] $cbr(0) attach-agent $udp(0) $cbr(0) set type_ CBR $cbr(0) set packet_size_ 500 $cbr(0) set rate_ 1mb $cbr(0) set random_ false $ns at 0.0 "$cbr(0) start" puts "" puts "2 Generating traffic between CN_host1 and WLAN_UE1" set udp(1) [new Agent/UDP] $UE0 attach-agent $udp(1) $CN_host0 ;# new command: the interface is used for sending set null(1) [new Agent/Null] $ns attach-agent $WLAN_UE0 $null(1) $ns connect $udp(1) $null(1) ########### set recoumts [new Agent/LossMonitor] $ns attach-agent $WLAN_UE0 $recoumts $ns connect $udp(1) $recoumts ########### set cbr(1) [new Application/Traffic/CBR] $cbr(1) attach-agent $udp(1) $cbr(1) set type_ CBR $cbr(1) set packet_size_ 1000 $cbr(1) set rate_ 1mb $cbr(1) set random_ false $ns at 1.0 "$cbr(1) start" puts "finished" puts "" ############################################################################################################## set udp(2) [new Agent/UDP] $UE0 attach-agent $udp(2) $WLAN_UE1 ;# the interface is used for sending set null(2) [new Agent/Null] $ns attach-agent $CN_host0 $null(2) $ns connect $udp(2) $null(2) set cbr(2) [new Application/Traffic/CBR] $cbr(2) attach-agent $udp(2) $cbr(2) set type_ CBR $cbr(2) set packet_size_ 500 $cbr(2) set rate_ 1mb $cbr(2) set random_ false $ns at 0.0 "$cbr(2) start" ############################################################################################################## # connect both TCP agent puts "3 Connecting send agent and recieve agent" #$UE0 connect-agent $tcp_(0) $tcp_(1) $UMTS_UE0 ;# new command: specify the interface to use #$tcp_(0) listen puts "finished" puts "" # do some kind of registration in UMTS puts "****************************************************************" puts "do some kind of registration in UMTS......" $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-DSCH, we must create. If any other, then use attach-hsdsch puts "Creating HS-DSCH for data transfering......" $ns create-hsdsch $UMTS_UE0 $udp(0) #$ns attach-hsdsch $UMTS_UE1 $udp(1) # we must set the trace for the environment. If not, then bandwidth is reduced and # packets are not sent the same way (it looks like they are queued, but TBC) puts "set trace for the environment......" $BS setErrorTrace 0 "idealtrace" #$BS setErrorTrace 1 "idealtrace" # load the CQI (Channel Quality Indication) puts "loading Channel Quality Indication......" $BS loadSnrBlerMatrix "SNRBLERMatrix" puts "finished" puts "****************************************************************" puts "################################################################" # we cannot start the connect right away. Give time to routing algorithm to run #$ns at 0.5 "$app_(1) connect $app_(0)" # install a procedure to print out the received data Application/TcpApp instproc recv {data} { global ns $ns trace-annotate "$self received data \"$data\"" puts "$self received data \"$data\"" } # function to redirect traffic from WLAN_UE0 to WLAN_UE0 proc redirectTraffic {} { puts "" puts "************it is time for handovering*********" puts "" global UE0 WLAN_UE0 WLAN_UE1 udp null CN_host0 ns $UE0 attach-agent $udp(0) $WLAN_UE1 ;# the interface is used for sending $UE0 connect-agent $udp(0) $null(0) $WLAN_UE1 ;# the interface is used for receiving #$UE1 attach-agent $udp(1) $WLAN_UE1 #$UE1 connect-agent $udp(1) $null(1) $WLAN_UE1 $UE0 attach-agent $udp(1) $CN_host0 ;# new command: the interface is used for sending $ns attach-agent $WLAN_UE1 $null(1) $ns connect $udp(1) $null(1) } # send a message via TcpApp # The string will be interpreted by the receiver as Tcl code. #for { set i 1 } { $i < 10 } { incr i} { # $ns at [expr $i + 0.5] "$app_(1) send 100 {$app_(0) recv {my message $i}}" #} # Initialize Flags set holdtime 0 set holdseq 0 set holdrate 0 #record the position of node proc record {} { global WLAN_UE0 null f0 f1 f2 holdtime holdseq holdrate set ns [Simulator instance] set time 0.1;# record 0.5 second set WLAN_UE0_x [$WLAN_UE0 set X_] set WLAN_UE0_y [$WLAN_UE0 set Y_] set now [$ns now] puts "$WLAN_UE0_x\t$WLAN_UE0_y" set bw0 [$null(0) set bytes_] set bw4 [$null(0) set nlost_] set bw8 [$null(0) set lastPktTime_] set bw9 [$null(0) set npkts_] set now [$ns now] # Record Bit Rate in Trace Files puts $f0 "$now [expr (($bw0+$holdrate)*8)/(2*$time*1000000)]" # puts $f0 "$now [expr ($bw0+$holdrate)/$time*8/1000000]" # Record Packet Loss Rate in File puts $f1 "$now [expr $bw4/$time]" # Record Packet Delay in File if { $bw9 > $holdseq } { puts $f2 "$now [expr ($bw8 - $holdtime)/($bw9 - $holdseq)]" } else { puts $f2 "$now [expr ($bw9 - $holdseq)]" } # Reset Variables $null(0) set bytes_ 0 $null(0) set nlost_ 0 set holdtime $bw8 set holdseq $bw9 set holdrate $bw0 $ns at [expr $now + $time] "record" } # Initialize Flags set holdtime1 0 set holdseq1 0 set holdrate1 0 proc record1 {} { global recoumts f01 f11 f21 holdtime1 holdseq1 holdrate1 set ns [Simulator instance] set time 0.5;# record 0.5 second set now [$ns now] set bw01 [$recoumts set bytes_] set bw41 [$recoumts set nlost_] set bw81 [$recoumts set lastPktTime_] set bw91 [$recoumts set npkts_] set now [$ns now] # Record Bit Rate in Trace Files puts $f01 "$now [expr (($bw01+$holdrate1)*8)/(2*$time*1000000)]" # puts $f0 "$now [expr ($bw0+$holdrate)/$time*8/1000000]" # Record Packet Loss Rate in File puts $f11 "$now [expr $bw41/$time]" # Record Packet Delay in File if { $bw91 > $holdseq1 } { puts $f21 "$now [expr ($bw81 - $holdtime1)/($bw91 - $holdseq1)]" } else { puts $f21 "$now [expr ($bw91 - $holdseq1)]" } # Reset Variables $recoumts set bytes_ 0 $recoumts set nlost_ 0 set holdtime1 $bw81 set holdseq1 $bw91 set holdrate1 $bw01 $ns at [expr $now + $time] "record1" } $ns at 0.0 "record" $ns at 0.0 "record1" # call to redirect traffic $ns at 3 "redirectTraffic" $ns at 3 "$ns trace-annotate \"Redirecting traffic\"" $ns at 5 "finish" puts " Simulation is running ... please wait ..." $ns run 2012/11/6 Basma Bejaoui <bejaoui.ba...@gmail.com> > > > ---------- Forwarded message ---------- > From: Basma Bejaoui <bejaoui.ba...@gmail.com> > Date: 2012/11/6 > Subject: Re: [ns] Multiface node problem > To: Nasim Ham <nhamay...@gmail.com> > > > Hi I already attach it, here it is again !! > > > 2012/11/5 Nasim Ham <nhamay...@gmail.com> > >> hi >> send your tcl , we may help you. >> >> >> On Tue, Nov 6, 2012 at 12:22 AM, Basma Bejaoui >> <bejaoui.ba...@gmail.com>wrote: >> >>> >>> >>> Hi every body >>> I simulate a scenario in which I have 3 networks >>> one umts and two wlan, a mobile node is multifaced : 2 interface wlan >>> and 1 >>> umts >>> >>> My scenario work so good if I use one AP, one UMTS_bs , and a mobile node >>> with 3 interfaces 2 wlan and one umts >>> >>> AP0 (4.0.0) --> interface WLAN_UE0 (4.0.1) >>> --> interface WLAN_UE1 (4.0.2) >>> UMTS_BS (0.0.1) -->interface umts_ue (0.0.2) >>> >>> But when I add another Basic station the traffic dont arrived to the >>> second >>> wlan interface >>> >>> AP0 (4.0.0) --> interface WLAN_UE0 (4.0.1) >>> AP1 (2.0.0) --> interface WLAN_UE1 (2.0.1) >>> UMTS_BS (0.0.1) -->interface umts_ue (0.0.2) >>> >>> the simulation starts by sending cbr traffic from umts interface to CN >>> then sending traffic from CN to interface WLAN_UE0 >>> then MN enters to the second WLAN, the CN stop sending to the interface >>> wlan_UE0 over AP0 , >>> CN send to interface WLAN_UE1 over AP1, but the traffic arrives to AP1 >>> only, and do not received by WLAN_UE1 >>> what 's the problem >>> >>> thank you for helping >>> >>> -- >>> *Cordialement* >>> *Basma Bejaoui* >>> *Ingénieur Informatique, Génie Télécommunication et Réseaux * >>> *+216 20 09 52 02 * >>> >>> >> > > > -- > *Cordialement* > *Basma Bejaoui* > *Ingénieur Informatique, Génie Télécommunication et Réseaux * > *+216 20 09 52 02 * > > > > > -- > *Cordialement* > *Basma Bejaoui* > *Ingénieur Informatique, Génie Télécommunication et Réseaux * > *+216 20 09 52 02 * > > -- *Cordialement* *Basma Bejaoui* *Ingénieur Informatique, Génie Télécommunication et Réseaux * *+216 20 09 52 02 *