Download
ing henry z rate ceballos redes ad hoc n.
Skip this Video
Loading SlideShow in 5 Seconds..
Ing. Henry Zárate Ceballos. Redes Ad Hoc PowerPoint Presentation
Download Presentation
Ing. Henry Zárate Ceballos. Redes Ad Hoc

Ing. Henry Zárate Ceballos. Redes Ad Hoc

81 Vues Download Presentation
Télécharger la présentation

Ing. Henry Zárate Ceballos. Redes Ad Hoc

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. SIMULADOR NS 2 Ing. Henry Zárate Ceballos. Redes Ad Hoc

  2. AGENDA

  3. INTRODUCCIÓN

  4. NS 2 Ns–2 es un simulador de redes basado en eventos discretos. NS es ampliamente utilizado como herramienta educativa y de investigación. Probablemente NS2 es el simulador de redes de código abierto más extendido en investigación como para propósitos docentes, funciona en varios sistemas operativos como Linux, OS X, Solaris, Windows y es el más útil para simular un escenario para MANET's de forma muy simple.

  5. ¿Que se puede SIMULAR?

  6. CICLO DE PROGRAMACIÓN

  7. Arquitectura Básica

  8. Ns - Arquitectura

  9. ARQUITECTURA

  10. Topología simple de una Red

  11. Creando topologías 5Mbps, 10ms 300Kbps, 100ms n1 n5 n3 500Kbps, 50ms n4 n2 n6 2Mbps, 20ms 300Kbps, 100ms

  12. Observación del comportamiento de la red Src Dst IP Address, Port time

  13. A simple Example – Creating the topology Bandwidth:1Mbps Latency: 10ms n1 n2

  14. Creating the topology #create a new simulator object set ns [new Simulator] #open the nam trace file set nf [open out.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 out.nam & exit 0 }

  15. Creating the topology (Contd) #create two nodes set n0 [$ns node] set n1 [$ns node] #create a duplex link between the nodes $ns duplex-link $n0 $n1 1Mb 10ms DropTail

  16. DEMO

  17. node agent source link cbr traffic 0.5 4.5 time 5.0 0.0 Adding traffic 1Mbps,10ms n1 n2 udp null cbr Packet Size: 500 bytes rate: 800Kbps Vacha Dave, University of Texas at Austin

  18. Uniendo todo el código #create a udp agent and attach it to node n0 set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0 #Create a CBR traffic source and attach it to udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ 0.005 $cbr0 attach-agent $udp0 #create a Null agent(a traffic sink) and attach it to node n1 set null0 [new Agent/Null] $ns attach-agent $n1 $null0 #Connect the traffic source to the sink $ns connect $udp0 $null0 #Schedule events for CBR traffic $ns at 0.5 "$cbr0 start" $ns at 4.5 "$cbr0 stop" #call the finish procedure after 5 secs of simulated time $ns at 5.0 "finish" #run the simulation $ns run Vacha Dave, University of Texas at Austin

  19. DEMO

  20. A second Scenario * (from NS by Example) Taken from NS by Example by Jae ChungandMark Claypool

  21. A second Example (From NS by Example) #Create a simulator object set ns [new Simulator] #Define different colors for data flows (for NAM) $ns color 1 Blue $ns color 2 Red #Open the NAM trace file set nf [open out.nam w] $ns namtrace-all $nf #Define a 'finish' procedure proc finish {} { global ns nf $ns flush-trace #Close the NAM trace file close $nf #Execute NAM on the trace file exec nam out.nam & exit 0 }

  22. A Second Scenario (Contd.) #Create four nodes set n0 [$ns node] set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] #Create links between the nodes $ns duplex-link $n0 $n2 2Mb 10ms DropTail $ns duplex-link $n1 $n2 2Mb 10ms DropTail $ns duplex-link $n2 $n3 1.7Mb 20ms DropTail #Set Queue Size of link (n2-n3) to 10 $ns queue-limit $n2 $n3 10

  23. A Second Scenario (Contd.) #Give node position (for NAM) $ns duplex-link-op $n0 $n2 orient right-down $ns duplex-link-op $n1 $n2 orient right-up $ns duplex-link-op $n2 $n3 orient right #Monitor the queue for link (n2-n3). (for NAM) $ns duplex-link-op $n2 $n3 queuePos 0.5

  24. A Second Scenario (Contd.) To create agents or traffic sources, we need to know the class names these objects (Agent/TCP, Agent/TCPSink, Application/FTP and so on). This information can be found in the NS documentation. But one shortcut is to look at the "ns-2/tcl/libs/ns-default.tcl" file. #Setup a TCP connection set tcp [new Agent/TCP] $tcp set class_ 2 $ns attach-agent $n0 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n3 $sink $ns connect $tcp $sink $tcp set fid_ 1 #Setup a FTP over TCP connection set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP

  25. A Second Scenario (Contd.) #Setup a UDP connection set udp [new Agent/UDP] $ns attach-agent $n1 $udp set null [new Agent/Null] $ns attach-agent $n3 $null $ns connect $udp $null $udp set fid_ 2 #Setup a CBR over UDP connection set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set type_ CBR $cbr set packet_size_ 1000 $cbr set rate_ 1mb $cbr set random_ false

  26. Simulación

  27. Ns all in one ns-allinone Tcl8.0 TK8.0 OTcl tclcl ns-2 nam-1 C++ code ... tcl mcast lib ... ex test mysrc examples msg.tcl validation tests OTcl code

  28. Instalación

  29. Pasos de instalación Desde el gestor de Descargas

  30. Pasos de instalación Desde el terminal $ sudo apt-get install «paquete» (para instalar) ns nam xgraph$ sudo apt-get remove «paquete» (para desinstalar)

  31. Entorno de Simulación

  32. Terminal

  33. Terminal

  34. Simulación y resultados

  35. Ejercicios

  36. Estructura

  37. Ejercicio 1 set ns [new Simulator] set nf [open out.nam w] $ns namtrace-all $nf procfinish {} { global ns nf $ns flush-trace close $nf exec nam out.nam & exit 0 }

  38. set n0 [$ns node] set n1 [$ns node] $ns duplex-link $n0 $n1 1Mb 10ms DropTail

  39. #Create a UDP agent and attachittonode n0 set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0

  40. # Create a CBR trafficsource and attachitto udp0 set cbr0 [new Application/Traffic/CBR] $cbr0 set packetSize_ 500 $cbr0 set interval_ 0.005 $cbr0 attach-agent $udp0 set null0 [new Agent/Null] $ns attach-agent $n1 $null0 $ns connect $udp0 $null0 $ns at 0.5 "$cbr0 start" $ns at 4.5 "$cbr0 stop"

  41. $ns at 5.0 "finish" $ns run

  42. Trabajo Post Simulación

  43. Awk Awk es un lenguaje de programación que permite una fácil manipulación delos datos estructurados y la generación de informes con formato. Awk es sinónimo de los nombres de sus autores "Aho, Weinberger, y Kernighan" Software analizador de trazas, es un complemento usado post simulación para analizar los resultados obtenidos en los diferentes simuladores

  44. Awk El Awk se utiliza sobre todo para el patrón de análisis y procesamiento. Busca uno o más archivos para ver si contienen las líneas que coincidan con los patrones especificados y a continuación realice las acciones asociadas. awk <pattern> '{print <stuff>}' <file> Ejemplo awk '{print "Hit the",$1,"with your",$2}' words.dataHit the nail with your hammerHit the pedal with your footHit the clown with your pie

  45. Awk Algunas de las características clave de Awk son: