IP Addresses

87
IP Addresses NETE0510 Presented by Dr.Apichan Kanjanavapastit

description

IP Addresses. NETE0510 Presented by Dr.Apichan Kanjanavapastit. Introduction. The identifier used in the IP layer of the TCP/IP protocol suite to identify each device connected to the Internet is called the Internet address or IP address - PowerPoint PPT Presentation

Transcript of IP Addresses

Page 1: IP Addresses

IP Addresses

NETE0510

Presented by

Dr.Apichan Kanjanavapastit

Page 2: IP Addresses

Introduction

• The identifier used in the IP layer of the TCP/IP The identifier used in the IP layer of the TCP/IP protocol suite to identify each device connected protocol suite to identify each device connected to the Internet is called the Internet address or IP to the Internet is called the Internet address or IP addressaddress

• An IP address is a An IP address is a 32-bit address32-bit address that uniquely that uniquely and universally defines the connection of a host and universally defines the connection of a host or a router to the Internetor a router to the Internet

• IP addresses are unique. They are unique in the IP addresses are unique. They are unique in the sense that each address defines one, and only sense that each address defines one, and only one, connection to the Internetone, connection to the Internet

• Two devices on the Internet can never have the Two devices on the Internet can never have the same address. same address.

Page 3: IP Addresses

Notation

• There are 3 common notations to show an IP address: binary notation, dotted decimal notation, and hexadecimal notation

• Binary notation. The IP address is displayed as 32 bits. To make the address more readable, one or more spaces is usually inserted between each octet (8 bits)

Page 4: IP Addresses

Notation (cont.)

• Dotted-Decimal Notation. To make the IP address more compact and easier to read, Internet addresses are usually written in decimal form with a decimal point (dot) separating the bytes

Page 5: IP Addresses

Find the error, if any, in the following IPv4 addresses:a. 111.56.045.78b. 221.34.7.8.20c. 75.45.301.14d. 11100010.23.14.67

Solutiona. There should be no leading zeroes (045).b. We may not have more than 4 bytes in an IPv4 address.c. Each byte should be less than or equal to 255.d.A mixture of binary notation and dotted-decimal notation.

ExampleExample 5.3

Page 6: IP Addresses

Notation (cont.)

• Hexadecimal Notation. Sometimes an IP address is displayed in the format of hexadecimal. Each hexadecimal digit is equivalent to 4 bits. This means that a 32-bit address has 8 hexadecimal digits. This notation is often used in network programming

10000001 00001011 00001011 11101111

0x810B0BEF or 810B0BEF16

Page 7: IP Addresses

Classful Addressing

• IP addresses, when started a few decades ago, IP addresses, when started a few decades ago, used the concept of classesused the concept of classes

• This architecture is called This architecture is called classful addressingclassful addressing• In the mid-1990s, a new architecture, called In the mid-1990s, a new architecture, called

classless addressing, was introduced and will classless addressing, was introduced and will eventually supersede the original architectureeventually supersede the original architecture

• However, part of the Internet is still using However, part of the Internet is still using classful addressing, but the migration is very fastclassful addressing, but the migration is very fast

Page 8: IP Addresses

Classful Addressing (cont.)

• In classful addressing, the IP address space is divided into 5 classes: A, B, C, D and E

• Each class occupies some part of the whole address space

Page 9: IP Addresses

Recognizing Class

• One can find the class of an address when the address is given in binary notation or dotted-decimal notation

• If the address is given in binary notation, the first few bits can immediately tell us the class of the address

Page 10: IP Addresses

Recognizing Class (cont.)

• One can follow the procedure to systematically check the bits and find the class

• The procedure can be easily programmed in any language

Page 11: IP Addresses

Recognizing Class (cont.)

• When the address is given in dotted-decimal notation, we need to look at the first byte to determine the class of the address

• Each class has a specific range of numbers

Page 12: IP Addresses

Netid and Hostid

• In classful addressing, an IP address in classes A, B, and C is divided into netid and hostid

• These parts are of varying lengths, depending on the class of the address

Page 13: IP Addresses

Classes and Blocks

• One problem with classful addressing is that each class is divided into a fexed number of blocks with each block having a fixed size

• Class A. Class A is divided into 128 blocks with each block having a different netid

• Class A addresses were designed for large organization with a large number of hosts or routers attached to their network

• However, the number of addresses in each block, 16,777,216, is probably larger than the needs of amost all organizations

Page 14: IP Addresses

Classes and Blocks (cont.)

Page 15: IP Addresses

Classes and Blocks (cont.)

• Class B. Class B is divided into 16,384 blocks with each block having a different netid

