[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] Bandwidth isn't correct in ns, it seems.



Hi,

I observed an abnormal in ns. I made the following
simple topology.
        16Mbps, 10ms        8Mbps, 10ms
  node0 ------------- node1 ------------ node2
An udp agent, udp0, is attached at node0. A null agent
is attached at node2 and is connected to udp0. udp0 is
sending packets of size 1000 bytes, at the interval of
0.5ms. Thus the incoming rate at node1 is (1000 * 8
/(0.5 * 10^-3)) = 16Mbps. The abnormal is that there
is no queue built up at node1. In case that the unit
of packet size is bits (ns documents say it's bytes),
I used packet size of 8000. But there is still no
queue. 
What's wrong? I attached the tcl file so that you can
repeat the simulation (The tcl file is not well
written, I am not good at it).

__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/
#Create a simulator object
set ns [new Simulator]

#Open the nam trace file
set nf [open udp1.nam w]
$ns namtrace-all $nf

#Define a 'finish' procedure
proc finish {} {
    global ns nf
    $ns flush-trace
    #Close the trace file
    close $nf
    #Execute nam on the trace file
    exec nam udp1.nam &
    exit 0
}

# Define a test topology
for {set i 0} {$i < 2} {incr i} {
    set R($i) [$ns node]
}

$ns duplex-link $R(0) $R(1) 8Mb 10ms RED

# Define end host
for {set i 0} {$i < 3} {incr i} {
    set H($i) [$ns node]
        $ns duplex-link $H($i) $R(0) 16Mb 10ms RED
}
for {set i 3} {$i < 6} {incr i} {
    set H($i) [$ns node]
        $ns duplex-link $H($i) $R(1) 16Mb 10ms RED
}

# Control layout
$ns duplex-link-op $R(0) $R(1) orient right

$ns duplex-link-op $H(0) $R(0) orient right-down
$ns duplex-link-op $H(1) $R(0) orient right
$ns duplex-link-op $H(2) $R(0) orient right-up

$ns duplex-link-op $H(3) $R(1) orient left-up
$ns duplex-link-op $R(1) $H(4) orient right
$ns duplex-link-op $H(5) $R(1) orient left-down

# Create UDP agents
for {set i 0} {$i < 3} {incr i} {
	set udp($i) [new Agent/UDP]
	$udp($i) set fid_ $i
	
	# attach to host
	$ns attach-agent $H($i) $udp($i)
	
	set cbr($i) [new Application/Traffic/CBR]
	$cbr($i) attach-agent $udp($i)
	$udp($i) set packetSize_ 8000
	if {$i == 0} {
		$udp($i) set interval_ 0.0005
		$cbr($i) set interval_ 0.0005
	}
	if {$i == 1} {
		$udp($i) set interval_ 0.2
		$cbr($i) set interval_ 0.2
	}
	if {$i == 2} {
		$udp($i) set interval_ 0.2
		$cbr($i) set interval_ 0.2
	}

	set null($i) [new Agent/Null]
	set index $i
	incr index 3
	$ns attach-agent $H($index) $null($i)
	$ns connect $udp($i) $null($i)
	$ns at 0.0 "$cbr($i) start"
}	

# Monitor queue
$ns duplex-link-op $R(0) $R(1) queuePos 0.5

# Color flows
$ns color 0 Black
$ns color 1 Green
$ns color 2 Red

#Call the finish procedure after 1 seconds simulation time
$ns at 1.0 "finish"

#Run the simulation
$ns run