# 
======================================================================
  # Define options
  # 
======================================================================
  set val(chan) Channel/WirelessChannel
  set val(prop) Propagation/TwoRayGround
  set val(netif) Phy/WirelessPhy
  set val(mac) Mac/802_11
  set val(ifq) Queue/DropTail/PriQueue
  set val(ll) LL
  set val(ant) Antenna/OmniAntenna
  set val(x) 1000 ;# X dimension of the topography
  set val(y) 1000 ;# Y dimension of the topography
  set val(ifqlen) CMUPriqueue ;# max packet in ifq
  set val(seed) 0.0
  set val(adhocRouting) DSDV
  set val(nn) 50 ;# how many nodes are simulated
  set val(cp) "f1" ;# connection pattern file
  set val(sc) "s1" 
  set val(rp) DSR
  set val(stop) 450.0
  # 
=====================================================================
  # Main Program
  # 
======================================================================
  #
  # Initialize Global Variables
  #
  # create simulator instance
  set ns_ [new Simulator]
  # setup topography object
  set topo [new Topography]
  # create trace object for ns and nam
  set f1 [open f1.tr w]
  set f2 [open f2.nam w]
  $ns_ trace-all $f1
  $ns_ use-newtrace
  $ns_ namtrace-all-wireless $f2 $val(x) $val(y)
  # define topology
  $topo load_flatgrid $val(x) $val(y)
  #
  # Create God
  #
  set god_ [create-god $val(nn)]
  #
  # define how node should be created
  #
  #global node setting
  $ns_ node-config -adhocRouting $val(adhocRouting) \
  -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 
  #
  # Create the specified number of nodes [$val(nn)] and "attach" them
  # to the channel. 
  for {set i 0} {$i < $val(nn) } {incr i} {
  set node_($i) [$ns_ node] 
  $node_($i) random-motion 1 ;# disable random motion
  }
   
  # 
  # Define node movement model
  #
  puts "Loading connection pattern..."
  source $val(cp)
  # 
  # Define traffic model
  #
  puts "Loading scenario file..."
  source $val(sc)
  # Define node initial position in nam
   
  #
  # Tell nodes when the simulation ends
  #
  for {set i 0} {$i < $val(nn) } {incr i} {
  $ns_ at $val(stop).0 "$node_($i) reset";
  }
  
################################test###########################################
  
##############################################################################
  $ns_ at $val(stop).0002 "puts \"NS EXITING...\" ; $ns_ halt"
  proc finish {} {
  puts "je suis en finish"
  global ns f1 
  close $f1
  
  # puts "running nam..."
  exec nam f2.nam &
  exit 0
  }
  puts "avant TCP"
  $ns_ at 400.0 "finish"
  # puts $f1 "M 0.0 nn $val(nn) x $val(x) y $val(y) rp 
$val(adhocRouting)" 
  puts "Starting Simulation..."
  $ns_ run
   
  Merci  bcq



                
---------------------------------
 Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs 
exceptionnels pour appeler la France et l'international.Téléchargez la version 
beta.

Reply via email to