[ns] Question about fairness in wired-cum wireless scenario
Eric Jespersen
zcafeus at yahoo.com
Sat May 29 11:08:31 PDT 2004
Hi all,
I am using ns2.27, simulate wired-cum wireless: 1
wired node, 1 base station, 8 mobile nodes. 8 seperate
UDP CBR 1Mbps transmissions from the wired nodes to 8
mobile nodes.
802.11b 11Mbps, RTS/CTS enable and disable.
UDP payload 1460 bytes (maximum size because threshold
fragmentation of Ethernet, which connects wired- to
wirless-network, is 1500 bytes)
Some strange results obtained:
1. There's no fainess between connections. Some gets
throughput near 1Mbps, some very low, almost 0. (as I
understand, THEY MUST BE FAIR) for both cases RTS/CTS
on or off.
2. The result doens't depends on the positions of
wireless nodes at all, close or far from base station,
static or mobile.
3. The result changes if transmitting start time of
each connection changes. But still no fairness.
4. I look at the trace file, all packets are
fragmented at 1000 bytes. Why? How to change this
threshold?
I send here my tcl script. Pls look at it.
Anyone can help me? I may have mistake in the script.
Any parameters need to be concerned?
Thanks in advance
Eric
#=========================================
# BEGIN OF FILE
#=========================================
# simulation of a wired-cum-wireless scenario
consisting of 1 wired node
# connected to a wireless domain through a
base-station node.
#
======================================================================
# 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
Mac/802_11 set dataRate_ 11Mb
Mac/802_11 set RTSThreshold_ 3000
Phy/WirelessPhy set Pt_ 0.030
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(adhocRouting) DSDV ;#
routing protocol
set opt(cp) "" ;#
connection pattern file
#set opt(sc)
"./Scen/scen-200m-8u-100s-static.tcl" ;# node movement
file.
set opt(sc) ""
set opt(x) 200 ;# x
coordinate of topology
set opt(y) 200 ;# y
coordinate of topology
set opt(seed) 0.0 ;# seed
for random number gen.
set opt(pktsize) 1460 ;#
Packet size
set opt(dataspeed) 0.7Mb ;# Data
speed of each station
set opt(nn) 7 ;# number
of mobilenodes
set opt(interval) 1 ;# interval
to count received packets
set opt(record-start) 0.0 ;# time to
start record
set opt(stop) 100.0 ;# time
to stop simulation
# Generate the starting time of each transmission
for {set j 0} {$j < $opt(nn)} {incr j} {
set cbr_start($j) [expr 2 * $j]
}
#set opt(cbr0-start) 0.0
#set opt(cbr1-start) 0.0
set num_wired_nodes 8
set num_bs_nodes 1
# create simulator instance
set ns_ [new Simulator]
# set up for hierarchical routing
$ns_ node-config -addressType hierarchical
AddrParams set domain_num_ 2 ;# number of
domains
lappend cluster_num 1 1 ;# number of
clusters in each domain
AddrParams set cluster_num_ $cluster_num
lappend eilastlevel $num_wired_nodes [expr $opt(nn)+
$num_bs_nodes] ;# number of nodes in each cluster
AddrParams set nodes_num_ $eilastlevel ;# of each
domain
set tracefd [open ex2-out.tr w]
#set namtrace [open ex2-out.nam w]
$ns_ trace-all $tracefd
#$ns_ namtrace-all-wireless $namtrace $opt(x) $opt(y)
# Create topography object
set topo [new Topography]
# define topology
$topo load_flatgrid $opt(x) $opt(y)
# create God
create-god [expr $opt(nn) + $num_bs_nodes]
#create wired nodes
for {set j 0} {$j < $num_wired_nodes} {incr j} {
set temp1($j) 0.0.$j
set W($j) [$ns_ node $temp1($j)]
} ;# hierarchical addresses for wired domain
#====================================================================
##########Phy/WirelessPhy set Pt_ 0.0030
# configure for base-station node
$ns_ node-config -adhocRouting $opt(adhocRouting) \
-llType $opt(ll) \
-macType $opt(mac) \
-ifqType $opt(ifq) \
-ifqLen $opt(ifqlen) \
-antType $opt(ant) \
-propType $opt(prop) \
-phyType $opt(netif) \
-channelType $opt(chan) \
-topoInstance $topo \
-wiredRouting ON \
-agentTrace ON \
-routerTrace OFF \
-macTrace OFF \
-movementTrace OFF
for {set j 0} {$j < [expr $opt(nn)+1]} {incr j} {
#create base-station node
set temp($j) 1.0.$j
}
#set temp {1.0.0 1.0.1 1.0.2} ;# hier address to be
used for wireless
;# domain
#set BS(0) [$ns_ node [lindex $temp 0]]
set BS(0) [$ns_ node $temp(0)]
$BS(0) random-motion 0 ;# disable random
motion
#provide some co-ord (fixed) to base station node
$BS(0) set X_ [expr $opt(x)/2]
$BS(0) set Y_ [expr $opt(y)/2]
$BS(0) set Z_ 0.0
# create mobilenodes in the same domain as BS(0)
# note the position and movement of mobilenodes is as
defined
# in $opt(sc)
#configure for mobilenodes
$ns_ node-config -wiredRouting OFF
for {set j 0} {$j < $opt(nn)} {incr j} {
#set node_($j) [ $ns_ node [lindex $temp [expr
$j+1]] ]
set node_($j) [$ns_ node $temp([expr $j+1]) ]
$node_($j) base-station [AddrParams addr2id \
[$BS(0) node-addr]]
}
#create links between wired and BS nodes
for {set i 0} {$i < $num_wired_nodes} {incr i} {
$ns_ duplex-link $W($i) $BS(0) 100Mb 2ms DropTail
}
#====================================================
# source connection-pattern and node-movement scripts
if { $opt(cp) == "" } {
puts "*** NOTE: no connection pattern specified."
set opt(cp) "none"
} else {
puts "Loading connection pattern..."
source $opt(cp)
}
if { $opt(sc) == "" } {
puts "*** NOTE: no scenario file specified."
set opt(sc) "none"
} else {
puts "Loading scenario file..."
source $opt(sc)
puts "Load complete..."
}
#=====================================================
# Define initial node position in nam
#for {set i 0} {$i < $opt(nn)} {incr i} {
# 20 defines the node size in nam, must adjust it
according to your
# scenario
# The function must be called after mobility model
is defined
# $ns_ initial_node_pos $node_($i) 5
#}
#====================================================
#====================================================
#Open the output files
set f [open ex2-out.data w]
# for {set i 0} {$i < $opt(nn)} {incr i} {
# set f($i) [open ex2-out$i.tr w]
# }
#
==========================================================
#Define a 'finish' procedure
proc finish {} {
#Close the output files
global f
close $f
# for {set i 0} {$i < $opt(nn)} {incr i} {
# close $f($i)
# }
exit 0
}
#Define a 'stop' procedure
proc stop {} {
global ns_ tracefd; # namtrace
# $ns_ flush-trace
close $tracefd
# close $namtrace
}
#====================================================
#Define a procedure that attaches a UDP agent to a
previously created node
#'node' and attaches a CBR traffic generator to the
agent with the
#characteristic values 'size' for packet size 'burst'
for burst time,
#'idle' for idle time and 'rate' for burst peak rate.
The procedure connects
#the source with the previously defined traffic sink
'sink' and returns the
#source object.
proc attach-cbr { node sink size rate } {
#Get an instance of the simulator
set ns [Simulator instance]
#Create a UDP agent and attach it to the node
set source [new Agent/UDP]
$ns attach-agent $node $source
#Create an CBR traffic agent and set its
configuration parameters
set traffic [new Application/Traffic/CBR]
$traffic set packetSize_ $size
#$traffic set interval_ [expr
$size*8.0/$rate/1000000]
$traffic set rate_ $rate
# Attach traffic source to the traffic
generator
$traffic attach-agent $source
#Connect the source and the sink
$ns connect $source $sink
return $traffic
}
#====================================================
#Define a procedure which periodically records the
bandwidth received by the
#three traffic sinks sink0/1/2 and writes it to the
three files f0/1/2.
proc record {} {
#global sink0 sink1 sink2 sink3 sink4 f0 f1 f2
f3 f4
global sink f opt
#Get an instance of the simulator
set ns [Simulator instance]
#Set the time after which the procedure should be
called again
set time $opt(interval)
#Get the current time
set now [$ns now]
# Write current time into file
puts -nonewline $f "$now, "
for {set i 0} {$i < $opt(nn)} {incr i} {
#How many bytes have been received by the
traffic sinks?
set bw($i) [$sink($i) set bytes_]
#Calculate the bandwidth (in MBit/s)
set thput($i) [expr $bw($i)/$time*8]; # in bit
# Write it to the files
# puts $f($i) "$now $thput($i)"
if {$i<[expr $opt(nn)-1]} {puts -nonewline $f
"$thput($i), "}
if {$i ==[expr $opt(nn)-1]} {puts $f "$thput($i)"}
#Reset the bytes_ values on the traffic sinks
$sink($i) set bytes_ 0
}
#Re-schedule the procedure
$ns at [expr $now+$time] "record"
}
#=====================================================
#=====================================================
# #Create $opt(nn) traffic sinks and attach them to
the mobile nodes
for {set i 0} {$i < $opt(nn)} {incr i} {
#Create three traffic sinks and attach them to
the mobile nodes
set sink($i) [new Agent/LossMonitor]
$ns_ attach-agent $node_($i) $sink($i)
#Create three traffic sources
set source($i) ["attach-cbr" $W($i) $sink($i)
$opt(pktsize) $opt(dataspeed)]
}
# set sink0 [new Agent/LossMonitor]
# $ns_ attach-agent $node_(0) $sink0
# #Create three traffic sources
# set source0 ["attach-cbr" $W(0) $sink0 1460 1.0Mb]
#====================================================
puts "Starting Simulation..."
for {set i 0} {$i < $opt(nn)} {incr i} {
# Start the traffic sources
$ns_ at $cbr_start($i) "$source($i) start"
}
#$ns_ at $opt(cbr0-start) "$source0 start"
#$ns_ at $opt(cbr1-start) "$source1 start"
#=====================================================
# Tell all nodes when the simulation ends
for {set i } {$i < $opt(nn) } {incr i} {
$ns_ at $opt(stop).0 "$node_($i) reset";
}
$ns_ at $opt(stop).0 "$BS(0) reset";
$ns_ at $opt(stop).0002 "puts \"NS EXITING...\" ; $ns_
halt"
$ns_ at $opt(stop).0001 "stop"
# informative headers for CMUTracefile
puts $tracefd "M 0.0 nn $opt(nn) x $opt(x) y $opt(y)
rp \
$opt(adhocRouting)"
puts $tracefd "M 0.0 sc $opt(sc) cp $opt(cp) seed
$opt(seed)"
puts $tracefd "M 0.0 prop $opt(prop) ant $opt(ant)\n"
#====================================================
#Start logging the received bandwidth
$ns_ at $opt(record-start) "record"
$ns_ at $opt(stop) "finish"
# Run the simulation
$ns_ run
#=========================================
# END OF FILE
#=========================================
__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.
http://messenger.yahoo.com/
More information about the Ns-users
mailing list