Hi ns-users,
My name is Kevin, I'm doing
a project about queue scheduling. I applied a new scheduling
algorithm into NS2 wireless Ad hoc network module. My
algorithm uses multi -queue to buffer the data and use fuzzy to dequeue
the data based on type of data. I evaluate it by comparing with CBQ, SFQ so
I generate a tcl-scripts file using different types of queue scheduling
algorithm but the same set of traffic. I found out that only the message packets
will pass into the queue scheduling algorithms (CBQ, SFQ and my
algorithm) but all the data packets will just call enque( ) and deque(
) methods from PacketQueue class in queue.h directly. Here is my
tcl code, is there anything else I've missed.
Thank you in advance for the help.
Regards,
Kevin
#
======================================================================
# Define options # ====================================================================== set val(chan) Channel/WirelessChannel ;# channel type set val(prop) Propagation/TwoRayGround ;# radio-propagationmodel set val(netif) Phy/WirelessPhy ;# network interfacetype set val(mac) Mac/802_11 ;# MAC type set val(ifq) Queue/DropTail/PriQueue ;# interface queue type ****************** I change this ifq value to
different algorithms *********************************
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 ofmobilenodes set val(rp) DSDV ;# routing protocol # ===================================nam
===================================
# Main Program # ====================================================================== #Open the output files
#set f0 [open out0.tr w] #set f1 [open out1.tr w] #
# Initialize Global Variables # set ns_ [new Simulator]
set tracefd [open trace/case1a.tr w] set namtrace [open nam/case1a.nam w] $ns_ use-newtrace
# set up topography object
set topo [new Topography] $topo load_flatgrid 600 500
#set node_(0) [$ns_ node]
#set node_(1) [$ns_ node] $ns_ trace-all $tracefd $ns_ namtrace-all-wireless $namtrace 600 600 #
# Create God # set 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 OFF for {set i 0} {$i < $val(nn) } {incr i} { set node_($i) [$ns_ node] $node_($i) random-motion 0 ;# disable randommotion } #
# Provide initial (X,Y, for now Z=0) co-ordinates for mobilenodes set sink [new Agent/TCPSink] # $node_(0) set X_ 100.0 $node_(0) set Y_ 300.0 $node_(0) set Z_ 0.0 $node_(1) set X_ 500.0
$node_(1) set Y_ 300.0 $node_(1) set Z_ 0.0 for {set i 0} {$i < $val(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) 40 } # --------- start here--------
#Create a CBR agent and attach it to node n0
set udp [new Agent/UDP] $ns_ attach-agent $node_(0) $udp #$udp set class_ 1 #$udp set fid_ 1 set lost0 [new Agent/LossMonitor]
#$ns_ attach-agent $node_(0) $lost0 set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 1000 #$cbr set interval_ 0.01 $cbr set rate_ 50000 Kb $cbr attach-agent $udp set udp2 [new Agent/UDP]
$ns_ attach-agent $node_(0) $udp2 #$udp2 set class_ 1 #$udp2 set fid_ 1 set cbr2 [new Application/Traffic/CBR]
$cbr2 set packetSize_ 1000 #$cbr set interval_ 0.01 $cbr2 set rate_ 60000 Kb $cbr2 attach-agent $udp2 set null1 [new Agent/Null] $ns_ attach-agent $node_(1) $null1 $ns_ connect $udp2 $null1 #Create a Null agent (a traffic sink) and attach it
to node
set null0 [new Agent/Null]
$ns_ attach-agent $node_(1) $null0 $ns_ attach-agent $node_(1) $lost0 #Connect the traffic sources with the traffic
sink
$ns_ connect $udp $null0 # VBR traffic generating section
set udp3 [new Agent/UDP] $ns_ attach-agent $node_(1) $udp3 set null3 [new Agent/Null]
$ns_ attach-agent $node_(0) $null3 $ns_ connect $udp3 $null3
set tfile [new Tracefile]
$tfile filename /root/vin/final/starwars.nsformat set trace [new Application/Traffic/Trace] $trace attach-tracefile $tfile $trace attach-agent $udp3 # end of VBR set tcp1 [new Agent/TCP]
$tcp1 set class_ 2 $tcp1 set fid_ 2 set sink1 [new Agent/TCPSink] set ftp [new Application/FTP] $ftp attach-agent $tcp1 $ns_ attach-agent $node_(0) $tcp1 $ns_ attach-agent $node_(1) $sink1 $ns_ connect $tcp1 $sink1 set tcp2 [new Agent/TCP]
set sink2 [new Agent/TCPSink] set tel [new Application/Telnet] $tel attach-agent $tcp2 $ns_ attach-agent $node_(0) $tcp2 $ns_ attach-agent $node_(1) $sink2 $ns_ connect $tcp2 $sink2 #Schedule events for the CBR
agents
$ns_ at 1.0 "$cbr start"
$ns_ at 35.5 "$cbr stop" $ns_ at 3.0 "$ftp start" #VBR
$ns_ at 16.0 "$trace start"
$ns_ at 19.0 "$trace stop" $ns_ at 22.0 "$trace start"
$ns_ at 26.0 "$trace stop" $ns_ at 4.0 "$cbr2 start" $ns_ at 20.0 "$cbr2 stop" $ns_ at 7.0 "$ftp produce 100"
$ns_ at 4.0 "$tel start" $ns_ at 10.0 "$tel stop" $ns_ at 14.0 "$ftp produce 100" $ns_ at 20.0 "$ftp produce 100" $ns_ at 33.0 "$ftp produce 200"
$ns_ at 36.0 "$ftp produce 200" #-------------------------------------------------- # # Tell nodes when the simulation ends # for {set i 0} {$i < $val(nn) } {incr i} { $ns_ at 150.0 "$node_($i) reset"; } $ns_ at 40.0 "stop" $ns_ at 50.01 "puts \"NS EXITING...\" ; $ns_ halt" proc stop {} {
global ns_ tracefd $ns_ flush-trace close $tracefd } puts "Starting Simulation..." $ns_ run |