Vous êtes sur la page 1sur 101

CHAPTER 3

IP ADDRESSING
Izaz A Khan

McGraw-Hill

The McGraw-Hill Companies, Inc., 2000

IP Address
Was invented by Robert E. Kahn (an American Engineer) in 1974. The IP Address is a unique number assigned to your computer connection by your home or office or employer's Internet Service Provider (ISP).

This unique number serves as the ID of your connection when it's accessing the Internet.
It functions like your street addressif someone wants to send you mail or you order a pizza, your address is needed for the postman or delivery person to find your home. The same process applies to your computer, your IP address is used to route information from the Internet to your computer.

Standards OF IP Addresses
Two Standards
1. IPv4: Each address is 32 bits. (Mostly used) 2. IPv6: Each address is 128 bits.

Dynamic vs static IP
Dynamic IP addresses can change each time you connect to the Internet, while static IP addresses are reserved for you statically and don't change over time. Residential Internet connections, whether broadband or dialup usually use dynamic IP addresses, while commercial leased lines and servers have static IPs, so they can always be reached at the same address.

Private vs Public IP
Public IP Address
A public (or external) IP address is the one that your ISP (Internet Service Provider) provides to identify your home network to the outside world. It is an IP address that is unique throughout the entire Internet.

Private IP Address
Just as your network's public IP address is issued by your ISP, your router issues private (or internal) IP addresses to each network device inside your network. This provides unique identification for devices that are within your home network, such as your computer, your mobile, and so on.

IPv4 ADDRESSES
An IPv4 address is a 32-bit address that uniquely and universally defines the connection of a device (for example, a computer or a router) to the Internet.

Note

The IPv4 addresses are unique and universal.

IP addresses are unique in the sense that each address defines one, and only one, connection to the Internet. IP addresses are universal in the sense that the addressing system must be accepted by any host that wants to be connected to the Internet.

Address Space
A protocol such as IPv4 that define addresses has an address space. An address space is the total number of addresses used by the protocol.

RULE:
If a protocol uses N bits to define an address, N the address space is 2 because each bit can have two different values (0 and N1) and N bits can have 2 values.

Note

The address space of IPv4 is 232 or 4,294,967,296.

NOTATIONS
There are two notations to show an IPv4 address.
1. Binary Notation. 2. Dotted-Decimal Notation. (Mostly used)

1-Binary Notation
In binary notation, the IPv4 address is displayed as 32 bits.
The 32 bits are divided into 4 octets (means 8 bits each). Each octet is often referred to as a byte. So, it is common to hear an IPv4 address referred to as a 32-bit address or a 4-byte address.

Binary Notation

01110101 10010101 00011101 11101010

2- dotted-decimal notation
To make the IPv4 address more compact and easier to read, IP addresses are usually written in decimal form with a decimal point (dot) separating the bytes.
For each octet, the decimal equivalent of the 8 bits binary number is written and the decimal numbers are separated by dots.

Dotted-decimal notation

Example 1

Change the following IP address from binary notation to dotted-decimal notation.

10000001 00001011 00001011 11101111

Solution

129.11.11.239

Example 2

Change the following IP address from dotted-decimal notation to binary notation.

111.56.45.78

Solution

01101111 00111000 00101101 01001110

Example 3

Find the error, if any, in the following IP address: 111.56.045.78

Solution

There are no leading zeroes in dotted-decimal notation (045).

Example 4

Find the error, if any, in the following IP address: 75.45.301.14

Solution
In dotted-decimal notation, each number is less than or equal to 255; 301 is outside this range. (As we know, there are 8 bits in each octet. Even if all the bits are 1 that is 11111111 still its decimal equivalent will be 255 that is why we say that In dotted-decimal notation, each number is less than or equal to 255).

Types of Addressing
Two types of addressing.
1. Classful Addressing 2. Classless Addressing

1- Classful Addressing

In classful addressing, the address space is divided into five classes: A, B, C, D, and E.

Finding the class in binary notation

Finding the address class

Example 6

Find the class of the address: 00000001 00001011 00001011 11101111

Solution

The first bit is 0. This is a class A address.

Example 7

Find the class of the address: 11000001 10000011 00011011 11111111

Solution

The first 2 bits are 1; the third bit is 0. This is a class C address.

Finding the class in decimal notation

