[ns] RE: Ns-users Digest, Vol 16, Issue 20

rachid elgambouri elgambouri at hotmail.com
Fri Apr 15 06:13:00 PDT 2005



I will want to calculate the duration of transmission delay between sends 
and the reception of packet.  I used Mac/802.11 set dataRate_1, Mac/802.11 
set dataRate_11, and I find the same result, and I do not know how I can 
change the value of Mac/802.11 set dataRate _.

thank you for your help

i use ns2.27
code :


  # Start of script

#======================================================================
  # Define options
  #

#======================================================================
  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)             2                         ;# number of mobilenodes
  set val(rp)             DSDV                 ;# routing protocol

  #

#======================================================================
  #

#======================================================================
  # Main Program
  #

#======================================================================

  # Initialize Global Variables
  #-------------------------------------------

  set stoptime_ 100
  set lambda  10
  set ns_		[new Simulator]
  puts "stoptime=$stoptime_"
  #$ns_ use-newtrace
  #$ns_ use-smalltrace
  set tracefd [open testpoisson.tr w]
  $ns_ trace-all $tracefd

  #Set -66 dBm of both RX and CS Threshold
  Phy/WirelessPhy set CSThresh_ 2.5e-10
  Phy/WirelessPhy set RXThresh_ 2.5e-10
  #Set datarate
  Mac/802_11 set dataRate_ 1

  # Set up topography object
  set topo [new Topography]
  $topo load_flatgrid 800 800

  # Create God
  #-------------------------------------------
  create-god $val(nn)

  # 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) \
      -topoInstance $topo \
      -agentTrace OFF \
      -routerTrace OFF \
      -macTrace ON \
      -movementTrace OFF \
      -channel [new $val(chan)]

  for {set i 0} {$i < $val(nn) } {incr i} {
  	set node_($i) [$ns_ node]
  	$node_($i) random-motion 0	;# disable random motion
  }

  # Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes
  $node_(0) set X_ 50.0
  $node_(0) set Y_ 200.0
  $node_(0) set Z_ 0.0

  $node_(1) set X_ 250.0
  $node_(1) set Y_ 200.0
  $node_(1) set Z_ 0.0

  # Now place the nodes
  $ns_ at 0 "$node_(0) setdest 50.0 200.0 0.0"
  $ns_ at 0 "$node_(1) setdest 250.0 200.0 0.0"

  # Setup traffic flow between nodes

  Agent/UDP set packetSize_ 3000

  set udp0 [new Agent/UDP]
  $udp0 set class_ 1
  set cbr0 [new Application/Traffic/CBR]
  $cbr0 set packetSize_ 2000
  set ival_ [expr 1.0/$lambda]
  $cbr0 set interval_ $ival_
  puts "$ival_"
  $cbr0 attach-agent $udp0

  set sink1 [new Agent/Null]

  $ns_ attach-agent $node_(0) $udp0
  $ns_ attach-agent $node_(1) $sink1

  $ns_ connect $udp0 $sink1
  $ns_ at 0.2 "$cbr0 start"
  $ns_ at $stoptime_ "stop"

  proc stop {} {
      global ns_ tracefd
      $ns_ flush-trace
      close $tracefd
      exit 0
  }
  puts "Starting Simulation ..."
  $ns_ run

  #### End of script #############

_________________________________________________________________
MSN Messenger : discutez en direct avec vos amis ! 
http://www.msn.fr/msger/default.asp



More information about the Ns-users mailing list