livellorete indizzamentoip (v4) e...

69
Reti (già “Reti di Calcolatori”) Livello Rete Indizzamento IP (v4) e inoltro dei pacchetti Renato Lo Cigno http://disi.unitn.it/locigno/teaching-duties/reti

Upload: others

Post on 23-Mar-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Reti(già “Reti di Calcolatori”)

Livello ReteIndizzamento IP (v4) e inoltro dei pacchetti

RenatoLoCigno

http://disi.unitn.it/locigno/teaching-duties/reti

Page 2: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Acknowledgement

• Credits– Partof thematerialis based onslides provided by thefollowing authors

• JimKurose,KeithRoss,“ComputerNetworking:ATopDownApproach,”4thedition,Addison-Wesley,July2007

• DouglasComer,“ComputerNetworksandInternets,”5thedition,PrenticeHall

• Behrouz A.Forouzan,Sophia Chung Fegan,“TCP/IPProtocolSuite,”McGraw-Hill,January 2005

• Latraduzione,sepresente,èingeneraleopera(eresponsabilità)deldocente

[email protected] LivelloRete- IPv4 2

Page 3: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Contenuto e temi

• Spaziodiindirizzamento

• IndirizziIPelorouso

• Consegnadeipacchetti

• ConfigurazionedeiPCedellereti

• InstradamentoeRouting

[email protected] LivelloRete- IPv4 3

Page 4: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

1- Fisico

Livello Rete

Livellidiapplicazione(utente)

Livellidirete2- Collegamentodati

Fisico

3- Rete

4- Trasporto

5- Sessione

6- Presentazione

7- Applicazione

Collegamentodati:Ethernet,PPP,ATM,...

Rete:IP

Trasporto:TCP- UDP

Applicaz.:HTTP,E-mail

[email protected] LivelloRete- IPv4 4

Page 5: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

[email protected] LivelloRete- IPv4 5

Consegna Diretta e Indiretta

NtwA165.5.1.0/24

NtwB98.23.0.0/16

NtwC201.12.82.0/24

HostA

HostC

165.5.1.5

201.12.82.4

NtwD201.12.83.0/24

NtwE198.35.112.0/24

Questo router è non è collegato allarete C, come fa a conoscere l’host201.12.82.4? E come fa a inoltrare i pacchetticorrettamente verso ques’ultimo?

Page 6: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Prospettiva globale

• Trasportodeipacchettidasorgentearicevitore.Ipacchetticontengonounsegmentodilivellotrasporto

• IpacchettisonoincapsulatiintrameL2

• Alricevitoreisegmentisonoestrattidaipacchettieconsegnatiallivellotrasporto

• Iprotocollidiretesonointuttiglihost erouter

• Unrouterdeveesaminarel’intestazionedituttiipacchetticheloattraversano

Applicaz.

Trasporto

Rete

DataLink

Fisico

Applicaz.

Trasporto

Rete

DataLink

Fisico

Rete

L2

L1

L2

L1

Rete

L2

L1

L2

L1

IPL2

IP

IPL2

IPL2

IP

IPL2

IPL2

IPL2IPL2

IP

IPL2

IPL2

IP

[email protected] LivelloRete- IPv4 6

Page 7: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Funzioni fondamentali del livello rete

• Instradamento(Routing)– Trovareilpercorsodallasorgentealladestinazioneè AlgoritmidiRouting

• Simileapianificareunviaggio:devodeterminarelestradedafareegliincrociincuicambiarelamiastrada

• Inoltro(Forwarding)– Funzionecheesegueiltrasportodeipacchettidagliingressialleuscitedeirouter...datocheilpercorsoègiànoto

• Simileaprenderel’uscitagiustadiunarotonda,sapendochedevoandareinunaspecificadirezione

• Entramberichiedonounospaziodiindirizzamentoappropriato...eirelativiindirizzi

[email protected] LivelloRete- IPv4 7

Page 8: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

1

23

0111

valore dell’indirizzonel pacchetto in arrivo

routing algorithm

local forwarding tableheader value output link

0100010101111001

3221

Relazione tra routing e forwarding

[email protected] LivelloRete- IPv4 8

Page 9: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Schema di architettura dei Router