• Since each block in this class contains 65,536 addresses, the organization should be large enough to use all of these addresses

• Class B addresses were designed for mid-size organizations that may have only tens of thousands of hosts or routers attached to their networks

Page 16: IP Addresses
Page 17: IP Addresses

Classes and Blocks (cont.)

• Class C. Class C is divided into 2,097,152 blocks. However, each block in this class contains only 256 addresses, which means the organization should be small enough to need less than 256 address

• The number of addresses in each block is so limited most organizations do not want a block in this class

Page 18: IP Addresses
Page 19: IP Addresses

Classes and Blocks (cont.)

• Class D. There is just one block of class D addresses. It is designed for multicasting

• Class E. There is just one block of class E addresses. It was designed for use as reserved addresses

Page 20: IP Addresses

Network Addresses

• Network addresses play a very important role in classful addressing

• A network address has several properties:– The network address is the first address in the

block– The network address defines the network to

the rest of the Inter– Given the network address, we can find the

class of the address, the block, and the range of the addresses in the block

Page 21: IP Addresses

Mask

• One way we can find the network address is to first find the class of the address and the netid

• We then set the hostid to zero to find the network address

• The above method is feasible if we have not subnetted the network; that is, if we have not divided the network into subnetworks

• A general procedure that can be used involves a mask to find the network address from a given address

• A mask is a 32-bit number that gives the first address in the block (the network address) when bitwise

Page 22: IP Addresses

Masking Concept

Page 23: IP Addresses

Default Masks

• In the AND operation for classful addressing, there are 3 masks, one for each class

Page 24: IP Addresses

CIDR Notation

• Although in classful addressing each address has a default mask, it is sometimes convenient to explicitely indicate the default mask

• The CIDR (pronounced cider), or classless interdomain routing, notation is used for this purpose

• In this notation, the number of 1s in the mask is added after a slash at the end of the address

• For example, the address 18.46.74.10, which is a class A address with the mask 255.0.0.0, is written as 18.46.74.10/8

Page 25: IP Addresses

Multihomed Devices

• A computer that is connected to different networks is called a multihomed computer and will have more than one address, each possibly belonging to a different class

• A router must be connected to more than one network, otherwise it cannot route

Page 26: IP Addresses

Special Addresses

• Some parts of the address space are used for special addresses

Page 27: IP Addresses

Network Address

Page 28: IP Addresses

Direct Broadcast Address

Page 29: IP Addresses

Limited Broadcast Address

• In classes A, B, and C, an address with all 1s for the netid and hostid defines a broadcast address in the current network

• However, a route will block a packet having this type of address to confine the broadcasting to the local network

Page 30: IP Addresses

This Host on This Network

• If an IP address is composed of all zeros, it means this host on this network

• This is used by a host at bootstrap time when it does not know its IP address

Page 31: IP Addresses

Specific Host on This Network

• An IP address with a netid of all zeros means a specific host on this network

• It is used by a host to send a message to another host on the same network

Page 32: IP Addresses

Loopback Address• The IP address with the first byte equal to 127 is used for the

loopback address, which is an address used to test the software on a machine

• When this address is used, a packet never leaves the machine; it simply returns to the protocol software

Page 33: IP Addresses

Private Address

• A number of blocks in each class are assigned for private use. They are not recognized globally

• These address are used either in isolation or in connection with network address translation techniques

Page 34: IP Addresses

Unicast, Multicast, and Broadcast Addrsses

• Unicast addresses. Unicast communication is one-to-one. When a packet is sent from an individual source to an individual destination, a unicast communication takes place

• Multicast addresses. Multicast communication is one-to-many. When a packet is sent from an individual source to a group of destination, a multicast communication takes place

• Broadcast Addresses. Broadcast communication is one-to-all. The Internet allows broadcasting only at the local level

Page 35: IP Addresses

Sample internet

Page 36: IP Addresses

Subnetting

• In subnetting, a network is divided into several smaller subnetworks with each subnetwork having its own subnetwork address

• IP addresses are designed with 2 levels of hierarchy. However, in many cases, these 2 levels of hierarchy are not enough since the hosts cannot be organized into groups

• One solution is subnetting, the further division of a network into smaller networks called subnetworks (or subnets)

Page 37: IP Addresses
Page 38: IP Addresses

Subnetting (cont.)• Adding subnetworks creates an intermediate level of hierarchy in

the IP addressing system• Now we have 3 levels: site, subnet, and host. The site is the first

level. The 2nd level is the subnet. This host is the 3rd level• The routing of an IP datagram now involves 3 steps: delivery to

the site, delivery to the subnetwork, and delivery to the host

