Upload
victorandres
View
8
Download
0
Embed Size (px)
DESCRIPTION
Redes de computacion, protocolos y demas
Citation preview
Introducción a NS2
UNIVERSIDAD DISTRITAL FRANCISCO JOSE DE CALDAS
FACULTAD DE INGENIERÍA
Agenda
Introducción al NS2 Introducción al TCL, variables,
procedimientos, llamado a otros programas, Comandos de TCL
Estructura de una simulación en NS2, Scripts de simulación
Network AniMator Construcción de nodos, wireless nodes,
configuración, variables globales de NS2 Análisis de archivos de Trace de NS2
NS2, Network Simulator
A discrete event simulator
Developed for networking research
Focused on modeling network protocols
Not a finished product
NS Goals
Support networking research and education Protocol design, traffic studies, etc.
Provide a collaborative environment Freely distributed, open source
Share code, protocols, models, etc.
Allow easy comparison of similar protocols Increase confidence in results
Multiple levels of detail in one simulator
NS functionalities Wired world
Routing Protocols Transport Protocols Traffic sources: HTTP, FTP, Telnet, CBR Queuing disciplines QoS Models: IntServ and Diffserv
Wireless Ad hoc routing and mobile IP Sensor-MAC
Tracing, visualization, various utilities
NS Components
NS, the simulator itself NAM, the network animator
Visualize NS (or other) output NAM editor: GUI interface
Pre-processing: Traffic and topology generators
Post-processing: Simple trace analysis, often in Awk, Perl, or Tcl
Installation, resources
Download ns fromhttp://www.isi.edu/nsnam/ns/ns-build.html
Installation problems and bug fixeshttp://www.isi.edu/nsnam/ns/ns-problems.html
ns mailing list: [email protected] ns manual
http://www.isi.edu/nsnam/ns/ns-documentation.html ns-nam search site:
http://www.isi.edu/nsnam/htdig/search.html
TCL
Lenguaje de Script, orientado a la configuración de las entidades de la simulación.
set ns [new Simulator]
set n0 [$ns node]set n1 [$ns node]$ns duplex-link $n0 $n1 1Mb 10ms DropTail
set udp0 [new Agent/UDP]$ns attach-agent $n0 $udp0
set cbr0 [new Application/Traffic/CBR]$cbr0 set packetSize_ 500$cbr0 set interval_ 0.001$cbr0 attach-agent $udp0
set null0 [new Agent/Null]$ns attach-agent $n1 $null0$ns connect $udp0 $null0
$ns at 5.0 "finish"$ns at 0.5 "$cbr0 start"$ns at 4.99 "$cbr0 stop"$ns run
TCL
Declaración y utilización de variables
Store a random number in the variable r: set r [expr rand()] set a 10 set b 20 set c [expr $a + $b]
Usando NS
Problem
Simulationmodel
Setup/run simulation
with ns
Resultanalysis
Modifyns
Estructura de una simulación
Definición de parámetros, configuración general.
Definición de procedimientos varios. Definición de entidades, topología. Programación de eventos. Ejecución de la simulación.
Creación de nodos en el NS2$ns node-config -adhocRouting
$val(rp) \-llType $val(ll) \-macType $val(mac) \-ifqType $val(ifq) \-ifqLen $val(ifqlen) \-antType $val(ant) \-propType $val(prop) \-phyType $val(netif) \-topoInstance $topo \-channelType $val(chan) \-agentTrace ON \-routerTrace ON \-macTrace ON \-movementTrace OFF
#Create nodesfor {set i 0} {$i < $val(nn) } {incr i} {
set node_($i) [$ns node ]}
Dentro de los Scripts analizados, se ejecutaron comandos como los siguientes.
set n0 [$ns node] set n1 [$ns node]
set val(chan) Channel/WirelessChannel; set val(prop) Propagation/TwoRayGround; set val(ant) Antenna/OmniAntenna ; set val(ll) LL ; set val(ifq) CMUPriQueue ;set val(ifqlen) 50 ; set val(netif) Phy/WirelessPhy ;
set val(mac) Mac/802_11 ; set val(rp) DSR ;set val(nn) 2 ;
Wireless Internals
Mobilenode Basic node that has address and port de-
muxes, routing agent etc Stack of network components consisting
of LL, MAC, NetIF radio-model etc Wireless channel
Mobile Node: Components
Link Layer Same as LAN, but with a separate ARP module Sends queries to ARP
ARP Resolves IP address to hardware (MAC) address Broadcasts ARP query
Interface queue Gives priority to routing protocol packets Has packet filtering capacity
Mobile Node: Components
MAC 802.11
IEEE RTS/CTS/DATA/ACK for unicast Sends DATA directly for broadcast
Network interface (PHY) Used by mobilenode to access channel Stamps outgoing packets with meta-data Interface with radio/antenna models
Ad Hoc Routing
Four routing protocols currently supported: DSDV
Contributed by CMU DSR
Contributed by CMU; recently updated AODV
Recently updated from Univ. of Cincinnati TORA
Contributed by CMU Examples under tcl/test/test-suite-wireless- { lan-newnode.tcl, lan-aodv.tcl, lan-tora.tcl }
Creating Network
Nodesset n0 [$ns node]set n1 [$ns node]
Links and queuing$ns <link_type> $n0 $n1 <bandwidth>
<delay> <queue_type> <link_type>: duplex-link, simplex-link <queue_type>: DropTail, RED, CBQ, FQ,
SFQ, DRR, diffserv RED queues
Creating Connection and Traffic
UDPset udp [new Agent/UDP]set null [new Agent/Null]$ns attach-agent $n0 $udp$ns attach-agent $n1 $null$ns connect $udp $null
CBRset src [new
Application/Traffic/CBR] Exponential or Pareto
on-offset src [new
Application/Traffic/Exponential]set src [new
Application/Traffic/Pareto]
Creating Connection and Traffic II
TCPset tcp [new Agent/TCP]set tcpsink [new Agent/TCPSink]$ns attach-agent $n0 $tcp$ns attach-agent $n1 $tcpsink$ns connect $tcp $tcpsink
FTPset ftp [new Application/FTP]$ftp attach-agent $tcp Telnetset telnet [new Application/Telnet]$telnet attach-agent $tcp
Creating Event Scheduler
Create event schedulerset ns [new Simulator]
Schedule events$ns at <time> <event>
<event>: any legitimate ns/tcl commands$ns at 5.0 “finish”
Start scheduler$ns run
Tracing and Monitoring
Packet tracing: On all links: $ns trace-all [open out.tr w] On one specific link: $ns trace-queue $n0 $n1 $tr
<Event> <time> <from> <to> <pkt> <size> -- <fid> <src> <dst> <seq> <attr>
+ 1 0 2 cbr 210 ------- 0 0.0 3.1 0 0
- 1 0 2 cbr 210 ------- 0 0.0 3.1 0 0
r 1.00234 0 2 cbr 210 ------- 0 0.0 3.1 0 0
Visualize trace in nam$ns namtrace-all [open test.nam w]
$ns namtrace-queue $n0 $n1
Archivos de salida de NS2
Mostrar los formatos de los archivos de salida de NS2.
Mostrar las herramientas de análisis de Unix cat, awk.
Preguntas