See the verification of the above ranges in the next slide.

Verification of ranges
We know that for class A in binary, the first bit from left of the address will always be 0, so 0 will stay 0 and the remaining 7 bits can change. Means the range will be from 00000000 (minimum) to 01111111 (maximum) which is from 0 to 127 in decimal. Similarly for class B, In binary the first 2 bits from the left will be 1 0 always, so these two bits will not change and remaining 6 bits can change. Means the range will be from 10000000 (minimum) to 10111111 (maximum) which is from 128 to 191 in decimal.
By similar approach we can verify the ranges for the remaining 3 classes.

Note
We see that the range of Class A is 0 to 127, but the available range is 1 to 126 (0 to 127 is the total range).
It means we cannot assign an ip address starting from 0 i.e (0.87.5.6) and starting from 127 i.e (127.1.5.60). This is because 0 is reserved for Default Route and 127 is reserved for Loopback. Explanation in the next slides.

Default route
A default route allows traffic to be forwarded, even without a specific route to a destination.
This route generally points to another router, which treats the packet the same way. If a route matches the packet is forwarded accordingly otherwise the packet is forwarded to the default route of the router. The process continues until packet is delivered.

The default route in IPv4 is designated as the zero address 0.0.0.0.

LOoPbACK
Loopback is used to check whether TCP/IP protocol is installed or not.
The loopback address is 127.0.0.0. The command ping 127.0.0.0 is useful in situations when there is no LAN card in the computer. Means we cannot check from the properties of LAN card whether TCP/IP is installed or not. By typing the above command if we get a reply (means if the ping works) then it will be understood that TCP/IP protocol is installed.

Example 8

Find the class of the address: 227.12.14.87

Solution

The first byte is 227 (between 224 and 239); the class is D.

Example 9

Find the class of the address: 193.14.56.22

Solution

The first byte is 193 (between 192 and 223); the class is C.

CLASS D and E
The range of Class D is 224 239. It is used for multicasting and it is not for our use.
The range of Class E is 240 - 255. It is used for future experiment and it is not for our use.

Netid and Hostid


Netid = network id, Hostid = host id.

Netid identifies the network and Hostid identifies the host.


In classful addressing, an ip address in class A,B or C is divided into netid and hostid. These parts are of various lengths depending on the class of the address. The figure in the next slide shows some netid and hostid bytes. The netid is in color, the hostid is in white. Note that the concept does not apply to class D and E. In class A: 1 byte = netid, 3 bytes = hostid. In class B: 2 bytes = netid, 2 bytes = hostid. In class C: 3 bytes = netid, 1 byte = hostid.

Finding the classes in binary and dotted-decimal notation

Classes and Blocks


Class A B Number of Blocks 128 16,384 Block Size 16,777,216 65,536

2,097,152

256

Classes and Blocks


Number of Blocks = number of networks.
Block Size = Number of hosts / Addresses per network.

Classes and Blocks


Clas s Leading Size of Size of bits network. rest bit Network bit field field 0 10 110 8 16 24 24 16 8 Number of network s 128 (27) 16384 (214) 2097152 (221) Addresse Start End s per addres address network s 16777216 (224) 65536 (216) 256 (28) 0.0.0.0 127.255.2 55.255

A B C

128.0.0 191.255.2 .0 55.255 192.0.0 223.255.2 .0 55.255

How? See proofs in the next slides.

FOR Class A
In class A, the number of networks are 128=27. This is because we know that in class A only the first byte represent the network (netid). And we also know that the first bit in class A address is 0 (see slide 21). The formula to find the number of networks for a class is given by
= 2number of bits in the netid after the first zero from left

In this case the first bit is zero from the left which means the number of networks will be = 27 , as we are left with 7 bits in the netid.

Note
In the previous slide we see that the number of networks in Class A are 128. And the range will be from 0 to 127.
But if we take out the Default route(0) and Loopback(127) then we are left with 128-2= 126. So the total number of networks in Class A are 128 but the available number of networks are 126. In Class B and C the total number of networks are available, means no reservations.

FOR class B
Similarly in class B, for netid we have 2 bytes and the address starts from 1 0 so the number of bits remaining in the netid after the first 0 from the left is 14 that is why the number of networks in class B is = 214 = 16384

