Created
April 16, 2013 03:17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# start new simulation | |
set ns [new Simulator] | |
# setup tracing/nam | |
set tr [open voip.tr w] | |
set nf [open voip.nam w] | |
$ns trace-all $tr | |
$ns namtrace-all $nf | |
# finish function, close all trace files and open up nam | |
proc finish {} { | |
global ns nf tr | |
$ns flush-trace | |
close $nf | |
close $tr | |
exec nam voip.nam & | |
exit 0 | |
} | |
### creating nodes | |
set node0 [$ns node] | |
$node0 label "Voz 1" | |
$node0 color red | |
set node1 [$ns node] | |
$node1 label "Voz 2" | |
$node1 color blue | |
# creating duplex-link | |
$ns duplex-link $node0 $node1 256Kb 50ms DropTail | |
$ns duplex-link-op $node0 $node1 orient right | |
# setup colors | |
$ns color 1 Yellow | |
$ns color 2 Green | |
## 2-way VoIP connection | |
#Create a UDP agent and attach it to node0 | |
set udp0 [new Agent/UDP] | |
$ns attach-agent $node0 $udp0 | |
# set udp0 flowid to 1 | |
$udp0 set fid_ 1 | |
# Create a CBR traffic source and attach it to udp0 | |
set cbr0 [new Application/Traffic/CBR] | |
$cbr0 set packetSize_ 128 | |
$cbr0 set interval_ 0.020 | |
# set traffic class to 1 | |
$cbr0 set class_ 1 | |
$cbr0 attach-agent $udp0 | |
# Create a Null sink to receive UDP | |
set sinknode1 [new Agent/LossMonitor] | |
$ns attach-agent $node1 $sinknode1 | |
# Connect the UDP traffic source to Null sink | |
$ns connect $udp0 $sinknode1 | |
set udp1 [new Agent/UDP] | |
$ns attach-agent $node1 $udp1 | |
$udp1 set fid_ 2 | |
set cbr1 [new Application/Traffic/CBR] | |
$cbr1 set packetSize_ 128 | |
$cbr1 set interval_ 0.020 | |
$cbr1 set class_ 2 | |
$cbr1 attach-agent $udp1 | |
set sinknode0 [new Agent/LossMonitor] | |
$ns attach-agent $node0 $sinknode0 | |
$ns connect $udp1 $sinknode0 | |
# end of voice simulation setup | |
# start up traffic | |
$ns at 0.1 "$cbr0 start" | |
$ns at 0.1 "$cbr1 start" | |
$ns at 10.0 "$cbr0 stop" | |
$ns at 10.0 "$cbr1 stop" | |
$ns at 10.5 "finish" | |
# run the simulation | |
$ns run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment