0% found this document useful (0 votes)
35 views69 pages

UNIT4

Uploaded by

Syam Om
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views69 pages

UNIT4

Uploaded by

Syam Om
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Chapter 19

Network Layer:

Logical Addressing

19.1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
What is IP ?
 An IP stands for internet protocol.
 An IP address is assigned to each device connected to a network.
 Each device uses an IP address for communication.
 It also behaves as an identifier as this address is used to identify the

device on a network.
 We can also define an IP address as a numeric address assigned to

each device on a network.


 To facilitate the routing of packets, TCP/IP protocol uses a 32-bit

logical address known as IPv4


19.2
What is IP ?
 An IP address consists of two parts, i.e., the first one is a

network address, and the other one is a host address.


 There are two types of IP addresses:

1. IPv4
2. IPv6

19.3
Note

An IPv4 address is 32 bits long.

19.4
Note

The IPv4 addresses are unique

and universal.

19.5
 A19-1
protocol such
ADDRESSES as IPv4 that defines addresses has an
SPACE

address space. An address space is the total number of

addresses used by the protocol.

 If a protocol uses N bits to define an address, the

N
address space is 2 because each bit can have two

N
19.6 different values (0 or 1) and N bits can have 2
An address space has a total of 1024 addresses.

How many bits are needed to represent an address?

19.7
Note

The address space of IPv4 is


32
2 or 4,294,967,296.

19.8
Figure 19.1 Dotted-decimal notation and binary notation for an IPv4 address

19.9
Example 19.1

Change the following IPv4 addresses from binary notation to dotted-decimal notation.

Solution

We replace each group of 8 bits with its equivalent decimal number (see Appendix B) and add dots

for separation.

19.10
19.11
Change the following IP addresses from dotted-decimal notation to binary

notation.

1. 114.34.2.8
2. 129.14.6.8
3. 208.34.54.12
4. 238.34.2.1

Change the following IP addresses from binary notation to dotted-decimal

notation.
19.12
Note

In classful addressing, the address space is divided into five classes:

A, B, C, D, and E.

19.13
Figure 19.2 Finding the classes in binary and dotted-decimal notation

19.14
19.15
Example 19.4

Find the class of each address.

a. 00000001 00001011 00001011 11101111

b. 11000001 10000011 00011011 11111111

c. 14.23.120.8

d. 252.5.15.111

Solution

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

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

address.

c. The first byte is 14; the class is A.

d. The first byte is 252; the class is E.


19.16
Table 19.1 Number of blocks and block size in classful IPv4 addressing

19.17
Note

In classful addressing, a large part of the available addresses were

wasted.

19.18
 In classful addressing, an IP address in class A, B, or C is divided
NETWORK ADDRESS AND HOST ADDRESS
into netid and hostid. These parts are of varying lengths, depending

on the class of the address.

 Network Address: The network address specifies the unique number

which is assigned to your network.

 Host Address: A host address is a specific address number assigned

to each host machine. With the help of the host address, each

machine is identified in your network. The network address will be


19.19
19.21
Table 19.2 Default masks for classful addressing

19.22
Note

Classful addressing, which is almost obsolete, is replaced with

classless addressing.

19.23
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.

19.24
Note

The first address in the block can be found by setting the rightmost

32 − n bits to 0s.

19.25
Example 19.6

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 32−28 rightmost bits to 0, we get

11001101 00010000 00100101 0010000

or

205.16.37.32.

This is actually the block shown in Figure 19.3.

19.26
Note

The last address in the block can be found by setting the rightmost

32 − n bits to 1s.

19.27
Example 19.7

Find the last address for the block in Example 19.6.

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 Figure 19.3.

19.28
Note

The number of addresses in the block can be found by using the

formula
32−n
2 .

19.29
Example 19.8

Find the number of addresses in Example 19.6.

Solution

The value of n is 28, which means that number


32−28
of addresses is 2 or 16.

19.30
Example 19.9

Another way to find the first address, the last address, and the number of addresses is to represent

the mask as a 32-bit binary (or 8-digit hexadecimal) number. This is particularly useful when we

are writing a program to find these pieces of information. In Example 19.5 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.

19.31
Example 19.9 (continued)

Solution

a. The first address can be found by ANDing the given

addresses 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.

19.32
Example 19.9 (continued)

b. The last address can be found by ORing the given

addresses 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.

19.33
Figure 19.4 A network configuration for the block 205.16.37.32/28

19.34
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.

19.35
Figure 19.6 A frame in a character-oriented protocol

19.36
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.

19.37
Figure 19.7 Configuration and addresses in a subnetted network

19.38
Figure 19.8 Three-level hierarchy in an IPv4 address

19.39
Example 19.10

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:

a. The first group has 64 customers; each needs 256

addresses.

b. The second group has 128 customers; each needs 128

addresses.

c. 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.

19.40
Example 19.10 (continued)

Solution

Figure 19.9 shows the situation.

Group 1

For this group, each customer needs 256 addresses. This means that 8 (log2 256) bits are needed to

define each host. The prefix length is then 32 − 8 = 24. The addresses are

19.41
Example 19.10 (continued)

Group 2

For this group, each customer needs 128 addresses. This means that 7 (log2 128) bits are needed to

define each host. The prefix length is then 32 − 7 = 25. The addresses are

19.42
Example 19.10 (continued)