Page 39: IP Addresses

Subnet Mask

• When a network is subnetted, we must have a subnet mask

• The default mask creates the network address; the subnet mask creates the subnetwork address

Page 40: IP Addresses

Number of Subnetworks/Number of Addresses per Subnet

• The number of subnetworks can be found by counting the extra 1s that are added to the default mask to make the subnetmask

• The number of addresses per subnetwork can be found by counting the number of 0s in the subnet mask

Page 41: IP Addresses

Supernetting

• In supernetting, an organization can combine several class C blocks to create a larger range of addresses

Page 42: IP Addresses

Supernet Mask

• A supernet mask is the reverse of a subnet mask

• A supernet mask for class C has less 1s than the default mask for this class

Page 43: IP Addresses

Obsolescence

The idea of subnetting and supernetting of classful addresses is almost obsolete.

Page 44: IP Addresses

Classless IP Addressing

• During the 1990s, Internet service providers (ISPs) came into prominece

• An ISP is granted a large range of addresses and then subdivides the addresses, giving a range to household or a small business

• To facilitate this evolution the problems of classful addressing, in 1996, the Internet authorities announced a new architecture called classless addressing

Page 45: IP Addresses

Variable-Length Blocks

• In classless addressing, variable-length blocks are assigned that belong to no class

• We can have a block of 2 addresses, 4 addresses, 128 addresses, and so on

• In this architecture, the entire address space (232 addresses) is divided into blocks of different sizes

Page 46: IP Addresses

Restrictions

• Number of addresses in a block. There is only one restriction on the number of addresses in a block; it must be a power of 2 (2, 4, 8, …)

• First address. The 1st address must be evenly divisible by the number of addresses. For example, if a block contains 4 addresses, the 1st address must be divisible by 4

Page 47: IP Addresses

Which of the following can be the beginning address of a block that contains 16 addresses?

a. 205.16.37.32 b.190.16.42.44c. 17.17.33.80 d.123.45.24.52

Example 1

SolutionOnly two are eligible (a and c). The address 205.16.37.32 is eligible because 32 is divisible by 16. The address 17.17.33.80 is eligible because 80 is divisible by 16.

Page 48: IP Addresses

Restrictions (cont.)

• Mask. In classless addressing, the address must be accompanied by the mask. The mask is given in CIDR notation with the number of 1s in the mask

The n after the slash defines the number of bits that are the same in every address in the block. If n is 20, it means the 20 leftmost bits are identical in each address with 12 bits not the same

Page 49: IP Addresses

Restrictions (cont.)

• Prefix and Prefix length. Prefix is similar to netid and the prefix length is the length of the prefix (n in the CIDR notation). There is a one-to-one relationship between a mask and a prefix length

Page 50: IP Addresses

Restrictions (cont.)

• Suffix and suffix length. The suffix is the varying part (similar to the hostid). The suffix length is the length of the suffix (32-n) in CIDR notation

Page 51: IP Addresses

Finding the Block

• In classless addressing, an organization is assigned a block of address

• The size of the block is not fixed; it varies according to the needs of the organization

• However, when a classless address is given, we can find the block

• We can find the 1st address, the number of addresses, and the last address

Page 52: IP Addresses

Finding the First Address

• In classless addressing, the prefix length is the mask

• We can AND the mask and the address to find the first address

• Just keep the first n bits and change the rest of the bits to 0s

Page 53: IP Addresses

What is the first address in the block if one of the addresses is 167.199.170.82/27?

Example 2

Address in binary: 10100111 11000111 10101010 01010010

Keep the left 27 bits: 10100111 11000111 10101010 01000000

Result in CIDR notation: 167.199.170.64/27

SolutionThe prefix length is 27, which means that we must keep the first 27 bits as is and change the remaining bits (5) to 0s. The following shows the process:

Page 54: IP Addresses

Finding the Number of Addresses in the Block

• The total number of addresses in the block is 232-n

Find the number of addresses in the block if one of the addresses is 140.120.84.24/20.

Example 3

SolutionThe prefix length is 20. The number of addresses in the block is 232−20 or 212 or 4096. Note thatthis is a large block with 4096 addresses.

Page 55: IP Addresses

Finding the Last Address in the Block

• We give 2 methods that find the last address in the block

• In the 1st method, we add the number of addresses in the block minus 1 to the first address to find the last address

• In the 2nd method, we add the first address to the complement of the mask

• The complement of the mask is found by changing all 0s to 1s and vice versa

Page 56: IP Addresses

Using the first method, find the last address in the block if one of the addresses is 140.120.84.24/20.

Example 4

