[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] RTP questions using Agent/RTP and Application/Traffic/CBR
Dear all,
I am a newbies using ns to do RTP simulation for VoIP
(Voice over IP).
I have some problems with my simulation.
I have created two nodes such that RTP data are sent from
one node to another node. In the sender node, I use
Agent/RTP to send data generated from Application/Traffic/CBR.
That is:
set rtp1 [new Agent/RTP]
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $rtp1
Then I start the simulation using
$ns at 0.50 "$cbr1 start"
$ns at 0.50 "$rtp1 start"
I found that if I comment out the line starting $cbr1,
the number of packets sent by this RTP stream will be halved.
Why the number of packets is havled?
To conclude, what I am trying to do is:
Application/Traffic/CBR -> Agent/RTP -> network
But it seems that the simulator is doing this for me:
Application/Traffic/CBR -> network
Agent/RTP -> network
The two objects are sending data to the network in parallel!
Why this happens?
Attached with this email is my simulation tcl script.
You may try to comment/uncomment the "$cbr1 start" line
and you can see the number of packets is halved/doubled.
Please help me, thank you very much!
Regards,
Kevin
M.Phil Year 2
The Chinese University of Hong Kong
========================================================================
# voip.tcl
#
# Description: The simulation script for VoIP
#
# Written by: Kevin (knyuen@cse)
#
# v1.2: Generate graphs for the link bandwidth utilization
# v1.1: Use Agent/RTP as lower class,
# then use Application/Traffic/CBR to provide VoIP traffic
# for the RTP packets
# v1.0: initial code
# Setup simulator object
set ns [new Simulator -multicast on]
# Enable multicast
$ns multicast
# Open file for simulation
set nf [open crm.nam w]
$ns namtrace-all $nf
# Open file for plotting graphs
set f1 [open out1.tr w]
set f3 [open temp.tr w]
proc finish {} {
global ns nf f1 f3
$ns flush-trace
# Close files
close $nf
close $f1
close $f3
exec xgraph out1.tr -t "Simulation 1" -0 "Stream 1" -geometry 800x400 &
exec xgraph temp.tr -t "Packet arrivals" -geometry 800x400 &
exec nam crm.nam
exit 0
}
# Setup network topology: nodes
for {set i 0} {$i < 6} {incr i} {
set n($i) [$ns node]
}
# Color
$ns color 1 red
$ns color 30 purple
$ns color 31 bisque
$ns color 32 green
# Setup network topology: links
for {set i 1} {$i <= 5} {incr i} {
$ns duplex-link $n($i) $n(0) 100Mb 10ms DropTail
}
$ns duplex-link-op $n(0) $n(1) orient left-up
$ns duplex-link-op $n(0) $n(2) orient right-up
$ns duplex-link-op $n(0) $n(3) orient right
$ns duplex-link-op $n(0) $n(4) orient right-down
$ns duplex-link-op $n(0) $n(5) orient left-down
# Set multicast parameters
set mproto DM
set mrthandle [$ns mrtproto $mproto {}]
# Setup RTP agents
set rtp1 [new Agent/RTP]
set rtp3 [new Agent/LossMonitor]
$ns attach-agent $n(1) $rtp1
$ns attach-agent $n(3) $rtp3
$rtp1 set packetSize_ 99
$rtp1 set interval_ 60ms
# Setup CBR on RTP
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $rtp1
$cbr1 set packet_size_ 99
$cbr1 set interval_ 60ms
$ns connect $rtp1 $rtp3
# Specify the record function
proc record {} {
global f1 f2 f3 rtp3
# Initialize variables
set ns [Simulator instance]
set time 0.5
set now [$ns now]
set bw1 [$rtp3 set bytes_]
set bw3 [$rtp3 set npkts_]
puts $f1 "$now [expr $bw1/$time*8]"
puts $f3 "$now $bw3"
$rtp3 set bytes_ 0
$rtp3 set npkts_ 0
# Schedule next execution
$ns at [expr $now+$time] "record"
}
# *** Initialize ***
$ns at 0.00 "record"
# *** Run ***
# Strange... uncomment the following line will double the bandwidth!
#$ns at 0.50 "$cbr1 start"
$ns at 0.50 "$rtp1 start"
# *** Finish ***
$ns at 5.00 "finish"
$ns run