0% found this document useful (0 votes)
13 views

Networl layer

An IPv4 address is a unique 32-bit identifier for devices on the Internet, with a total address space of over 4 billion. The document discusses the conversion between binary and dotted-decimal notation, classful and classless addressing, subnetting, and the structure of IPv4 datagrams, including header fields and their functions. It also covers the importance of address blocks and restrictions in classless addressing to manage IP address allocation effectively.

Uploaded by

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

Networl layer

An IPv4 address is a unique 32-bit identifier for devices on the Internet, with a total address space of over 4 billion. The document discusses the conversion between binary and dotted-decimal notation, classful and classless addressing, subnetting, and the structure of IPv4 datagrams, including header fields and their functions. It also covers the importance of address blocks and restrictions in classless addressing to manage IP address allocation effectively.

Uploaded by

nasim sayyad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

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. An IPv4 address is 32 bits long.
IPv4IPv4 addresses are unique. They are unique in the sense that each address defines
one, and only one, connection to the Internet.
Address Space
A protocol such as IPv4 that defines addresses has an 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 address space is 2N because each bit can have two different values (0 or 1)
and N bits can have 2N values.
IPv4 uses 32-bit addresses, which means that the address space is 232 or
4,294,967,296 (more than 4 billion).
Binary Notation
In binary notation, the IPv4 address is displayed as 32 bits. 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. The following is an example of an IPv4 address in binary notation:
01110101 10010101 00011101 00000010
Dotted-Decimal Notation
To make the IPv4 address more compact and easier to read, Internet addresses are usually
written in decimal form with a decimal point (dot) separating the bytes. The following
is the dotted~decimal notation of the above address:
117.149.29.2
Figure 19.1 shows an IPv4 address in both binary and dotted-decimal notation.
Note that because each byte (octet) is 8 bits, each number in dotted-decimal notation is
a value ranging from 0 to 255.
1000-000-0 --000-010II 00000011 00011111
128 ----11-----3------31

Change the following IPv4 addresses from binary notation to dotted-decimal notation.
a. 10000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
Solution
We replace each group of 8 bits with its equivalent decimal number (see Appendix B) and add
dots for separation.
a. 129.11.11.239
b. 193.131.27.255
Example 19.2
Change the following IPv4 addresses from dotted-decimal notation to binary notation.
a. 111.56.45.78
b. 221.34.7.82
Solution
We replace each decimal number with its binary equivalent (see Appendix B).
a.• 01101111 00111000 00101101 01001110
b. 11011101 00100010 00000111 01010010
Example 19.3
Find the error, if any, in the following IPv4 addresses.
a. 111.56.045.78
b. 221.34.7.8.20
c. 75.45.301.14
d. 11100010.23.14.67
Solution
a. There must be no leading zero (045).
b. There can be no more than four numbers in an IPv4 address.
c. Each number needs to be less than or equal to 255 (301 is outside this range).
d. A mixture of binary notation and dotted-decimal notation is not allowed.

Classful Addressing
IPv4 addressing, at its inception, used the concept of classes. This architecture is called
classful addressing. Although this scheme is becoming obsolete, we briefly discuss it
here to show the rationale behind classless addressing.
In classful addressing, the address space is divided into five classes: A, B, C, D,
and E. Each class occupies some part of the address space.
In classful addressing, the address space is divided into five classes:
A, B, C, D, and E.
Classes and Blocks

Netid and Hostid


