G.Bianchi, G.Neglia, V.Mancuso
Lecture 8.Lecture 8.
Internet Network Layer:Internet Network Layer:
IP FundamentalsIP Fundamentals
G.Bianchi, G.Neglia, V.Mancuso
OutlineOutline
Layer 3 functionalitiesInternet Protocol (IP) characteristicsIP packet (first look)IP addressesRouting tables: how to useARP
G.Bianchi, G.Neglia, V.Mancuso
Layer 3 functionalitiesLayer 3 functionalities
This layer handles the routing of the data: i.e. delivery data to the correct destinationLayer 3 functionalities are spread all over the network
in ad hoc apparatus (routers)in your PC (as routing software)
G.Bianchi, G.Neglia, V.Mancuso
CircuitCircuit SwitchedSwitched NetworkNetwork
G.Bianchi, G.Neglia, V.Mancuso
PacketPacket SwitchedSwitched NetworkNetwork
Router CRouter B
Router F
Router D
Internet routing
Router E
A
G
G.Bianchi, G.Neglia, V.Mancuso
Internet Protocol (IP)Internet Protocol (IP)RFC 791 (1981)RFC 791 (1981)
Connectionlessdatagram delivery service
Best-effortUnreliable
no guarantees of reception & packet ordererror-handling algorithm: throw away packet!
Upon buffer congestionUpon error check failed
G.Bianchi, G.Neglia, V.Mancuso
IP functions in your PCIP functions in your PCin trasmission:
Encapsulates data from transport layer into datagramsprepare header (src & dest addresses, etc)apply routing algorithmsend datagram to network interface
in reception:check validity of incoming datagramsread headerverify whether datagram is to be forwardedif datagram has reached destination, deliverpayload to higher layer protocol
G.Bianchi, G.Neglia, V.Mancuso
IP IP datagramdatagram formatformat20 20 bytesbytes headerheader (minimum)(minimum)
0 3 7 15 31Type of Service
TOS Total Length
Options (if any)
32 bit destination IP address
Data (if any)
Version Headerlength
16 bit identification
32 bit source IP address
Time to LiveTTL Protocol
13 bit fragment offset
Header checksum
flags3 bit
Padding (0s)
G.Bianchi, G.Neglia, V.Mancuso
IP addressIP address32 bit string
Bit-wise notationthe natural notation
dotted notation:4 x 8 bitseach 8 bit = 0:255 integerintended for humans
10010011101000110001010000001001
10010011 . 10100011 . 00010100 . 00001001
147 . 163 . 20 . 9
Dotted Notation is often misleading, as it may hide address properties
G.Bianchi, G.Neglia, V.Mancuso
Notation conversionNotation conversionbin bin --> dotted> dotted
147.163.20.9 (www.diepa.unipa.it)
binary 128 64 32 16 8 4 2 1 decimal
10010011 1 0 0 1 0 0 1 1 128+16+2+1=147
10100011 1 0 1 0 0 0 1 1 128+32+2+1 = 163
00010100 0 0 0 1 0 1 0 0 16+4 = 20
00001001 0 0 0 0 1 0 0 1 8+1 = 9
10010011.10100011.00010100.00001001
G.Bianchi, G.Neglia, V.Mancuso
Notation conversionNotation conversiondotted dotted --> bin> bin
131.175.21.1 (morgana.elet.polimi.it)
decimal 128 64 32 16 8 4 2 1 binary
131 1 0 0 0 0 0 1 1 128+2+1=10000011
175 1 0 1 0 1 1 1 1 128+32+8+4+2+1 = 10101111
21 0 0 0 1 0 1 0 1 16+4+1 = 00010101
1 0 0 0 0 0 0 0 1 1 = 00000001
10000011.10101111.00010101.00000001
G.Bianchi, G.Neglia, V.Mancuso
Need for network nameNeed for network name
Host bHost a Host c Host d
Host e Host f
All other worldwidenetworksHost g
a => left, b => left,c => right, d => righte => left, f => leftg => left, ...
in 2000 100M nodes!
R1
R2
G.Bianchi, G.Neglia, V.Mancuso
Need for network nameNeed for network name
Host bHost a Host c Host d
Host e Host f
All other worldwidenetworksHost g
R1
R2
X => left, Y => right,Z => left, W => left,...
Network X Network Y
Network W
Network Z
G.Bianchi, G.Neglia, V.Mancuso
Need for network nameNeed for network name
Host bHost a Host c Host d
Host e Host f
All other worldwidenetworksHost g
R1
R2
X=>left, Y=>right,everything else =>R2 knows
Network X Network Y
Network W
Network Z
Where is network name?
G.Bianchi, G.Neglia, V.Mancuso
IP Address StructureIP Address Structurepartitioned into two fieldspartitioned into two fields
Network id (or prefix)(part used for routing)
Host number(specifies device on the net)
32 bit IP address
Dotted notation: AAA.BBB.CCC.DDD - no physical meaning!A more correct notation should be: NNNNN-HHHHH
G.Bianchi, G.Neglia, V.Mancuso
IP Address StructureIP Address Structurepartitioned into two fieldspartitioned into two fields
Network prefix: 3 Host number(specifies device on the net)
32 bit IP address
3-2 3-5 3-8
Host Addresses3-8 means: host 8 on network 3
G.Bianchi, G.Neglia, V.Mancuso
Dotted notation Dotted notation vsvs IP address structureIP address structure
Dotted NotationAAA.BBB.CCC.DDD
no physical meaning!often misleading!
– it may hide address properties
More correct notation:NNNNN-HHHHH
Physical meaning (network prefix, host #)Prefix size is variable,Not implicit in the IP address (from 1993)
Separator must be provided externally
G.Bianchi, G.Neglia, V.Mancuso
ExampleExampleIP address 147.163.22.130
Bitwise notation:
Network prefix:Externally providedExample: first 22 bits network ID, last 10 bits host ID
Network prefix notation:/22 (modern notation)Netmask (traditional notation)
Netmask dotted decimal: 255.255.252.0
10010011.10100011.00010110.10000010
11111111.11111111.11111100.00000000
10010011.10100011.00010110.10000010
G.Bianchi, G.Neglia, V.Mancuso
Network AddressNetwork Address
Local Host Interface:147.163.21.9/22 10010011.10100011.00010101.00001001
147.163.21.9
Network Address 10010011.10100011.00010100.00000000
Network prefix Hostid
Dotted notation for the network address147.163.20.0
Pure Convenience (not only for men)!
G.Bianchi, G.Neglia, V.Mancuso
Naming in IP: networksNaming in IP: networks
Network 143
Host 2Host 1
Network 542
Host 12 Host 2
Network xxx
Network yyy All other worldwidenetworks
Network name: Network prefix 00000000000000
Special IP addresses, with all 0’s in host partAll existing (physical) networks have different names!
G.Bianchi, G.Neglia, V.Mancuso
Naming in Naming in IPIP: hosts: hosts
Worldwide Unique Network address AssignmentWithin a network, unique IP address assignment to each host (better: interface)
CONCLUSION: ALL EXISTING HOSTS HAVE DIFFERENT IP ADDRESSES
3-2 3-5 3-8
Host Addresses3-8 means: host 8 on network 3Network address: 3-0
Host-id field set to 0 means this addressis a name for an entire network(this is network 3, unique name in all the world)
Netid3
Hostid0
G.Bianchi, G.Neglia, V.Mancuso
IP address 147.163.22.130
Network prefix:/22 (equivalently: 255.255.252.0)
It is an IP address for a HOSTSimple: not all 0’s in host part
Which belongs to network 147.163.20.0/22Simple: just set 0’s in host part
ExampleExample
10010011.10100011.00010110.10000010
10010011.10100011.00010110.10000010
10010011.10100011.00010100.00000000
G.Bianchi, G.Neglia, V.Mancuso
Naming in Naming in IPIP: broadcast: broadcast
3-2 3-5 3-8
Netaddr3
HostidAll 1’s Means: all the hosts on the considered network!
Used to send a “broadcast” information (to all the Attached hosts)
Example: network 147.163.20.0/22What is the IP address to use for broadcasting?Simple: just set all 1’s in host part
Broadcast address: 147.163.23.255
10010011.10100011.00010111.11111111
G.Bianchi, G.Neglia, V.Mancuso
TestTest
147.163.0.128 (prefix: /26)Network? Host? Broadcast?
147.163.0.128 (prefix: /24)Network? Host? Broadcast?
147.163.14.3 (prefix: /30)Network? Host? Broadcast?
174.163.20.255 (prefix: /22)Network? Host? Broadcast?
Think in binary! And everything becomes trivial….
G.Bianchi, G.Neglia, V.Mancuso
Second role of an IP address: routingSecond role of an IP address: routingRouting = ability to forward packets to destinationRouting = ability to forward packets to destination
Network 143
143-1
Host 2Host 1
143-2143-3
542-1
Network 542
Host 12
542-3
Host 2
542-2
Routing: based on network addresses
Key idea: first find the physical network where the host resides, and then find specific host routing tables addressing each of 100M+ hosts would be unfeasible
A Router (2nd definition): computer with 2+ interfaces
Connects different networks (hence the name inter-net), eventually with different technologiesAn IP address per each interfaceTask: collect datagrams on one interface and forward on other(s)
G.Bianchi, G.Neglia, V.Mancuso
PacketPacket RoutingRouting (at (at locallocal hosthost))
Application running at local computergenerates a datagram destined toIP address 321-2 [host 2 on network 321]
Local host operation:Knows its IP address NNN-XXXThus knows on which network NNN the computer is attachedHence, knows whether packet 321-2 needs to be forwarded to
A. an host on this same networkB. an host on a different network
321-2
Local host runs IP routing SW(some people thinksRouting sw confined At routers…)
G.Bianchi, G.Neglia, V.Mancuso
NetAddressNetAddress computation (Masking)computation (Masking)
Is on the same network?
Local Host Interface:147.163.21.9
Destination IPaddr:147.163.22.130 10010011.10100011.00010110.10000010
147.163.22.130
147.163.21.9
10010011.10100011.00010101.00001001
Netaddresses are equal!
They are on the same network!
How does IP software really work?
G.Bianchi, G.Neglia, V.Mancuso
NetAddressNetAddress computation (Masking)computation (Masking)Network mask
associated to the network addressstring of 1s in network address, 0s in host address
Local Host Interface:147.163.21.9 10010011.10100011.00010101.00001001
147.163.21.9
Netmask 11111111.11111111.11111100.00000000
Netaddress Hostid
Dotted notation for the netmask255.255.252.0
G.Bianchi, G.Neglia, V.Mancuso
NetAddressNetAddress computation (Masking)computation (Masking)
Is on the same network?
Destination IPaddr:147.163.22.130 10010011.10100011.00010110.10000010
147.163.22.130
147.163.21.9255.255.252.0
Netmask:255.255.252.0 11111111.11111111.11111100.00000000
Bitwise AND
10010011.10100011.00010100.00000000Network Address:147.163.20.0
=?
=10010011.10100011.00010100.00000000
=
They are on the same network!
G.Bianchi, G.Neglia, V.Mancuso
Inside the LANInside the LAN
43-543-3
• Router not involved43-1
Who is IP 43-1?
43-1ff:ff:ff:ff:ff:ff
43-0 = 43-0 (it is on this net)
Physical transmission: a) resolve IP address in physical network address, b) encapsulate packet in datalink frame, and c) deliver according to local networking technology
43-1
G.Bianchi, G.Neglia, V.Mancuso
Host configuration (Windows)Host configuration (Windows)
G.Bianchi, G.Neglia, V.Mancuso
Possible Possible netmasknetmask valuesvalues““magic magic netmasknetmask numbersnumbers””
1 1 1 1 1 1 1 1 = 2551 1 1 1 1 1 1 0 = 2541 1 1 1 1 1 0 0 = 2521 1 1 1 1 0 0 0 = 2481 1 1 1 0 0 0 0 = 2401 1 1 0 0 0 0 0 = 2241 1 0 0 0 0 0 0 = 1921 0 0 0 0 0 0 0 = 128128 64 32 16 8 4 2 1
Examples: /21 255.255.248.0/29 255.255.255.248
G.Bianchi, G.Neglia, V.Mancuso
GoingGoing through a through a RouterRouter
43-143-3
• At least one router on the network• Local router IP interface: destination for all packets
addressed outside the local physical network
321-2
Who is IP 43-3? MAC ff:04.a
321-2ff:04.a
321-0 != 43-0 (not on this net!)Send to 43-3: he knows more…
Physical transmission: a) resolve IP address in physical network address, b) encapsulate packet in datalink frame, and c) deliver according to local networking technology
43-5
G.Bianchi, G.Neglia, V.Mancuso
Network 321
321-12 321-2
Network 4343-1
321-2Net 321?? Not this net!Go to host 43-3
43-3 321-2Net 321?? Yes, I’m attached to!translate 321-1 in phynet address & deliver
Network 175175-1 175-2
RouterRouter operationoperation::Direct Direct ForwardingForwarding
G.Bianchi, G.Neglia, V.Mancuso
Network 175 Network 321175-1 175-2
321-12 321-2
Network 4343-1
175-2Net 175?? Not this net!Go to host 43-3
151-6
175-2Net 175?? Not here.But my tables say thatrouter 151.4 knows.Go there (with 151 nettechnology)
43-3
151-4Network 151
INTERNET = arbitrary networks interconnected via routers
RouterRouter operationoperation::IndirectIndirect ForwardingForwarding
G.Bianchi, G.Neglia, V.Mancuso
Layered viewLayered view
IP
N.i. 1
application
transport
IPnetwork
interface 3
Logicalnetwork14000-0
application
transport
IPnetworkinterface
Host B 29999-6
N.i. 2
IP
N.i. 2 N.i.3
dest. addr. 29999-6Host A 14000-4
RouterIndirect
forwarding
RouterDirect
forwarding
Logicalnetwork29999-0
Logicalnetwork111-0
Datagrams travel from router to router (indirect forwarding)until a router is on the same network of dest host (direct forwarding)
G.Bianchi, G.Neglia, V.Mancuso
Inter Inter -- Net exampleNet example
Ethernet
IP
TCP UDP
ATM PPP FDDI
IP
FDDI
IP
TCP UDP
AtmEthernet ATM
IP
ATMswitch
hosthost
PPP
IP
ATM networkEthernetTelephone
line
FDDI
router router router... ... ... ... ... ... ... ...
1 hop = ATM network andswitch crossing!
G.Bianchi, G.Neglia, V.Mancuso
Internet Internet vsvs specificspecificphysicalphysical networkingnetworking technologytechnologyIP: an overlay networking protocol
interconnection of widely heterogeneous networksseen by TCP/IP as sub networksRouters do not care about specific network technology (LAN, WAN,circuit switching, packet switching, …) but they NEED to have a specific network interface (Routers with Ethernet interfaces cheap; with FDDI or ATM very expensive…)
Router duties: just select destination (end or intermediate router)!then map IPaddr in physical network addressIP datagrams tunneled into underlying network data unitsspecific physical network routing may be extremely complex (router sees this as single hop)
G.Bianchi, G.Neglia, V.Mancuso
Routing tableRouting table20000-5 20000-6 30000-12 30000-7
Net20000
Net30000R1 R2 R3
10000-32
Net10000
Other nets
Net 50000
40000-8
Destination Network Next Hop20000 Direct forward30000 Direct forward10000 20000-540000 30000-750000 30000-7default 20000-5
R2 routing table
Net 40000
Three cases: 1) direct forwarding 2) Indirect forwarding (explicit) 3) Indirect forwarding via default router (when available)
Routing vianetwork Id,not host Id!
Otherwisetoo large tables
G.Bianchi, G.Neglia, V.Mancuso
Routing table lookupRouting table lookup132.43.3.5 132.43.0.6 208.0.1.12 208.0.1.7
Net132.43.0.0
Net208.0.1.0R1 R2 R3
10.12.1.32
Net10.0.0.0
Other nets
Net 193.33.9.0
208.0.2.8
Dest net /mask Next Hop132.43.0.0 /16 Direct forward208.0.1.0 /24 Direct forward10.0.0.0 /8 132.43.3.5208.0.2.0 /24 208.0.1.7193.33.9.0 /24 208.0.1.7208.1.1.0 /24 132.43.3.5
R2 routing table
Net 208.0.2.0
208.1.1.0
default 132.43.3.5
IP dest: 208.1.1.14
For (rows in rtab)IP_dest&mask == dest_net?
Found:208.1.1.0
Lookup?goto 132.43.3.5
G.Bianchi, G.Neglia, V.Mancuso
Route print (Route print (DOS,unixDOS,unix))shows routing table of your PCshows routing table of your PC
(remember: your PC is a simple IP router)(remember: your PC is a simple IP router)
===========================================================================Active Routes:Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 10.163.57.1 10.163.57.77 110.163.57.0 255.255.255.0 10.163.57.77 10.163.57.77 110.163.57.77 255.255.255.255 127.0.0.1 127.0.0.1 1
10.255.255.255 255.255.255.255 10.163.57.77 10.163.57.77 1127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1224.0.0.0 224.0.0.0 10.163.57.77 10.163.57.77 1
255.255.255.255 255.255.255.255 10.163.57.77 10.163.57.77 1Default Gateway: 10.163.57.1===========================================================================
G.Bianchi, G.Neglia, V.Mancuso
ClassfulClassful IP AddressingIP AddressingOriginally (from 1981) a rigid two-level
address structure
Network number(network prefix) Host number
32 bit IP address8,16 or 24 bits
G.Bianchi, G.Neglia, V.Mancuso
Primary Address ClassesPrimary Address Classes3 standardized classes3 standardized classes
0 NET ID (7bit) HOST ID (24 bit)
1 NET ID (14bit) HOST ID (16 bit)0
1 NET ID (21bit) HOST ID (8 bit)1 0
Class A - /8 network prefix
Class B - /16 network prefix
Class C - /24 network prefix
/xx notation: modern notationin principle not necessary for classful IP addressing
G.Bianchi, G.Neglia, V.Mancuso
Additional classesAdditional classes
1 Multicast Group ID (28 bit)1 1
Class D: IP multicasting0
1 reserved1 1
Class E: reserved for experimental use1
G.Bianchi, G.Neglia, V.Mancuso
Dotted Decimal RangesDotted Decimal Ranges
Address Class
Class A
Class B
Class C
Dotted Decimal ranges
1.xxx.xxx.xxx through 126.xxx.xxx.xxx
128.0.xxx.xxx through 191.255.xxx.xxx
192.0.0.xxx through 223.255.255.xxx
Class D (mcast) 224.xxx.xxx.xxx through 239.xxx.xxx.xxx
Class E (exper) 240.xxx.xxx.xxx through 255.xxx.xxx.xxx
G.Bianchi, G.Neglia, V.Mancuso
ExamplesExamples
15.10.10.90Net ID Host ID
CLASS A
131.175.12.3Net ID Host ID
CLASS B
195.31.235.10Net ID Host ID
CLASS C
G.Bianchi, G.Neglia, V.Mancuso
Addressing networksAddressing networksAll 0s host ID = reserved for network name. Examples:
CLASS A network: 13.0.0.0CLASS B network: 131.175.0.0CLASS C network: 193.32.43.0
Test:188.66.32.0 = ???122.0.0.0 = ???
G.Bianchi, G.Neglia, V.Mancuso
Special AddressesSpecial Addressesall 1s host id: broadcast address (all hosts in the network)
es. 131.175.255.255 =all hosts attached to the 131.175 net
0.0.0.0 = THIS host on THIS network (0.x.x.x also reserved)
e.g. to boot diskless WS (BOOTP)
127.x.x.x used for loopback (es. 127.0.0.1=localhost)
all 1s = 255.255.255.255 = limited broadcast all nodes on THIS local network
G.Bianchi, G.Neglia, V.Mancuso
Address blocks for private InternetsAddress blocks for private Internets(RFC 1918)(RFC 1918)
IANAIANA--AllocatedAllocated, Non, Non--Internet Internet RoutableRoutable,,IP IP AddressAddress SchemesSchemes
Class Network Address RangeA 10.0.0.0 - 10.255.255.255 B 172.16.0.0 - 172.31.255.255 C 192.168.0.0 - 192.168.255.255
To be used by private organizations not connected to the InternetNo need to ask to IANA or InterNIC for these addresses.Use Network Address Translator (NAT) when external connectivity needed
G.Bianchi, G.Neglia, V.Mancuso
Network Address TranslatorNetwork Address Translator“Inside” Network “Outside” Network
10.0.0.2
10.0.0.3
NAT Table
Inside LocalIP Address
GlobalIP Address
10.0.0.210.0.0.3
192.69.1.1192.69.1.2
Source Address
NAT
Internet10.0.0.2 192.69.1.1
Map external address with Internal ones (may be a subset)
G.Bianchi, G.Neglia, V.Mancuso
Counting upCounting up32 bit IP address:
232 = 4.294.967.296 theoretical IP addressesclass A:
27-2 =126 networks [0.0.0.0 and 127.0.0.0 reserved]224-2 = 16.777.214 maximum hosts
2.113.928.964 addressable hosts (49,22% of max)class B
214=16.384 networks216-2 = 65.534 maximum hosts
1.073.709.056 addressable hosts (24,99% of max)class C
221=2.097.152 networks28-2 = 254 maximum hosts
532.676.608 addressable hosts (12,40% of max)
Class AClass B
CDE
The IPaddress
Pie!
G.Bianchi, G.Neglia, V.Mancuso
Routing table lookupRouting table lookup132.43.3.5 132.43.0.6 208.0.1.12 208.0.1.7
Net132.43.0.0
Net208.0.1.0R1 R2 R3
10.12.1.32
Net10.0.0.0
Other nets
Net 193.33.9.0
208.0.2.8
Destination net Next Hop132.43.0.0 Direct forward208.0.1.0 Direct forward10.0.0.0 132.43.3.5208.0.2.0 208.0.1.7193.33.9.0 208.0.1.7208.1.1.0 132.43.3.5
R2 routing table
Net 208.0.2.0
208.1.1.0
default 132.43.3.5
IP dest: 208.1.1.14
Which class?C
Destination net?208.1.1.0
Lookup?goto 132.43.3.5
G.Bianchi, G.Neglia, V.Mancuso
Net Address computation Net Address computation (Masking)(Masking)
class mask:Depends on first bits of address (which specify class)
Class A mask: 255.0.0.0 Class B mask: 255.255.0.0Class C mask: 255.255.255.0
10011111 01100100 00001001 00010010
11111111 11111111 00000000 00000000
DEST IP address:159.100.9.18
class B
Class B Mask:255.255.0.0
Bitwise AND
Net address159.100.0.0 10011111 01100100 00000000 00000000