FOR class C
For class C, for netid we have 3 bytes and the address starts from 1 1 0 so the number of bits remaining in the netid after the first 0 from the left is 21 that is why the number of networks in class B is = 221 = 2097152

Addresses per network


For class A:
We have 3 bytes for hostid so, 224 = 16777218 For class B:

We have 2 bytes for hostid so, 216 = 65536


For class C: We have 1 byte for hostid so, 28 = 256

mask
Although the length of the netid and hostid is predetermined in classful addressing, we can also use a mask (also called default mask), a 32-bit number made of 1s followed by 0s. The mask can help us to find the netid and the hostid. For example, the mask for a class A address has eight 1s, which means the first 8 bits of any address in class A define the netid; the next 24 bits define the hostid.
See the table in the next slide.

Default masks for classful addressing

CIDR = ? Next slide

CIDR
The last column of the table in the last slide shows the mask in the form /n where n can be 8,16 or 24 in classful addressing.
This notation is also called slash notation or Classless Interdomain Routing (CIDR) notation. It is used mostly in classless addressing which will be discussed later. However it can also be used in classful addressing. For example, /8 means we have 8 bits for netid so the address is class A and /16 means we have 16 bits for netid so the address is class B.

Note

Classful addressing, which is almost obsolete (not generally in use), is replaced with classless addressing.

2- Classless Addressing
To overcome address depletion (the act of decreasing something) classless addressing was designed and implemented.
In this scheme, there are no classes, but the addresses are still granted in blocks.

Address blocks
In classless addressing, when an entity, small or large, needs to be connected to the Internet, it is granted a block (range) of addresses. The size of the block (the number of addresses) varies based on the nature and size of the entity.
For example, a household may be given only two addresses; a large organization may be given thousands of addresses.

Restrictions
To simplify the handling of addresses, the internet authorities impose three restrictions on classless address blocks.
1. The addresses in a block must be contiguous, one after another. 2. The number of addresses in a block must be a power of 2 (1,2,4,8,16,32,64,128,).

3. The first address must be evenly divisible by the number of addresses.

Example 10
The figure in the next slide shows a block of addresses, in both binary and dotted-decimal notation, granted to a small business that needs 16 addresses. We can see that the restrictions are applied to this block. The addresses are contiguous. The number of addresses is a power of 2 (16 = 24), and the first address is divisible by 16. The first address, when converted to a decimal number, is 3,440,387,360, which when divided by 16 results in 215,024,210.

A block of 16 addresses granted to a small organization

How to convert an IPv4 address to decimal?


In Example 10 we say, The first address, when converted to a decimal number, is 3,440,387,360.How?
The first address is 205.16.37.32 and it can be converted into decimal number by the following method = 205*2563 + 16*2562 + 37*2561 + 32*2560

= 3,440,387,360.

Mask
A better way to define a block of addresses is to select any address in the block and the mask.
As we discussed before, a mask is a 32-bit number in which the n left most bits are 1s and the 32 n rightmost bits are 0s. However, in classless addressing the mask for a block can take any value from 0 to 32.

It is very convenient to give just the value of n preceded by a slash (CIDR notation).

Note

In IPv4 addressing, a block of addresses can be defined as x.y.z.t /n in which x.y.z.t defines one of the addresses and the /n defines the mask.

Note

The first address in the block can be found by setting the rightmost 32 n bits to 0s.

Example 11
A block of addresses is granted to a small organization. We know that one of the addresses is 205.16.37.39/28. What is the first address in the block? Solution The binary representation of the given address is 11001101 00010000 00100101 00100111 If we set 3228 rightmost bits to 0, we get 11001101 00010000 00100101 00100000 or 205.16.37.32. This is actually the block shown in Example 10.

Note

The last address in the block can be found by setting the rightmost 32 n bits to 1s.

Example 12
Find the last address for the block in Example 11.
Solution The binary representation of the given address is 11001101 00010000 00100101 00100111 If we set 32 28 rightmost bits to 1, we get 11001101 00010000 00100101 00101111 or 205.16.37.47 This is actually the block shown in Example 10.

Note

The number of addresses in the block can be found by using the formula 232n.

Example 13
Find the number of addresses in Example 11, where one of the address was given as 205.16.37.39/28 Solution The value of n is 28, which means that number of addresses is 2 3228 or 16.

