El protocolo de red de Internet: IP :: Redes ::
El protocolo de red de Internet: IP :: Redes ::
El protocolo de red de Internet: IP :: Redes ::
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Versión 28/02/11<br />
:: Re<strong>de</strong>s ::<br />
aplicación<br />
transporte<br />
<strong>red</strong><br />
enlace<br />
<strong>El</strong> <strong>protocolo</strong> <strong>de</strong> <strong>red</strong><br />
<strong>de</strong> <strong>Internet</strong>: <strong>IP</strong><br />
física<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 1
Introducción<br />
Protocolo <strong>IP</strong><br />
● Formato <strong>de</strong>l paquete <strong>IP</strong><br />
Contenido<br />
● Direccionamiento<br />
● DHCP<br />
ARP<br />
ICMP<br />
Gestión <strong>de</strong> Re<strong>de</strong>s <strong>IP</strong><br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 2
:: Protocolo <strong>IP</strong> ::<br />
Introducción<br />
RFC<br />
791<br />
<strong>IP</strong> (<strong>Internet</strong> Protocol) proporciona un servicio <strong>de</strong><br />
comunicación no confiable y no orientado a conexión<br />
(datagramas).<br />
No se garantiza la entrega <strong>de</strong> los paquetes, ni el or<strong>de</strong>n <strong>de</strong><br />
entrega.<br />
Realiza un servicio best-effort. Es <strong>de</strong>cir, sin ninguna<br />
garantía <strong>de</strong> entrega.<br />
Los paquetes se encaminan a su <strong>de</strong>stino como entida<strong>de</strong>s<br />
in<strong>de</strong>pendientes entre sí.<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 3
:: Protocolo <strong>IP</strong> ::<br />
Introducción<br />
<strong>IP</strong> cubre los aspectos fundamentales <strong>de</strong> la capa <strong>de</strong> <strong>red</strong>:<br />
●<br />
Formato <strong>de</strong>l datagrama <strong>IP</strong><br />
●<br />
Esquema <strong>de</strong> direccionamiento<br />
●<br />
Encaminamiento<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 4
:: Protocolo <strong>IP</strong> ::<br />
Paquete <strong>IP</strong> :: Formato <strong>de</strong>l paquete<br />
Paquete <strong>IP</strong><br />
20 – 60 bytes<br />
encabezado<br />
20 – 65536 bytes<br />
carga (payload)<br />
0 1 2 3<br />
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1<br />
20 bytes<br />
versión IHL tipo <strong>de</strong> servicio longitud total<br />
i<strong>de</strong>ntificación<br />
tiempo <strong>de</strong> vida <strong>protocolo</strong> checksum<br />
D<br />
F<br />
M<br />
F<br />
dirección <strong>de</strong>l origen<br />
offset <strong>de</strong>l fragmento<br />
dirección <strong>de</strong>l <strong>de</strong>stino<br />
0 – 40 B<br />
opciones<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 5
:: Protocolo <strong>IP</strong> ::<br />
Paquete <strong>IP</strong> :: Encabezado<br />
Versión (4 bits): Es la versión <strong>de</strong>l <strong>protocolo</strong> <strong>IP</strong>. Es un 4 para <strong>IP</strong>v4<br />
y un 6 en <strong>IP</strong>v6.<br />
IHL (<strong>Internet</strong> Hea<strong>de</strong>r Length) (4 bits): Es la longitud <strong>de</strong>l<br />
encabezado, se indica en palabras <strong>de</strong> 32 bits.<br />
Tipo <strong>de</strong> servicio / Servicios diferenciados (8 bits)<br />
●<br />
Sirven para priorización <strong>de</strong> tráfico y distinción <strong>de</strong> servicios. En<br />
la práctica la mayoría <strong>de</strong> los routers lo ignoran<br />
Longitud total (16 bits)<br />
●<br />
Tamaño total <strong>de</strong>l paquete incluido el encabezado. Por tanto, el<br />
tamaño máximo <strong>de</strong> un paquete <strong>IP</strong> es 65.535 bytes.<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 6
:: Protocolo <strong>IP</strong> ::<br />
Paquete <strong>IP</strong> :: Encabezado<br />
I<strong>de</strong>ntificación (16 bits): Todos los fragmentos <strong>de</strong> un mismo<br />
datagrama utilizan el mismo i<strong>de</strong>ntificador.<br />
DF (Don't Fragment) (1 bit). Indica a los enrutadores que no<br />
fragmenten este paquete.<br />
MF (More Fragments) (1 bit). Indica que hay más fragmentos para<br />
este datagrama. En el último fragmento vale 0.<br />
Desplazamiento (13 bits). Es la posición <strong>de</strong> este fragmento en el<br />
datagrama fragmentado. Se indica en palabras <strong>de</strong> 8 bytes. Pue<strong>de</strong><br />
haber un máximo <strong>de</strong> 8192 fragmentos para un mismo datagrama.<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 7
:: Protocolo <strong>IP</strong> ::<br />
Paquete <strong>IP</strong> :: Encabezado<br />
Tiempo <strong>de</strong> vida (8 bits): Es el tiempo máximo <strong>de</strong> vida (en<br />
segundos) pero en la práctica sólo se <strong>de</strong>crementa cuando un<br />
enrutador reenvía el paquete. Es el nº <strong>de</strong> saltos.<br />
Protocolo (8 bits): Un código que indica qué <strong>protocolo</strong> <strong>de</strong><br />
transporte está encapsulado en la carga <strong>de</strong>l paquete.<br />
● ICMP – 1<br />
● IGMP – 2<br />
● TCP – 6<br />
● UDP – 17<br />
● OSPF – 89<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 8
:: Protocolo <strong>IP</strong> ::<br />
Paquete <strong>IP</strong> :: Encabezado<br />
Checksum (16 bits): Es una verificación que afecta<br />
únicamente al encabezado. Se <strong>de</strong>be recalcular a cada salto.<br />
Origen (32 bits): Dirección <strong>IP</strong> <strong>de</strong>l host origen.<br />
Destino (32 bits): Dirección <strong>IP</strong> <strong>de</strong>l host <strong>de</strong>stino.<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 9
:: Protocolo <strong>IP</strong> ::<br />
Paquete <strong>IP</strong> :: Ejemplo <strong>de</strong> Fragmentación<br />
14.567 1<br />
1420<br />
000<br />
f.1<br />
datos<br />
0000 - 1399<br />
14.567 1<br />
820<br />
175<br />
f.2.1<br />
14.567 0<br />
4020<br />
000<br />
14.567 1<br />
1420<br />
175<br />
f.2<br />
datos<br />
1400 - 2199<br />
datos<br />
0000 - 3999<br />
datagrama original<br />
datos<br />
1400 - 2799<br />
14.567 1<br />
620<br />
275<br />
f.2.2<br />
14.567 0<br />
1220<br />
350<br />
f.3<br />
datos<br />
2200 - 2799<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
[<strong>de</strong>: B.A.Forouzan, TCP/<strong>IP</strong> Protocol Suite]<br />
datos<br />
2800 - 3999<br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 10
:: Protocolo <strong>IP</strong> ::<br />
Paquete <strong>IP</strong> :: Opciones<br />
Las opciones sirven para indicar características <strong>de</strong> poco uso o<br />
para exten<strong>de</strong>r la funcionalidad <strong>de</strong>l <strong>protocolo</strong>.<br />
código longitud datos<br />
8 8<br />
Variable<br />
copiar<br />
clase<br />
número<br />
1<br />
2<br />
5<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
Copiar: copiar esta opción en todos los fragmentos o sólo en el primero<br />
Clase: 00 (control), 10 (gestión y <strong>de</strong>puración), 11 y 01 (no <strong>de</strong>finidos)<br />
Número: <strong>El</strong> tipo <strong>de</strong> opción. En la actualidad hay 6, <strong>de</strong> 32 posibles<br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 11
:: Protocolo <strong>IP</strong> ::<br />
Paquete <strong>IP</strong> :: Opciones :: tipos<br />
Las opciones sirven para indicar características <strong>de</strong> poco uso o<br />
para exten<strong>de</strong>r la funcionalidad <strong>de</strong>l <strong>protocolo</strong>.<br />
●<br />
0 00 00000 – End of option<br />
●<br />
0 00 00001 – No operation<br />
●<br />
1 00 00011 – Loose source route<br />
●<br />
0 10 00100 – Timestamp<br />
●<br />
0 00 00111 – Record Route<br />
●<br />
1 00 01001 – Strict Source Route<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 12
:: Protocolo <strong>IP</strong> ::<br />
Paquete <strong>IP</strong> :: Opciones :: No operación<br />
Se utiliza como relleno para alinear la siguiente opción a 16 o 32 bits<br />
0<br />
0 1 2 3 4 5 6 7 8 9<br />
1<br />
0 1 2 3 4 5 6 7 8 9<br />
2<br />
0 1 2 3 4 5 6 7 8 9<br />
3<br />
0 1<br />
opción <strong>de</strong> 11 bytes<br />
nop (1 byte)<br />
0<br />
0 1 2 3 4 5 6 7 8 9<br />
1<br />
0 1 2 3 4 5 6 7 8 9<br />
2<br />
0 1 2 3 4 5 6 7 8 9<br />
3<br />
0 1<br />
opción <strong>de</strong> 7 bytes<br />
nop (1 byte)<br />
opción <strong>de</strong> 8 bytes<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 13
:: Protocolo <strong>IP</strong> ::<br />
Paquete <strong>IP</strong> :: Opciones :: Opción <strong>de</strong> fin<br />
Se utiliza como relleno al final <strong>de</strong> la lista <strong>de</strong> opciones.<br />
0<br />
0 1 2 3 4 5 6 7 8 9<br />
1<br />
0 1 2 3 4 5 6 7 8 9<br />
2<br />
0 1 2 3 4 5 6 7 8 9<br />
3<br />
0 1<br />
opciones<br />
end (1 byte)<br />
datos<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 14
:: Protocolo <strong>IP</strong> ::<br />
Paquete <strong>IP</strong> :: Opciones :: Registrar ruta<br />
Se utiliza para indicar a los enrutadores que almacenen su<br />
dirección cuando procesen este datagrama.<br />
0<br />
0 1 2 3 4 5 6 7 8 9<br />
1<br />
0 1 2 3 4 5 6 7 8 9<br />
2<br />
0 1 2 3 4 5 6 7 8 9<br />
3<br />
0 1<br />
código (7)<br />
tamaño<br />
puntero<br />
<strong>IP</strong> <strong>de</strong>l primer enrutador<br />
<strong>IP</strong> <strong>de</strong>l segundo enrutador<br />
...<br />
<strong>IP</strong> <strong>de</strong>l último enrutador<br />
La lista <strong>de</strong> direcciones tiene siempre el mismo tamaño. <strong>El</strong> origen la<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
inicializa cuando envía el datagrama a la <strong>red</strong>.<br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 15
:: Protocolo <strong>IP</strong> ::<br />
Paquete <strong>IP</strong> :: Opciones ::<br />
Enrutamiento estricto <strong>de</strong>s<strong>de</strong> el origen<br />
<strong>El</strong> datagrama <strong>de</strong>be pasar por todos los enrutadores que aparecen<br />
en la lista, y sólo por ellos.<br />
0<br />
0 1 2 3 4 5 6 7 8 9<br />
1<br />
0 1 2 3 4 5 6 7 8 9<br />
2<br />
0 1 2 3 4 5 6 7 8 9<br />
3<br />
0 1<br />
código (137)<br />
tamaño<br />
puntero<br />
<strong>IP</strong> <strong>de</strong>l primer enrutador<br />
<strong>IP</strong> <strong>de</strong>l segundo enrutador<br />
...<br />
<strong>IP</strong> <strong>de</strong>l último enrutador<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 16
:: Protocolo <strong>IP</strong> ::<br />
Paquete <strong>IP</strong> :: Opciones ::<br />
Enrutamiento libre <strong>de</strong>s<strong>de</strong> el origen<br />
<strong>El</strong> datagrama <strong>de</strong>be pasar por todos los enrutadores que aparecen<br />
en la lista, pero pue<strong>de</strong> pasar también por otros.<br />
0<br />
0 1 2 3 4 5 6 7 8 9<br />
1<br />
0 1 2 3 4 5 6 7 8 9<br />
2<br />
0 1 2 3 4 5 6 7 8 9<br />
3<br />
0 1<br />
código (131)<br />
tamaño<br />
puntero<br />
<strong>IP</strong> <strong>de</strong>l primer enrutador<br />
<strong>IP</strong> <strong>de</strong>l segundo enrutador<br />
...<br />
<strong>IP</strong> <strong>de</strong>l último enrutador<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 17
:: Protocolo <strong>IP</strong> ::<br />
Paquete <strong>IP</strong> :: Opciones :: Marca <strong>de</strong> tiempo<br />
Los enrutadores apuntarán en el datagrama una marca <strong>de</strong> tiempo<br />
<strong>de</strong> 32 bits y <strong>de</strong>pendiendo <strong>de</strong> los flags también su dirección <strong>IP</strong><br />
0<br />
0 1 2 3 4 5 6 7 8 9<br />
1<br />
0 1 2 3 4 5 6 7 8 9<br />
2<br />
0 1 2 3 4 5 6 7 8 9<br />
3<br />
0 1<br />
código (68)<br />
tamaño<br />
puntero<br />
O-Flow<br />
Flags<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 18
:: Direccionamiento ::<br />
La dirección <strong>IP</strong> es un número <strong>de</strong> 32 bits e i<strong>de</strong>ntifica el punto <strong>de</strong><br />
conexión (la interface) entre un host y una <strong>red</strong>. <strong>El</strong> espacio <strong>de</strong><br />
direccionamiento es 2 32 = 4.294.967.296<br />
Un host con conexiones a varias re<strong>de</strong>s <strong>de</strong>be tener (al menos) una<br />
dirección <strong>IP</strong> por cada interfaz.<br />
La dirección <strong>IP</strong> tiene dos partes:<br />
●<br />
●<br />
Direccionamiento <strong>IP</strong><br />
Un NetID, que i<strong>de</strong>ntifica una <strong>red</strong> (<strong>de</strong>signado por una autoridad global),<br />
la IANA (<strong>Internet</strong> Assigned Number Authority)<br />
Un HostID, que i<strong>de</strong>ntifica un host <strong>de</strong>ntro <strong>de</strong> esa <strong>red</strong>.<br />
sub<strong>red</strong><br />
host<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
32 bits<br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 19
Direccionamiento <strong>IP</strong> :: Direcciones especiales<br />
00000000.00000000.00000000.00000000<br />
Este host<br />
11111111.11111111.11111111.11111111 Todos los hosts <strong>de</strong> esta <strong>red</strong><br />
XX ... XX<br />
00 ... 00<br />
Esa <strong>red</strong><br />
XX ... XX<br />
11 ... 11<br />
Todos los host <strong>de</strong> esa <strong>red</strong><br />
00 ... 00 XX ... XX Un host <strong>de</strong> esta <strong>red</strong><br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
01111111.00000000.00000000.00000001 iface loopback<br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 20
:: Direccionamiento ::<br />
Direccionamiento con clase (classful addressing)<br />
Hay 5 clases, que se reconocen por los bits más significativos:<br />
0<br />
0 1 2 3 4 5 6 7 8 9<br />
1<br />
0 1 2 3 4 5 6 7 8 9<br />
2<br />
0 1 2 3 4 5 6 7 8 9<br />
3<br />
0 1<br />
0 net id<br />
host id<br />
Clase A (2 7 -3 re<strong>de</strong>s)<br />
10 net id<br />
host id Clase B (2 14 -16 re<strong>de</strong>s)<br />
110 net id<br />
host id Clase C (2 21 -256 re<strong>de</strong>s)<br />
1110 dirección multicast<br />
Clase D<br />
1111 reservado uso futuro<br />
Clase E<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 21
:: Direccionamiento ::<br />
Direccionamiento con clase (classful addressing)<br />
Clases:<br />
A: 2 31 direcciones (50%). 1.0.0.0 - 127.255.255.255<br />
B: 2 30 direcciones (25%). 128.0.0.0 - 191.255.255.255<br />
C: 2 29 direcciones (12,5%). 192.0.0.0 - 223.255.255.255<br />
D: 2 28 direcciones (6,25%). 224.0.0.0 - 239.255.255.255<br />
E: 2 28 direcciones (6,25%). 240.0.0.0 - 255.255.255.255<br />
RFC<br />
3330<br />
La IANA (<strong>Internet</strong> Assigned Numbers Authority) asigna bloques <strong>de</strong> direcciones.<br />
IANA <strong>de</strong>pen<strong>de</strong> <strong>de</strong> ICANN (<strong>Internet</strong> Corporation for Asigned Names and Numbers).<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 22
:: Direccionamiento ::<br />
Rangos para direccionamiento privado. Los paquetes cuyo <strong>de</strong>stino<br />
sea una dirección <strong>IP</strong> privada no pue<strong>de</strong>n atravesar ningún enrutador.<br />
10.0.0.0 - 10.255.255.255/8<br />
●<br />
(16.777.216 hosts en 1 bloque)<br />
172.16.0.0 - 172.31.255.255/12<br />
●<br />
(1.048.576 hosts en 16 bloques)<br />
192.168.0.0 - 192.168.255.255/16<br />
●<br />
(65.536 hosts en 256 bloques)<br />
Direcciones privadas<br />
RFC<br />
1918<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
http://xkcd.com/742/<br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 23
:: Direccionamiento ::<br />
Direccionamiento con clase :: direcciones <strong>de</strong> <strong>red</strong> (net id)<br />
Las direcciones <strong>de</strong> <strong>red</strong> tienen varias propieda<strong>de</strong>s:<br />
●<br />
●<br />
●<br />
Es la primera dirección <strong>de</strong> cada bloque<br />
I<strong>de</strong>ntifica a la <strong>red</strong> <strong>de</strong>s<strong>de</strong> el punto <strong>de</strong> vista <strong>de</strong> internet<br />
Dada una dirección <strong>de</strong> <strong>red</strong> se pue<strong>de</strong> averiguar la clase a la que<br />
pertenece, el bloque (net id) y el rango <strong>de</strong> direcciones en ese<br />
bloque.<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 24
:: Direccionamiento ::<br />
Direccionamiento con clase :: máscara <strong>de</strong> <strong>red</strong><br />
Una máscara es un número <strong>de</strong> 32 bits tal que al hacer un AND<br />
con dirección <strong>IP</strong> dada obtenemos la dirección <strong>de</strong> <strong>red</strong>.<br />
es <strong>de</strong> clase B<br />
161 67 38 13<br />
1010 0001<br />
0100 0011 0010 0110 0000 1101<br />
máscara<br />
1111 1111 1111 1111 0000 0000 0000 0000<br />
dirección <strong>de</strong> <strong>red</strong><br />
1010 0001 0100 0011 0000 0000<br />
0000 0000<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 25
:: Direccionamiento ::<br />
Direccionamiento con clase :: máscara <strong>de</strong> <strong>red</strong><br />
Máscaras por <strong>de</strong>fecto para las tres clases<br />
A<br />
B<br />
C<br />
255 0 0 0<br />
255 255 0 0<br />
255 255 255 0<br />
Si se utiliza estrictamente el esquema <strong>de</strong> direccionamiento con<br />
clases no son necesarias las máscaras.<br />
La máscara 255.255.0.0 se pue<strong>de</strong> indicar también así:<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
●<br />
161.67.27.38 /16 (Se <strong>de</strong>nomina notación CIDR)<br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 26
:: Enrutamiento <strong>IP</strong> ::<br />
Enrutamiento <strong>IP</strong><br />
Todos los nodos <strong>de</strong> una <strong>red</strong> <strong>IP</strong> tienen una tabla <strong>de</strong><br />
enrutamiento que asocia una tupla (dirección <strong>IP</strong>, máscara)<br />
con el método <strong>de</strong> entrega, que pue<strong>de</strong> ser:<br />
●<br />
la dirección <strong>IP</strong> <strong>de</strong> un enrutador (next hop address).<br />
●<br />
entrega directa (direct <strong>de</strong>livery)<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 27
:: Enrutamiento <strong>IP</strong> ::<br />
Enrutamiento <strong>IP</strong><br />
30.0.0.0<br />
128.1.0.0<br />
30.0.0.7<br />
128.1.0.8 - eth1 128.1.0.9<br />
40.0.0.7 40.0.0.8 - eth0<br />
192.4.10.9<br />
40.0.0.0<br />
192.4.10.0<br />
<strong>de</strong>stino máscara next hop iface<br />
30.0.0.0 255.0.0.0 40.0.0.7 eth0<br />
40.0.0.0 255.0.0.0 entrega directa eth0<br />
128.1.0.0 255.255.0.0 entrega directa eth1<br />
192.4.10.0 255.255.255.0 128.1.0.9 eth1<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 28
:: Enrutamiento <strong>IP</strong> ::<br />
Enrutamiento <strong>IP</strong> :: Algoritmo<br />
d = datagrama.<strong>de</strong>stino<br />
for entrada in tabla_enrutamiento:<br />
n = d & entrada.máscara<br />
if n == entrada.<strong>de</strong>stino:<br />
enviar(datagrama, entrada.next_hop)<br />
return<br />
if <strong>de</strong>fault_router:<br />
enviar(datagrama, <strong>de</strong>fault_router)<br />
else:<br />
raise RoutingError # enviar ICMP<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 29
Transmisión <strong>de</strong> Datagramas<br />
Es la entrega <strong>de</strong> un datagrama <strong>de</strong>s<strong>de</strong> un nodo a otro en la<br />
misma <strong>red</strong> física.<br />
Es necesario encapsular el datagrama en una trama, para lo<br />
que se necesita la dirección física <strong>de</strong>l <strong>de</strong>stino, y la propia.<br />
Necesitamos un modo <strong>de</strong> averiguar la dirección física <strong>de</strong>l<br />
<strong>de</strong>stino conocida su dirección <strong>IP</strong>.<br />
cabecera <strong>IP</strong><br />
carga útil<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
cabecera<br />
<strong>de</strong> trama<br />
área <strong>de</strong> datos <strong>de</strong> la trama<br />
terminador<br />
<strong>de</strong> la trama<br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 30
:: ARP ::<br />
ARP (Address Resolution Protocol)<br />
RFC<br />
826<br />
Es un <strong>protocolo</strong> que abstrae a la capa <strong>de</strong> <strong>red</strong> <strong>de</strong>l direccionamiento<br />
físico que <strong>de</strong>pen<strong>de</strong> únicamente <strong>de</strong> la tecnología física subyacente.<br />
Cada host mantiene una tabla (caché ARP) que relaciona<br />
cada dirección física con la dirección lógica asociada (<strong>IP</strong>).<br />
Cuando un host quiere averiguar la dirección física <strong>de</strong> un host:<br />
●<br />
●<br />
envía un paquete ARP request (broadcast) en el que aparece la<br />
dirección <strong>IP</strong> <strong>de</strong> dicho host.<br />
el host aludido respon<strong>de</strong> con un ARP reply (unicast) indicando<br />
su dirección fisica<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 31
:: ARP ::<br />
ARP :: Formato <strong>de</strong>l mensaje<br />
Formato <strong>de</strong>l paquete<br />
0<br />
1<br />
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9<br />
2<br />
0 1 2 3 4 5 6 7 8 9<br />
3<br />
0 1<br />
tipo <strong>de</strong> <strong>red</strong> física (Ethernet)<br />
tipo <strong>de</strong> <strong>protocolo</strong> (<strong>IP</strong>)<br />
HW len<br />
Protocol len<br />
operación (request o reply)<br />
dirección física <strong>de</strong>l origen (6 bytes en Ethernet)<br />
dirección lógica <strong>de</strong> <strong>de</strong>l origen (4 bytes en <strong>IP</strong>)<br />
dirección física <strong>de</strong>l <strong>de</strong>stino (vacío en en el request)<br />
dirección lógica <strong>de</strong>l <strong>de</strong>stino<br />
Encapsulación sobre Ethernet:<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
tipo<br />
Preámbulo Destino Origen Checksum<br />
(0x0806)<br />
ARP (petición o respuesta) relleno<br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 32
:: ARP ::<br />
ARP :: Paquete<br />
A<br />
161.67.38.12<br />
B1:34:56:23:AD:1E<br />
161.67.38.95<br />
46:57:92:AF:FC:21<br />
B<br />
ARP request (<strong>de</strong> A a todos)<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
CRC<br />
Preámbulo<br />
0x06<br />
0x0002<br />
0x04<br />
ARP reply (<strong>de</strong> B a A)<br />
B1:34:56:23:AD:1E<br />
0x0001<br />
B1:34:56:23:AD:1E<br />
161.67.38.12<br />
00:00:00:00:00:00<br />
161.67.38.95<br />
0x0800<br />
46:57:92:AF:FC:21<br />
tipo<br />
(0x0806)<br />
tipo<br />
(0x0806)<br />
B1:34:56:23:AD:1E<br />
0x04 0x0002<br />
46:57:92:AF:FC:21<br />
161.67.38.95<br />
B1:34:56:23:AD:1E<br />
161.67.38.12<br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 33<br />
0x06<br />
0x0002<br />
FF:FF:FF:FF:FF:FF<br />
0x0800<br />
Preámbulo<br />
CRC
:: ICMP ::<br />
ICMP (<strong>Internet</strong> Control Message Protocol)<br />
RFC<br />
792<br />
Es un <strong>protocolo</strong> la capa <strong>de</strong> <strong>red</strong>, que acompaña a <strong>IP</strong> para paliar<br />
en parte sus limitaciones en cuanto a confiabilidad.<br />
●<br />
●<br />
Inci<strong>de</strong>ncias en el envío <strong>de</strong> tráfico <strong>IP</strong><br />
Peticiones <strong>de</strong> información y respuestas entre hosts y enrutadores<br />
Los paquetes ICMP se encapsulan en paquetes <strong>IP</strong><br />
cabecera<br />
<strong>de</strong> trama<br />
cabecera <strong>IP</strong><br />
cabecera<br />
ICMP<br />
área <strong>de</strong> datos <strong>IP</strong><br />
área <strong>de</strong> datos <strong>de</strong> la trama<br />
datos<br />
ICMP<br />
terminador<br />
<strong>de</strong> la trama<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 34
:: ICMP ::<br />
ICMP :: Formato <strong>de</strong>l mensaje<br />
Formato <strong>de</strong>l paquete<br />
0<br />
1<br />
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9<br />
2<br />
0 1 2 3 4 5 6 7 8 9<br />
3<br />
0 1<br />
tipo<br />
código<br />
resto <strong>de</strong> cabecera<br />
checksum<br />
área <strong>de</strong> datos<br />
Tipos <strong>de</strong> paquetes:<br />
●<br />
Errores<br />
•<br />
<strong>de</strong>stination unreachable<br />
•<br />
source quench<br />
●<br />
Peticiones / Respuesta<br />
•<br />
Echo (petición y respuesta)<br />
•<br />
Timestamp (petición y respuesta)<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
•<br />
time excee<strong>de</strong>d<br />
•<br />
Address mask (petición y<br />
•<br />
parameter problem<br />
respuesta)<br />
•<br />
<strong>red</strong>irection<br />
•<br />
Router solicitation o advertisement<br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 35
:: ICMP ::<br />
ICMP :: Errores<br />
Los mensajes ICMP <strong>de</strong> error se envían al origen <strong>de</strong>l<br />
paquete <strong>IP</strong> que produjo el error<br />
ICMP no corrige, sólo informa<br />
No se generan mensajes ICMP en los siguientes casos<br />
●<br />
●<br />
●<br />
Un error en un datagrama <strong>IP</strong> que porta un ICMP<br />
Para un fragmento <strong>de</strong> datagrama que no sea el primero<br />
Para datagramas <strong>IP</strong> multicast<br />
● Para datagramas con direcciones especiales como 127.0.0.1<br />
Los paquetes ICMP <strong>de</strong> error incluyen la cabecera <strong>de</strong>l<br />
paquete <strong>IP</strong> que causó el error más 8 bytes <strong>de</strong> su carga.<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 36
:: ICMP ::<br />
ICMP :: Errores<br />
Destino inalcanzable (Destination unreachable)<br />
●<br />
●<br />
Lo envía un enrutador (o el <strong>de</strong>stino) cuando no pue<strong>de</strong> enrutar el paquete.<br />
En el paquete se indica el motivo (16 códigos diferentes)<br />
Source quench<br />
●<br />
Lo envía un enturador cuando <strong>de</strong>be <strong>de</strong>scartar un datagrama a causa <strong>de</strong><br />
la congestión<br />
Tiempo excedido<br />
●<br />
Se envía cuando el TTL llega a 0 (enrutador) o cuando expira el<br />
temporizador <strong>de</strong> reensamble <strong>de</strong> fragmentos (<strong>de</strong>stino)<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 37
:: ICMP ::<br />
ICMP :: Errores<br />
Problema con los parámetros<br />
●<br />
Si existe un error, ambigüedad o falta un campo necesario se envía un<br />
paquete ICMP. Lo pue<strong>de</strong>n hacer los enrutadores y el <strong>de</strong>stino.<br />
Redirección<br />
●<br />
●<br />
Cuando un host envía un datagrama a un enrutador equivocado, éste<br />
pue<strong>de</strong> <strong>red</strong>irigir el datagrama al enrutador a<strong>de</strong>cuado.<br />
En ese caso, el enrutador informa al host mediante un paquete ICMP<br />
para que actualice su tabla <strong>de</strong> rutas.<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 38
:: ICMP ::<br />
Echo<br />
ICMP :: Peticiones<br />
Se utiliza para verificar la conectividad <strong>IP</strong>. Cuando un host o enrutador<br />
recibe un Echo-Request, fabrica un Echo-Reply y lo envía al origen.<br />
Timestamp<br />
Se usa para medir el retardo entre origen y <strong>de</strong>stino o para sincronización.<br />
Address mask<br />
Lo utilizan los hosts para preguntar la máscara a los enrutadores<br />
Solicitud <strong>de</strong> Enrutador (Router Solicitation)<br />
Los hosts pue<strong>de</strong>n enviar este tipo <strong>de</strong> paquetes ICMP para averiguar quién<br />
es el enrutador en la sub-<strong>red</strong>. <strong>El</strong> enrutador respon<strong>de</strong> i<strong>de</strong>ntificándose.<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 39
:: Gestión <strong>de</strong> Re<strong>de</strong>s <strong>IP</strong> ::<br />
La asignación <strong>de</strong> direcciones <strong>IP</strong> a los hosts supone un<br />
importante problema <strong>de</strong> administración.<br />
Gestión <strong>de</strong> Re<strong>de</strong>s <strong>IP</strong><br />
● La configuración manual es una tarea ardua cuando la <strong>red</strong><br />
adquiere cierto tamaño.<br />
● La asignación estática pue<strong>de</strong> no ser posible si no se dispone <strong>de</strong><br />
suficientes direcciones.<br />
● Dificultad para poner en operación nuevos hosts.<br />
● RARP<br />
● BOOTP<br />
● DHCP<br />
Para resolver este problema hay varias alternativas<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 40
:: Gestión <strong>de</strong> Re<strong>de</strong>s <strong>IP</strong> ::<br />
RARP (Reverse Address Resolution Protocol)<br />
RFC<br />
903<br />
Cuando un host arranca ¿Qué dirección <strong>IP</strong> <strong>de</strong>be usar?<br />
¿Qué ocurre si el sistema está implementado en ROM?<br />
La solución más antigua es equivalente a ARP, pero a la<br />
inversa: conocida la dirección física averiguar la <strong>IP</strong>.<br />
<strong>El</strong> host que <strong>de</strong>sconoce su <strong>IP</strong> envía una trama broadcast en<br />
la que indica su dirección física.<br />
En esa misma <strong>red</strong> <strong>de</strong>be haber un servidor que responda a<br />
la petición, indicándole cuál es su dirección <strong>IP</strong>.<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 41
:: Gestión <strong>de</strong> Re<strong>de</strong>s <strong>IP</strong> ::<br />
BOOTP (Bootstrap Protocol)<br />
RARP no es suficiente cuando el host necesita más cosas a<br />
parte <strong>de</strong> su dirección <strong>IP</strong>.<br />
RARP tiene varios problemas:<br />
●<br />
Dado que RARP se encapsula sobre tramas pue<strong>de</strong> ser difícil construir<br />
servidores<br />
●<br />
●<br />
<strong>El</strong> servidor <strong>de</strong>be estar en la misma <strong>red</strong> física<br />
Se <strong>de</strong>sperdicia espacio si sólo se indica la dirección <strong>IP</strong><br />
Si un host no tiene (o no usa) el disco para arrancar, necesita:<br />
●<br />
Cargar una imagen ejecutable<br />
●<br />
●<br />
Averiguar la dirección <strong>IP</strong> <strong>de</strong> u servidor <strong>de</strong> ficheros<br />
Averiguar la dirección <strong>de</strong> un enrutador.<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 42
:: Gestión <strong>de</strong> Re<strong>de</strong>s <strong>IP</strong> ::<br />
BOOTP<br />
BOOTP es un <strong>protocolo</strong> <strong>de</strong>l nivel <strong>de</strong> aplicación (se encapsula<br />
sobre UDP). La fiabilidad <strong>de</strong> la comunicación corre a cargo <strong>de</strong>l<br />
cliente.<br />
<strong>El</strong> cliente envía una petición BOOTP sobre un paquete UDP<br />
broadcast (255.255.255.255), indicando que la respuesta <strong>de</strong>be<br />
ser no fragmentada.<br />
<strong>El</strong> servidor respon<strong>de</strong> con otro paquete broadcast. Pue<strong>de</strong><br />
aprovechar para actualizar su caché ARP.<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 43
:: Gestión <strong>de</strong> Re<strong>de</strong>s <strong>IP</strong> ::<br />
BOOTP :: Formato <strong>de</strong>l mensaje<br />
0<br />
1<br />
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9<br />
tipo (req/reply)<br />
nº <strong>de</strong> segundos<br />
tipo HW<br />
id. transacción<br />
long dir. física<br />
2<br />
0 1 2 3 4 5 6 7 8 9<br />
no usado<br />
dirección <strong>IP</strong> <strong>de</strong>l cliente (a 0 en la petición)<br />
hops<br />
3<br />
0 1<br />
En el campo <strong>de</strong> opciones el<br />
servidor pue<strong>de</strong> indicar cosas<br />
como:<br />
●<br />
máscara <strong>de</strong> sub-<strong>red</strong><br />
dirección <strong>IP</strong> asignada<br />
dirección <strong>IP</strong> <strong>de</strong>l servidor<br />
dirección <strong>IP</strong> <strong>de</strong>l enrutador<br />
dirección física <strong>de</strong>l cliente (16 bytes)<br />
nombre <strong>de</strong>l dominio <strong>de</strong>l servidor (64 bytes)<br />
●<br />
●<br />
●<br />
●<br />
servidores <strong>de</strong> tiempo<br />
servidores DNS<br />
servidores <strong>de</strong> impresión<br />
nombre <strong>de</strong>l host<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
ruta al fichero <strong>de</strong> arranque (128 bytes)<br />
opciones<br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 44<br />
●<br />
hora
:: Gestión <strong>de</strong> Re<strong>de</strong>s <strong>IP</strong> ::<br />
DHCP (Dynamic Host Configuration Protocol)<br />
RFC<br />
2131<br />
BOOTP no resuelve todos los problemas porque es un<br />
sistema <strong>de</strong> asignación estático<br />
DHCP permite tener menos direcciones que hosts pero<br />
teniendo tantas direcciones como hosts activos.<br />
DHCP ce<strong>de</strong> direcciones durante un tiempo y con ciertas<br />
condiciones.<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 45
:: Gestión <strong>de</strong> Re<strong>de</strong>s <strong>IP</strong> ::<br />
DHCP<br />
<strong>El</strong> paquete DHCP es muy similar a BOOTP, con las siguientes diferencias:<br />
●<br />
●<br />
el campo “no usado” <strong>de</strong> BOOTP se usa como campo flags<br />
en las opciones, a<strong>de</strong>más, se indica el estado <strong>de</strong>l alquiler<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 46
Referencias<br />
Se recomienda repasar y profundizar el contenido <strong>de</strong> este tema utilizando (al<br />
menos) la siguiente bibliografía básica:<br />
B.F. Transmisión <strong>de</strong> datos y re<strong>de</strong>s <strong>de</strong> comunicaciones, cuarta edición 2007.<br />
●<br />
Secciones 20.1, 19.1, 21.1 y 21.2<br />
A.S. Re<strong>de</strong>s <strong>de</strong> computadores. Pearson Educación, Cuarta edición, 2003.<br />
● Capítulos 5. Apartados 1, 6 - 6.3<br />
CISCO Systems. Inc. Guía <strong>de</strong>l primer año. CCNA 1 y 2. Cisco Press, 2003.<br />
● Capítulos 7, 8 y 17<br />
Material e-learning CISCO Networking Aca<strong>de</strong>my<br />
●<br />
Módulo 6 <strong>de</strong> CCNA Exploration<br />
Re<strong>de</strong>s : : <strong>IP</strong><br />
David Villa :: http://www.esi.uclm.es/www/dvilla/ 47