SolutionWe found in the previous examples that the first address is 140.120.80.0/20 and the number of addresses is 4096. To find the last address, we need to add 4095 (4096 − 1) to the first address.

Page 57: IP Addresses

To keep the format in dotted-decimal notation, we need to represent 4095 in base 256 (see Appendix B) and do the calculation in base 256. We write 4095 as 15.255. We then add the first address to this number (in base 255) to obtain the last address as shown below:

Example 4 (Continued)

140 . 120 . 80 . 0 15 . 255

-------------------------140 . 120 . 95 . 255

The last address is 140.120.95.255/20.

Page 58: IP Addresses

Using the second method, find the last address in the block if one of the addresses is 140.120.84.24/20.

Example 5

SolutionThe mask has twenty 1s and twelve 0s. The complement of the mask has twenty 0s and twelve 1s. In other words, the mask complement is

00000000 00000000 00001111 11111111

or 0.0.15.255. We add the mask complement to the beginning address to find the last address.

Page 59: IP Addresses

140 . 120 . 80 . 0 0 . 0 . 15 . 255----------------------------140 . 120 . 95 . 255

Example 5 (Continued)

We add the mask complement to the beginning address to find the last address.

The last address is 140.120.95.255/20.

Page 60: IP Addresses

Finding the Block

• To find the block, find the first address, the number of addresses, and the last address

Page 61: IP Addresses

Find the block if one of the addresses is 190.87.140.202/29.

Example 6

SolutionWe follow the procedure in the previous examples to find the first address, the number of addresses, and the last address. To find the first address, we notice that the mask (/29) has five 1s in the last byte. So we write the last byte as powers of 2 and retain only the leftmost five as shown below:

Page 62: IP Addresses

202 ➡ 128 + 64 + 0 + 0 + 8 + 0 + 2 + 0

The leftmost 5 numbers are ➡ 128 + 64 + 0 + 0 + 8

The first address is 190.87.140.200/29

Example 7 (Continued)

The number of addresses is 232−29 or 8. To find the last address, we use the complement of the mask. The mask has twenty-nine 1s; the complement has three 1s. The complement is 0.0.0.7. If we add this to the first address, we get 190.87.140.207/29. In other words, the first address is 190.87.140.200/29, the last address is 190.87.140.207/20. There are only 8 addresses in this block.

Page 63: IP Addresses

Show a network configuration for the block in the previous example.

Example 8

SolutionThe organization that is granted the block in the previous example can assign the addresses in the block to the hosts in its network. However, the first address needs to be used as the network address and the last address is kept as a special address (limited broadcast address). Figure 5.5 shows how the block can be used by an organization. Note that the last address ends with 207, which is different from the 255 seen in classful addressing.

Page 64: IP Addresses
Page 65: IP Addresses

Granted Block

• The block of addresses is granted by an ISP

• The granted block is defined by the first address and the prefix length

• For instance, in the previous example, the block is defined as 190.87.140.200/29

Page 66: IP Addresses

Subnetting

• When an organization is granted a block of addresses, it can create subnets to meet its needs

• The network administrator can design a subnet mask for each subnet

• The prefix length (n) increases to define the subnet prefix length

Page 67: IP Addresses

Finding the Subnet Mask

• The number of desired subnets defines the subnet prefix

• If the number of subnets is s, the number of extra 1s in the prefix length is log2s, where s = 2number of extra 1s

• If we want fixed-length subnets (each subnet has the same number of addresses), the number of subnets needs to be a power of 2

Page 68: IP Addresses

An organization is granted the block 130.34.12.64/26. The organization needs 4 subnets. What is the subnet prefix length?

Example 9

SolutionWe need 4 subnets, which means we need to add two more 1s (log2 4 = 2) to the site prefix. The subnet prefix is then /28.

Page 69: IP Addresses

Finding the Subnet Addresses

• After finding the subnet mask, it is easy to find the range of addresses in each subnet

Page 70: IP Addresses

What are the subnet addresses and the range of addresses for each subnet in the previous example?

Example 10

1. The first address in the first subnet is 130.34.12.64/28, using the procedure we showed in the previous examples. Note that the first address of the first subnet is the first address of the block. The last address of the subnet can be found by adding 15 (16 −1) to the first address. The last address is 130.34.12.79/28.

Page 71: IP Addresses

Example 10 (Continued)

2.The first address in the second subnet is 130.34.12.80/28; it is found by adding 1 to the last address of the previous subnet. Again adding 15 to the first address, we obtain the last address, 130.34.12.95/28.

3. Similarly, we find the first address of the third subnet to be 130.34.12.96/28 and the last to be 130.34.12.111/28.

