# ====================================================================== # Define options # ====================================================================== set opt(chan) Channel/WirelessChannel ;# channel type set opt(prop) Propagation/TwoRayGround ;# radio-propagation model set opt(netif) Phy/WirelessPhy ;# network interface type set opt(mac) Mac/802_11 ;# MAC type set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type set opt(ll) LL ;# link layer type set opt(ant) Antenna/OmniAntenna ;# antenna model set opt(ifqlen) 50 ;# max packet in ifq set opt(nn) 2 ;# number of mobilenodes set opt(rp) DSDV ;# routing protocol # Create the event scheduler ... FILL IN HERE ... # Set up an ns trace file and an nam trace file # Note that setting up the nam trace file will # be slightly different from what we have done # before ... FILL IN HERE ... # Set up topography set topo [new Topography] $topo load_flatgrid 500 500 # Create God ... FILL IN HERE ... # Configure node set channel [new $opt(chan)] $ns_ node-config -adhocRouting $opt(rp) \ -llType $opt(ll) \ -macType $opt(mac) \ -ifqType $opt(ifq) \ -ifqLen $opt(ifqlen) \ -antType $opt(ant) \ -propType $opt(prop) \ -phyType $opt(netif) \ -channel $channel \ -topoInstance $topo \ -agentTrace ON \ -routerTrace ON \ -macTrace OFF \ -movementTrace OFF # Create node0 and node1 and disable random # motion ... FILL IN HERE ... # Set the initial location of the two nodes # Note that we need to set Z-axis to 0 ... FILL IN HERE ... # Define node initial position in nam for {set i 0} {$i < $opt(nn)} {incr i} { $ns_ initial_node_pos $node_($i) 20 } # Setup a TCP connection between node0 and node1 # The TCP connection will carry FTP traffic ... FILL IN HERE ... # At 10s, node0 start FTP ... FILL IN HERE ... # At 20s, node0 and node1 starts to move towards # each other as stated in specification ... FILL IN HERE ... # At 50s, node0 and node1 starts to move away # from each other as stated in specification ... FILL IN HERE ... # Reset nodes at 80.0s for {set i 0} {$i < $opt(nn) } {incr i} { $ns_ at 80.0 "$node_($i) reset"; } # Stop simulation $ns_ at 80.1 "stop" $ns_ at 80.2 "puts \"NS EXITING...\" ; $ns_ halt" proc stop {} { global ns_ tracefd $ns_ flush-trace close $tracefd } puts "Starting Simulation..." $ns_ run