1 Lecture 8. Internet Network Layer: IP Fundamentals
2 Outline Layer 3 functionalities Internet Protocol (IP) characteristics IP packet (first look) IP addresses Routing tables: how to use ARP
3 Layer 3 functionalities This layer handles the routing of the data: i.e. delivery data to the correct destination Layer 3 functionalities are spread all over the network in ad hoc apparatus (routers) in your PC (as routing software)
4 Circuit Switched Network
5 Packet Switched Network A Router B Router C Router E Router D Router F G Internet routing
6 Internet Protocol (IP) RFC 791 (1981) Connectionless datagram delivery service Best-effort Unreliable no guarantees of reception & packet order error-handling algorithm: throw away packet! Upon buffer congestion Upon error check failed
7 IP functions in your PC in trasmission: Encapsulates data from transport layer into datagrams prepare header (src & dest addresses, etc) apply routing algorithm send datagram to network interface in reception: check validity of incoming datagrams read header verify whether datagram is to be forwarded if datagram has reached destination, deliver payload to higher layer protocol
8 IP datagram format 20 bytes header (minimum) Version Header Type of Service length TOS Total Length flags 16 bit identification 3 bit 13 bit fragment offset Time to Live TTL Protocol Header checksum 32 bit source IP address 32 bit destination IP address Options (if any) Padding (0s) Data (if any)
9 32 bit string Bit-wise notation the natural notation IP address dotted notation: 4 x 8 bits each 8 bit = 0:255 integer intended for humans Dotted Notation is often misleading, as it may hide address properties
10 Notation conversion bin -> > dotted binary decimal = = = = (www.diepa.unipa.it)
11 Notation conversion dotted -> > bin (morgana.elet.polimi.it) decimal binary = = = =
12 Need for network name Host g All other worldwide networks Host e Host f R2 a => left, b => left, c => right, d => right e => left, f => left g => left,... in M nodes! Host a Host b Host c Host d R1
13 Need for network name Network W Host g All other worldwide networks Host e Host f X => left, Y => right, Z => left, W => left,... Network Z R2 Host a Host b Host c Host d R1 Network X Network Y
14 Need for network name Network W Host g All other worldwide networks Host e Host f X=>left, Y=>right, everything else =>R2 knows Network Z Whereisnetwork name? R2 Host a Host b Host c Host d R1 Network X Network Y
15 IP Address Structure partitioned into two fields 32 bit IP address Network id (or prefix) (part used for routing) Host number (specifies device on the net) Dotted notation: AAA.BBB.CCC.DDD - no physical meaning! A more correct notation should be: NNNNN-HHHHH
16 IP Address Structure partitioned into two fields 32 bit IP address Network prefix: 3 Host number (specifies device on the net) Host Addresses 3-8 means: host 8 on network 3
17 Dotted notation vs IP address structure Dotted Notation AAA.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
18 Example IP address Bitwise notation: Network prefix: Externally provided Example: first 22 bits network ID, last 10 bits host ID Network prefix notation: /22 (modern notation) Netmask (traditional notation) Netmask dotted decimal:
19 Network Address Local Host Interface: / Network prefix Hostid Network Address Dotted notation for the network address Pure Convenience (not only for men)!
20 Naming in IP: networks Network yyy All other worldwide networks Network xxx Host 1 Host 2 Host 12 Host 2 Network 143 Network 542 Network name: Network prefix Special IP addresses, with all 0 s in host part All existing (physical) networks have different names!
21 Naming in IP: : hosts Netid 3 Hostid 0 Network address: 3-0 Host-id field set to 0 means this address is a name for an entire network (this is network 3, unique name in all the world) Host Addresses 3-8 means: host 8 on network 3 Worldwide Unique Network address Assignment Within a network, unique IP address assignment to each host (better: interface) CONCLUSION: ALL EXISTING HOSTS HAVE DIFFERENT IP ADDRESSES
22 Example IP address Network prefix: /22 (equivalently: ) It is an IP address for a HOST Simple: not all 0 s in host part Which belongs to network /22 Simple: just set 0 s in host part
23 Naming in IP: : broadcast Netaddr 3 Hostid All 1 s Example: network /22 What is the IP address to use for broadcasting? Simple: just set all 1 s in host part Means: all the hosts on the considered network! Used to send a broadcast information (to all the Attached hosts) Broadcast address:
24 Test (prefix: /26) Network? Host? Broadcast? (prefix: /24) Network? Host? Broadcast? (prefix: /30) Network? Host? Broadcast? (prefix: /22) Network? Host? Broadcast? Think in binary! And everything becomes trivial.
25 Second role of an IP address: routing Routing = ability to forward packets to destination 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 (2 nd definition): computer with 2+ interfaces Connects different networks (hence the name inter-net), eventually with different technologies An IP address per each interface Task: collect datagrams on one interface and forward on other(s) Host 1 Host Host 12 Host Network 143 Network 542
26 Packet Routing (at local host) Application running at local computer generates a datagram destined to IP address [host 2 on network 321] Local host runs IP routing SW (some people thinks Routing sw confined At routers ) Local host operation: Knows its IP address NNN-XXX Thus knows on which network NNN the computer is attached Hence, knows whether packet needs to be forwarded to A. an host on this same network B. an host on a different network
27 NetAddress computation (Masking) Is on the same network? Local Host Interface: Destination IPaddr: Netaddresses are equal! They are on the same network! How does IP software really work?
28 NetAddress computation (Masking) Network mask associated to the network address string of 1s in network address, 0s in host address Local Host Interface: Netaddress Hostid Netmask Dotted notation for the netmask
29 NetAddress computation (Masking) Is on the same network? Destination IPaddr: Netmask: Bitwise AND = Network Address: =? They are on the same network!
30 Inside the LAN 43-1 Router not involved 43-0 = 43-0 (it is on this net) Who is IP 43-1? ff:ff:ff:ff:ff:ff 43-1 Physical transmission: a) resolve IP address in physical network address, b) encapsulate packet in datalink frame, and c) deliver according to local networking technology
31 Host configuration (Windows)
32 Possible netmask values magic netmask numbers = = = = = = = = 255 Examples: / /
33 Going through a Router At least one router on the network Local router IP interface: destination for all packets addressed outside the local physical network 321-0!= 43-0 (not on this net!) Send to 43-3: he knows more Who is IP 43-3? MAC ff:04.a ff:04.a Physical transmission: a) resolve IP address in physical network address, b) encapsulate packet in datalink frame, and c) deliver according to local networking technology
34 Router operation: Direct Forwarding Network Network Net 321?? Not this net! Go to host Net 321?? Yes, I m attached to! translate in phy net address & deliver Network 43
35 Router operation: Indirect Forwarding Network 175 Network Network Net 175?? Not this net! Go to host 43-3 Network INTERNET = arbitrary networks interconnected via routers Net 175?? Not here. But my tables say that router knows. Go there (with 151 net technology)
36 Layered view Host A application transport IP network interface Logical network N.i. 1 dest. addr Router Indirect forwarding IP N.i. 2 Logical network Router Direct forwarding N.i. 2 IP N.i.3 Logical network Host B application transport IP network interface 3 Datagrams travel from router to router (indirect forwarding) until a router is on the same network of dest host (direct forwarding)
37 Inter - Net example Ethernet ATM network Telephone line FDDI host router TCP UDP ATM router router TCP UDP switch IP IP Ethernet Ethernet IP ATM IP ATM Atm PPP PPP FDDI IP host FDDI 1 hop = ATM network and switch crossing!
38 Internet vs specific physical networking technology IP: an overlay networking protocol interconnection of widely heterogeneous networks seen by TCP/IP as sub networks Routers 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 address IP datagrams tunneled into underlying network data units specific physical network routing may be extremely complex (router sees this as single hop)
39 Routing table Net Other nets R1 Net Net R R3 Destination Network R2 routing table Next Hop Direct forward Direct forward default Net Net Routing via network Id, not host Id! Otherwise too large tables Three cases: 1) direct forwarding 2) Indirect forwarding (explicit) 3) Indirect forwarding via default router (when available)
40 Routing table lookup Net Other nets R1 Net Net R R3 Dest net /mask R2 routing table Next Hop /16 Direct forward /24 Direct forward / / / / default Net Net IP dest: For (rows in rtab) IP_dest&mask == dest_net? Found: Lookup? goto
41 Route print (DOS,unix( DOS,unix) shows routing table of your PC (remember: your PC is a simple IP router) =========================================================================== Active Routes: Network Destination Netmask Gateway Interface Metric Default Gateway: ===========================================================================
42 Classful IP Addressing Originally (from 1981) a rigid two-level 8,16 or 24 bits address structure 32 bit IP address Network number (network prefix) Host number
43 Primary Address Classes 3 standardized classes Class A - /8 network prefix 0 NET ID (7bit) HOST ID (24 bit) Class B - /16 network prefix 1 0 NET ID (14bit) HOST ID (16 bit) NET ID (21bit) HOST ID (8 bit) Class C - /24 network prefix /xx notation: modern notation in principle not necessary for classful IP addressing
44 Additional classes Class D: IP multicasting Multicast Group ID (28 bit) Class E: reserved for experimental use reserved
45 Dotted Decimal Ranges Address Class Class A Class B Class C Class D (mcast) Class E (exper) Dotted Decimal ranges 1.xxx.xxx.xxx through 126.xxx.xxx.xxx xxx.xxx through xxx.xxx xxx through xxx 224.xxx.xxx.xxx through 239.xxx.xxx.xxx 240.xxx.xxx.xxx through 255.xxx.xxx.xxx
46 Examples CLASS A Net ID Host ID CLASS B Net ID Host ID CLASS C Net ID Host ID
47 Addressing networks All 0s host ID = reserved for network name. Examples: CLASS A network: CLASS B network: CLASS C network: Test: =??? =???
48 Special Addresses all 1s host id: broadcast address (all hosts in the network) es =all hosts attached to the net = 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 =localhost) all 1s = = limited broadcast all nodes on THIS local network
49 Address blocks for private Internets (RFC 1918) IANA-Allocated Allocated,, Non-Internet Routable, IP Address Schemes Class Network Address Range A B C To be used by private organizations not connected to the Internet No need to ask to IANA or InterNIC for these addresses. Use Network Address Translator (NAT) when external connectivity needed
50 Network Address Translator Inside Network Outside Network NAT Internet Source Address NAT Table Inside Local IP Address Global IP Address Map external address with Internal ones (may be a subset)
51 Counting up 32 bit IP address: 2 32 = theoretical IP addresses class A: =126 networks [ and reserved] = maximum hosts addressable hosts (49,22% of max) class B 2 14 = networks = maximum hosts addressable hosts (24,99% of max) class C 2 21 = networks = 254 maximum hosts addressable hosts (12,40% of max) Class A The IP address Pie! Class B E C D
52 Routing table lookup Net Other nets R1 Net Net R R3 Destination net R2 routing table Next Hop Direct forward Direct forward default Net Net IP dest: Which class? C Destination net? Lookup? goto
53 Net Address computation (Masking) class mask: Depends on first bits of address (which specify class) Class A mask: Class B mask: Class C mask: DEST IP address: class B Class B Mask: Bitwise AND Net address