Hi all,
I have a problem to compute instant free space in a RED queue. I'm making
a simulation for a ethernet lan using optical like physical layer. I've 5
nodes in my network and I want to visualize instant free space in queue
between nodes 1 and lannode.
My script is below
#### Simulate an Ethernet LAN ####
###################################
##### DEFINITION DES VARABLES #####
###################################
set opt(chan) Channel ;# channel type
set opt(mac) Mac/802_3 ;# MAC type
set opt(bw) 50Mb ;# Nominal link bandwidth
set opt(delay) 0.0005ms ;# Nominal link delay
set opt(ifq) RED ;# interface queue type
set opt(ll) LL ;# link layer type
set opt(ifqlen) 1500 ;# max packet in ifq
set opt(node) 5 ;# number of nodes
set opt(seed) 0.0 ;# seed for random
number gen.
set opt(stop) 200 ;# time to stop
simulation
############ MAIN ###############
#Create a simulator object
set ns [new Simulator]
##### Open the nam trace file #####
set nf [open flux_tcp.nam w]
$ns namtrace-all $nf
set tr [open flux_tcp.tr w]
$ns trace-all $tr
set qt [open qt.tr w]
###################################
#### create topography object #####
###################################
proc create-topology {} {
global ns opt ifq
global lan node
set num $opt(node)
for {set i 1} {$i <= $num} {incr i} {
set node($i) [$ns node]
lappend nodelist $node($i)
}
# This really specifies how the LAN should look like.
set lan [$ns newLan $nodelist $opt(bw) $opt(delay) \
-llType $opt(ll) -ifqType $opt(ifq) -ifqLen $opt(ifqlen) \
-macType $opt(mac) -chanType $opt(chan) \
-phyType Phy/WiredPhy -mactrace true]
}
##### End-of-create-Topology ######
####### 'finish' procedure #######
proc finish {} {
global ns tr nf qt ifq
$ns flush-trace
#Close the NAM trace file
close $tr
#Execute NAM on the trace file
close $qt
exec nam flux_tcp.nam &
exit 0
}
proc record {} {
global opt ns qt ifq lan
set redq [[$ns link $node(1) $lan] queue]
$redq trace curq_
$redq trace ave_
$redq attach $qt
puts $qt "[$ns now] $queutail "
$ns at [expr [$ns now] + 0.1] "record"
}
##Run the 'create topology' function##
create-topology
############## S1 ################
set tcp(1) [new Agent/TCP]
$tcp(1) set fid_ 1
$tcp(1) set window_ 100
$ns attach-agent $node(1) $tcp(1)
$tcp(1) set packetSize_ 1024
set ftp(1) [new Application/FTP]
$ftp(1) attach-agent $tcp(1)
############## S4################
set sink(4) [new Agent/TCPSink]
$ns attach-agent $node(4) $sink(4)
##################################
############# color ##############
##################################
$ns color 1 Green
##################################
######### ************ ###########
##################################
$ns connect $tcp(1) $sink(4)
$ns at 5.0 "$ftp(1) start"
$ns at 182.0 "$ftp(1) stop"
$ns at 190.0 "ns detach-agent $node(1) $tcp(1)"
$ns at 190.0 "$ns detach-agent $node(4) $sink(4)"
$ns at $opt(stop).0001 "finish"
####### Finish Procedure ########
#
# begin simulation
#
$ns at 0.1 "record "
puts "Starting Simulation..."
puts "Nombre de noeud dans le réseau : $opt(node)"
puts "... in progress "
$ns run