• duefunzionifondamentali:– eseguireiprotocolliealgoritmidiinstradamento(RIP,OSPF,BGP)– inoltrareidatagrammi(pacchetti)dagliingressialleuscite

[email protected] LivelloRete- IPv4 9

Page 10: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

IL PROTOCOLLO IP(VERSIONE 4)

[email protected] LivelloRete- IPv4 10

Page 11: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Il Datagramma IP

• TCP/IPusailtermine“IPdatagram”peridentificareunpacchettodilivellorete

• Ciascundatagrammaècompostodaunaintestazione (header)– da20a60bytes checontengonoleinformazioniessenzialiperl’instradamentoelaconsegna

• seguitadaidatitrasportati (payload)– Ladimensionedeipayload nonèfissa– Ladimensioneeffettivaèdeterminatadall’applicazionee/odalprotocolloditrasporto

– C’e` unadimensionemassimadi64kB(65536)

[email protected] LivelloRete- IPv4 11

Page 12: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Formato del Datagramma IP

• L’headercontieneinformazioniutiliperl’instradamentodeldatagramma:– L’indirizzodellasorgente(chihainviatoperprimoildatagramma)

– L’indirizzodelladestinazione(chiriceveràildatagrammasetuttovabene)

– Iltipodiprotocollochehageneratoidati– ...

• GliindirizzisonoditipoIP(ovvio)• GliindirizziMACsono“esterni”aldatagramma• Icampisonodidimensionefissaperefficienzadimanipolazione

[email protected] LivelloRete- IPv4 12

Page 13: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

The IP Datagram Header Format

[email protected] LivelloRete- IPv4

Page 14: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

The IP Datagram Header Format

• VERS:Eachdatagrambeginswitha4-bitprotocolversionnumber• H.LEN:4-bitheaderspecifiesthenumberof32-bitquantitiesinthe

header– Ifnooptionsarepresent,thevalueis5

• TypeofService(ToS)– 8-bitfieldthatcarriesaclassofserviceforthedatagram

• potentiallyusedforDiffServ andECN(ExplicitCongestionNotification)

• seldomusedinpractice• TOTALLENGTH:16-bitintegerthatspecifiesthetotalnumberof

bytesincludingboththeheaderandthedata

[email protected] LivelloRete- IPv4 14

Page 15: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

The IP Datagram Header Format

• IDENTIFICATION– 16-bitnumber(usuallysequential)assignedtothedatagram

• usedtogatherallfragmentsforreassemblytothedatagram• FLAGS

– 3-bitfieldwithindividualbitsspecifyingwhetherthedatagramisafragment

• Ifso,thenwhetherthefragmentcorrespondstothelastpieceoftheoriginaldatagram

• FRAGMENTOFFSET– 13-bitfieldthatspecifieswhereintheoriginaldatagramthedatainthisfragmentbelongs

– thevalueofthefieldismultipliedby8toobtainanoffset

[email protected] LivelloRete- IPv4 15

Page 16: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

The IP Datagram Header Format

• TIMETOLIVE(TTL)– 8-bitintegerinitializedbytheoriginalsender– itisdecrementedbyeachrouter thatprocessesthedatagram– ifthevaluereacheszero(0)thedatagramisdiscarded andanerrormessageissentbacktothesource

• PROTOCOL– 8-bitfieldthatspecifiesthetypeofthepayload,i.e.,theprotocolabove(e.g.,6forTCP,17forUDP)

• HEADERCHECKSUM– 16-bitones-complementchecksumofheaderfields

• SOURCEIPADDRESS– 32-bitInternetaddressoftheoriginalsender

[email protected] LivelloRete- IPv4 16

Page 17: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

The IP Datagram Header Format

• DESTINATIONIPADDRESS– The32-bitInternetaddressoftheultimatedestination

• IPOPTIONS– Optionalheaderfieldsusedtocontrolroutinganddatagramprocessing

– Mostdatagramsdonotcontainanyoptions• PADDING

– Ifoptionsdonotendona32-bitboundary• zerobitsofpaddingareaddedtomaketheheaderamultipleof32bits

[email protected] LivelloRete- IPv4 17

Page 18: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

FRAMMENTAZIONE DEI PACCHETTI IP

L’USO DELLA FRAMMENTAZIONE È “DEPRECATO”. MOLTI ROUTER SEMPLICEMENTE NON LA IMPLEMENTANOE SCARTANO IL PACCHETTO.

[email protected] LivelloRete- IPv4 18

Page 19: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

MTU and Datagram Fragmentation

• Eachhardwaretechnologyspecifiesthemaximumamountofdatathataframecancarry– ThelimitisknownasaMaximumTransmissionUnit (MTU)

• NetworkhardwareisnotdesignedtoacceptortransferframesthatcarrymoredatathantheMTUallows– AdatagrammustbesmallerorequaltothenetworkMTU

• oritcannotbeencapsulatedfortransmission• Inaninternetthatcontainsheterogeneousnetworks,MTU

restrictionscreateaproblem• AroutercanconnectnetworkswithdifferentMTUvalues

– adatagramthatarouterreceivesoveronenetworkcanbetoolargetosendoveranothernetwork

[email protected] LivelloRete- IPv4 19

Page 20: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

MTUs for some networks

[email protected] LivelloRete- IPv4

variabile

Page 21: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

MTU and Datagram Fragmentation

• Example:arouterinterconnectstwonetworkswithMTUvaluesof1500and1000– HostH1 attachestoanetworkwithanMTUof1500

• andcansendadatagramthatisupto1500octets– HostH2 attachestoanetworkthathasanMTUof1000

• whichmeansthatitcannotsend/receiveadatagramlargerthan1000octets

– IfhostH1 sendsa1500-octetdatagramtohostH2

• routerRwillnotbeabletoencapsulateitfortransmissionacrossnetwork2

[email protected] LivelloRete- IPv4 21

Page 22: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

MTU and Datagram Fragmentation

• WhenadatagramislargerthantheMTUofthenetworkoverwhichitmustbesent– therouterdividesthedatagramintosmallerpiecescalledfragments

– andsendseachfragmentindependently• Afragmenthasthesameformatasotherdatagrams

– abitintheFLAGSfieldoftheheaderindicateswhetheradatagramisafragmentoracompletedatagram

• Otherfieldsintheheaderareassignedinformationfortheultimatedestinationtoreassemblefragments– toreproducetheoriginaldatagram

• TheFRAGMENTOFFSETspecifieswhereintheoriginaldatagramthefragmentbelongs

[email protected] LivelloRete- IPv4 22

Page 23: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

MTU and Datagram Fragmentation

• ArouterusesthenetworkMTUandtheheadersizetocalculate– themaximumamountofdatathatcanbesentineachfragment– andthenumberoffragmentsthatwillbeneeded

• Theroutercreatesthefragments– Itusesfieldsfromtheoriginalheadertocreateafragmentheader

– Itcopiestheappropriatedatafromtheoriginaldatagramintothefragment

– Transmitstheresult

[email protected] LivelloRete- IPv4 23

Page 24: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Flags field

[email protected] LivelloRete- IPv4

Page 25: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Reassembling a Datagram

• Example:packetssentfromH1toH2– ifhostH1sendsa1500-octetdatagramtohostH2,routerR1willdividethedatagramintotwofragments,whichitwillforwardtoR2

– RouterR2doesnotreassemblethefragments• InsteadRusesthedestinationaddressinafragmenttoforwardthefragmentasusual

– Theultimatedestinationhost,H2,collectsthefragmentsandreassemblesthemtoproducetheoriginaldatagram

[email protected] LivelloRete- IPv4 25

Page 26: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Reassembling a Datagram

• Requiringtheultimatedestinationtoreassemblefragmentshastwoadvantages:– Itreducestheamountofstateinformationinrouters

• Whenforwardingadatagram,arouterdoesnotneedtoknowwhetherthedatagramisafragment

– Itallowsroutes tochangedynamically• Ifanintermediaterouterweretoreassemblefragments,allfragmentswouldneedtoreachtherouter

• Bypostponingreassemblyuntiltheultimatedestination– IPisfreetopasssomefragmentsfromadatagramalongdifferentroutesthanotherfragments

[email protected] LivelloRete- IPv4 26

Page 27: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

The Consequence of Fragment Loss

• Adatagramcannotbereassembleduntilallfragmentsarrive• Thereceivermustsave(buffer)thefragments

– Incasemissingfragmentsareonlydelayed– Areceivercannotholdfragmentsanarbitrarilylongtime

• IPspecifiesamaximumtimetoholdfragments• Whenthefirstfragmentarrivesfromagivendatagram

– thereceiverstartsareassemblytimer• Ifallfragmentsofadatagramarrivebeforethetimerexpires

– thereceivercancelsthetimerandreassemblesthedatagram• Otherwisethereceiverdiscardsthefragments

[email protected] LivelloRete- IPv4 27

Page 28: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

GLI INDIRIZZI DI INTERNET:IPV4

[email protected] LivelloRete- IPv4 28

Page 29: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Gli indirizzi di Internet

• Lospaziodiindirizzamentoèuncomponentecritico• Tuttiglihost eirouterdevonousareunoschemadiindirizzamento

uniforme• GliindirizziUnicast,cheidentificanounaspecificainterfacciadevono

essereunici• EsistonoduespazidiindirizzamentospecificatiperInternet

– IPv4:quelloattualmenteinusoconindirizzia32bit– IPv6:ilsistemadiindirizzamentocheavrebbedovutosostituireIPv4,machecontinuaanonfarlo

• indirizzia128bit• funzioni“avanzate”• esistonomolte“isole”IPv6eormaituttiirouterdeimaggiorivendor losupportano

[email protected] LivelloRete- IPv4 29

Page 30: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

The IP Addressing Scheme

• IPaddressesaresuppliedbyprotocolsoftware

• Eachnetworkinterfaceisassignedaunique32-bitnumber– TheinterfaceIPaddress orInternetaddress

• WhensendingapacketacrosstheInternet,sender’sprotocolsoftwaremustspecify– itsown32-bitIPaddress(thesourceaddress)– andtheaddressoftheintendedrecipient(thedestinationaddress)

• Routersonlyusethedestinationaddressforforwrding androuting

[email protected] LivelloRete- IPv4 30

Page 31: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Dotted Decimal Notation

• Insteadofwriting32bits,anotationmoreconvenientforhumanstounderstandisused,knownasdotteddecimalnotation– expresseach8-bitsectionofa32-bitnumberasadecimalvalue– useperiodstoseparatethesections

• Dotteddecimaltreatseachoctet(byte)asanunsignedbinaryinteger– thesmallestvalue,0

• occurswhenallbitsofanoctetarezero(0)– thelargestvalue,255

• occurswhenallbitsofanoctetareone(1)– dotteddecimaladdressesrange

0.0.0.0through255.255.255.255

[email protected] LivelloRete- IPv4 31

Page 32: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Dotted Decimal Notation: examples

[email protected] LivelloRete- IPv4

Page 33: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

The IP Address Hierarchy

• IPaddressisdividedintotwoparts:• Aprefixè identifiesthephysicalnetworktowhichthehostis

attached(alsoknownadNetID)– EachnetworkintheInternetisassignedauniquenetworknumber

• Asuffixè identifiesaspecificinterfaceonthenetwork(alsoknownadHostID)– EachNIConagivennetworkisassignedauniquesuffix

• IPaddressschemeguaranteestwoproperties:– Eachcomputerisassignedauniqueaddress– Networknumbers(prefix)mustbecoordinatedglobally– Suffixesareassignedlocallywithoutglobalcoordination

[email protected] LivelloRete- IPv4 33

Page 34: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

INDIRIZZAMENTO CON CLASSI (OBSOLETO)

Schemadiorganizzazionedegliindirizziusatofinoallametàdeglianni‘90ebasatosuunadivisionestaticatraNetID eHostID

Èusoancoraoggiriferirel’organizzazionedegliindirizziadunconcetto(eterminologia)diclasse

[email protected] LivelloRete- IPv4 34

Page 35: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Original Classes of IP Addresses

• Internetcontainsafewlargephysicalnetworksandmanysmallnetworks– thedesignerschoseanaddressingschemetoaccommodateacombinationoflargeandsmallnetworks

• Theoriginalclassful IPaddressingdividedtheIPaddressspaceinto3primaryclasses– eachclasshasadifferentsizeprefixandsuffix

• ThefirstfourbitsofanIPaddressdeterminedtheclasstowhichtheaddressbelonged– Itspecifieshowtheremainderoftheaddresswasdividedintoprefixandsuffix

[email protected] LivelloRete- IPv4 35

Page 36: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Original Classes of IP Addresses

[email protected] LivelloRete- IPv4

Page 37: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Division of the Address Space

• Theclassful schemedividedtheaddressspaceintounequalsizes• Thedesignerschoseanunequaldivisiontoaccommodateavariety

ofscenarios– Forexample,althoughitislimitedto128networks,classAcontainshalfofalladdresses

• ThemotivationwastoallowmajorISPstoeachdeployalargenetworkthatconnectedmillionsofcomputers

• ButAclasseswereassignedtosmallnetworksallintheUS...– Similarly,themotivationforclassCwastoallowanorganizationtohaveafewcomputersconnectedonaLAN

[email protected] LivelloRete- IPv4 37

Page 38: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Division of the Address Space

[email protected] LivelloRete- IPv4

Page 39: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Authority for Addresses

• InternetCorporationforAssignedNamesandNumbers(ICANN)authorityhasbeenestablished– tohandleaddressassignmentandadjudicatedisputes

• ICANNdoesnotassignindividualprefixes– Instead,ICANNauthorizesasetofregistrars todoso

• RegistrarsmakeblocksofaddressesavailabletoISPs– ISPsprovideaddressestosubscribers

• Toobtainaprefix– acorporationusuallycontactsanISP

[email protected] LivelloRete- IPv4 39

Page 40: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

INDIRIZZAMENTO SENZA CLASSI E CIDR

SchemainusoattualecondivisionedinamicatraNetID eHostID

CIDR(Classless Inter-DomainRouting)consentel’instradamentoglobalesenzausarelanozionediclasse

[email protected] LivelloRete- IPv4 40

Page 41: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Subnets and Classless Addressing

• AstheInternetgrewtheoriginalclassfuladdressingschemebecamealimitation

• EveryonedemandedaclassAorclassBaddress– Sotheywouldhaveenoughaddressesforfuturegrowth

• butmanyaddressesinclassAandBwereunused• Twomechanisms,closelyrelated,weredesignedtoovercomethe

limitation– Subnetaddressing– Classlessaddressing

• Insteadofhavingthreedistinctaddressclasses,allowthedivisionbetweenprefix/suffixonanarbitrarybitboundary

[email protected] LivelloRete- IPv4 41

Page 42: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Classless Addressing: Motivation

• ConsideranISPthathandsoutprefixes.SupposeacustomeroftheISPrequestsaprefixforanetworkthatcontains55hosts– classfuladdressingrequiresacompleteclassCprefix– only6bitsofsuffixareneededtorepresentallpossiblehostvalues

• means190ofthe254possiblesuffixeswouldneverbeassigned

– mostoftheclassCaddressspaceiswasted• Fortheaboveexample

– classlessaddressingallowstheISPtoassign• aprefixthatis26bitslong• asuffixthatis6bitslong

[email protected] LivelloRete- IPv4 42

Page 43: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Classless Addressing: Example

• AssumeanISPownsaclassCprefix– Classfuladdressingassignstheentireprefixtooneorganization

• Withclasslessaddressing– theISPcandividetheprefixintoseverallongerprefixes

• Forinstance,theISPcandivideaclassCprefixinto4longerprefixes– eachonecanaccommodateanetworkofupto62hosts

• all0sandall1sarereserved• TheoriginalclassCaddresshas8bitsofsuffix

– andeachoftheclasslessaddresseshas6bitsofsuffix• Thus,insteadofwastingaddresses

– ISPcanassigneachofthe4classlessprefixestoasubscriber

[email protected] LivelloRete- IPv4 43

Page 44: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Classless Addressing: Example

[email protected] LivelloRete- IPv4

Page 45: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Address (subnet) Masks

• HowcananIPaddressbedividedatanarbitraryboundary?• Theclasslessandsubnetaddressingschemesrequirehostsand

routerstostoreanadditionalpieceofinformation:– avaluethatspecifiestheexactboundarybetweenprefixandsuffix

• Tomarktheboundary,IPusesa32-bitvalue– knownasanaddressmask,alsocalledasubnetmask

• Whystoretheboundarysizeasabitmask?– Amaskmakesprocessingefficient

• Hostsandroutersneedtocomparethenetworkprefixportionoftheaddresstoavalueintheirforwardingtables– Thebit-maskrepresentationmakesthecomparisonefficient

[email protected] LivelloRete- IPv4 45

Page 46: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Address Masks

• Supposearouterisgiven– adestinationaddress,D– anetworkprefixrepresentedasa32-bitvalue,N– a32-bitaddressmask,M

• AssumethetopbitsofNcontainanetworkprefix,andtheremainingbitshavebeensettozero

• Totestwhetherthedestinationliesonthespecifiednetwork,therouterteststhecondition:

N==(D&M)• Therouter

– usesthemaskwitha“logicaland(&)”operationtosetthehostbitsofaddressDtozero(0)

– andthencomparestheresultwiththenetworkprefixN

[email protected] LivelloRete- IPv4 46

Page 47: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Address Masks: Example

• Considerthefollowing32-bitnetworkprefix:10000000000010100000000000000000 à 128.10.0.0

• Considera32-bitmask:11111111111111110000000000000000 à 255.255.0.0

• Considera32-bitdestinationaddress,whichhasa10000000000010100000001000000011 à 128.10.2.3

• Alogical &betweenthedestinationaddressandtheaddressmaskextractsthehigh-order16-bits10000000000010100000000000000000 à 128.10.0.0

[email protected] LivelloRete- IPv4 47

Page 48: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

CIDR Notation

• ClasslessInter-DomainRouting(CIDR)• Considera maskdefiningasubnetwith26 nodes

– Ithas26bitsof1sfollowedby6bitsof0s– Indotteddecimal,themaskis:255.255.255.192

• ThegeneralformofCIDRnotationis:ddd.ddd.ddd.ddd/m– ddd isthedecimalvalueforanoctetoftheaddress– m isthenumberofonebitsinthemask

• Thus,onemightwritethefollowing:192.5.48.69/26– whichspecifiesamaskof26bits

[email protected] LivelloRete- IPv4 48

Page 49: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

A CIDR Example

• AssumeanISPhasthefollowingblock128.211.0.0/16• SupposetheISPhas2customers

– onecustomerneeds12IPaddressesandtheotherneeds9• TheISPcanassign

– customer1CIDR:128.211.0.16/28– customer2CIDR:128.211.0.32/28– bothcustomershavethesamemasksize(28bits),theprefixesdiffer

[email protected] LivelloRete- IPv4 49

Page 50: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

A CIDR Example (cont’d)

• Thebinaryvalueassignedtocustomer1is:– 10000000110100110000000000010000

• Thebinaryvalueassignedtocustomer2is:– 10000000110100110000000000100000

• Thereisnoambiguity– Eachcustomerhasauniqueprefix– Moreimportant,theISPretainsmostoftheoriginaladdressblock

• itcanthenallocatetoothercustomers

[email protected] LivelloRete- IPv4 50

Page 51: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

CIDR Host Addresses

• OnceanISPassignsacustomeraCIDRprefix– thecustomercanassignhostaddressesforitsnetworkusers

• Supposeanorganizationisassigned128.211.0.16/28– theorganizationwillhave4-bitstouseasahostaddressfield

• Disadvantageofclasslessaddressing– Becausethehostsuffixcanstartonanarbitraryboundary,valuesarenoteasytoreadindotteddecimal

[email protected] LivelloRete- IPv4 51

Page 52: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

CIDR Host Addresses

[email protected] LivelloRete- IPv4

Page 53: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

INDIRIZZI PRIVATI, SPECIALI E INDIRIZZI DEI ROUTERNontuttigliindirizziIPsonoutilizzabili,alcuniindirizzihannosignificatosolointernoalcomputerealtriconsentonodifareilbootstrap dellemacchineprimacheabbianounindirizzoIPconcuicomunicare.IRoutersonomacchineconpiùindirizziIP...anchesenonsempreconpiùinterfaccefisichedicomunicazione.

[email protected] LivelloRete- IPv4 53

Page 54: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Indirizzi pubblici e privati

• NontuttigliindirizziIPUnicast validisonouguali• Alcuniindirizzisonostatidefiniti“privati”enonsonoinstradabiliin

Internet– PossonoessereusatipercostruireIntra-netprivate

• Unhost conindirizzoIPprivatohabisognodiunaapparatoattivochetraducaopportunamenteisuoipacchettiperaccedereaInternet

• NAT:NetworkAddress Translator– Mappala5-tuplacheidentificaunflussosuun’altra5-tuplaconindirizzopubblico,lavoraalivelloL3/L4

• Proxy– GatewaydiL7,cheinterconnettealivellodisingolaapplicazione

[email protected] LivelloRete- IPv4 54

Page 55: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Indirizzi Privati

• 10.0.0.0– 10.255.255.255• 172.16.0.0– 172.31.255.255• 192.168.0.0– 192.168.255.255

• Unindirizzoprivatopuòessereriutilizzatoinmoltipostidiversi• All’internodiunastessaretedevonoessereuniciepossonoessere

“routati”finoaun“border router”cheinveceimpediscediandareversoInternet

• NormalmentesonoassegnatitramiteDHCPenonsonoassegnatistaticamenteaunhost

• Nonc’è una reale differenza tra i tre gruppi diindirizzi,maingenere i router“domestici”usano 192.168.x.y/24

[email protected] LivelloRete- IPv4 55

Page 56: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Special IP Addresses

• IPdefinesasetofspecialaddressformsthatarereserved– Thatis,specialaddressesareneverassignedtohosts

• Examples:– NetworkAddress– DirectedBroadcastAddress– LimitedBroadcastAddress– ThisComputerAddress– LoopbackAddress– Multicastaddresses

[email protected] LivelloRete- IPv4 56

Page 57: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Network Address

• Itisconvenienttohaveanaddressthatcanbeusedtodenotetheprefix assignedtoagivennetwork

• IPreserveshostaddresszero– andusesittodenoteanetwork

• Thus,theaddress128.211.0.16/28denotesanetwork– becausethebitsbeyondthe28arezero– 10000000110100110000000000010000

• Anetworkaddressshouldneverappearasthedestinationaddressinapacket

[email protected] LivelloRete- IPv4 57

Page 58: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Directed Broadcast Address

• Tosimplifybroadcasting(sendtoall)– IPdefinesadirectedbroadcastaddressforeachphysicalnetwork

• Whenapacketissenttoanetwork'sdirectedbroadcast– asinglecopyofthepackettravelsacrosstheInternet

• untilitreachesthespecifiednetwork– thepacketisthendeliveredtoallhostsonthenetwork

• Thedirectedbroadcastaddressforanetworkisformedbyaddingasuffixthatconsistsofall1bitstothenetworkprefix– 10000000110100110000000000011111

[email protected] LivelloRete- IPv4 58

Page 59: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Limited Broadcast Address

• Limitedbroadcastreferstoabroadcastonadirectly-connectednetwork:– informally,wesaythatthebroadcastislimitedtoa“singleLAN”meaningthatitwillneverbeforwardedbyarouter,evenifthe“LAN”canbeahugeCampusLANwithhundredsofcomputers

• Limitedbroadcastisusedduringsystemstartup– byacomputerthatdoesnotyetknowthenetworknumber

• IPreservestheaddressconsistingof32-bitsof1s– 11111111111111111111111111111111

• Thus,IPwillbroadcastanypacketsenttotheall-1saddressacrossthelocalnetwork

[email protected] LivelloRete- IPv4 59

Page 60: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

This Computer Address

• AcomputerneedstoknowitsIPaddress– beforeitcansendorreceiveInternetpackets

• TCP/IPcontainsprotocolsacomputercanusetoobtainitsIPaddressautomaticallywhenthecomputerboots– …butthestartupprotocolsalsouseanIPtocommunicate

• Whenusingsuchstartupprotocols– acomputercannotsupplyacorrectIPsourceaddress– TohandlesuchcasesIPreservestheaddressthatconsistsofall0stomeanthiscomputer

– 00000000000000000000000000000000

[email protected] LivelloRete- IPv4 60

Page 61: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Loopback Address

• Loopbackaddressusedtotestnetworkapplications– e.g.,forpreliminarydebuggingafteranetworkapplicationhasbeencreated

• Aprogrammermusthavetwoapplicationprogramsthatareintendedtocommunicateacrossanetwork

• Insteadofexecutingeachprogramonaseparatecomputer– theprogrammerrunsbothprogramsonasinglecomputer– andinstructsthemtousealoopbackaddresswhencommunicating

• Whenoneapplicationsendsdatatoanother– datatravelsdowntheprotocolstacktotheIPsoftware– thenforwardsitbackupthroughtheprotocolstacktothesecondprogram

[email protected] LivelloRete- IPv4 61

Page 62: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Loopback Address (cont’d)

• IPreservesthenetworkprefix127/8 forusewithloopback• Thehostaddressusedwith127isirrelevant

– allhostaddressesaretreatedthesame– programmersoftenusehostnumber1– soitmakes127.0.0.1 themostpopularloopbackaddress

• Duringloopbacktestingnopacketseverleaveacomputer– theIPsoftwareforwardspacketsfromoneapplicationtoanother

• Theloopbackaddressneverappearsinapackettravelingacrossanetwork

[email protected] LivelloRete- IPv4 62

Page 63: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Summary of Special IP Addresses

[email protected] LivelloRete- IPv4

Page 64: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Indirizzo Multicast

• Internetammettel’inviodipacchettia“molti”• Iroutersipreoccupano(complesso,nonlovediamoinquesto

corso)dicapireilpuntoottimodoveduplicarel’informazione• Unpacchettomulticast è inviato aunindirizzo di“gruppo”• InIPv4:ClassD,iniziano per1110• 224.0.0.0– 239.255.255.255• Esistonogruppimulticast “well known”• 224.0.0.1:All Hosts onthis Subnet• 224.0.0.2:All Routers onthis Subnet• Glialtripossonoessereusatiperapplicazioniproprietarieonuove• PurtropponontuttigliISPpermettonotrafficomulticast senonper

lagestionedeiprotocollidirouting stessi

[email protected] LivelloRete- IPv4 64

Page 65: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Multicast Routing

• Multicast:deliveryofsamepackettoagroupofreceiverswiththeminimumoverhead

• Multipleunicastvs.multicast– Hostbasedvs.networkbased

[email protected] LivelloRete- IPv4 65

Page 66: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Routers and IP Addresses

• EachrouterisassignedtwoormoreIPaddresses– oneaddressforeach logicalnetworktowhichtherouterattaches

• Tounderstandwhy,recalltwofacts:– Arouter connectsmultipleIPnetworks(bydefinition)– EachIPaddresscontainsaprefixthatspecifiesa logicalnetwork

• AsingleIPaddressdoesnotsufficeforarouter– becauseeachrouterconnectstomultiplenetworks– andeachnetworkhasauniqueprefix

• TheIPschemecanbeexplainedbyaprinciple:– AnIPaddressdoesnotidentifyaspecificcomputer– eachaddressidentifies ininterface,i.e.,alogicalconnectionbetween

acomputerandanetwork– Acomputerwithmultiplenetworkconnections(e.g.,arouter)must

beassignedoneIPaddressforeachconnection

[email protected] LivelloRete- IPv4 66

Page 67: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

An Example

[email protected] LivelloRete- IPv4

Page 68: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Un altro esempio

[email protected] LivelloRete- IPv4 68

Campus LAN con 4 reti IP private: 192.168.1.0/24192.168.2.0/24192.168.3.0/24192.168.4.0/24

Routerdicampuscheinterconnettele4 retiedinoltraalRouterNATdicollegamentoversoInternet:5 indirizziIPtuttisullastessainterfacciafisicadellacampusLAN

192.168.1.1192.168.2.1192.168.3.1192.168.4.1192.168.5.1

Router,NATFirewallperaccessoaInternet2 indirizziIPsudueinterfaccediverse

153.18.125.1192.168.5.2

Page 69: LivelloRete IndizzamentoIP (v4) e inoltrodeipacchettidisi.unitn.it/locigno/teaching-duties/reti/aa17-18/05.1...–IPv4: quello attualmente in uso con indirizzi a 32 bit –IPv6: il

Un altro esempio (cont)

[email protected] LivelloRete- IPv4 69

Routerdicampuscheinterconnettele4retiedinoltraalRouterNATdicollegamentoversoInternet:5 indirizziIPtuttisullastessainterfacciafisicadellacampusLAN

168.192.1.1168.192.2.1168.192.3.1168.192.4.1168.192.5.1

Collegamentoalivelloethernet

153.18.125.1168.192.5.2

...