In classful addressing, an IP address in class A, B, or C is divided into netid and hostid.
These parts are of varying lengths, depending on the class of the address. Figure 19.2
shows some netid and hostid bytes. The netid is in color, the hostid is in white. Note that
the concept does not apply to classes D and E.
In class A, one byte defines the netid and three bytes define the hostid. In class B,
two bytes define the netid and two bytes define the hostid. In class C, three bytes define
the netid and one byte defines the hostid.
Mask
Although the length of the netid and hostid (in bits) is predetermined in classful addressing,
we can also use a mask (also called the default mask), a 32-bit number made of
554 CHAPTER 19 NETWORK lAYER: LOG1CALADDRESSING
contiguous Is followed by contiguous as. The masks for classes A, B, and C are shown
in Table 19.2. The concept does not apply to classes D and E.
Subnetting
During the era of classful addressing, subnetting was introduced. If an organization was
granted a large block in class A or B, it could divide the addresses into several contiguous
groups and assign each group to smaller networks (called subnets) or, in rare cases,
share part of the addresses with neighbors. Subnetting increases the number of Is in the
mask, as we will see later when we discuss classless addressing.
Supernetting
The time came when most of the class A and class B addresses were depleted; however,
there was still a huge demand for midsize blocks. The size of a class C block with a
maximum number of 256 addresses did not satisfy the needs of most organizations.
Even a midsize organization needed more addresses. One solution was supernetting.
In supernetting, an organization can combine several class C blocks to create a larger
range of addresses. In other words, several networks are combined to create a supernetwork
or a supemet. An organization can apply for a set of class C blocks instead of
just one. For example, an organization that needs 1000 addresses can be granted four
contiguous class C blocks. The organization can then use these addresses to create one
supernetwork. Supernetting decreases the number of Is in the mask. For example, if an
organization is given four class C addresses, the mask changes from /24 to /22. We will
see that classless addressing eliminated the need for supernetting.

Classless Addressing
To overcome address depletion and give more organizations access to the Internet,
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. An ISP, as the Internet service provider, may be given thousands or hundreds
of thousands based on the number of customers it may serve.
Restriction 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 (I, 2, 4, 8, ... ).
3. The first address must be evenly divisible by the number of addresses.
First Address The first address in the block can be found by setting the 32 - n rightmost
bits in the binary notation of the address to Os.
The first address in the block can be found by setting the rightmost 32 - n bits to Os.
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 00100 I 11. If
we
set 32 - 28 rightmost bits to 0, we get 11001101 000100000100101 0010000 or 205.16.37.32.
This is actually the block shown in Figure 19.3.
Last Address The last address in the block can be found by setting the 32 - n rightmost
bits in the binary notation of the address to Is.
The last address in the block can be found by setting the rightmost 32 - n bits to Is.

In Example 19.5 the /28 can be represented


as 11111111 11111111 11111111 11110000 (twenty-eight Is and four Os). Find
a. The first address
h. The last address
c. The number of addresses
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 Is; the result is 0 otherwise.
Address:
Mask:
First address:
11001101 00010000 00100101 00100111
11111111 11111111 11111111 11110000
11001101 00010000 00100101 00100000
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 Os; the
result is 1 otherwise. The complement of a number is found by changing each 1 to 0 and
each 0 to 1.
Address:
Mask complement:
Last address:
11001101 00010000 00100101 00100111
00000000 00000000 00000000 00001111
11001101 00010000 00100101 00101111
c. The number of addresses can be found by complementing the mask, interpreting it as a
decimal number, and adding 1 to it.
Mask complement:
Number of addresses:
000000000 00000000 00000000 00001111
15 + 1 =16

Datagram
Packets in the IPv4 layer are called datagrams. Figure 20.5 shows the IPv4 datagram
format.
datagram is a variable-length packet consisting of two parts: header and data.
The header is 20 to 60 bytes in length and contains information essential to routing and
Version (VER). This 4-bit field defines the version of the IPv4 protocol. Currently
the version is 4. However, version 6 (or IPng) may totally replace version 4 in the
future. This field tells the IPv4 software running in the processing machine that the
datagram has the format of version 4. All fields must be interpreted as specified
in the fourth version of the protocol. If the machine is using some other version of
IPv4, the datagram is discarded rather than interpreted incorrectly.
o Header length (HLEN). This 4-bit field defines the total length of the datagram
header in 4-byte words. This field is needed because the length of the header
is variable (between 20 and 60 bytes). When there are no options, the header length
is 20 bytes, and the value of this field is 5 (5 x 4 = 20). When the option field is
at its maximum size, the value of this field is 15 (15 x 4 = 60).
o Services. IETF has changed the interpretation and name of this 8-bit field. This
field, previously called service type, is now called differentiated services. We show
both interpretations in Figure
1. Service Type
In this interpretation, the first 3 bits are called precedence bits. The next 4 bits are
called type of service (TOS) bits, and the last bit is not used.
a. Precedence is a 3-bit subfield ranging from 0 (000 in binary) to 7 (111 in binary).
The precedence defines the priority of the datagram in issues such as congestion.
If a router is congested and needs to discard some datagrams, those datagrams
with lowest precedence are discarded first. Some datagrams in the Internet are
more important than others. For example, a datagram used for network management
is much more urgent and important than a datagram containing optional
information for a group.
The precedence subfield was part of version 4, but never used.
b. TOS bits is a 4-bit subfield with each bit having a special meaning. Although a
bit can be either 0 or 1, one and only one of the bits can have the value of 1 in
each datagram. The bit patterns and their interpretations are given in Table 20.1.
With only 1 bit set at a time, we can have five different types of services.