4. Similarly, we find the first address of the fourth subnet to be 130.34.12.112/28 and the last to be 130.34.12.127/28.

Page 72: IP Addresses
Page 73: IP Addresses

Variable-Length Subnets

• We can also design subnets having variable-length masks

• This allows an organization to assign addresses based on the needs of the subnet

Page 74: IP Addresses

An organization is granted a block of addresses with the beginning address 14.24.74.0/24. There are 232−24= 256 addresses in this block. The organization needs to have 11 subnets as shown below:

a. two subnets, each with 64 addresses.

b. two subnets, each with 32 addresses.

c. three subnets, each with 16 addresses.

d. four subnets, each with 4 addresses.

Design the subnets.

Example 11

Page 75: IP Addresses

1. We use the first 128 addresses for the first two subnets, each with 64 addresses. Note that the mask for each network is /26.

2. We use the next 64 addresses for the next two subnets, each with 32 addresses. Note that the mask for each network is /27.

Example 11 (Continuted)

3. We use the next 48 addresses for the next three subnets, each with 16 addresses. Note that the mask for each network is /28.

4. We use the last 16 addresses for the last four subnets, each with 4 addresses. Note that the mask for each network is /30.

Page 76: IP Addresses
Page 77: IP Addresses

Address Allocation

• Address allocation is the responsibility of a Address allocation is the responsibility of a global authority called the Internet Corporation global authority called the Internet Corporation for Assigned Names and Addresses (ICANN)for Assigned Names and Addresses (ICANN)

• It usually assigns a large block of addresses to It usually assigns a large block of addresses to an ISP to be distributed to its Internet usersan ISP to be distributed to its Internet users

• Each ISP, in turn, divides its assigned block into Each ISP, in turn, divides its assigned block into smaller subblocks and grants the subblocks to smaller subblocks and grants the subblocks to its customersits customers

Page 78: IP Addresses

An ISP is granted a block of addresses starting with 190.100.0.0/16 (65,536 addresses). The ISP needs to distribute these addresses to three groups of customers as follows:

Example 12

a. The first group has 64 customers; each needs 256 addresses.b. The second group has 128 customers; each needs 128 addressesc. The third group has 128 customers; each needs 64 addresses.

Design the subblocks and find out how many addresses are still available after these allocations.

Page 79: IP Addresses

Group 1For this group, each customer needs 256 addresses. This means the suffix length is 8 (28 =256). The prefix length is then 32 − 8 = 24. The addresses are:

Example 12 (Continued)

1st Customer 190.100.0.0/24 190.100.0.255/242nd Customer 190.100.1.0/24 190.100.1.255/24. . .64th Customer 190.100.63.0/24 190.100.63.255/24Total = 64 × 256 = 16,384

Page 80: IP Addresses

Group 2For this group, each customer needs 128 addresses. This means the suffix length is 7 (27 =128). The prefix length is then 32 − 7 = 25. The addresses are:

Example 12 (Continued)

1st Customer 190.100.64.0/25 190.100.64.127/252nd Customer 190.100.64.128/25 190.100.64.255/25· · ·128th Customer 190.100.127.128/25 190.100.127.255/25

Total = 128 × 128 = 16,384

Page 81: IP Addresses

Group 3 For this group, each customer needs 64 addresses. This means the suffix length is 6 (26 = 64). The prefix length is then 32 − 6 = 26. The addresses are:

Example 12 (continued)

1st Customer 190.100.128.0/26 190.100.128.63/26

2nd Customer 190.100.128.64/26 190.100.128.127/26· · ·128th Customer 190.100.159.192/26 190.100.159.255/26

Total = 128 × 64 = 8,192

Page 82: IP Addresses

Number of granted addresses to the ISP: 65,536

Number of allocated addresses by the ISP: 40,960

Number of available addresses: 24,576

Example 12 (continued)

Page 83: IP Addresses

5-5 NAT

The distribution of addresses through ISPs has created a new problem. If the business grows or the household needs a larger range, the ISP may not be able to grant the demand because the addresses before and after the range may have already been allocated to other networks. In most situations, however, only a portion of computers in a small network need access to the Internet simultaneously. A technology that can help in this cases is network address translation (NAT).

Page 84: IP Addresses

Figure 5.39 NAT

Page 85: IP Addresses

Figure 5.40 Address resolution

Internet

Site using private addresses

172.18.3.1

172.18.3.2

172.18.3.20

Source: 172.18.3.1 Source: 200.24.5.8

Destination: 200.24.5.8Destination: 172.18.3.1

Page 86: IP Addresses

Figure 5.41 Translation

Page 87: IP Addresses