1 Internet Protocol version 4 Claudio Cicconetti International Master on Communication Networks Engineering 2006/2007
2 Table of Contents IP Addressing Class-based IP addresses IP subnets IP routing Methods of delivery IP address exhaustion problem Private IP addresses Classless Inter-Domain Routing IP datagram IP fragmentation
3 Internet Protocol (IP) IP is a standard protocol with STD number 5 (see IP is the protocol that hides the underlying physical network by creating a virtual network view. It is an unreliable, best-effort, and connectionless packet delivery protocol.
4 Internet Protocol (IP) Best-effort means that datagrams may: belost; arrive out of order; even be duplicated. IP assumes that higher layer protocols (e.g., TCP) will address these anomalies. This makes IP a very robust network protocol. In fact, the US DoD intended to deploy a network that would still be operational if parts of the country were destroyed.
5 IP Addressing In any network protocol, such as IP, addressing is needed to allow any two hosts to communicate between each other. IP addresses are represented by a 32-bit unsigned binary value, which is usually expressed in a dotted decimal format (e.g., ) because the numeric form (e.g., ) is hard to read.
6 IP Addressing The binary format of the 32-bit IP address is: An easier way to remember IP addresses is by assigning to them a name (e.g., which is resolver through the Domain Name System (DNS).
7 IP Addressing Strictly speaking, an IP address identifies an interface that is capable of sending and receiving IP datagrams. One system can have multiple such interfaces. Usually, hosts have only one interface (thus, one IP address), whereas routers have many interfaces (thus, many IP addresses).
8 IP Addressing IP datagrams (the basic data packets exchanged between hosts) are transmitted by a physical network attached to the host. Each IP datagram contains a source IP address and a destination IP address.
9 Class-based IP addresses There are five classes of IP addresses. The prefix is referred to as the network part, the suffix as the host part.
10 Class-based IP addresses The division of an IP address into two parts also separates the responsibility for selecting the complete IP address. The network number portion of the address is assigned by the Regional Internet Registries (RIRs). The host number portion is assigned by the authority controlling the network.
11 Class-based IP addresses Not all suffixes are available: all 0 s: this address refers to the network itself, e.g., means the whole network 10.*. all 1 s: this is the directed broadcast for this network, e.g., means all the hosts on network 10.*.
12 Class-based IP addresses The Class A network is defined as the loopback network. Usually, the host part is set to 1, which results in being the loopback IP address of the host. Addresses from that network are assigned to interfaces that process data within the local system. Thus, these loopback interfaces never access a physical network.
13 Class-based IP addresses Class A addresses These addresses use 7 bits for the network and 24 bits for the host portion of the IP address. This allows for (126) networks (both 0 and 127 are reserved values) each with (16,777,214) hosts, for a total of 2,113,928,964 available addresses.
14 Class-based IP addresses Class B addresses These addresses use 14 bits for the network and 16 bits for the host portion of the IP address. This allows for 2 14 (16384) networks each with (65,534) hosts, for a total of 1,073,709,056 available addresses.
15 Class-based IP addresses Class C addresses These addresses use 21 bits for the network and 8 bits for the host portion of the IP address. This allows for 2 21 ( ) networks each with (254) hosts, for a total of 532,676,608 available addresses.
16 Class-based IP addresses Class D addresses are reserved for multicasting (a sort of broadcasting, but not in a limited area, and only to hosts using the same class D addresses). Class E addresses are reserved for future use (likely, they will never be used at all).
17 Class-based IP addresses A Class A address is suitable for networks with an extremely large number of hosts. Class C addresses are suitable for networks with a small number of hosts. This means that medium-sized networks (those with more than 254 hosts or where there is an expectation of more than 254 hosts) must use Class B addresses.
18 Class-based IP addresses However, the number of small- to mediumsized networks has been growing very rapidly. It was feared that if this growth had been allowed to continue unabated, all of the available Class B network addresses would have been used by the mid-1990s. This is known as the IP address exhaustion problem.
19 IP subnets An additional problem of the original IP addressing scheme was that it required a centralized authority, i.e., the RIR, to assign network numbers. This problem was then solved through IP subnetting, which allows the network administrator to locally partition her network into several IP subnets.
20 IP subnets The host number part of the IP address is subdivided into a second network number (i.e., subnet) and a host number. The entire network still appears as one IP network to the outside world. Thus, a host within a network that has subnets is aware of the subnetting structure. A host in a different network is not. This remote host still regards the local part (subnet + host) of the IP address as a host number.
21 IP subnets Any bits in the local portion can be used to form the subnet. The division is done using a 32-bit subnet mask, which is usually written in dotted decimal form network subnet- --host network mask
22 IP subnets The special treatment of all bits zero and all bits one applies to each of the three parts of a subnetted IP address just as it does to both parts of an IP address that has not been subnetted. There are two types of subnetting: static subnetting, i.e., all subnets have the same prefix; variable subnetting, i.e., subnets may have different prefixes.
23 IP subnets For example, assume that you have been assigned an address pool ( /24) to be subnetted so as to serve a set of 6 LANs with the following requirements: LAN 1: 2 hosts LAN 3: 2 hosts LAN 5: 2 hosts LAN 2: 2 hosts LAN 4: 2 hosts LAN 6: 30 hosts
24 IP subnets An example of variable length subnetting is : /27 -> 30 hosts (30 needed) /30 -> 2 hosts (2 needed) /30 -> 2 hosts (2 needed) /30 -> 2 hosts (2 needed) /30 -> 2 hosts (2 needed) /30 -> 2 hosts (2 needed) With static subnetting you can have: /27 -> 30 hosts (30 needed) /27 -> 30 hosts (2 needed) /27 -> 30 hosts (2 needed) /27 -> 30 hosts (2 needed) /27 -> 30 hosts (2 needed) /27 -> 30 hosts (2 needed)
25 IP subnets For example, assume that you have been assigned the Class C network , and you need to partition the networks so that the following requirements are satisfied: LAN 1: 50 hosts LAN 2: 50 hosts LAN 3: 50 hosts LAN 4: 30 hosts LAN 5: 30 hosts
26 IP subnets This cannot be achieved with static subnetting, because you would require five subnets, each allowing up to 64 hosts (i.e., masks). However, you can accomplish your task with variable length subnetting, by partitioning the network into three subnetworks, and two subnetworks.
27 IP routing Whenever a host has a physical connection to multiple networks or subnets, it is described as being multi-homed. Typically, a multihomed host has different IP addresses associated with all its network adapters, each connected to a different subnet or network. Such a multi-homed host is usually employed as router.
28 IP routing A router forwards incoming IP datagrams towards a destination through a physical interface. Its decisions are based on the datagrams destination IP addresses, according to its routing table.
29 IP routing Four kinds of destinations: hosts or networks that are directly attached to one of the physical networks to which the router is attached (e.g., / ); hosts or networks for which the router has been given explicit definitions (e.g., / ); hosts or networks for which the router has received an ICMP redirect message; adefault for all other destinations (e.g., last entry of the routing table above).
30 IP routing There are many Interior Gateway Protocols (IGPs), such as: Open Shortest Path First (OSPF); Routing Information Protocol (RIP); Interior Gateway Routing Protocol (IGRP); Enhanced IGRP (EIGRP). On the other hand, the most common Exterior Gateway Protocol (EGP) is the Border Gateway Protocol version 4 (BGP4).
31 IP routing If the destination host is attached to the same physical network as the source host, IP datagrams can be directly exchanged. This is done by encapsulating the IP datagram in the physical network frame. This is called direct routing. Indirect routing occurs when the destination host is not connected to a network directly attached to the source host. The only way to reach the destination is via one or more IP routers.
32 IP routing lan /26 Host A Router R lan0: lan1: lan /26 Host B Host C
33 IP routing Host B communicates directly with Host B. Host A communicates with Host B and Host C indirectly via Route R. Router R routing table: Destination Netmask Interface Next-hop lan lan1 Host A routing table: Destination Netmask Interface Next-hop lan lan
34 IP routing
35 IP routing Even though Host A and Host B are connected to the same physical network, they cannot communicate directly, because they belong to different logical subnetwork. Router R routing table: Destination Netmask Interface Next-hop lan lan0 Host A routing table: Destination Netmask Interface Next-hop lan lan
36 IP routing Without subnetting, IP uses the following algorithm to route datagrams: Is the destination IP network address equal to my IP network address? If so, send the IP datagram on local network. Otherwise send the IP datagram to the router corresponding to the destination IP network address.
37 IP routing With subnetting, IP uses the following algorithm to route datagrams: - Is (destination IP address & subnet mask) equal to (my IP address & subnet mask)? - If so, send the IP datagram on local network. - Otherwise send IP datagram to router corresponding to the destination IP (sub)network address.
38 Methods of delivery The majority of IP addresses refer to a single recipient, this is called a unicast address. Unicast connections specify a one-to-one relationship between a single source and a single destination. Additionally, there are three special types of IP addresses used for addressing multiple recipients: broadcast addresses, multicast addresses and anycast addresses.
39 Methods of delivery Broadcast addresses are never valid as a source address. They must specify the destination address. Different types of broadcast addresses: limited broadcast address; network-directed broadcast address; subnet-directed broadcast address; all-subnets-directed broadcast address.
40 Methods of delivery Limited broadcast address Address (all bits 1 in all parts of the IP address), meaning all hosts on the local subnet. Routers do not forward this packet.
41 Methods of delivery Network-directed broadcast address This is used in an unsubnetted environment, with the host part being all 1 s, e.g., , meaning all hosts on a network. Routers should forward these broadcast messages.
42 Methods of delivery With multicasting, any host in the Internet can associate to a multicast group, which is identified by a Class D multicast address. Packets sent to a multicast address are forwarded only to the members of the corresponding host group, which allows for one-to-many connections. E.g., used for audio/video brodcasting.
43 Methods of delivery With anycasting (not available in IPv4), hosts can be grouped into anycast pools, which are considered by the network to be interchangeable. When a remote host sends an IP datagram to an anycast address, that datagram is delivered to any of the hosts in the pool. E.g., used for web proxies.
44 The IP address exhaustion problem The number of networks on the Internet has been approximately doubling annually for a number of years. Nearly all of the new networks assigned in the late 1980s were Class B, and in 1990 it became apparent that if this trend continued, the last Class B network number would be assigned during On the other hand, Class C networks were hardly being used.
45 The IP address exhaustion problem To mitigate the exhaustion problem, Class B networks have been only assigned to organizations that: have a subnetting plan that documents more than 32 subnets within its organizational network; have more than 4096 hosts. Otherwise, a consecutively numbered block of Class C network numbers are assigned instead. Any requirements for a Class A network would be handled on an individual case basis.
46 Private IP addresses Another approach to conserve the IP address space is to use private IP addresses. Private IP addresses do not need to be unique within the Internet. However, hosts with private IP addresses cannot communicate with hosts outside their local networks.
47 Private IP addresses Three ranges of addresses have been reserved for this purpose: , as a single Class A network; through , as 16 contiguous Class B networks; through , as 256 contiguous Class C networks. These addresses can be used without requesting authorization from the RIR.
48 Classless Inter-Domain Routing While subnetting and careful assignment of IP addresses mitigated the IP address exhaustion problem, a new issue arised: the routing table explosion problem. Assume an organization has 4000 hosts. Then, it cannot be assigned a Class B network, and is allocate 16 Class C networks instead. This requires 16 entries in the routing table of every router in the world for the same organization.
49 Classless Inter-Domain Routing The solution to this problem is called Classless Inter-Domain Routing (CIDR). CIDR does not route according to the class of the network number (hence the term classless). On the other hand, it is based solely on the high order bits of the IP address.
50 Classless Inter-Domain Routing Each CIDR routing table entry contains a 32-bit IP address and a 32-bit network mask, which together give the length and value of the IP prefix: <IP_address> <network_mask> For example, to address a block of eight Class C addresses with one single routing table entry, the following representation suffices: < > < >
51 Classless Inter-Domain Routing This process of combining multiple networks into a single entry is referred to as supernetting. Routing is based on network masks that are shorter than the natural network mask of an IP address. This contrasts subnetting where the subnet masks are longer than the natural network mask.
52 Classless Inter-Domain Routing Supernetting example = (class C address) (network mask) ======== ======== ======== ======== logical_and = (IP prefix) = (class C address) (network mask) ======== ======== ======== ======== logical_and = (same IP prefix)
53 IP datagram The unit of transfer in an IP network is called an IP datagram. It consists of an IP header and data relevant to higher level protocols.
54 IP datagram
55 IP datagram VER is the field that contains the IP protocol version. The current version is 4. 5 is an experimental version. 6 is the version for IPv6. HLEN is the length of the IP header in multiples of 32 bits, without the data field. The minimum value for a correct header is 5 (i.e., 20 bytes), the maximum value is 15 (i.e., 60 bytes).
56 IP datagram Service Type The service type is an indication of the quality of service requested for this IP datagram. It contains the following information. Precedence specifies the nature/priority: 000: Routine 001: Priority 010: Immediate 011: Flash 100: Flash override 101: Critical 110: Internetwork control 111: Network control
57 IP datagram TOS specifies the type of service value: 1000: Minimize delay 0100: Maximize throughput 0010: Maximize reliability 0001: Minimize monetary cost 0000: Normal service The last bit is reserved for future use.
58 IP datagram Total Length specifies the total length of the datagram, header and data, in octets. Identification is a unique number assigned by the sender used with fragmentation. Flags contains control flags: the first bit is reserved and must be zero; the 2nd bit is DF (Do not Fragment), 0 means allow fragmentation; the third is MF (More Fragments), 0 means that this is the last fragment.
59 IP datagram Fragment Offset is used to reassemble the full datagram. The value in this field contains the number of 64-bit segments (header bytes are not counted) contained in earlier fragments. If this is the first (or only) fragment, this field contains a value of zero. TTL (Time to Live) specifies the time (in seconds) the datagram is allowed to travel. In practice, this is used as a hop counter to detect routing loops.
60 IP datagram Protocol Number indicates the higher level protocol to which IP should deliver the data in this datagram. E.g., ICMP = 1; TCP = 6; UDP = 17. Header Checksum is a checksum for the information contained in the header. If the header checksum does not match the contents, the datagram is discarded. Source/Destination IP Addresses are the 32-bit source/destination IP addresses.
61 IP datagram IP Options is a variable-length field (there may be zero or more options) used for control or debugging and measurement. For instance: the loose source routing option provides a means for the source of an IP datagram to supply explicit routing information; the timestamp option tells the routers along the route to put timestamps in the option data. Padding is used to ensure that the IP header ends on a 32 bit boundary. The padding is zero.
62 IP fragmentation IP provides fragmentation/reassembly of datagrams. The maximum length of an IP datagram is 65,535 octets. When an IP datagram travels from one host to another, it may pass through different physical networks. Each physical network has a maximum frame size, called maximum transmission unit (MTU), which limits the datagram length.
63 IP fragmentation A fragment is treated as a normal IP datagram while being transported to their destination. Thus, fragments of a datagram each have a header. If one of the fragments gets lost, the complete datagram is considered lost. It is possible that fragments of the same IP datagram reach the destination host via multiple routes. Finally, Since they may pass through networks with a smaller MTU than the sender s one, they are subject to further fragmentation.
64 Fragment #2 Fragment #1 H H H Fragment #1 Fragment #2 H H Fragment #1 H Fragment #2 H Fragment #1 Fragment #2 H H H IP fragmentation IP datagram Fragment #1 H Fragment #2 H IP datagram
65 IP fragmentation
66 IP fragmentation Fragmentation process: The DF flag bit is checked to see if fragmentation is allowed. If the bit is set, the datagram will be discarded and an ICMP error returned to the originator. Based on the MTU value, the data field is split into two or more parts. All newly created data portions must have a length that is a multiple of 8 octets, with the exception of the last data portion. Each data portion is placed in an IP datagram.
67 IP fragmentation LEN = 1500 OFFSET = 0 DF = 0, MF = 1 LEN = 3499 OFFSET = 0 DF = 0, MF = 0 DATA (3500 bytes) MTU = 1500 DATA (1500 bytes) LEN = 1500 OFFSET = 1500 DF = 0, MF = 1 DATA (1500 bytes) LEN = 499 OFFSET = 3000 DF = 0, MF = 0 DATA (499 bytes)
68 IP fragmentation Modification to the headers of fragments: the MF flag is set in all fragments except the last; the fragment offset field is updated; if options were included in the original datagram, they may be copied to all fragment datagrams or only the first datagram (depends on the option); the header length field is set; the total length field is set; the header checksum is re-calculated.
69 IP fragmentation At the destination host, data are reassembled into the original datagram. The identification field set by the sending host is used together with the source and destination IP addresses in the datagram. Fragmentation does not alter this field. In order to reassemble the fragments, the receiving host allocates a storage buffer when the first fragment arrives.
70 IP fragmentation The host also starts a timer. If the timer is exceeded and fragments remain outstanding, the datagram is discarded (in linux this value, in seconds, is stored into /proc/sys/net/ipv4/ipfrag_time). When subsequent fragments of the datagram arrive, data are copied into the buffer storage at the location indicated by the fragment offset field. When all fragments have arrived, the original unfragmented datagram is restored and passed to upper layers, if needed.