Download - Ing. Henry Zárate Ceballos. Redes Ad Hoc
![Page 1: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/1.jpg)
Ing. Henry Zárate Ceballos.Redes Ad Hoc
![Page 2: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/2.jpg)
Page 2
AGENDA
1. INTRODUCCIÓN
2. ENTORNO DE SIMULACIÓN
3.Ejercicios.
4. BASICOS
5. REDES AD HOC
6. REDES MESH
7. CONCLUSIONES
8. PREGUNTAS
![Page 3: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/3.jpg)
Page 3
INTRODUCCIÓN
![Page 4: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/4.jpg)
Page 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.
![Page 5: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/5.jpg)
Page 5
¿Que se puede SIMULAR?
![Page 6: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/6.jpg)
Page 6
![Page 7: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/7.jpg)
Page 7
Simular estructuras y protocolos de redes de todo tipo (satélite, wireless, cableadas, etc..)
Desarrollar nuevos protocolos y algoritmos y comprobar su funcionamiento.
Comparar distintos protocolos en cuanto a prestaciones
![Page 8: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/8.jpg)
Page 8
CICLO DE PROGRAMACIÓN
Archivo de entrada
Depuración lenguaje Otcl
Archivo de salida
![Page 9: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/9.jpg)
Page 9
Arquitectura Básica
![Page 10: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/10.jpg)
Page 10
![Page 11: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/11.jpg)
Page 11
Ns - Arquitectura
![Page 12: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/12.jpg)
Page 12
ARQUITECTURA
![Page 13: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/13.jpg)
Page 13
Topología simple de una Red
![Page 14: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/14.jpg)
Page 14
Creando topologías
14
n1
n4
n2
n5
n6
n3
5Mbps,10ms
2Mbps,20ms
300Kbps,100ms
300Kbps,100ms
500Kbps,50ms
![Page 15: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/15.jpg)
Page 15
Observación del comportamiento de la red
Src Dst IP Address, Port
time
![Page 16: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/16.jpg)
Page 16
A simple Example – Creating the topology
n1 n2
Bandwidth:1MbpsLatency: 10ms
![Page 17: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/17.jpg)
Page 17
#create a new simulator objectset ns [new Simulator]
#open the nam trace fileset nf [open out.nam w]$ns namtrace-all $nf
#define a 'finish' procedureproc 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}
Creating the topology
![Page 18: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/18.jpg)
Page 18
Creating the topology (Contd)
#create two nodesset n0 [$ns node]set n1 [$ns node]
#create a duplex link between the nodes$ns duplex-link $n0 $n1 1Mb 10ms DropTail
![Page 19: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/19.jpg)
Page 19
DEMO
![Page 20: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/20.jpg)
Page 20 Vacha Dave, University of Texas at Austin20
Adding traffic
n1 n21Mbps,10ms
udp null
cbr
Packet Size: 500 bytesrate: 800Kbps
cbr traffic
0.00.5 5.04.5 time
node agent sourcelink
![Page 21: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/21.jpg)
Page 21 Vacha Dave, University of Texas at Austin21
Uniendo todo el código
#create a udp agent and attach it to node n0set udp0 [new Agent/UDP]$ns attach-agent $n0 $udp0
#Create a CBR traffic source and attach it to udp0set 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 n1set 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
![Page 22: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/22.jpg)
Page 22
DEMO
![Page 23: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/23.jpg)
Page 23
A second Scenario * (from NS by Example)
Taken from NS by Example by Jae ChungandMark Claypool
![Page 24: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/24.jpg)
Page 24
A second Example (From NS by Example)
#Create a simulator objectset ns [new Simulator]
#Define different colors for data flows (for NAM)$ns color 1 Blue$ns color 2 Red
#Open the NAM trace fileset nf [open out.nam w]$ns namtrace-all $nf
#Define a 'finish' procedureproc 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}
![Page 25: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/25.jpg)
Page 25
A Second Scenario (Contd.)
#Create four nodesset 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
![Page 26: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/26.jpg)
Page 26
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
![Page 27: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/27.jpg)
Page 27
A Second Scenario (Contd.)
#Setup a TCP connectionset tcp [new Agent/TCP]$tcp set class_ 2$ns attach-agent $n0 $tcpset sink [new Agent/TCPSink]$ns attach-agent $n3 $sink$ns connect $tcp $sink$tcp set fid_ 1
#Setup a FTP over TCP connectionset ftp [new Application/FTP]$ftp attach-agent $tcp$ftp set type_ FTP
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.
![Page 28: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/28.jpg)
Page 28
A Second Scenario (Contd.)
#Setup a UDP connectionset udp [new Agent/UDP]$ns attach-agent $n1 $udpset null [new Agent/Null]$ns attach-agent $n3 $null$ns connect $udp $null$udp set fid_ 2
#Setup a CBR over UDP connectionset 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
![Page 29: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/29.jpg)
Page 29
![Page 30: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/30.jpg)
Page 30
Simulación
![Page 31: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/31.jpg)
Page 31
Ns all in one
TK8.0 OTcl tclclTcl8.0 ns-2 nam-1
tcl
ex test lib
...
...
examples validation tests
C++ code
OTcl code
ns-allinone
mcastmysrc
msg.tcl
![Page 32: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/32.jpg)
Page 32
INSTALACIÓN
![Page 33: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/33.jpg)
Page 33
Pasos de instalación Desde el gestor de Descargas
![Page 34: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/34.jpg)
Page 34
Pasos de instalación
Desde el terminal
$ sudo apt-get install «paquete» (para instalar) ns
nam xgraph
$ sudo apt-get remove «paquete» (para desinstalar)
![Page 35: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/35.jpg)
Page 35
ENTORNO DE SIMULACIÓN
![Page 36: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/36.jpg)
Page 36
Terminal
![Page 37: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/37.jpg)
Page 37
Terminal
![Page 38: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/38.jpg)
Page 38
Simulación y resultados
![Page 39: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/39.jpg)
Page 39
![Page 40: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/40.jpg)
Page 40
EJERCICIOS
![Page 41: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/41.jpg)
Page 41
Estructura
![Page 42: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/42.jpg)
Page 42
Ejercicio 1
set ns [new Simulator] set nf [open out.nam w] $ns namtrace-all $nf proc finish {} { global ns nf $ns flush-trace close $nf exec nam out.nam & exit 0 }
![Page 43: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/43.jpg)
Page 43
set n0 [$ns node] set n1 [$ns node] $ns duplex-link $n0 $n1 1Mb 10ms DropTail
![Page 44: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/44.jpg)
Page 44
#Create a UDP agent and attach it to node n0 set udp0 [new Agent/UDP] $ns attach-agent $n0 $udp0
![Page 45: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/45.jpg)
Page 45
# 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 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"
![Page 46: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/46.jpg)
Page 46
$ns at 5.0 "finish" $ns run
![Page 47: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/47.jpg)
Page 47
TRABAJO POST SIMULACIÓN
![Page 48: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/48.jpg)
Page 48
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
![Page 49: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/49.jpg)
Page 49
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.data
Hit the nail with your hammerHit the pedal with your footHit the clown with your pie
![Page 50: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/50.jpg)
Page 50
Awk
Algunas de las características clave de Awk son:
1 •Awk ve un archivo de texto como los registros y campos.Como el lenguaje de programación común, Awk tiene variables, condicionales y bucles
2 •Awk tiene la aritmética y de cadena.•Awk puede generar informes en formato
3 •Awk lee de un archivo o desde su entrada estándar, y las salidas a su salida estándar. Awk no se lleva bien con archivos de texto no.
![Page 51: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/51.jpg)
Page 51
Ejemplo
![Page 52: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/52.jpg)
Page 52
Ejemplo
![Page 53: Ing. Henry Zárate Ceballos. Redes Ad Hoc](https://reader035.vdocuments.pub/reader035/viewer/2022062502/5681335b550346895d9a7282/html5/thumbnails/53.jpg)
Page 53
CONCLUSIONES