Total length. This is a In-bit field that defines the total length (header plus data)
of the IPv4 datagram in bytes. To find the length of the data coming from the upper
layer, subtract the header length from the total length. The header length can be
found by multiplying the value in the HLEN field by 4.
Length of data =total length - header length
Time to live. A datagram has a limited lifetime in its travel through an internet.
This field was originally designed to hold a timestamp, which was decremented by
each visited router. The datagram was discarded when the value became zero. However,
for this scheme, all the machines must have synchronized clocks and must
know how long it takes for a datagram to go from one machine to another. Today,
this field is used mostly to control the maximum number of hops (routers) visited by
the datagram. When a source host sends the datagram, it stores a number in this
field. This value is approximately 2 times the maximum number of routes between
any two hosts. Each router that processes the datagram decrements this number by 1.
If this value, after being decremented, is zero, the router discards the datagram.
This field is needed because routing tables in the Internet can become corrupted.
A datagram may travel between two or more routers for a long time without ever getting
delivered to the destination host. This field limits the lifetime of a datagram.
Another use of this field is to intentionally limit the journey of the packet. For
example, if the source wants to confine the packet to the local network, it can store
1 in this field. When the packet arrives at the first router, this value is decremented
to 0, and the datagram is discarded.
o Protocol. This 8-bit field defines the higher-level protocol that uses the services of
the IPv4 layer. An IPv4 datagram can encapsulate data from several higher-level
protocols such as TCP, UDP, ICMP, and IGMP. This field specifies the final destination
protocol to which the IPv4 datagram is delivered. In other words, since the
IPv4 protocol carries data from different other protocols, the value of this field
helps the receiving network layer know to which protocol the data belong
 Source address. This 32-bit field defines the IPv4 address of the source. This field
must remain unchanged during the time the IPv4 datagram travels from the source
host to the destination host.
o Destination address. This 32-bit field defines the IPv4 address of the destination.
This field must remain unchanged during the time the IPv4 datagram travels from
the source host to the destination host.
Fragmentation offset. This 13-bit field shows the relative position of this fragment
with respect to the whole datagram. It is the offset of the data in the original
datagram measured in units of 8 bytes. Figure 20.11 shows a datagram with a data
size of 4000 bytes fragmented into three fragments.
The bytes in the original datagram are numbered 0 to 3999. The first fragment
carries bytes 0 to 1399. The offset for this datagram is 0/8 =O. The second fragment
carries bytes 1400 to 2799; the offset value for this fragment is 1400/8 = 175.
Finally, the third fragment carries bytes 2800 to 3999. The offset value for this
fragment is 2800/8 =350.
First,
the value of the checksum field is set to O. Then the entire header is divided into 16-bit
sections and added together. The result (sum) is complemented and inserted into the
checksum field.
The checksum in the IPv4 packet covers only the header, not the data. There are two
good reasons for this. First, all higher-level protocols that encapsulate data in the IPv4
datagram have a checksum field that covers the whole packet. Therefore, the checksum
for the IPv4 datagram does not have to check the encapsulated data. Second, the header
of the IPv4 packet changes with each visited router, but the data do not. So the checksum
includes only the part that has changed. If the data were included, each router must recalculate
the checksum for the whole packet, which means an increase in processing time.

Options
The header of the IPv4 datagram is made of two parts: a fixed palt and a variable part.
The fixed part is 20 bytes long and was discussed in the previous section. The variable
part comprises the options that can be a maximum of 40 bytes.
Options, as the name implies, are not required for a datagram

Structure
An IPv6 address consists of 16 bytes (octets); it is 128 bits long.
An IPv6 address is 128 bits long.