Group 3

For this group, each customer needs 64 addresses. This means that 6 (log 264) bits are needed to

each host. The prefix length is then 32 − 6 = 26. The addresses are

Number of granted addresses to the ISP: 65,536

Number of allocated addresses by the ISP: 40,960

Number of available addresses: 24,576

19.43
Figure 19.10 A NAT implementation

19.44
Figure 19.11 Addresses in a NAT

19.45
Figure 19.12 NAT address translation

19.46
Table 19.4 Five-column translation table

19.47
19-2 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.

Topics discussed in this section:

Structure

Address Space

19.48
Note

An IPv6 address is 128 bits long.

19.49
Figure 19.14 IPv6 address in binary and hexadecimal colon notation

19.50
Figure 19.15 Abbreviated IPv6 addresses

19.51
Example 19.11

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.

19.52
IPv4 Addressing Concepts
and Their IPv6 Equivalents
IPv4 Address IPv6 Address
Address Length – 32 bits 128 bits

Address Representation - decimal hexadecimal

Internet address classes Not applicable in IPv6

Multicast addresses (224.0.0.0/4) IPv6 multicast addresses (FF00::/8)

Broadcast addresses Not applicable in IPv6

Unspecified address is 0.0.0.0 Unspecified address is ::

Loopback address is 127.0.0.1 Loopback address is ::1


Public IP addresses Global unicast addresses

Private IP addresses (10.0.0.0/8, Site-local addresses (FEC0::/10)


172.16.0.0/12, and 192.168.0.0/16)
Autoconfigured addresses (169.254.0.0/16) Link-local addresses (FE80::/64)

53
IPv6 Packet Format
IPv4 Header Structure

 basic IPv4 header contains 12 fields.


 each field of the IPv4 header has a specific use.
 Shaded field are removed in IPv6.
55
IPv4 Header - Review
IPv4 Header - Review
 Version (4 bits)
 Indicates the version of IP and is set to 4.
 Internet Header Length (4 bits)
 Indicates the number of 4-byte blocks in the IPv4 header.
 Because an IPv4 header is a minimum of 20 bytes in size, the
smallest value of the Internet Header Length (IHL) field is 5.
 Type of Service (4 bits)
 Indicates the desired service expected by this packet for delivery
through routers across the IPv4 internetwork.

57
IPv6 Packet Format
IPv4 Header - Review

58
IPv6 Packet Format
IPv4 Header - Review

59
IPv6 Packet Format
IPv4 Header - Review

60
IPv6 Packet Format
IPv6 Packet Format
Version (4 bits)​
IP PACKET STRUCTURE
The first four bits of the IP header represent the IP version being used. For IPv4, this field

is set to "0100," while for IPv6, it is set to "0110.“

Header Length (4 bits):

The header length field indicates the length of the IPv4 header in 32-bit words. Since the

header is a fixed size of 20 bytes, the value of this field is typically 5.

Type of Service (8 bits): This field is used to define the quality of service (QoS) for the

packet, including priorities and other parameters for routing and processing.

Total Length (16 bits): The total length field specifies the length of the entire IPv4 packet,

including both the header and the data, in bytes.

Identification (16 bits): The identification field is used for packet fragmentation and

reassembly. It helps in grouping fragments of a larger packet together.

Flags (3 bits): These bits are used for controlling and identifying packet fragmentation.
Fragment Offset (13 bits): The fragment offset field specifies the position of the fragment

within the original packet. ItIP PACKET


is used STRUCTURE
to reassemble fragmented packets correctly.

Time to Live (TTL) (8 bits): The TTL field represents the maximum number of hops

(routers or network segments) that the packet can traverse before it is discarded. Each router

decrements this value by one.

Protocol (8 bits): This field indicates the type of protocol used in the data portion of the

packet, such as TCP, UDP, ICMP, or others.

Header Checksum (16 bits): The header checksum field is used to verify the integrity of the

IPv4 header during transmission. Routers and devices recalculate this checksum to check for

errors.

Source IP Address (32 bits): This field contains the IP address of the sender or source of the

packet.

Destination IP Address (32 bits): This field holds the IP address of the recipient or
IPv6 Header

65
IPv6 Packet Format
IPv6 Header Fields
 Based on these rules, RFC 2460 defines the following IPv6 header fields:

1. Version (4 bits)

4 bits are used to indicate the version of IP and is set to 6

 Traffic Class (8 bits)


 same function as the Type of Service field in the IPv4 header.

1. Flow Label (20 bits)


 identifies a flow and it is intended to enable the router to identify
packets that should be treated in a similar way without the need
for deep lookups within those packets.
 set by the source and should not be changed by routers along the
path to destination.
IPv6 Header Fields
4. Payload Length (16 bits)
 With the header length fixed at 40 bytes, it is enough to indicate the
length of the payload to determine the length of the entire packet.

5. Next Header (8 bits)


 Indicates either the first extension header (if present) or the protocol
in the upper layer PDU (such as TCP, UDP, or ICMPv6).

6. Hop Limit (8 bits)


 In IPv6, the IPv4 TTL was appropriately renamed Hop Limit because it
is a variable that is decremented at each hop, and it does not have a
temporal dimension.

67
IPv6 Packet Format
IPv6 Header Fields

68
IPv6 Packet Format
Values of the Next Header Field

69
IPv6 Packet Format

You might also like