Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set val(chan) Channel/WirelessChannel ;# channel type
- set val(prop) Propagation/TwoRayGround ;# radio-propagation model
- set val(netif) Phy/WirelessPhy ;# network interface type
- set val(mac) Mac/802_11 ;# MAC type
- set val(ifq) Queue/DropTail/PriQueue ;# interface queue type
- set val(ll) LL ;# link layer type
- set val(ant) Antenna/OmniAntenna ;# antenna model
- set val(ifqlen) 50 ;# max packet in ifq
- set val(nn) 34 ;# number of mobilenodes
- set val(rp) AODV ;# routing protocol
- set opt(x) 2000
- set opt(y) 1054
- # ======================================================================
- # Main Program
- # ======================================================================
- #
- # Initialize Global Variables
- #
- set ns_ [new Simulator]
- set tracefd [open luthfi.tr w]
- $ns_ trace-all $tracefd
- set namf [open luthfi.nam w]
- $ns_ namtrace-all-wireless $namf $opt(x) $opt(y)
- # set up topography object
- set topo [new Topography]
- $topo load_flatgrid $opt(x) $opt(y)
- #
- # Create God
- #
- create-god $val(nn)
- #
- # Create the specified number of mobilenodes [$val(nn)] and "attach" them
- # to the channel.
- # Here two nodes are created : node(0) and node(1)
- # configure node
- $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) \
- -channelType $val(chan) \
- -topoInstance $topo \
- -agentTrace ON \
- -routerTrace ON \
- -macTrace OFF \
- -movementTrace ON
- for {set i 0} {$i < $val(nn) } {incr i} {
- set node_($i) [$ns_ node]
- $node_($i) random-motion 0 ;# disable random motion
- $ns_ initial_node_pos $node_($i) 20
- }
- source mobility.tcl
- set tcp [new Agent/TCP]
- $tcp set class_ 2
- set sink [new Agent/TCPSink]
- $ns_ attach-agent $node_(0) $tcp
- $ns_ attach-agent $node_(22) $sink
- $ns_ connect $tcp $sink
- set ftp [new Application/FTP]
- $ftp attach-agent $tcp
- $ns_ at 10.0 "$ftp start"
- #
- # Tell nodes when the simulation ends
- #
- for {set i 0} {$i < $val(nn) } {incr i} {
- $ns_ at 100.0 "$node_($i) reset";
- }
- $ns_ at 100.0 "stop"
- $ns_ at 100.01 "puts \"NS EXITING...\" ; $ns_ halt"
- proc stop {} {
- global ns_ tracefd
- $ns_ flush-trace
- close $tracefd
- }
- puts "Starting Simulation..."
- $ns_ run
Advertisement
Add Comment
Please, Sign In to add comment