[ns] about the saturation throughput in 802.11 simulation, pls help me

redhero at enorth.com.cn redhero at enorth.com.cn
Tue May 18 20:42:16 PDT 2004


I simulate a 802.11 wireless network.I want to check the system throughput under saturation mode.But I found when the nodes increasing,the throughput did not decrease uniformly,ie 719kbps(20node) 723kbps(30node).The following is my code.what is the problem.Any remark is welcome.
mycode.tcl
# simple-wireless.tcl
# A simple example for wireless simulation
source no_node.tcl
# ======================================================================
# 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)             12                          ;# number of mobilenodes
set val(rp)             DumbAgent                       ;# routing protocol

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


#
# Initialize Global Variables
#
set ns_		[new Simulator]
set tracefd     [open simple2.tr w]
$ns_ trace-all $tracefd


# set up topography object
set topo       [new Topography]

$topo load_flatgrid 100 100

#
# Create God
#
set god_ [create-god $val(nn)]

set chan_1_ [new $val(chan)]

#
#  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) \
			 -channel $chan_1_ \
			 -topoInstance $topo \
			 -agentTrace ON\
			 -routerTrace ON\
			 -macTrace ON\
			 -movementTrace OFF			

#Configuration for Orinoco 802.11b 11Mbps PC card with ->22.5m range
Phy/WirelessPhy set Pt_ 0.28183815
Phy/WirelessPhy set bandwidth_ 1Mb
#$val(mac) set dataRate_ 11Mb
#Mac/802_11 set basicRate_ 1Mb 
	# for broadcast packets
Phy/WirelessPhy set freq_ 2.472e9 
	# channel-13.2.472GHz
Phy/WirelessPhy set CPThresh_ 10.0
Phy/WirelessPhy set CSThresh_ 5.011872e-12
Phy/WirelessPhy set L_ 1.0               
Phy/WirelessPhy set RXThresh_ 5.82587e-09
Mac/802_11 set dataRate_ 1Mb			 
for {set i 0} {$i < $val(nn) } {incr i} {
		set node_($i) [$ns_ node]
                $node_($i) set X_ 0
                $node_($i) set Y_ [expr $i*100/$val(nn)]
                $node_($i) set Z_ 0
		$node_($i) random-motion 0		;# disable random motion
}


#source scene




# Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes
#

# Setup traffic flow between nodes
for {set i 0} {$i < [expr $val(nn)/2] } {incr i} {
set udp_($i) [new Agent/UDP]
#$udp_($i) set packetSize_ 1000
set sink_($i) [new Agent/Null]

$ns_ attach-agent $node_([expr $i*2]) $udp_($i)
$ns_ attach-agent $node_([expr $i*2 +1]) $sink_($i)
$ns_ connect $udp_($i) $sink_($i)

# generate cbr traffic

set cbr_($i) [new Application/Traffic/CBR]
$cbr_($i) attach-agent $udp_($i)
$cbr_($i) set packetSize_ 1000
$cbr_($i) set rate_ 1000Mb
$ns_ at 1.0 "$cbr_($i) start" 
}


#
# Tell nodes when the simulation ends
#
for {set i 0} {$i < $val(nn) } {incr i} {
    $ns_ at 10.0 "$node_($i) reset";
}
$ns_ at 10.0 "stop"
$ns_ at 10.01 "puts \"NS EXITING...\" ; $ns_ halt"
proc stop {} {
    global ns_ tracefd 
    $ns_ flush-trace
    close $tracefd
   
  #  exec nam out.nam &
    exit 0
}

puts "Starting Simulation..."
$ns_ run

awk file

BEGIN {
  total = 0;
  n=0;
  throughput=0;
 # start=1.0;
}


{

if (($7 =="tcp") &&(NF==21)) {
 if (($1 =="r") && ($4 =="MAC")) {
  if (n == 0) start = $2;
  total += $8 * 8;
  n +=1;
  end = $2;
 }
}


}

END {
if(end != start)
  throughput = total / 9 / 1024;
 
  print start, "\t", end, "\t",throughput, "Kbps";
 # print start, "\t", end, "\t",n;
}



More information about the Ns-users mailing list