NS2 / NS3 / MATLAB Project Implementation @ Low COST

Send Your Base Paper / Abstract to nsallinone@gmail.com  and get Implementation Details @ FREE

 

Aqusim (Under Water Sensor Network) in ns2

Overview: 

Underwater acoustic communication is a technique of sending and receiving message below water. There are several ways of employing such communication but the most common is using hydrophones. Under water communication is difficult due to factors like multi-path propagation, time variations of the channel, small available bandwidth and strong signal attenuation, especially over long ranges. In underwater communication there are low data rates compared to terrestrial communication, since underwater communication uses acoustic waves instead of electromagnetic waves.

Aqua-Sim Overview


Aqua-Sim can effectively simulate acoustic signal attenuation and packet collisions in underwater sensor networks. Moreover, Aqua-Sim supports three-dimensional deployment. Further, Aqua-Sim can easily be integrated with the existing codes in NS-2. Aqua-Sim is in parallel with the CMU wireless simulation package. As shown in the figure below, Aqua-Sim is independent of the wireless simulation package and is not affected by any change in the wireless package. On the other hand, any change to Aqua-Sim is also confined to itself and does not have any impact on other packages in NS-2. In this way, Aqua-Sim can evolve independently.

Advantages of Aqua-Sim 

  • Discrete-event driven network simulator 
  • Support 3D networks and mobile networks 
  • Simulate underwater acoustic channels with high fidelity 
  • Implement a complete protocol stack from physical layer to application layer

    Aqua-sim in ns2:

    TCL file:
     set opt(chan)               Channel/UnderwaterChannel  
    set opt(prop) Propagation/UnderwaterPropagation
    set opt(netif) Phy/UnderwaterPhy
    set opt(mac) Mac/UnderwaterMac/BroadcastMac
    set opt(ifq) Queue/DropTail
    set opt(ll) LL
    set opt(energy) EnergyModel
    set opt(txpower) 0.6
    set opt(rxpower) 0.3
    set opt(initialenergy) 10000
    set opt(idlepower) 0.01
    set opt(ant) Antenna/OmniAntenna ;#we don't use it in underwater
    set opt(filters) GradientFilter ;# options can be one or more of
    ;# TPP/OPP/Gear/Rmst/SourceRoute/Log/TagFilter
    set opt(max_pkts) 300
    set opt(interval_) 0.2 ;# [lindex $argv 0]
    set opt(pkt_len) 80; #[lindex $argv 2] ;# pkt length of cbr
    # the following parameters are set fot protocols
    set opt(bit_rate) 5.0e3 ;#[lindex $argv 1];#1.0e4 ;#bandwidth of the phy link
    set opt(encoding_efficiency) 1
    set opt(ND_window) 1
    set opt(ACKND_window) 1
    set opt(PhaseOne_window) 3
    set opt(PhaseTwo_window) 1
    set opt(PhaseTwo_interval) 0.5
    set opt(IntervalPhase2Phase3) 1
    set opt(duration) 0.1
    set opt(PhyOverhead) 8
    set opt(large_packet_size) 480 ;# 60 bytes
    set opt(short_packet_size) 40 ;# 5 bytes
    set opt(PhaseOne_cycle) 4 ;
    set opt(PhaseTwo_cycle) 2 ;
    set opt(PeriodInterval) 2
    set opt(transmission_time_error) 0.0001;
    set opt(dz) 10
    set opt(hop) 7 ;# [lindex $argv 4]
    set opt(ifqlen) 50 ;# max packet in ifq
    set opt(nn) [expr $opt(hop)+1] ;#5 ;# number of nodes in the network
    set opt(layers) 1
    set opt(x) 300 ;# X dimension of the topography
    set opt(y) 300 ;# Y dimension of the topography
    set opt(z) 10
    set opt(seed) 648.88
    set opt(stop) 1000 ;#[lindex $argv 3] ;#150 ;# simulation time
    set opt(prestop) 80 ;# time to prepare to stop
    set opt(tr) "uw_rwp.tr" ;# trace file
    set opt(nam) "uw_rwp.nam" ;# nam file
    set opt(adhocRouting) Vectorbasedforward
    set opt(width) 20
    set opt(adj) 10
    set opt(interval) 0.001
    set start_time 10
    # ==================================================================
    LL set mindelay_ 50us
    LL set delay_ 25us
    LL set bandwidth_ 0 ;# not used
    #Queue/DropTail/PriQueue set Prefer_Routing_Protocols 1
    # 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_ 0
    Antenna/OmniAntenna set Y_ 0
    Antenna/OmniAntenna set Z_ 1.5
    Antenna/OmniAntenna set Z_ 0.05
    Antenna/OmniAntenna set Gt_ 1.0
    Antenna/OmniAntenna set Gr_ 1.0
    Mac/UnderwaterMac set bit_rate_ $opt(bit_rate)
    Mac/UnderwaterMac set encoding_efficiency_ $opt(encoding_efficiency)
    #Mac/UnderwaterMac/AlohaOverhear set MaxResendInterval_ 0.2
    #Mac/UnderwaterMac/AlohaOverhear set DeltaDelay_ 1
    Node/MobileNode/UnderwaterSensorNode set position_update_interval_ 1.0
    # Initialize the SharedMedia interface with parameters to make
    # it work like the 914MHz Lucent WaveLAN DSSS radio interface
    Phy/UnderwaterPhy set CPThresh_ 100 ;#10.0
    Phy/UnderwaterPhy set CSThresh_ 0 ;#1.559e-11
    Phy/UnderwaterPhy set RXThresh_ 0 ;#3.652e-10
    #Phy/UnderwaterPhy set Rb_ 2*1e6
    Phy/UnderwaterPhy set Pt_ 0.2818
    Phy/UnderwaterPhy set freq_ 25 ;#frequency range in khz
    Phy/UnderwaterPhy set K_ 2.0 ;#spherical spreading
    # ==================================================================
    # Main Program
    # =================================================================
    #
    # Initialize Global Variables
    #
    #set sink_ 1
    #remove-all-packet-headers
    set ns_ [new Simulator]
    set topo [new Topography]
    $topo load_cubicgrid $opt(x) $opt(y) $opt(z)
    #$ns_ use-newtrace
    set tracefd [open $opt(tr) w]
    $ns_ trace-all $tracefd
    set nf [open $opt(nam) w]
    $ns_ namtrace-all-wireless $nf $opt(x) $opt(y)
    set total_number [expr $opt(nn)-1]
    set god_ [create-god $opt(nn)]
    set chan_1_ [new $opt(chan)]
    global defaultRNG
    $defaultRNG seed $opt(seed)
    $ns_ node-config -adhocRouting $opt(adhocRouting) \
    -llType $opt(ll) \
    -macType $opt(mac) \
    -ifqType $opt(ifq) \
    -ifqLen $opt(ifqlen) \
    -antType $opt(ant) \
    -propType $opt(prop) \
    -phyType $opt(netif) \
    #-channelType $opt(chan) \
    -agentTrace ON \
    -routerTrace ON \
    -macTrace ON \
    -movementTrace ON \
    -topoInstance $topo\
    -energyModel $opt(energy)\
    -txpower $opt(txpower)\
    -rxpower $opt(rxpower)\
    -initialEnergy $opt(initialenergy)\
    -idlePower $opt(idlepower)\
    -channel $chan_1_
    set node_(0) [$ns_ node 0]
    #$node_(0) set sinkStatus_ 1
    #$node_(0) set passive 1
    $god_ new_node $node_(0)
    $node_(0) set passive 1
    set a_(0) [new Agent/Null]
    $node_(0) set-mobilitypattern RWP
    $node_(0) set max_speed 5
    $node_(0) set min_speed 1
    $ns_ attach-agent $node_(0) $a_(0)
    for {set i 1} {$i<$total_number} {incr i} {
    set node_($i) [$ns_ node $i]
    $node_($i) set sinkStatus_ 1
    $god_ new_node $node_($i)
    $node_($i) set-cx 50
    $node_($i) set-cy 50
    $node_($i) set-cz 0
    $node_($i) set_next_hop [expr $i-1] ;# target is node 0
    $node_($i) set-mobilitypattern RWP
    $node_($i) set max_speed 5
    $node_($i) set min_speed 1
    }
    #puts "the total number is $total_number"
    set node_($total_number) [$ns_ node $total_number]
    $god_ new_node $node_($total_number)
    $node_($total_number) set-cx 50
    $node_($total_number) set-cy 50
    $node_($total_number) set-cz 0
    $node_($total_number) set_next_hop [expr $total_number-1] ;# target is node 0
    $node_($total_number) set-mobilitypattern RWP
    $node_($total_number) set max_speed 5
    $node_($total_number) set min_speed 1
    set a_($total_number) [new Agent/UDP]
    $ns_ attach-agent $node_($total_number) $a_($total_number)
    $ns_ connect $a_($total_number) $a_(0)
    set cbr_(0) [new Application/Traffic/CBR]
    $cbr_(0) set packetSize $opt(pkt_len) ;#80
    $cbr_(0) set interval_ $opt(interval_)
    $cbr_(0) set random 1
    $cbr_(0) set maxpkts_ $opt(max_pkts)
    $cbr_(0) attach-agent $a_($total_number)
    for {set i 0} { $i < $opt(nn)} {incr i} {
    $ns_ initial_node_pos $node_($i) 2
    $node_($i) setPositionUpdateInterval 0.01
    $node_($i) random-motion 0
    $ns_ at 5.0 "$node_($i) start-mobility-pattern"
    }
    $ns_ at $start_time "$cbr_(0) start"
    #$ns_ at 15 "$a_($total_number) cbr-start"
    #$ns_ at $start_time "$a_($total_number) exp-start"
    #$ns_ at 4 "$a_(0) cbr-start"
    #$ns_ at 2.0003 "$a_(2) cbr-start"
    #$ns_ at 0.1 "$a_(0) announce"
    puts "+++++++AFTER ANNOUNCE++++++++++++++"
    ;#$ns_ at $opt(stop).001 "$a_(0) terminate"
    ;#$ns_ at $opt(stop).002 "$a_($total_number) terminate"
    for {set i 1} {$i<$total_number} {incr i} {
    #;$ns_ at $opt(stop).002 "$a_($i) terminate"
    $ns_ at $opt(stop).002 "$node_($i) reset"
    }
    $ns_ at $opt(stop).003 "$god_ compute_energy"
    $ns_ at $opt(stop).004 "$ns_ nam-end-wireless $opt(stop)"
    $ns_ at $opt(stop).005 "puts \"NS EXISTING...\"; $ns_ halt"
    puts $tracefd "vectorbased"
    puts $tracefd "M 0.0 nn $opt(nn) x $opt(x) y $opt(y) z $opt(z)"
    puts $tracefd "M 0.0 prop $opt(prop) ant $opt(ant)"
    puts "starting Simulation..."
    $ns_ run

    
    

    OUTPUTS:

    NAM Window:

    Trace File:

    AQUSIM 3D View:
                           

    OBS Network in NS2

    Optical burst switching (OBS) Network:

     Optical Burst Switching (OBS) is an optical network technology that aims to improve the use of optical networks resources when compared to optical circuit switching (OCS). OBS is implemented using Wavelength Division Multiplexing (WDM), a data transmission technology that transmits data in an optical fibre by establishing several channels, each channel corresponding to a specific light wavelength.

    Optical Burst Switching is used in core networks, and viewed as a feasible compromise between the existing Optical Circuit Switching (OCS) and the yet not viable Optical Packet Switching (OPS).

    In OBS, packets are aggregated into data bursts at the edge of the network to form the data payload


    Techopedia explains Optical Burst Switching (OBS)

    Optical Burst Switching has several distinctive features: first, the packets are aggregated in the ingress (entry) node, for a very short period of time. This allows that packets that have the same
    constraints, e.g., the same destination address and maybe, the same quality of service requirements are sent together as a burst of data (therefore the term Burst in the concept name). When the burst arrives at the egress (exit) node, it is disassembled and its constituent packets routed to their destination.

    While the burst is being assembled in the ingress node, or possibly, after the burst has been assembled, a control packet (or header packet), containing the routing information for that burst is sent to the network, ahead of the burst. The time that separates the transmission of the control packet and the transmission of the burst is termed the offset time, and it must be long enough to allow all the routers in the predicted path the burst will take, to be configured, and only for the time needed for the burst to cross the network. When the network nodes are configured, the burst departs the ingress node and travels through the network in an all-optical form, using the circuit that was previously established by the control packet.

    The second characteristic of OBS is that the routing information is transmitted in the Control Packet and is not part of the data burst itself. In fact, the burst crosses the intermediate nodes in the
    network using the pre-established and pre-configured circuit in an agnostic manner, i.e., the node does not need to interpreted the data in the burst, and so, it does not need to know the format of the data in the burst. This is another special feature of OBS.

    Another distinctive characteristic of OBS is that the Control Packet will undergo optical to electronic to optical conversion at each intermediate node, and also optical to electronic conversion at the egress node, as to allow these nodes to be able to configure its optical switching devices. A final characteristic of OBS networks is that there is what is called a data and control plane separation, i.e., the channel that is used to transmit the control packets is specific and different from the channels that are used to transmit the data bursts.


    OBS simulator module for ns-2:

    The source code of OBS (optical burst switching) extension that I created for ns-2 simulator is here. It was presented and used in “nOBS: an ns2 based simulation tool for performance evaluation of TCP traffic in OBS networks” journal paper available here. Please read readme.txt file for details

    TCL script for OBS Network Topology:


    proc my-duplex-link {ns n1 n2 bw delay queue_method queue_length} {
    $ns optical-duplex-link $n1 $n2 $bw $delay $queue_method
    $ns queue-limit $n1 $n2 $queue_length
    $ns queue-limit $n2 $n1 $queue_length
    }


    proc my-duplex-link2 {ns n1 n2 bw delay queue_method queue_length} {
    $ns optical-simplex-link $n1 $n2 $bw $delay $queue_method
    $ns simplex-link $n2 $n1 $bw $delay DropTail
    $ns queue-limit $n1 $n2 $queue_length
    $ns queue-limit $n2 $n1 $queue_length
    }


    #Create a simulator object
    set ns [new Simulator] 

    #Variable Simulation settings: max burst size [50,100,200,300,400,500], timeout = [1:1:10] msec, simulation time: 200 sec, buffer = 2*500*1040 bytes, receive window = 500 packets.
    set settings [new OpticalDefaults] 
    $settings set MAX_PACKET_NUM 20
    $settings set TIMEOUT 7ms
    $settings set MAX_FLOW_QUEUE 5
    # The following are the default values for settings, only the above have been changed.
    #OpticalDefaults set MAX_PACKET_NUM 500;
    #OpticalDefaults set HOP_DELAY 0.00001;
    #OpticalDefaults set TIMEOUT 0.005;
    #OpticalDefaults set MAX_LAMBDA 1;
    #OpticalDefaults set LINKSPEED 1Gb;
    #OpticalDefaults set SWITCHTIME 0.000005;
    #OpticalDefaults set LIFETIME 0.1;
    #OpticalDefaults set DEBUG 3;
    #OpticalDefaults set MAX_DEST 40;
    #OpticalDefaults set BURST_HEADER 40;
    #OpticalDefaults set MAX_DELAYED_BURST 2;
    #OpticalDefaults set MAX_FLOW_QUEUE 1;
    $settings set MAX_DELAYED_BURST 5


    $ns color 12 Red
    $ns color 13 Yellow
    $ns color 14 Green
    $ns color 15 Purple
    $ns color 16 Black
    $ns color 17 Magenta
    $ns color 18 Brown
    $ns color 19 Orange
    $ns color 20 Red
    $ns color 21 Blue

    #Open the win size file
    set winfile [open windows.txt w]
    set goodfile [open goodput.txt w]


    #Open the nam trace file
    set nf [open out.nam w]
    $ns namtrace-all $nf

    # enable source routing

    $ns op_src_rting 1



    #Open the nam trace file
    set nf [open out.tr w]
    $ns trace-all $nf
    set f [open out.nam w]
    $ns namtrace-all $f

    #Start from zero when numbering the nodes. 

    #Create 2 optical nodes
    for {set i 0} {$i < 2} {incr i} {
                set n($i) [$ns OpNode]
       #define optical nodes
       set temp [$n($i) set src_agent_]
       $temp optic_nodes 0 1
       $temp set nodetype_ 0
       $temp set conversiontype_ 1
       $temp create
       #whether acks are burstified
       $temp set ackdontburst 1

       set temp [$n($i) set burst_agent_]
       $temp optic_nodes 0 1
       #whether acks are burstified
       $temp set ackdontburst 1

       set temp [$n($i) set classifier_]
       $temp optic_nodes 0 1

    }



    #Create 20 electronic nodes
    for {set i 2} {$i < 22} {incr i} {
                set n($i) [$ns node]
       
       #define optical nodes
       set temp [$n($i) set src_agent_]
       $temp optic_nodes 0 1
       

       
       set temp [$n($i) set classifier_]
       $temp optic_nodes 0 1
       
    }

    set queue_length 100000

    #Create links between the nodes
     my-duplex-link2 $ns $n(0) $n(1) 1000Mb 10ms OpQueue $queue_length

    #creating the error model
    set loss_module [new ErrorModel]
    $loss_module set rate_ 0.01
    $loss_module unit pkt
    $loss_module ranvar [new RandomVariable/Uniform]
    $loss_module drop-target [new ONA]
    #set whether burst or control packet will be dropped
    $loss_module set opticaldrop_ 2
    #Inserting Error Module
    $ns lossmodel $loss_module $n(0) $n(1)
    for {set i 2} {$i < 12} {incr i} {
    $ns duplex-link $n($i) $n(0) 155Mb 1ms DropTail
    $ns queue-limit $n($i) $n(0) $queue_length
    $ns queue-limit $n(0) $n($i) $queue_length
    }


    for {set i 12} {$i < 22} {incr i} { 
    $ns duplex-link $n($i) $n(1) 155Mb 1ms DropTail
    $ns queue-limit $n($i) $n(1) $queue_length
    $ns queue-limit $n(1) $n($i) $queue_length
    }




     set flow 0

     for {set i 2} {$i < 12} {incr i} {

      set d [expr $i + 10]

      #Create a TCP agent and attach it to node n0
    set cbr($i) [new Agent/TCP/Reno]
    $ns attach-agent $n($i) $cbr($i)
    $cbr($i) set fid_ $d
    $cbr($i) set fid2_ $flow
    $cbr($i) set window_ 10000

    $cbr($i) target [$n($i) set src_agent_]

    set ftp($i) [$cbr($i) attach-source FTP]


    set null($i) [new Agent/TCPSink]
    $ns attach-agent $n($d) $null($i)
    #$null($i) set fid_ $s  #This part is not working. Hard coded in tcp sink.cc
    $null($i) set fid2_ $flow

    $null($i) target [$n($d) set src_agent_]

    $ns connect $cbr($i) $null($i)

    incr flow

      set temp [$n($i) set src_agent_]
    $temp install_connection $d         $i $d   $i 0 1 $d
    set temp [$n($d) set src_agent_]
    $temp install_connection $i         $d $i   $d 1 0 $i

     $ns at [expr $i] “$ftp($i) start” 

     }
      set temp [$n(0) set src_agent_]
    $temp install_connection 1         0 1   0 1 
    set temp [$n(1) set src_agent_]
    $temp install_connection 0         1 0   1 0



    proc plotWindow {file} {
    global goodfile
    global ns
    global cbr
    set time 0.01
    set now [$ns now]
    puts -nonewline $file “$now”
    puts -nonewline $goodfile “$now”
    for {set i 2} {$i < 12} {incr i} {
    set cwnd($i) [$cbr($i) set cwnd_]
    puts -nonewline $file ” $cwnd($i)”
    puts -nonewline $goodfile ” “
    puts -nonewline  $goodfile [$cbr($i) set ack_]
    #puts -nonewline  $goodfile [expr  [$cbr($i) set ack_]/[expr $now-$i]]
    }
    puts $file “”
    puts $goodfile “”
    $ns at [expr $now+$time] “plotWindow $file”
    }

    proc finish {} {
            #global ns nf
    #global f
    global winfile
    global goodfile
            #$ns flush-trace
    #Close the trace file
            #close $f
    close $winfile
    #Execute nam on the trace file
            #exec ./nam out.nam 
    close $goodfile
            exit 0
    }


    #$ns at 1 “plotWindow $winfile”
    $ns at 10 “finish”
    $ns run


    NAM and Trace Output:

                                

    IPV6 (Internet Protocol version 6) in NS2

    Introduction:

    Internet Protocol version 6 (IPv6) is the latest version of the Internet Protocol (IP), the communications protocol that provides an identification and location system for computers on networks and routes traffic across the Internet. IPv6 was developed by the Internet Engineering Task Force (IETF) to deal with the long-anticipated problem of IPv4 address exhaustion.

    IPv4 Vs IPV6:

    On the Internet, data is transmitted in the form of network packets. IPv6 specifies a new packet format, designed to minimize packet header processing by routers. Because the headers of IPv4 packets and IPv6 packets are significantly different, the two protocols are not interoperable. However, in most respects, IPv6 is a conservative extension of IPv4. Most transport and application-layer protocols need little or no change to operate over IPv6; exceptions are application protocols that embed internet-layer addresses, such as FTP and NTPv3, where the new address format may cause conflicts with existing protocol syntax.

    IPV6 in Ns2:


    You can get ipv6 mobiwan patch file for ns2 from the below link,
    Tcl Script for Ipv6:


    # Basic Mobile IPv6 example without using ns-topoman
    # Needs proc defined in file proc-mipv6-config.tcl
    Agent/MIPv6/MN set bs_forwarding_     0       ; # 1 if forwarding from previous BS
    ################################################################
    proc log-mn-movement_no_topo { } {
      global logtimer ns
      Class LogTimer -superclass Timer
      LogTimer instproc timeout {} {
      global mobile_
            $mobile_ log-movement 
            $self sched 1 
      }
      set logtimer [new LogTimer]
      $logtimer sched 1  
    }
    ################################################################
    # Create Topology
    ################################################################
    proc create-my-topo {} {
      global ns opt topo mobile_ cn_ mnn_nodes_
      # Create and define topography
      set topo        [new Topography]
      #   set prop        [new $opt(prop)]
      #   $prop topography $topo
      $topo load_flatgrid 800 800 
      # god is a necessary object when wireless is used
      # set to a value equal to the number of mobile nodes
      create-god 5 
      # Call node-config
      $ns node-config \
            -addressType hierarchical \
      -agentTrace ON \
      -routerTrace ON 
      # Set NS Addressing
      AddrParams set domain_num_ 2 
      AddrParams set cluster_num_ {1 5}
      AddrParams set nodes_num_ {1 1 3 1 1 1}
      # Create Nodes
      set cn_ [create-router 0.0.0]
      set router_ [create-router 1.0.0]
      set bs1_ [create-base-station 1.1.0 1.0.0 200 200 0]
      set bs2_ [create-base-station 1.2.0 1.0.0 200 600 0]
      set bs3_ [create-base-station 1.3.0 1.0.0 600 200 0]
      set bs4_ [create-base-station 1.4.0 1.0.0 600 600 0]
      set mobile_ [create-mobile 1.1.1 1.1.0 190 190 0 1 0.01]
      # Create Links
      $ns duplex-link $cn_ $router_ 100Mb 1.80ms DropTail
      $ns duplex-link $router_ $bs1_ 100Mb 1.80ms DropTail
      $ns duplex-link $router_ $bs2_ 100Mb 1.80ms DropTail
      display_ns_addr_domain
    }
    ################################################################
    # End of Simulation
    ################################################################
    proc finish { } {
      global tracef ns namf opt mobile_ cn_
      
      puts “Simulation finished” 
      # Dump the Binding Update List of MN and Binding Cache of HA
      [[$mobile_ set ha_] set regagent_] dump
      [$cn_ set regagent_] dump
      [$mobile_ set regagent_] dump
      $ns flush-trace
      flush $tracef
      close $tracef
      close $namf
      #puts “running nam with $opt(namfile) … “
      #exec nam $opt(namfile) &
      exit 0
    }
    ################################################################
    # Main 
    ################################################################
    proc main { } {
       global opt ns TOPOM namf n tracef mobile_ cn_ 
       source ../../tcl/mobility/timer.tcl
       set NAMF out.nam
       set TRACEF out.tr
       set INFOF out.info
       set opt(mactrace) ON
       set opt(NAM) 1 
       set opt(namfile) $NAMF
       set opt(stop) 100
       set opt(tracefile) $TRACEF
       
       #>————— Extract options from command line —————<
       #Getopt ; # Get option from the command line
       #DisplayCommandLine
       
       #>———————- Simulator Settings ———————-<
       set ns [new Simulator]
       #>———————— Open trace files ———————-<
       exec rm -f $opt(tracefile)
       set tracef [open $opt(tracefile) w]
       #… dump the file
       $ns trace-all $tracef
        
       set namf [open $opt(namfile) w]
       $ns namtrace-all $namf
       #>————- Protocol and Topology Settings ——————-<
       create-my-topo
       log-mn-movement_no_topo
       
       set-cbr
       # set-ping-int 0.1 $cn_ $mobile_ 10 $opt(stop)
       #>———————– Run Simulation ————————-<
       $ns at $opt(stop) “finish”
       $ns run
       $ns dump-topology $namf
       close $namf
       #puts “running nam with $opt(namfile) … “
       #exec nam $opt(namfile) &
    }
    proc set-cbr { } {
       global ns cn_ mobile_
       set udp [new Agent/UDP]
       $ns attach-agent $cn_ $udp
       
       set dst [new Agent/Null]
       $ns attach-agent $mobile_ $dst
       $ns connect $udp $dst
       set src [new Application/Traffic/CBR]
       $src set packetSize_ 1000
       $src set rate_ 100k
       $src set interval_ .001
       $src attach-agent $udp
       $ns at 20.0 “$src start”
    main
    Outputs:



    (adsbygoogle = window.adsbygoogle || []).push({});

    Handoff in ns2 (Handoff between Wlan and UMTS networks)

    Vertical Handoff means handoff is between two network access points or Base Stations that uses the different network access technologies.


    Steps of Vertical Handoff

    1.System Discovery: 

                                  Mobile terminals equipped with multiple interfaces deploy a system discovery agent to determine which networks can be used and the services available in each network. 

    2. Handoff decision: 

                                   Based on several parameters like RSS, availability of free channel and service charges, the mobile devices determine which network it should connect to.

    3. Handoff execution: 

                                    The connections are rerouted from the existing network to the new network in a seamless manner.

    Input Parameters of Vertical Handoff process

    1. Available Bandwidth (BAV): It is the amount of unused bandwidth of the candidate Base Station (BS) or Access point (AP).WLAN have greater bandwidth than cellular Network (UMTS).

    2. Speed of mobile terminal (VMT ): It is the velocity with which the mobile terminal (MT) is moving. For high speed MT, UMTS is preferred because of greater coverage area.

    3. Number of Users (UN): The QoS of WLAN is UN sensitive. As the number of users increase, the collisions increase and results in poor QoS.

    4. Received Signal Strength (RSS): It is the strength of the signal received, as the RSS of the neighboring network rises above the threshold the Vertical Handoff is feasible i.e. the handoff takes place if and only if RSS of the BS or AP is above the threshold.

    Handoff in ns2: (TCL scripts)
     

    remove-all-packet-headers
    add-packet-header MPEG4 MAC_HS RLC LL Mac RTP TCP IP Common Flags
    set val(x) 1000
    set val(y) 1000
    set ns [new Simulator]
    global ns
    set f [open out.tr w]
    $ns trace-all $f
    set namtrace [open log.nam w]
    $ns namtrace-all-wireless $namtrace $val(x) $val(y)
    #set f0 [open proj_simple.tr w]
    proc finish {} {
    global ns
    global f namtrace
    $ns flush-trace
    close $f
    close $namtrace
    puts " Simulation ended."
    exec nam log.nam &
    exit 0
    exit 0
    }
    #for {set i 0} {$i < $val(nn)} {incr i} {
    # $ns initial_node_pos $n($i) 30+i*100
    #}
    #$ns at 0.0 "$n(0) setdest 76.0 224.0 30000.0"
    #$ns at 0.0 "$n(0) label node_0"
    #-----------------------------------------------------------------------------------------------------------------------------
    $ns set debug_ 0
    $ns set hsdschEnabled_ 1
    $ns set hsdsch_rlc_set_ 0
    $ns set hsdsch_rlc_nif_ 0
    $ns node-config -UmtsNodeType rnc
    # Node address is 0.
    set rnc [$ns create-Umtsnode]
    $ns node-config -UmtsNodeType bs \
    -downlinkBW 32kbs \
    -downlinkTTI 10ms \
    -uplinkBW 32kbs \
    -uplinkTTI 10ms \
    -hs_downlinkTTI 2ms \
    -hs_downlinkBW 64kbs \
    # Node address is 1.
    set bs [$ns create-Umtsnode]
    $ns setup-Iub $bs $rnc 622Mbit 622Mbit 15ms 15ms DummyDropTail 2000
    $ns node-config -UmtsNodeType ue \
    -baseStation $bs \
    -radioNetworkController $rnc
    # Node address for ue1 and ue2 is 2 and 3, respectively.
    set ue1 [$ns create-Umtsnode]
    set ue2 [$ns create-Umtsnode]
    # Node address for sgsn0 and ggsn0 is 4 and 5, respectively.
    set sgsn0 [$ns node]
    set ggsn0 [$ns node]
    # Node address for node1 and node2 is 6 and 7, respectively.
    set node1 [$ns node]
    set node2 [$ns node]
    $ns duplex-link $rnc $sgsn0 622Mbit 0.4ms DropTail 1000
    $ns duplex-link $sgsn0 $ggsn0 622MBit 10ms DropTail 1000
    $ns duplex-link $ggsn0 $node1 10MBit 15ms DropTail 1000
    $ns duplex-link $node1 $node2 10MBit 35ms DropTail 1000
    $rnc add-gateway $sgsn0
    set tcp0 [new Agent/UDP]
    $tcp0 set fid_ 0
    $tcp0 set prio_ 2
    $ns at 0.0 "$node1 label Node1"
    $ns at 0.0 "$node2 label Node2"
    $ns at 0.0 "$ue1 label Umtsnode1"
    $ns at 0.0 "$ue2 label Umtsnode2"
    $ns at 0.0 "$bs label Base_Station"
    $ns at 0.0 "$bs label Base_Station"
    $ns at 0.0 "$sgsn0 label Node_1"
    $ns at 0.0 "$ggsn0 label Node_2"
    $ns at 0.0 "$rnc label Node_0"
    $node1 set X_ 119.0
    $node1 set Y_ 38.0
    $node1 set Z_ 0.0
    $bs set X_ 31.0
    $bs set Y_ 35.0
    $bs set Z_ 0.0
    $node2 set X_ 138.0
    $node2 set Y_ 3.0
    $node2 set Z_ 0.0
    $ue1 set X_ 7.0
    $ue1 set Y_ 72.0
    $ue1 set Z_ 0.0
    $ue2 set X_ 66.0
    $ue2 set Y_ 77.0
    $ue2 set Z_ 0.0
    $sgsn0 set X_ 71.0
    $sgsn0 set Y_ 37.0
    $sgsn0 set Z_ 0.0
    $ggsn0 set X_ 101.0
    $ggsn0 set Y_ 2.0
    $ggsn0 set Z_ 0.0
    $rnc set X_ 58.0
    $rnc set Y_ 4.0
    $rnc set Z_ 0.0
    $ns attach-agent $rnc $tcp0
    set ftp0 [new Application/Traffic/CBR]
    $ftp0 attach-agent $tcp0
    set sink0 [new Agent/Null]
    $sink0 set fid_ 0
    $ns attach-agent $ue1 $sink0
    $ns connect $tcp0 $sink0
    $ns node-config -llType UMTS/RLC/UM \
    -downlinkBW 64kbs \
    -uplinkBW 64kbs \
    -downlinkTTI 20ms \
    -uplinkTTI 20ms \
    -hs_downlinkTTI 2ms \
    -hs_downlinkBW 64kbs
    $ns create-hsdsch $ue1 $sink0
    $bs setErrorTrace 0 "/home/naveen/idealtrace"
    $bs setErrorTrace 1 "/home/naveen/idealtrace"
    $bs loadSnrBlerMatrix "/home/naveen/SNRBLERMatrix"
    #set dch0 [$ns create-dch $ue1 $sink0]
    $ue1 trace-inlink $f 1
    $bs trace-outlink $f 1
    #$rnc trace-inlink-tcp $f 0
    # tracing for all hsdpa traffic in downtarget
    $rnc trace-inlink-tcp $f 0
    $bs trace-outlink $f 2
    # per UE
    $ue1 trace-inlink $f 2
    $ue1 trace-outlink $f 3
    $bs trace-inlink $f 3
    $ue1 trace-inlink-tcp $f 2
    #______________________________________________________________
    set val(chan) Channel/WirelessChannel ;# channel type
    set val(prop) Propagation/TwoRayGround ;# radio-propagation model
    set val(ant) Antenna/OmniAntenna ;# Antenna type
    set val(ll) LL ;# Link layer type
    set val(ifq) Queue/DropTail/PriQueue ;# Interface queue type
    set val(ifqlen) 2000 ;# max packet in ifq
    set val(netif) Phy/WirelessPhy ;# network interface type
    set val(mac) Mac/802_11 ;# MAC type
    set val(nn) 51 ;# number of mobilenodes
    set val(rp) OPTG ;# routing protocol
    set umtsflow "umtsflow"
    set umts "umts"
    set topo [new Topography]
    $topo load_flatgrid $val(x) $val(y)
    #===========================================================================
    create-god $val(nn)
    #===========================================================================
    set chan_1 [new $val(chan)]
    $ns node-config -adhocRouting $val(rp) \
    -llType $val(ll) \
    -macType $val(mac) \
    -ifqType $val(ifq) \
    -ifqLen $val(ifqlen) \
    -antType $val(ant) \
    -propType $val(prop) \
    -phyType $val(netif) \
    -topoInstance $topo \
    -agentTrace ON \
    -routerTrace ON \
    -macTrace ON \
    -movementTrace OFF \
    -channel $chan_1 \
    -energyModel EnergyModel \
    -initialEnergy 20 \
    -txPower 0.09 \
    -rxPower 0.08 \
    -idlePower 0.0 \
    -sensePower 0.0175
    set n(0) [$ns node]
    $ns at 0.0 "$n(0) color blue"
    $n(0) color red
    $n(0) shape "circle"
    set n(1) [$ns node]
    $ns at 0.0 "$n(1) color red"
    $n(1) color red
    $n(1) shape "circle"
    set n(2) [$ns node]
    $ns at 0.0 "$n(2) color darkgreen"
    $n(2) color red
    $n(2) shape "circle"
    #-------------------
    set n(7) [$ns node]
    $ns at 0.0 "$n(7) color red"
    $n(7) color red
    $n(7) shape "circle"
    set n(8) [$ns node]
    $ns at 0.0 "$n(8) color red"
    $n(8) color red
    $n(8) shape "circle"
    set n(9) [$ns node]
    $ns at 0.0 "$n(9) color red"
    $n(9) color red
    $n(9) shape "circle"
    set n(10) [$ns node]
    $ns at 0.0 "$n(10) color red"
    $n(10) color red
    $n(10) shape "circle"
    set n(11) [$ns node]
    $ns at 0.0 "$n(11) color red"
    $n(11) color red
    $n(11) shape "circle"
    set n(12) [$ns node]
    $ns at 0.0 "$n(12) color red"
    $n(12) color red
    $n(12) shape "circle"
    set n(13) [$ns node]
    $ns at 0.0 "$n(13) color red"
    $n(13) color red
    $n(13) shape "circle"
    set n(14) [$ns node]
    $ns at 0.0 "$n(14) color red"
    $n(14) color red
    $n(14) shape "circle"
    set n(15) [$ns node]
    $ns at 0.0 "$n(15) color red"
    $n(15) color red
    $n(15) shape "circle"
    set n(16) [$ns node]
    $ns at 0.0 "$n(16) color red"
    $n(16) color red
    $n(16) shape "circle"
    set n(17) [$ns node]
    $ns at 0.0 "$n(17) color red"
    $n(17) color red
    $n(0) shape "circle"
    set n(18) [$ns node]
    $ns at 0.0 "$n(18) color red"
    $n(18) color red
    $n(18) shape "circle"
    set n(19) [$ns node]
    $ns at 0.0 "$n(19) color red"
    $n(19) color red
    $n(19) shape "circle"
    set n(20) [$ns node]
    $ns at 0.0 "$n(20) color red"
    $n(20) color red
    $n(20) shape "circle"
    set n(21) [$ns node]
    $ns at 0.0 "$n(21) color darkgreen"
    $n(21) color red
    $n(21) shape "circle"
    set n(22) [$ns node]
    $ns at 0.0 "$n(22) color red"
    $n(22) color red
    $n(22) shape "circle"
    set n(23) [$ns node]
    $ns at 0.0 "$n(23) color red"
    $n(23) color red
    $n(23) shape "circle"
    set n(24) [$ns node]
    $ns at 0.0 "$n(24) color red"
    $n(24) color red
    $n(24) shape "circle"
    set n(25) [$ns node]
    $ns at 0.0 "$n(25) color red"
    $n(25) color red
    $n(25) shape "circle"
    set n(26) [$ns node]
    $ns at 0.0 "$n(26) color darkgreen"
    $n(26) color red
    $n(26) shape "circle"
    set n(27) [$ns node]
    $ns at 0.0 "$n(27) color red"
    $n(27) color red
    $n(27) shape "circle"
    set n(28) [$ns node]
    $ns at 0.0 "$n(28) color red"
    $n(28) color green
    $n(28) shape "square"
    set n(29) [$ns node]
    $ns at 0.0 "$n(29) color red"
    $n(29) color green
    $n(29) shape "square"
    set n(30) [$ns node]
    $ns at 0.0 "$n(30) color darkgreen"
    $n(30) color green
    $n(30) shape "circle"
    set n(31) [$ns node]
    $ns at 0.0 "$n(31) color red"
    $n(31) color green
    $n(31) shape "circle"
    set n(32) [$ns node]
    $ns at 0.0 "$n(32) color red"
    $n(32) color green
    $n(32) shape "circle"
    set n(33) [$ns node]
    $ns at 0.0 "$n(33) color red"
    $n(33) color green
    $n(33) shape "circle"
    set n(34) [$ns node]
    $ns at 0.0 "$n(34) color darkgreen"
    $n(34) color green
    $n(34) shape "circle"
    set n(35) [$ns node]
    $ns at 0.0 "$n(35) color red"
    $n(35) color green
    $n(35) shape "square"
    set n(36) [$ns node]
    $ns at 0.0 "$n(36) color red"
    $n(36) color green
    $n(36) shape "square"
    set n(37) [$ns node]
    $ns at 0.0 "$n(37) color red"
    $n(37) color green
    $n(37) shape "circle"
    set n(38) [$ns node]
    $ns at 0.0 "$n(38) color darkgreen"
    $n(38) color green
    $n(38) shape "square"
    set n(39) [$ns node]
    $ns at 0.0 "$n(39) color red"
    $n(39) color green
    $n(39) shape "square"
    set n(40) [$ns node]
    $ns at 0.0 "$n(40) color red"
    $n(40) color green
    $n(40) shape "circle"
    set n(41) [$ns node]
    $ns at 0.0 "$n(41) color red"
    $n(41) color green
    $n(41) shape "circle"
    set n(42) [$ns node]
    $ns at 0.0 "$n(42) color red"
    $n(42) color green
    $n(42) shape "circle"
    set n(43) [$ns node]
    $ns at 0.0 "$n(43) color red"
    $n(43) color green
    $n(43) shape "circle"
    set n(44) [$ns node]
    $ns at 0.0 "$n(44) color red"
    $n(44) color green
    $n(44) shape "circle"
    set n(45) [$ns node]
    $ns at 0.0 "$n(45) color darkgreen"
    $n(45) color green
    $n(45) shape "square"
    set n(46) [$ns node]
    $ns at 0.0 "$n(46) color red"
    $n(46) color green
    $n(46) shape "square"
    set n(47) [$ns node]
    $ns at 0.0 "$n(47) color red"
    $n(47) color green
    $n(47) shape "circle"
    set n(48) [$ns node]
    $ns at 0.0 "$n(48) color red"
    $n(48) color green
    $n(48) shape "square"
    set n(50) [$ns node]
    $ns at 0.0 "$n(50) color darkgreen"
    $n(50) color green
    $n(50) shape "square"
    set n(49) [$ns node]
    $ns at 0.0 "$n(49) color darkgreen"
    $n(49) color green
    $n(49) shape "square"
    #--------
    set n(6) [$ns node]
    $ns at 0.0 "$n(6) color red"
    $ns at 2.81 "$n(6) color green"
    $ns at 2.82 "$n(6) color red"
    $ns at 2.83 "$n(6) color green"
    $ns at 2.84 "$n(6) color red"
    $ns at 2.85 "$n(6) color green"
    $ns at 2.86 "$n(6) color red"
    $ns at 2.87 "$n(6) color green"
    $ns at 2.88 "$n(6) color red"
    $ns at 2.89 "$n(6) color green"
    $ns at 2.90 "$n(6) color red"
    $ns at 3.83 "$n(40) color green"
    $ns at 3.84 "$n(40) color red"
    $ns at 3.842 "$n(40) color green"
    $ns at 3.845 "$n(40) color red"
    $ns at 3.85 "$n(40) color green"
    $ns at 3.86 "$n(40) color red"
    $n(6) color red
    $n(6) shape "circle"
    $ns at 0.0 "$n(0) label WLAN_NODE1"
    $ns at 0.0 "$n(1) label WLAN_NODE2"
    $ns at 0.0 "$n(2) label WLAN_BaseStation"
    $ns at 0.0 "$n(50) label NODE"
    $n(0) label-color black
    $n(1) label-color black
    $n(2) label-color black
    for {set i 0} {$i < 3} {incr i} {
    $ns initial_node_pos $n($i) 10+i*10
    }
    $n(0) set X_ 58.0
    $n(0) set Y_ 136.0
    $n(0) set Z_ 0.0
    $n(2) set X_ 34.0
    $n(2) set Y_ 104.0
    $n(2) set Z_ 0.0
    $n(1) set X_ 0.5
    $n(1) set Y_ 136.0
    $n(1) set Z_ 0.0
    $n(6) set X_ 6.0
    $n(6) set Y_ 94.0
    $n(6) set Z_ 0.0
    $ns at 0.0 "$n(0) setdest 58.0 136.0 100000.0"
    $ns at 0.0 "$n(2) setdest 25.0 111.0 100000.0"
    $ns at 0.0 "$n(1) setdest 0.5 136.0 100000.0"
    $ns at 0.0 "$n(6) setdest 6.0 94.0 100000.0"
    $ns at 2.0 "$n(6) setdest 46.0 76.0 100.0"
    $ns at 2.6 "$n(6) setdest 46.0 66.0 10.0"
    #---
    $ns at 0.0 "$n(7) setdest 300.0 500.0 10000.0"
    $ns at 0.0 "$n(8) setdest 300.0 700.0 10000.0"
    $ns at 0.0 "$n(9) setdest 300.0 900.0 10000.0"
    $ns at 0.0 "$n(10) setdest 500.0 100.0 10000.0"
    $ns at 0.0 "$n(11) setdest 500.0 300.0 10000.0"
    $ns at 0.0 "$n(12) setdest 500.0 500.0 10000.0"
    $ns at 0.0 "$n(13) setdest 500.0 700.0 10000.0"
    $ns at 0.0 "$n(14) setdest 500.0 900.0 10000.0"
    $ns at 0.0 "$n(15) setdest 700.0 100.0 10000.0"
    $ns at 0.0 "$n(16) setdest 700.0 300.0 10000.0"
    $ns at 0.0 "$n(17) setdest 700.0 500.0 10000.0"
    $ns at 0.0 "$n(18) setdest 700.0 700.0 10000.0"
    $ns at 0.0 "$n(19) setdest 700.0 900.0 10000.0"
    $ns at 0.0 "$n(20) setdest 900.0 100.0 10000.0"
    $ns at 0.0 "$n(21) setdest 900.0 300.0 10000.0"
    $ns at 0.0 "$n(22) setdest 900.0 500.0 10000.0"
    $ns at 0.0 "$n(23) setdest 900.0 700.0 10000.0"
    $ns at 0.0 "$n(24) setdest 900.0 900.0 10000.0"
    $ns at 0.0 "$n(25) setdest 579.0 425.0 10000.0"
    $ns at 0.0 "$n(26) setdest 450.0 10.0 10000.0"
    $ns at 0.0 "$n(27) setdest 999.0 500.0 10000.0"
    $ns at 0.0 "$n(28) setdest 999.0 700.0 10000.0"
    $ns at 0.0 "$n(29) setdest 999.0 300.0 10000.0"
    $ns at 0.0 "$n(30) setdest 749.0 189.0 10000.0"
    $ns at 0.0 "$n(31) setdest 850.0 300.0 10000.0"
    $ns at 0.0 "$n(32) setdest 750.0 500.0 10000.0"
    $ns at 0.0 "$n(33) setdest 550.0 700.0 10000.0"
    $ns at 0.0 "$n(34) setdest 550.0 900.0 10000.0"
    $ns at 0.0 "$n(35) setdest 220.1 257.1 10000.0"
    $ns at 4.4 "$n(35) setdest 51.1 91.1 100.0"
    $ns at 0.0 "$n(36) setdest 400.0 10.0 10000.0"
    $ns at 0.0 "$n(37) setdest 649.0 500.0 10000.0"
    $ns at 0.0 "$n(38) setdest 419.0 610.0 10000.0"
    $ns at 0.0 "$n(39) setdest 349.0 300.0 10000.0"
    $ns at 0.0 "$n(40) setdest 150.0 100.0 10000.0"
    $ns at 0.0 "$n(41) setdest 250.0 400.0 10000.0"
    $ns at 0.0 "$n(42) setdest 350.0 550.0 10000.0"
    $ns at 0.0 "$n(43) setdest 450.0 750.0 10000.0"
    $ns at 0.0 "$n(44) setdest 550.0 950.0 10000.0"
    $ns at 0.0 "$n(45) setdest 314.1 135.1 10000.0"
    $ns at 0.0 "$n(46) setdest 550.0 50.0 10000.0"
    $ns at 0.0 "$n(47) setdest 784.0 372.0 10000.0"
    $ns at 0.0 "$n(48) setdest 649.0 750.0 10000.0"
    $ns at 0.0 "$n(49) setdest 749.0 450.0 10000.0"
    $ns at 0.0 "$n(50) setdest 8.0 186.0 10000.0"
    $ns at 4.0 "$n(50) setdest 30.0 147.0 100.0"
    $ns at 3.1 "$n(8) setdest 100.0 500.0 10.0"
    $ns at 3.1 "$n(9) setdest 100.0 100.0 10.0"
    $ns at 3.1 "$n(10) setdest 700.0 300.0 10.0"
    $ns at 3.1 "$n(11) setdest 700.0 500.0 10.0"
    $ns at 3.1 "$n(12) setdest 500.0 500.0 10.0"
    $ns at 3.1 "$n(13) setdest 300.0 500.0 10.0"
    $ns at 3.1 "$n(14) setdest 300.0 700.0 10.0"
    $ns at 3.1 "$n(15) setdest 700.0 900.0 10.0"
    $ns at 3.1 "$n(16) setdest 900.0 500.0 10.0"
    $ns at 3.1 "$n(17) setdest 500.0 700.0 10.0"
    $ns at 3.1 "$n(18) setdest 500.0 900.0 10.0"
    $ns at 3.1 "$n(19) setdest 300.0 900.0 10.0"
    $ns at 3.1 "$n(20) setdest 900.0 700.0 10.0"
    $ns at 3.1 "$n(21) setdest 900.0 900.0 10.0"
    $ns at 3.1 "$n(22) setdest 700.0 700.0 10.0"
    $ns at 3.1 "$n(23) setdest 100.0 900.0 10.0"
    $ns at 3.1 "$n(24) setdest 100.0 700.0 10.0"
    $ns at 3.1 "$n(27) setdest 999.0 500.0 10.0"
    $ns at 3.1 "$n(28) setdest 999.0 700.0 10.0"
    $ns at 3.1 "$n(29) setdest 999.0 900.0 10.0"
    $ns at 3.0 "$n(30) setdest 950.0 100.0 10.0"
    $ns at 3.0 "$n(31) setdest 850.0 300. 10.0"
    $ns at 3.0 "$n(32) setdest 750.0 500.0 10.0"
    $ns at 3.0 "$n(33) setdest 550.0 700.0 10.0"
    $ns at 3.0 "$n(34) setdest 550.0 900.0 10.0"
    $ns at 3.0 "$n(35) setdest 50.1 0.1 10.0"
    $ns at 3.0 "$n(36) setdest 400.0 10.0 10.0"
    $ns at 3.0 "$n(37) setdest 649.0 500.0 10.0"
    $ns at 3.0 "$n(38) setdest 549.0 700.0 10.0"
    $ns at 3.0 "$n(39) setdest 349.0 300.0 10.0"
    $ns at 2.8 "$n(40) setdest 83.0 111.0 100.0"
    $ns at 3.5 "$n(40) setdest 95.0 67.0 100.0"
    $ns at 3.0 "$n(41) setdest 250.0 400.0 10.0"
    $ns at 3.0 "$n(42) setdest 350.0 550.0 10.0"
    $ns at 3.0 "$n(43) setdest 450.0 750.0 10.0"
    $ns at 3.0 "$n(44) setdest 550.0 950.0 10.0"
    $ns at 3.0 "$n(45) setdest 50.1 50.1 10.0"
    $ns at 3.0 "$n(46) setdest 550.0 50.0 10.0"
    $ns at 3.0 "$n(47) setdest 849.0 550.0 10.0"
    $ns at 3.0 "$n(48) setdest 649.0 750.0 10.0"
    $ns at 3.0 "$n(49) setdest 749.0 450.0 10.0"
    #--
    set sink9 [new Agent/LossMonitor]
    set sink10 [new Agent/LossMonitor]
    set sink11 [new Agent/LossMonitor]
    set sink15 [new Agent/LossMonitor]
    set sink16 [new Agent/LossMonitor]
    set sink17 [new Agent/LossMonitor]
    set sink18 [new Agent/LossMonitor]
    set sink19 [new Agent/LossMonitor]
    set sink20 [new Agent/LossMonitor]
    set sink21 [new Agent/LossMonitor]
    set sink22 [new Agent/LossMonitor]
    set sink23 [new Agent/LossMonitor]
    set sink24 [new Agent/LossMonitor]
    set sink25 [new Agent/LossMonitor]
    set sink26 [new Agent/LossMonitor]
    set sink27 [new Agent/LossMonitor]
    set sink28 [new Agent/LossMonitor]
    set sink29 [new Agent/LossMonitor]
    set sink30 [new Agent/LossMonitor]
    set sink31 [new Agent/LossMonitor]
    set sink32 [new Agent/LossMonitor]
    set sink33 [new Agent/LossMonitor]
    set sink34 [new Agent/LossMonitor]
    set sink35 [new Agent/LossMonitor]
    set sink36 [new Agent/LossMonitor]
    set sink37 [new Agent/LossMonitor]
    set sink38 [new Agent/LossMonitor]
    set sink39 [new Agent/LossMonitor]
    set sink40 [new Agent/LossMonitor]
    set sink41 [new Agent/LossMonitor]
    set sink42 [new Agent/LossMonitor]
    set sink43 [new Agent/LossMonitor]
    set sink44 [new Agent/LossMonitor]
    set sink45 [new Agent/LossMonitor]
    set sink46 [new Agent/LossMonitor]
    set sink47 [new Agent/LossMonitor]
    set sink48 [new Agent/LossMonitor]
    set sink49 [new Agent/LossMonitor]
    $ns attach-agent $n(0) $sink9
    $ns attach-agent $n(1) $sink10
    $ns attach-agent $n(2) $sink11
    $ns attach-agent $n(6) $sink15
    $ns attach-agent $n(16) $sink16
    $ns attach-agent $n(17) $sink17
    $ns attach-agent $n(18) $sink18
    $ns attach-agent $n(19) $sink19
    $ns attach-agent $n(20) $sink20
    $ns attach-agent $n(21) $sink21
    $ns attach-agent $n(22) $sink22
    $ns attach-agent $n(23) $sink23
    $ns attach-agent $n(24) $sink24
    $ns attach-agent $n(25) $sink25
    $ns attach-agent $n(26) $sink26
    $ns attach-agent $n(27) $sink27
    $ns attach-agent $n(28) $sink28
    $ns attach-agent $n(29) $sink29
    $ns attach-agent $n(30) $sink30
    $ns attach-agent $n(31) $sink31
    $ns attach-agent $n(32) $sink32
    $ns attach-agent $n(33) $sink33
    $ns attach-agent $n(34) $sink34
    $ns attach-agent $n(35) $sink35
    $ns attach-agent $n(36) $sink36
    $ns attach-agent $n(37) $sink37
    $ns attach-agent $n(38) $sink38
    $ns attach-agent $n(39) $sink39
    $ns attach-agent $n(40) $sink40
    $ns attach-agent $n(41) $sink41
    $ns attach-agent $n(42) $sink42
    $ns attach-agent $n(43) $sink43
    $ns attach-agent $n(44) $sink44
    $ns attach-agent $n(45) $sink45
    $ns attach-agent $n(46) $sink46
    $ns attach-agent $n(47) $sink47
    $ns attach-agent $n(48) $sink48
    $ns attach-agent $n(49) $sink49
    set tcp9 [new Agent/TCP]
    $ns attach-agent $n(0) $tcp9
    set tcp10 [new Agent/TCP]
    $ns attach-agent $n(1) $tcp10
    set tcp11 [new Agent/TCP]
    $ns attach-agent $n(2) $tcp11set tcp15 [new Agent/TCP]
    $ns attach-agent $n(6) $tcp15
    set tcp16 [new Agent/TCP]
    $ns attach-agent $n(16) $tcp16
    set tcp17 [new Agent/TCP]
    $ns attach-agent $n(17) $tcp17
    set tcp18 [new Agent/TCP]
    $ns attach-agent $n(18) $tcp18
    set tcp19 [new Agent/TCP]
    $ns attach-agent $n(19) $tcp19
    set tcp20 [new Agent/TCP]
    $ns attach-agent $n(20) $tcp20
    set tcp21 [new Agent/TCP]
    $ns attach-agent $n(21) $tcp21
    set tcp22 [new Agent/TCP]
    $ns attach-agent $n(22) $tcp22
    set tcp23 [new Agent/TCP]
    $ns attach-agent $n(23) $tcp23
    set tcp24 [new Agent/TCP]
    $ns attach-agent $n(24) $tcp24
    set tcp25 [new Agent/TCP]
    $ns attach-agent $n(25) $tcp25
    set tcp26 [new Agent/TCP]
    $ns attach-agent $n(26) $tcp26
    set tcp27 [new Agent/TCP]
    $ns attach-agent $n(27) $tcp27
    set tcp28 [new Agent/TCP]
    $ns attach-agent $n(28) $tcp28
    set tcp29 [new Agent/TCP]
    $ns attach-agent $n(29) $tcp29
    set tcp30 [new Agent/TCP]
    $ns attach-agent $n(30) $tcp30
    set tcp31 [new Agent/TCP]
    $ns attach-agent $n(31) $tcp31
    set tcp32 [new Agent/TCP]
    $ns attach-agent $n(32) $tcp32
    set tcp33 [new Agent/TCP]
    $ns attach-agent $n(33) $tcp33
    set tcp34 [new Agent/TCP]
    $ns attach-agent $n(34) $tcp34
    set tcp35 [new Agent/TCP]
    $ns attach-agent $n(35) $tcp35
    set tcp36 [new Agent/TCP]
    $ns attach-agent $n(36) $tcp36
    set tcp37 [new Agent/TCP]
    $ns attach-agent $n(37) $tcp37
    set tcp38 [new Agent/TCP]
    $ns attach-agent $n(38) $tcp38
    set tcp39 [new Agent/TCP]
    $ns attach-agent $n(39) $tcp39
    set tcp40 [new Agent/TCP]
    $ns attach-agent $n(40) $tcp40
    set tcp41 [new Agent/TCP]
    $ns attach-agent $n(41) $tcp41
    set tcp42 [new Agent/TCP]
    $ns attach-agent $n(42) $tcp42
    set tcp43 [new Agent/TCP]
    $ns attach-agent $n(43) $tcp43
    set tcp44 [new Agent/TCP]
    $ns attach-agent $n(44) $tcp44
    set tcp45 [new Agent/TCP]
    $ns attach-agent $n(45) $tcp45
    set tcp46 [new Agent/TCP]
    $ns attach-agent $n(46) $tcp46
    set tcp47 [new Agent/TCP]
    $ns attach-agent $n(47) $tcp47
    set tcp48 [new Agent/TCP]
    $ns attach-agent $n(48) $tcp48
    set tcp49 [new Agent/TCP]
    $ns attach-agent $n(49) $tcp49
    source umts
    proc attach-CBR-traffic { node sink size interval } {
    #Get an instance of the simulator
    set ns [Simulator instance]
    #Create a CBR agent and attach it to the node
    set cbr [new Agent/CBR]
    $ns attach-agent $node $cbr
    $cbr set packetSize_ $size
    $cbr set interval_ $interval
    #Attach CBR source to sink;
    $ns connect $cbr $sink
    return $cbr
    }
    #======================================================================================
    set cbr2112 [attach-CBR-traffic $n(0) $sink11 500 .03]
    set cbr2113 [attach-CBR-traffic $n(14) $sink34 500 .03]
    set cbr2114 [attach-CBR-traffic $n(44) $sink34 500 .03]
    set cbr2115 [attach-CBR-traffic $n(17) $sink49 500 .03]
    set cbr2116 [attach-CBR-traffic $n(32) $sink49 500 .03]
    set cbr2117 [attach-CBR-traffic $n(31) $sink21 500 .03]
    set cbr2118 [attach-CBR-traffic $n(29) $sink21 500 .03]
    set cbr2119 [attach-CBR-traffic $n(47) $sink49 500 .03]
    set cbr2120 [attach-CBR-traffic $n(36) $sink26 500 .03]
    set cbr2121 [attach-CBR-traffic $n(46) $sink26 500 .03]
    set cbr2122 [attach-CBR-traffic $n(30) $sink15 500 .03]
    set cbr2123 [attach-CBR-traffic $n(20) $sink30 500 .03]
    set cbr2124 [attach-CBR-traffic $n(42) $sink38 500 .03]
    set cbr2125 [attach-CBR-traffic $n(13) $sink38 500 .03]
    set cbr2126 [attach-CBR-traffic $n(41) $sink45 500 .03]
    $ns at 0.1 "$cbr2112 start"
    $ns at 0.192 "$cbr2113 start"
    $ns at 0.167 "$cbr2114 start"
    $ns at 0.1001 "$cbr2115 start"
    $ns at 0.155 "$cbr2116 start"
    $ns at 0.142 "$cbr2117 start"
    $ns at 0.131 "$cbr2118 start"
    $ns at 0.121 "$cbr2119 start"
    $ns at 0.111 "$cbr2120 start"
    $ns at 0.1911 "$cbr2121 start"
    $ns at 0.2111 "$cbr2122 start"
    $ns at 0.241 "$cbr2123 start"
    $ns at 0.2 "$cbr2124 start"
    $ns at 0.21 "$cbr2125 start"
    $ns at 0.241 "$cbr2125 start"
    #===================================================================================
    $ns at 0.0 "$ftp0 start"
    $ns at 16.0 "$ftp0 stop"
    $ns at 16.401 "finish"
    puts " Simulation is running ... please wait ..."
    $ns run

    Outputs and Graphs: