Hice un programa en el cual puedes generar los siguientes tipos de tráfico.
- Trafico CBR (Constant bit rate)
- Trafico exponencial
- Trafico Pareto
ns simulacion.tcl [Topologia] [Tipo de trafico] [Tamaño de paquetes] [Rate] [Esquema]
Por ejemplo podemos correr el programa de la siguiente manera.
ns simulacion.tcl arbol CBR 1000 1mb Heap
Se nos pide realizar un experimento sobre nuestra simulación es por eso que hice un python que obtiene del archivo .nam los valores de kbps y el tiempo para graficar la medida de desempeño Throughput de manera que podamos saber como afecta el trafico a un nodo udp con CBR en diferentes tamaños de paquetes y rates.
Obtuvimos los siguientes resultados.
De manera que podemos observar que al agregar paquetes más pesados en un rate medianamente alto se transmite menos flujo por segundo, pero con mayor cantidad de información, este experimento fue realizado con una topología de árbol y generando trafico CBR dado el ns2.
Este es el código.
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
set sim [new Simulator] | |
set archivo_1 [open salida_1.nam w] | |
$sim namtrace-all $archivo_1 | |
proc termina_1 {} { | |
global sim archivo_1 | |
$sim flush-trace | |
close $archivo_1 | |
exec nam salida_1.nam & | |
exit 0 | |
} | |
#Nodos suficientes para topologia | |
set padre [$sim node] | |
set hijo1 [$sim node] | |
set hijo2 [$sim node] | |
set hijo3 [$sim node] | |
set ter1 [$sim node] | |
set ter2 [$sim node] | |
set ter3 [$sim node] | |
set ter4 [$sim node] | |
set ter5 [$sim node] | |
#conexiones para topologia arbol | |
proc conecta_arbol {} { | |
global sim padre hijo1 hijo2 hijo3 ter1 ter2 ter3 ter4 ter5 | |
$sim duplex-link $padre $hijo1 2.5Mb 10ms DropTail | |
$sim duplex-link $hijo1 $hijo2 2Mb 10ms DropTail | |
$sim duplex-link $hijo1 $hijo3 2Mb 10ms DropTail | |
$sim duplex-link $hijo3 $ter1 1.5Mb 10ms DropTail | |
$sim duplex-link $hijo3 $ter2 1.5Mb 10ms DropTail | |
$sim duplex-link $hijo3 $ter3 1.5Mb 10ms DropTail | |
$sim duplex-link $hijo2 $ter4 1.5Mb 10ms DropTail | |
$sim duplex-link $ter3 $ter5 1.5Mb 10ms DropTail | |
$sim queue-limit $padre $hijo1 25 | |
$sim queue-limit $hijo1 $hijo2 15 | |
$sim queue-limit $hijo1 $hijo3 15 | |
$sim queue-limit $hijo3 $ter1 10 | |
$sim queue-limit $hijo3 $ter2 10 | |
$sim queue-limit $hijo3 $ter3 10 | |
$sim queue-limit $hijo2 $ter4 10 | |
$sim queue-limit $ter3 $ter5 10 | |
$sim duplex-link-op $padre $hijo1 orient down | |
$sim duplex-link-op $hijo1 $hijo2 orient down-right | |
$sim duplex-link-op $hijo1 $hijo3 orient down-left | |
$sim duplex-link-op $hijo3 $ter1 orient down-left | |
$sim duplex-link-op $hijo3 $ter2 orient down-right | |
$sim duplex-link-op $hijo3 $ter3 orient down | |
$sim duplex-link-op $ter3 $ter5 orient down | |
$sim duplex-link-op $hijo2 $ter4 orient down-right | |
} | |
#conexiones para topologia estrella | |
proc conecta_estrella {} { | |
global sim padre hijo1 hijo2 hijo3 ter1 ter2 ter3 ter4 ter5 | |
$sim duplex-link $padre $hijo1 2.5Mb 10ms DropTail | |
$sim duplex-link $padre $hijo2 2Mb 10ms DropTail | |
$sim duplex-link $padre $hijo3 2Mb 10ms DropTail | |
$sim duplex-link $padre $ter1 1.5Mb 10ms DropTail | |
$sim duplex-link $padre $ter2 1.5Mb 10ms DropTail | |
$sim duplex-link $padre $ter3 1.5Mb 10ms DropTail | |
$sim duplex-link $padre $ter4 1.5Mb 10ms DropTail | |
$sim duplex-link $padre $ter5 1.5Mb 10ms DropTail | |
$sim queue-limit $padre $hijo1 25 | |
$sim queue-limit $padre $hijo2 15 | |
$sim queue-limit $padre $hijo3 15 | |
$sim queue-limit $padre $ter1 10 | |
$sim queue-limit $padre $ter2 10 | |
$sim queue-limit $padre $ter3 10 | |
$sim queue-limit $padre $ter4 10 | |
$sim queue-limit $padre $ter5 10 | |
$sim duplex-link-op $padre $hijo1 orient down | |
$sim duplex-link-op $padre $hijo2 orient down-right | |
$sim duplex-link-op $padre $hijo3 orient down-left | |
$sim duplex-link-op $padre $ter1 orient up-left | |
$sim duplex-link-op $padre $ter2 orient up-right | |
$sim duplex-link-op $padre $ter3 orient up | |
$sim duplex-link-op $padre $ter5 orient right | |
$sim duplex-link-op $padre $ter4 orient left | |
} | |
#conexiones para topologia anillo | |
proc conecta_anillo {} { | |
global sim padre ter1 ter2 ter3 ter4 ter5 | |
$sim duplex-link $padre $ter1 1.5Mb 10ms DropTail | |
$sim duplex-link $ter1 $ter2 1.5Mb 10ms DropTail | |
$sim duplex-link $ter2 $ter3 1.5Mb 10ms DropTail | |
$sim duplex-link $ter3 $ter4 1.5Mb 10ms DropTail | |
$sim duplex-link $ter4 $ter5 1.5Mb 10ms DropTail | |
$sim duplex-link $ter5 $padre 1.5Mb 10ms DropTail | |
$sim queue-limit $padre $ter1 10 | |
$sim queue-limit $ter1 $ter2 10 | |
$sim queue-limit $ter2 $ter3 10 | |
$sim queue-limit $ter3 $ter4 10 | |
$sim queue-limit $ter4 $ter5 10 | |
$sim queue-limit $ter5 $padre 10 | |
$sim duplex-link-op $padre $ter1 orient down-right | |
$sim duplex-link-op $ter1 $ter2 orient down | |
$sim duplex-link-op $ter2 $ter3 orient down-left | |
$sim duplex-link-op $ter3 $ter4 orient up-left | |
$sim duplex-link-op $ter4 $ter5 orient up | |
$sim duplex-link-op $ter5 $padre orient up-right | |
} | |
#conexiones para topologia mixta | |
proc conecta_mixto {} { | |
global sim padre hijo1 hijo2 hijo3 ter1 ter2 ter3 ter4 ter5 | |
$sim duplex-link $padre $hijo1 2.5Mb 10ms DropTail | |
$sim duplex-link $padre $hijo2 2.5Mb 10ms DropTail | |
$sim duplex-link $hijo1 $hijo2 2Mb 10ms DropTail | |
$sim duplex-link $hijo1 $ter1 2Mb 10ms DropTail | |
$sim duplex-link $hijo2 $ter2 1.5Mb 10ms DropTail | |
$sim duplex-link $ter2 $ter1 1.5Mb 10ms DropTail | |
$sim duplex-link $ter1 $hijo3 1.5Mb 10ms DropTail | |
$sim duplex-link $hijo3 $ter3 1.5Mb 10ms DropTail | |
$sim duplex-link $hijo3 $ter1 1.5Mb 10ms DropTail | |
$sim duplex-link $ter3 $ter4 1.5Mb 10ms DropTail | |
$sim duplex-link $ter4 $ter1 1.5Mb 10ms DropTail | |
$sim duplex-link $ter4 $ter5 1.5Mb 10ms DropTail | |
$sim duplex-link $ter5 $ter2 1.5Mb 10ms DropTail | |
$sim queue-limit $padre $hijo1 25 | |
$sim queue-limit $padre $hijo2 15 | |
$sim queue-limit $hijo1 $hijo2 15 | |
$sim queue-limit $hijo2 $ter2 10 | |
$sim queue-limit $ter2 $ter1 10 | |
$sim queue-limit $ter1 $hijo3 10 | |
$sim queue-limit $hijo3 $ter3 10 | |
$sim queue-limit $hijo3 $ter1 10 | |
$sim queue-limit $ter3 $ter4 10 | |
$sim queue-limit $ter4 $ter1 10 | |
$sim queue-limit $ter4 $ter5 10 | |
$sim queue-limit $ter5 $ter2 10 | |
$sim duplex-link-op $padre $hijo1 queuePos 0.5 | |
$sim duplex-link-op $padre $hijo2 queuePos 0.5 | |
$sim duplex-link-op $hijo1 $hijo2 queuePos 0.5 | |
$sim duplex-link-op $hijo2 $ter2 queuePos 0.5 | |
$sim duplex-link-op $ter2 $ter1 queuePos 0.5 | |
$sim duplex-link-op $ter1 $hijo3 queuePos 0.5 | |
$sim duplex-link-op $hijo3 $ter3 queuePos 0.5 | |
$sim duplex-link-op $hijo3 $ter1 queuePos 0.5 | |
$sim duplex-link-op $ter3 $ter4 queuePos 0.5 | |
$sim duplex-link-op $ter4 $ter1 queuePos 0.5 | |
$sim duplex-link-op $ter4 $ter5 queuePos 0.5 | |
$sim duplex-link-op $ter5 $ter2 queuePos 0.5 | |
} | |
#conexiones para topologia lineal | |
proc conecta_lineal {} { | |
global sim padre hijo1 hijo2 hijo3 ter1 ter2 ter3 ter4 ter5 | |
$sim duplex-link $padre $hijo1 2.5Mb 10ms DropTail | |
$sim duplex-link $hijo1 $hijo2 2Mb 10ms DropTail | |
$sim duplex-link $hijo2 $hijo3 2Mb 10ms DropTail | |
$sim duplex-link $hijo3 $ter1 1.5Mb 10ms DropTail | |
$sim duplex-link $ter1 $ter2 1.5Mb 10ms DropTail | |
$sim duplex-link $ter2 $ter3 1.5Mb 10ms DropTail | |
$sim duplex-link $ter3 $ter4 1.5Mb 10ms DropTail | |
$sim duplex-link $ter4 $ter5 1.5Mb 10ms DropTail | |
$sim queue-limit $padre $hijo1 25 | |
$sim queue-limit $hijo1 $hijo2 15 | |
$sim queue-limit $hijo2 $hijo3 15 | |
$sim queue-limit $hijo3 $ter1 10 | |
$sim queue-limit $ter1 $ter2 10 | |
$sim queue-limit $ter2 $ter3 10 | |
$sim queue-limit $ter3 $ter4 10 | |
$sim queue-limit $ter4 $ter5 10 | |
$sim duplex-link-op $padre $hijo1 orient left | |
$sim duplex-link-op $hijo1 $hijo2 orient left | |
$sim duplex-link-op $hijo2 $hijo3 orient left | |
$sim duplex-link-op $hijo3 $ter1 orient left | |
$sim duplex-link-op $ter1 $ter2 orient left | |
$sim duplex-link-op $ter2 $ter3 orient left | |
$sim duplex-link-op $ter3 $ter4 orient left | |
$sim duplex-link-op $ter4 $ter5 orient left | |
} | |
proc llamada {topo} { | |
if {$topo == "estrella"} { | |
conecta_estrella | |
} elseif {$topo == "arbol"} { | |
conecta_arbol | |
} elseif {$topo == "anillo"} { | |
conecta_anillo | |
} elseif {$topo == "mixto"} { | |
conecta_mixto | |
} elseif {$topo == "lineal"} { | |
conecta_lineal | |
} else { | |
puts "Selecciona un comando, prueba arbol" | |
conecta_arbol | |
} | |
} | |
proc control {sch} { | |
global sim | |
if {$sch == "Calendar"} { | |
$sim use-scheduler Calendar | |
} elseif {$sch == "List"} { | |
$sim use-scheduler List | |
} elseif {$sch == "Heap"} { | |
$sim use-scheduler Heap | |
} else { | |
$sim use-scheduler Calenadar | |
} | |
} | |
set topo [lindex $argv 0] | |
set gene [lindex $argv 1] | |
set tam_paq [lindex $argv 2] | |
set rate [lindex $argv 3] | |
set sch [lindex $argv 4] | |
puts "Topologia seleccionada: $topo Tipo de trafico: $gene Tamano de paquete: $tam_paq Rate: $rate Scheme: $sch" | |
control $sch | |
llamada $topo | |
global sim padre ter4 ter5 | |
set tcp [new Agent/TCP] | |
$sim attach-agent $padre $tcp | |
set sink [new Agent/TCPSink] | |
$sim attach-agent $ter4 $sink | |
$sim connect $tcp $sink | |
set tcp2 [new Agent/TCP] | |
$sim attach-agent $padre $tcp2 | |
set sink2 [new Agent/TCPSink] | |
$sim attach-agent $ter5 $sink2 | |
$sim connect $tcp2 $sink2 | |
set ftp [new Application/FTP] | |
$ftp attach-agent $tcp | |
set ftp2 [new Application/FTP] | |
$ftp2 attach-agent $tcp2 | |
set udp [new Agent/UDP] | |
$sim attach-agent $padre $udp | |
set null [new Agent/Null] | |
$sim attach-agent $ter4 $null | |
$sim connect $udp $null | |
if {$gene == "CBR"} { | |
puts "algo" | |
set traffic [new Application/Traffic/CBR] | |
$traffic attach-agent $udp | |
$traffic set type_ CBR | |
$traffic set packetSize_ $tam_paq | |
$traffic set rate_ $rate | |
$traffic set random_ false | |
} elseif {$gene == "Expo"} { | |
set traffic [new Application/Traffic/Exponential] | |
$traffic attach-agent $udp | |
$traffic set packetSize_ $tam_paq | |
$traffic set rate_ $rate | |
$traffic set burst_time_ 500ms | |
$traffic set idle_time_ 50ms | |
} elseif {$gene == "Pareto"} { | |
set traffic [new Application/Traffic/Pareto] | |
$traffic attach-agent $udp | |
$traffic set burst_time_ 500ms | |
$traffic set idle_time_ 50ms | |
$traffic set rate_ $rate | |
$traffic set packetSize_ $tam_paq | |
$traffic set shape_ 1.5 | |
} else { | |
puts "Selecciona un comando, prueba CBR" | |
set traffic [new Application/Traffic/CBR] | |
$traffic attach-agent $udp | |
$traffic set type_ CBR | |
$traffic set packetSize_ $tam_paq | |
$traffic set rate_ $rate | |
$traffic set random_ true | |
} | |
$sim at 0.001 "$traffic start" | |
$sim at 0.01 "$ftp start" | |
$sim at 0.5 "$ftp stop" | |
$sim at 0.51 "$ftp2 start" | |
$sim at 1.0 "$ftp2 stop" | |
$sim at 1.5 "$traffic stop" | |
$sim at 1.0 "termina_1" | |
$sim run |