Example 14
Another way to find the first address, the last address, and the number of addresses is to represent the mask as a 32bit binary number.. In Example 13 the /28 can be represented as 11111111 11111111 11111111 11110000 (twenty-eight 1s and four 0s). Find a. The first address b. The last address c. The number of addresses.

Example 14 (continued)
Solution The first address can be found by ANDing the given addresses (205.16.37.39) with the mask. ANDing here is done bit by bit. The result of ANDing 2 bits is 1 if both bits are 1s; the result is 0 otherwise.

Example 14 (continued)
The last address can be found by ORing the given addresses (205.16.37.39 with the complement of the mask. Oring here is done bit by bit. The result of ORing 2 bits is 0 if both bits are 0s; the result is 1 otherwise. The complement of a number is found by changing each 1 to 0 and each 0 to 1.

Example 14 (continued)
The number of addresses can be found by complementing the mask, converting it as a decimal number, and adding 1 to it.

A network configuration for the block 205.16.37.32/28

Network and Broadcast Addresses

When an organization is given a block of addresses, the organization is free to allocate the addresses to the devices that need to be connected to the Internet. The first and last address of the block however is treated specially.
The first address is called the Network address and the last address is called Broadcast address.

Note

The first address in a block is normally not assigned to any device; it is used as the network address that represents the organization to the rest of the world.

Network Addresses


The network address is the first address.
The network address defines the network to the rest of the Internet. Given the network address, we can find the class of the address, the block, and the range of the addresses in the block

Broadcast Addresses
A special type of networking address that is reserved for sending messages to all machines on a given network segment.
For example, if a server wants to send a message to all clients it will broadcast the message. The last address in a block will be always reserved for broadcasting, means through that address a message can be broadcasted to all the devices in the network.

Hierarchy
Hierarchy means any system of persons or things ranked one above another.
IP addresses have levels of hierarchy. For example, a telephone network in North America has three levels of hierarchy. The leftmost three digits define the are code, the next three digits define the exchange, the last four digits define the connection of the local loop to the central office.

The local loop (also referred to as a subscriber line) is the physical link or circuit that connects the customer premises to the Telecommunications service provider's network.

Hierarchy in a Telephone Network in North America

Tw0 levels hierarchy: NO SUBNETTING

An IP address can define only two levels of hierarchy when not subnetted.
The n left most bits of the address x.y.z.t/n define the network (organization network). The 32-n right most bits define the particular host (computer or router) to the network. The part of the address that defines the network is called the prefix and the part of the address that defines the host is called the suffix.

Note

Each address in the block can be considered as a two-level hierarchical structure: the leftmost n bits (prefix) define the network; the rightmost 32 n bits define the host (suffix).

Three levels of hierarchy: SUBNETTING

Due to Subnetting a large network is divided into smaller networks (subnets).


Subnets are created to serve as a physical separations say between floors, buildings, cities, and even departments. An organization that is granted a large block of addresses may want to create subnets and divide the addresses between the different subnets.

The rest of the world still sees the organization as one entity; however, internally there are several subnets.

SUBNetting
All messages are sent to the router address that connects the organization to the rest of the Internet; the router routes the message to the appropriate subnets. The organization, however, needs to create small sub blocks of addresses, each assigned to specific subnets.
The organization has its own mask; each subnet must also have its own.

SUBNetting
As an example, suppose an organization is given the block 17.12.40.0/26, which contain 64 addresses (232-n). The organization has three offices and needs to divide the addresses into three sub blocks of 32,16 and 16 addresses. We can find the new masks by using the following arguments.
1. Suppose the mask for the first subnet is n1, then 232-n1 must be 32 (because we need 32 addresses in the first sub block), which means that n1=27.

SUBNetting
2. Suppose the mask for the second subnet is n2, then
232-n2 must be 16, which means that n2=28.

3. Suppose the mask for the third subnet is n3, then 232-n3 must be 16, which means that n3=28. This means that we have the masks 27,28,28 for subnets and 26 for the organization. The figure in the next slide shows the whole

Configuration and addresses in a subnetted network

NOTE
The diagram in the last page is taken from the book Data Communications and Networking by Behrouz 4th edition.
In the diagram, in every subnet the last address is assigned to devices which is not correct. Because generally the last address in a network or sub network is used for broadcasting.

Finding the Subnet Address


In subnet 1, the address 17.12.14.29/27 can give us the subnet address if we use the mask /27 because
Host: 00010001 00001100 00001110 00011101 Mask: /27 Subnet: 00010001 00001100 00001110 00000000 Subnet: 17.12.14.0
As we know that the Network Address (sub network address) or Subnet Address is the first address of the network (sub network). That is why we find it by the above method which is also the method for finding the first address.

Finding the Subnet Address


In subnet 2, the address 17.12.14.45/28 can give us the subnet address if we use the mask /28 because
Host: 00010001 00001100 00001110 00101101 Mask: /28 Subnet: 00010001 00001100 00001110 00100000 Subnet: 17.12.14.32

Finding the Subnet Address


In subnet 3, the address 17.12.14.50/28 can give us the subnet address if we use the mask /28 because
Host: 00010001 00001100 00001110 00110010 Mask: /28 Subnet: 00010001 00001100 00001110 00110000 Subnet: 17.12.14.48

Finding the Broadcast Address

As we know that Broadcast Address is the Last Address in a network (subnet).


So for every subnet the broadcast address (last address) can be determined by the formula of finding the last address. The (Broadcast) last address in the block can be found by setting the rightmost 32 n bits to 1s (See slide 57 and 58).

The same formula will be applied to all the subnets for finding the Broadcast Address.

Network Address translation (NAT)

NAT enables a user to have a large set of addresses internally and one address externally.
The traffic inside can use the large set; the traffic outside the small set. To separate the addresses used inside the home or business and the ones used for the Internet, the Internet authorities have reserved three sets of addresses as private addresses shown in the next slide.

Addresses for private networks

Addresses for private networks

Any organization can use an address out of the set of addresses for private networks without permission from the Internet authorities.
Everyone knows that these reserved addresses are for private networks. They are unique inside the organization, but they are not unique globally.

No router will forward a packet that has one of these addresses as the destination address.

Implementation of NAT
The site must have only one single connection to the global Internet through the router (using NAT).
The figure in the slide shows a simple implementation of NAT. In the figure, the private network uses private address. The router that connects the network to the global address uses one private address and one global address. The private network is not visible to the rest of the internet; the rest of the Internet sees only the NAT router with the address 200.24.5.8.

A NAT implementation

Address translation
All the outgoing packets go through the NAT router, which replaces the source address in the packet with the global NAT address.
All incoming packets also pass through the NAT router, which replaces the destination address in the packet (the NAT router global address) with the appropriate private address. The figure in the next slide shows an example of address translation.

Addresses in a NAT

Where 200.24.5.8 is the NAT router global address.

Question
The reader may have noticed that translating the source addresses for outgoing packets is straightforward. But how does the NAT router know the destination address for a packet coming from the Internet? There may be tens or hundreds of private IP addresses, each belonging to one specific host.
The problem is solved if the NAT router has a Translation Table.

Translation table
A translation table has only two columns: the private address and the external address (destination address of the packet).
When the router translates the source address of the outgoing packet, it also makes note of the destination address (where the packet is going). When the response comes back from the destination, the router uses the source address of the packet (as the external address) to find the private address of the packet. The figure in the next slide shows the idea.

NAT address translation

Where 200.24.5.8 is the NAT router global address.

IPv6 ADDRESSES
Despite all short-term solutions, address depletion is still a long-term problem for the Internet. This and other problems in the IP protocol itself have been the motivation for IPv6.

Note

An IPv6 address is 128 bits long.

Note

The address space of IPv6 is 2128.

IPv6
Consists of 8 Quarteds separated by colons.
1:2:3:4:5:6:7:8 Hexadecimals values are used in each quardet.

IPv6 vs IPV4
IPv6
Quarted Hexadecimal Colon format 16 bits/quarted 16 = 4 hexadecimal values Octet Decimal Dot format 8 bits/octet

IPv4

IPv6 address in binary and hexadecimal colon notation

1 hexadecimal digit = 4 bits => 4*32 = 128 bits

Abbreviated IPv6 addresses

Note that :: can be used only once is an address and


preference will be given to the left.

Example 15
Expand the address 0:15::1:12:1213 to its original. Solution We first need to align the left side of the double colon to the left of the original pattern and the right side of the double colon to the right of the original pattern to find how many 0s we need to replace the double colon.

This means that the original address is.

Vous aimerez peut-être aussi