Advantages
The next-generation IP, or IPv6, has some advantages over IPv4 that can be summarized
as follows:
o Larger address space. An IPv6 address is 128 bits long, as we discussed in Chapter
19. Compared with the 32-bit address of IPv4, this is a huge (296) increase in
the address space.
o Better header format. IPv6 uses a new header format in which options are separated
from the base header and inserted, when needed, between the base header
and the upper-layer data. This simplifies and speeds up the routing process because
most of the options do not need to be checked by routers.
o New options. IPv6 has new options to allow for additional functionalities.
o Allowance for extension. IPv6 is designed to allow the extension of the protocol if
required by new technologies or applications.
o Support for resource allocation. In IPv6, the type-of-service field has been
o Flow label. The flow label is a 3-byte (24-bit) field that is designed to provide
special handling for a particular flow of data. We will discuss this field later.
o Payload length. The 2-byte payload length field defines the length of the IP datagram
excluding the base header.
o Next header. The next header is an 8-bit field defining the header that follows the
base header in the datagram. The next header is either one of the optional extension
headers used by IP or the header of an encapsulated packet such as UDP or
TCP. Each extension header also contains this field. Table 20.6 shows the values of
next headers. Note that this field in version 4 is called the protocol.
o Hop limit. This 8-bit hop limit field serves the same purpose as the TIL field in IPv4.
o Source address. The source address field is a 16-byte (128-bit) Internet address
that identifies the original source of the datagram.
removed, but a mechanism (calledjlow label) has been added to enable the source
to request special handling of the packet. This mechanism can be used to support
traffic such as real-time audio and video.
o Support for more security. The encryption and authentication options in IPv6
provide confidentiality and integrity of the packet.
Priority
The priority field of the IPv6 packet defines the priority of each packet with respect to
other packets from the same source. For example, if one of two consecutive datagrams
must be discarded due to congestion, the datagram with the lower packet priority will
be discarded. IPv6 divides traffic into two broad categories: congestion-controlled and
noncongestion-controlled.
Congestion-Controlled Traffic If a source adapts itself to traffic slowdown when
there is congestion, the traffic is referred to as congestion-controlled traffic. For
example, TCP, which uses the sliding window protocol, can easily respond to traffic. In
congestion-controlled traffic, it is understood that packets may arrive delayed, lost, or
out of order. Congestion-controlled data are assigned priorities from 0 to 7, as listed in
Table 20.7. A priority of 0 is the lowest; a priority of 7 is the highest.
Hexadecimal Colon Notation
To make addresses more readable, IPv6 specifies hexadecimal colon notation. In this notation,
128 bits is divided into eight sections, each 2 bytes in length. Two bytes in hexadecimal
notation requires four hexadecimal digits. Therefore, the address consists of 32 hexadecimal
digits, with every four digits separated by a colon, as shown in Figure 19.14.
Figure 19.14 IPv6 address in binary and hexadecimal colon notation

1111110111101100
128 bits = 16 bytes = 32 hex digits
1111111111111111
IFDEC I:I 0074 I: I 0000 I: t 0000 I: I 0000 I: I BOFF I: I 0000 I: I FFFF I
Unicast Addresses
A unicast address defines a single computer. The packet sent to a unicast address must
be delivered to that specific computer. IPv6 defines two types of unicast addresses:
geographically
based and provider-based. We discuss the second type here; the first type is
left for future definition. The provider-based address is generally used by a normal host
as a unicast address.
Multicast Addresses
Multicast addresses are used to define a group of hosts instead ofjust one. A packet sent
to a multicast address must be delivered to each member of the group. Figure 19.17
shows the format of a multicast address.

DIffernce IPV6& IPV4:


Header Translation Procedure
1. The IPv6 mapped address is changed to an IPv4 address by extracting the rightmost 32 bits.
2. The value of the IPv6 priority field is discarded.
3. The type of service field in IPv4 is set to zero.
4. The checksum for IPv4 is calculated and inserted in the corresponding field.
5. The IPv6 flow label is ignored.
6. Compatible extension headers are converted to options and inserted in the IPv4 header.
Some may have to be dropped.
7. The length of IPv4 header is calculated and inserted into the corresponding field.
8. The total length of the IPv4 packet is calculated and inserted in the corresponding field.

You might also like