# Define options set opt(chan) Channel/WirelessChannel set opt(prop) Propagation/TwoRayGround set opt(netif) Phy/WirelessPhy set opt(mac) Mac/802_11 set opt(ifq) Queue/DropTail/PriQueue set opt(ll) LL set opt(ant) Antenna/OmniAntenna set opt(x) 1500 set opt(y) 1000 set opt(rp) dsr set opt(ifqlen) 50 set opt(seed) 0.5 set opt(cc) "off" set opt(tr) mobileip.tr set opt(cp) "" set opt(sc) "" set num_wired_nodes 8 set num_wireless_nodes 1 set opt(nn) 9 #Other class settings set AgentTrace ON set RouterTrace OFF set MacTrace OFF LL set mindelay_ 50us LL set delay_ 25us Agent/Null set sport_ 0 Agent/Null set dport_ 0 Agent/CBR set sport_ 0 Agent/CBR set dport_ 0 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 Gt_ 1.0 Antenna/OmniAntenna set Gr_ 1.0 # Initialize the SharedMedia interface with parameters to make # it work like the 914MHz Lucent WaveLAN DSSS radio interface Phy/WirelessPhy set CPThresh_ 10.0 Phy/WirelessPhy set CSThresh_ 1.559e-11 Phy/WirelessPhy set RXThresh_ 3.652e-10 Phy/WirelessPhy set Rb_ 2*1e6 Phy/WirelessPhy set Pt_ 0.2818 Phy/WirelessPhy set freq_ 914e+6 Phy/WirelessPhy set L_ 1.0 #Define the sources source /opt/ns/ns-2.1b6-current/tcl/lib/ns-wireless-mip.tcl #Initial setup set ns [new Simulator] #Set addressing to hierarchical $ns set-address-format hierarchical #Set mobileIP flag Simulator set mobile_ip_ 1 #Open a trace file set namtrace [open mobileip.nam w] $ns namtrace-all $namtrace set trace [open mobileip_trace.tr w] $ns trace-all $trace #Define a 'finish' procedure proc finish {} { global ns trace namtrace $ns flush-trace close $namtrace close $trace exec nam mobileip.nam & exit 0 } #Define the structure AddrParams set domain_num_ 10 lappend cluster_num 8 1 1 1 1 1 1 1 1 1 AddrParams set cluster_num_ $cluster_num lappend eilastlevel 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 AddrParams set nodes_num_ $eilastlevel #Setup the wired nodes set temp {0.0.0 0.1.0 0.2.0 0.3.0 0.4.0 0.5.0 0.6.0 0.7.0} for {set i 0} {$i < $num_wired_nodes} {incr i} { set W($i) [$ns node [lindex $temp $i]] } #Create common objects reqd for wireless sim. if { $opt(x) == 0 || $opt(y) == 0 } { puts "No X-Y boundary values given for wireless topology\n" } set chan [new $opt(chan)] set prop [new $opt(prop)] set topo [new Topography] set tracefd [open $opt(tr) w] #Setup topography and propagation model $topo load_flatgrid $opt(x) $opt(y) $prop topography $topo #Create God create-god $opt(nn) #Setup HomeAgent and base station nodes set HA [create-base-station-node 1.0.0] set BS1 [create-base-station-node 2.0.0] set BS2 [create-base-station-node 3.0.0] set BS3 [create-base-station-node 4.0.0] set BS4 [create-base-station-node 5.0.0] set BS5 [create-base-station-node 6.0.0] set BS6 [create-base-station-node 7.0.0] set BS7 [create-base-station-node 8.0.0] set BS8 [create-base-station-node 9.0.0] #Provide some co-ord (fixed) to these base-station nodes. $HA set X_ 500.000000000000 $HA set Y_ 900.000000000000 $HA set Z_ 0.000000000000 $BS1 set X_ 1000.000000000000 $BS1 set Y_ 500.000000000000 $BS1 set Z_ 0.000000000000 $BS2 set X_ 1150.000000000000 $BS2 set Y_ 500.000000000000 $BS2 set Z_ 0.000000000000 $BS3 set X_ 1300.000000000000 $BS3 set Y_ 500.000000000000 $BS3 set Z_ 0.000000000000 $BS4 set X_ 1450.000000000000 $BS4 set Y_ 500.000000000000 $BS4 set Z_ 0.000000000000 $BS5 set X_ 1600.000000000000 $BS5 set Y_ 500.000000000000 $BS5 set Z_ 0.000000000000 $BS6 set X_ 1750.000000000000 $BS6 set Y_ 500.000000000000 $BS6 set Z_ 0.000000000000 $BS7 set X_ 1900.000000000000 $BS7 set Y_ 500.000000000000 $BS7 set Z_ 0.000000000000 $BS8 set X_ 2050.000000000000 $BS8 set Y_ 500.000000000000 $BS8 set Z_ 0.000000000000 #Create a mobilenode that would be moving between HA and BS1 and BS2. #note address of MH indicates its in the same domain as HA. set MH [$opt(rp)-create-mobile-node 0 1.0.2] set HAaddress [AddrParams set-hieraddr [$HA node-addr]] [$MH set regagent_] set home_agent_ $HAaddress #Movement of the MH $MH set Z_ 0.000000000000 $MH set Y_ 900.000000000000 $MH set X_ 500.000000000000 #Starts to move towards BS1 $ns at 1.000000000000 "$MH setdest 1000.000000000000 500.000000000000 20.000000000000" #Goes from BS1 to BS2 $ns at 40.000000000000 "$MH setdest 1150.000000000000 500.000000000000 10.0000000000000" #Starts to move towards BS3 #$ns at 60.000000000000 "$MH setdest 1300.000000000000 50.000000000000 10.000000000000" #Goes to BS4# #$ns at 80.000000000000 "$MH setdest 1450.000000000000 50.000000000000 10.000000000000" #Goes to BS5 #$ns at 100.000000000000 "$MH setdest 1600.000000000000 50.000000000000 10.000000000000" if { $opt(x) == 0 || $opt(y) == 0 } { usage $argv0 exit 1 } if {$opt(seed) > 0} { puts "Seeding Random number generator with $opt(seed)\n" ns-random $opt(seed) } # Source the Connection and Movement scripts if { $opt(cp) == "" } { puts "*** NOTE: no connection pattern specified." set opt(cp) "none" } else { puts "Loading connection pattern..." source $opt(cp) } if { $opt(sc) == "" } { puts "*** NOTE: no scenario file specified." set opt(sc) "none" } else { puts "Loading scenario file..." source $opt(sc) puts "Load complete..." } #Create links between wired and BaseStation nodes $ns duplex-link $W(0) $W(1) 7Mb 10ms DropTail $ns duplex-link $W(0) $HA 7Mb 10ms DropTail $ns duplex-link $W(1) $HA 7Mb 10ms DropTail $ns duplex-link $W(1) $W(2) 7Mb 10ms DropTail $ns duplex-link $W(1) $W(3) 7Mb 10ms DropTail $ns duplex-link $W(2) $W(4) 2.5Mb 1ms DropTail $ns duplex-link $W(2) $W(5) 2.5Mb 1ms DropTail $ns duplex-link $W(3) $W(6) 2.5Mb 1ms DropTail $ns duplex-link $W(3) $W(7) 2.5Mb 1ms DropTail $ns duplex-link $W(4) $BS1 2.5Mb 1ms DropTail $ns duplex-link $W(4) $BS2 2.5Mb 1ms DropTail $ns duplex-link $W(5) $BS3 2.5Mb 1ms DropTail $ns duplex-link $W(5) $BS4 2.5Mb 1ms DropTail $ns duplex-link $W(6) $BS5 2.5Mb 1ms DropTail $ns duplex-link $W(6) $BS6 2.5Mb 1ms DropTail $ns duplex-link $W(7) $BS7 2.5Mb 1ms DropTail $ns duplex-link $W(7) $BS8 2.5Mb 1ms DropTail set opt(ftp1-start) 10.0 set opt(stop) 60.0 #Setup TCP connections between a wired node and the MobileHost set udp0 [new Agent/UDP] set null0 [new Agent/Null] $ns attach-agent $MH $udp0 $udp0 set packetSize_ 64 $ns attach-agent $W(0) $null0 $ns connect $null0 $udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 attach-agent $udp0 #$cbr0 set packetSize_ 500 #$cbr0 set interval_ 0.01 $cbr0 set rate_ 2512k $ns at $opt(ftp1-start) "$cbr0 start" #set exp1 [new Application/Traffic/Exponential] #$exp1 attach-agent $udp0 #$exp1 set rate_ 2312k #$ns at $opt(ftp1-start) "$exp1 start" #$ns at $opt(stop).000000000 "$exp1 stop" #Stop the traffic source $ns at $opt(stop).000000000 "$cbr0 stop" # Tell all the nodes when the simulation ends for {set i 0} {$i < $num_wireless_nodes } {incr i} { $ns_ at $opt(stop).0000010 "$node_($i) reset"; } $ns at $opt(stop).0000010 "$HA reset"; $ns at $opt(stop).0000010 "$BS1 reset"; $ns at $opt(stop).0000010 "$BS2 reset"; $ns at $opt(stop).0000010 "$BS3 reset"; $ns at $opt(stop).0000010 "$BS4 reset"; $ns at $opt(stop).0000010 "$BS5 reset"; $ns at $opt(stop).0000010 "$BS6 reset"; $ns at $opt(stop).0000010 "$BS7 reset"; $ns at $opt(stop).0000010 "$BS8 reset"; #Call the finish procedure $ns at $opt(stop).21 "finish" $ns at $opt(stop).20 "puts \"NS EXITING...\" ; " puts "Starting Simulation..." #debug 1 #Run the simulation $ns run