CSE3155 DATA COMMUNICATION AND COMPUTER
NETWORKS
Module-3.1
Network Layer-Logical Addressing
1
Lecture 22
Network Layer Services, Routing and Forwarding, Packet Switching
LO1: Recall Routing and Forwarding in detail.
LO2: Illustrate Packet Switching techniques in detail.
Network Layer
The Network Layer is the third layer of the TCP/IP model.
It handles the service requests from the transport layer and further forwards the service request to the
data link layer.
The network layer translates the logical addresses into physical addresses
It determines the route from the source to the destination and also manages the traffic problems such as
switching, routing and controls the congestion of data packets.
The main role of the network layer is to move the packets from sending host to the receiving host.
Features
Main responsibility of Network layer is to carry the data packets from the source to the
destination without changing or using it.
If the packets are too large for delivery, they are fragmented i.e., broken down into
smaller packets.
It decides the route to be taken by the packets to travel from the source to the
destination among the multiple routes available in a network (also called as routing).
The source and destination addresses are added to the data packets inside the network
layer.
Advantages of Network Layer services
• Packetizing service in network layer provides an ease of transportation of the data
packets.
• Packetizing also eliminates single points of failure in data communication
systems.
• Routers present in the network layer reduce network traffic by creating broadcast
domains.
• With the help of Forwarding, data packets are transferred from one place to
another in the network.
PACKET SWITCHING
Packet Switching
Packet Switching uses Store and Forward technique while switching the packets; while
forwarding the packet each hop first store that packet then forward. This technique is very
beneficial because packets may get discarded at any hop due to some reason.
Packet-Switched networks were designed to overcome the weaknesses of Circuit-Switched
networks since circuit-switched networks were not very effective for small messages.
Advantages of Packet Switching
• More efficient in terms of bandwidth, since the concept of reserving circuit is not there.
• Minimal transmission latency.
• More reliable as destination can detect the missing packet.
• More fault tolerant because packets may follow different path in case any link is down,
Unlike Circuit Switching.
• Cost effective and comparatively cheaper to implement.
Internet Protocol Address
IP addresses are binary numbers but are typically expressed in decimal form (IPv4) or
hexadecimal form (IPv6) to make reading and using them easier for humans.
IP stands for Internet Protocol and describes a set of standards and requirements for
creating and transmitting data packets, or datagrams, across networks.
The Internet Protocol (IP) is part of the Internet layer of the Internet protocol suite. In the
OSI model, IP would be considered part of the network layer.
IP is traditionally used in conjunction with a higher-level protocol, most notably TCP. The
IP standard is governed by RFC 791.
Approaches in packet switching
• Datagram Approach: Connectionless packet switching
• Virtual Approach: Connection oriented packet switching
Connectionless packet switching
• In Connectionless Packet Switching each packet contains all necessary addressing
information such as source address, destination address and port numbers etc.
• In Datagram Packet Switching, each packet is treated independently.
• Packets belonging to one flow may take different routes because routing decisions are
made dynamically, so the packets arrived at destination might be out of order.
• It has no connection setup and teardown phase, like Virtual Circuits.
• Packet delivery is not guaranteed in connectionless packet switching, so the reliable
delivery must be provided by end systems using additional protocols.
Connectionless packet switching
Connection oriented packet switching
Before starting the transmission, it establishes a logical path or virtual connection using
signaling protocol, between sender and receiver and all packets belongs to this flow will
follow this predefined route.
Virtual Circuit ID (Identifier) is provided by switches/routers to uniquely identify this
virtual connection.
Data is divided into small units and all these small units are appended with help of sequence
number. Overall, three phases takes place here- Setup, data transfer and tear down phase.
Connection oriented packet switching
Lecture 23
IPV4 Address, Address Space,IPV4 Datagram format
LO1: Find the valid ip address.
LO2: Outline IPV4 Datagram format in detail.
Internet Protocol Address
An IP address (internet protocol address) is a numerical representation that uniquely
identifies a specific interface on the network.
Addresses in IPv4 are 32-bits long. This allows for a maximum of 4,294,967,296 (232)
unique addresses.
Addresses in IPv6 are 128-bits, which allows for 3.4 x 1038 (2128) unique addresses.
IPv4 Protocol
IPv4 is an unreliable datagram protocol—a best-effort delivery service.
If reliability is important, IPv4 must be paired with a reliable transport-layer protocol such as TCP.
An example of a more commonly understood best-effort delivery service is the post office.
IPv4 is also a connectionless protocol that uses the datagram approach. This means that each
datagram is handled independently, and each datagram can follow a different route to the
destination.
This implies that datagrams sent by the same source to the same destination could arrive out of
order.
Datagram Format
In this section, we begin by discussing the first service provided by IPv4, packetizing.
We show how IPv4 defines the format of a packet in which the data coming from the upper layer or other
protocols are encapsulated.
Packets used by the IP are called datagrams.
Figure below shows the IPv4 datagram format.
A datagram is a variable length packet consisting of two parts: header and payload (data).
The header is 20 to 60 bytes in length and contains information essential to routing and delivery.
Datagram Format
Description of each field
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.
Header Length: The 4-bit header length (HLEN) field defines the total length of the datagram header in
4-byte words. The IPv4 datagram has a variable-length header. However, to make the value of the header
length (number of bytes) fit in a 4-bit header length, the total length of the header is calculated as 4-byte
words. The total length is divided by 4 and the value is inserted in the field. The receiver needs to multiply
the value of this field by 4 to find the total length.
Cntd…
Service Type: In the original design of the IP header, this field was referred to as type of service (TOS),
which defined how the datagram should be handled.
Total Length: This 16-bit field defines the total length (header plus data) of the IP datagram in bytes.
This field helps the receiving device to know when the packet has completely arrived. 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.
Cntd…
Identification, Flags, and Fragmentation Offset: These three fields are related to the fragmentation of
the IP datagram when the size of the datagram is larger than the underlying network can carry.
Time-to-live: Due to some malfunctioning of routing protocols a datagram may be circulating in the
Internet, visiting some networks over and over without reaching the destination. This may create extra
traffic in the Internet. The time to-live (TTL) field is used 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.
Each router that processes the datagram decrements this number by one. If this value, after being
decremented, is zero, the router discards the datagram.
Cntd…
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. When
the payload is encapsulated in a datagram at the source IP, the corresponding protocol number is
inserted in this field; when the datagram arrives at the destination, the value of this field helps to define to
which protocol the payload should be delivered.
Cntd…
Header checksum: IP is not a reliable protocol; it does not check whether the payload carried by a
datagram is corrupted during the transmission. The datagram header, however, is added by IP, and its
error-checking is the responsibility of IP. Errors in the IP header can be a disaster.
For example, if the destination IP address is corrupted, the packet can be delivered to the wrong host. If
the protocol field is corrupted, the payload may be delivered to the wrong protocol. If the fields related
to the fragmentation are corrupted, the datagram cannot be reassembled correctly at the destination,
and so on. For these reasons, IP adds a header checksum field to check the header, but not the payload.
Cntd…
Source and Destination Addresses: These 32-bit source and destination address fields define the IP
address of the source and destination respectively. Note that the value of these fields must remain
unchanged during the time the IP datagram travels from the source host to the destination host.
Options: A datagram header can have up to 40 bytes of options. Options can be used for network testing
and debugging.
Options
The header of the IPv4 datagram is made of two parts: a fixed part 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. They can be used for network testing and debugging.
Although options are not a required part of the IPv4 header, option processing is required for the IPv4 software. This
means that all implementations must be able to handle options if they are present in the header.
IPv4 Address
• 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.
• IPv4 addresses are unique.
• They are unique in the sense that each address defines one, and only one, connection
to the Internet.
• Two devices on the Internet can never have the same address at the same time.
• If a device operating at the network layer has m connections to the Internet, it needs
to have m addresses.
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 2^N because each bit can have two
different values (0 or 1) and N bits can have 2^N values.
• IPv4 uses 32-bit addresses, which means that the address space is 2^32 or 4,294,967,296 (more than
4 billion).
• This means that, theoretically, if there were no restrictions, more than 4 billion devices could be
connected to the Internet.
Notations
There are two prevalent notations to show an IPv4 address: binary notation and dotted-decimal notation.
Binary Notation
In binary notation, the IPv4 address is displayed as 32 bits. Each octet is often referred to as a byte.
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:
[Link]
Dotted-decimal notation and binary notation for an IPv4 address
Example Problems
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 and add dots for
separation.
Example Problems
Change the following IPv4 addresses from dotted-decimal notation to binary notation.
Solution
We replace each decimal number with its binary equivalent.
Example Problems
Change the following IPv4 addresses from dotted-decimal notation to binary notation.
Solution
a. There must be no leading zero (045).
b. There can be no more than four numbers.
c. Each number needs to be less than or equal to 255.
d. A mixture of binary notation and dotted-decimal
notation is not allowed.
Lecture 24
Classfull Addressing and Problems
LO1:Name the class for the given IP address. [Link] ,[Link]
LO2: Explain different classfull addressing with range and examples
Classfull addressing
In classfull addressing, the address space is divided into five classes: A, B, C, D and E.
Each class occupies some part of the address space.
If the address is given in binary notation, the first few bits can immediately tell us the class of the address.
If the address is given in decimal-dotted notation, the first byte defines the class.
Classfull Addressing
Disadvantages of Classfull Addressing
If we consider class A, the number of addresses in each block is more than enough for almost any organization.
So, it results in wastage of addresses.
Same is the case with class B, probably an organization receiving block from class B would not require that
much of addresses. So, it also results in wastage of addresses.
A block in class C may be too small to fulfil the addresses requirement of an organization.
Each address in class D defines a group of hosts. Hosts need to multicast the address. So, the addresses are
wasted here too.
Addresses of class E are reserved for the future purpose which is also wastage of addresses.
The main issue here is; we are not assigning addresses according to user requirements. We directly assign
a block of a fixed size which has a fixed number of addresses which leads to wastage of address.
Subnetting
• A subnet, or subnetwork, is a segmented piece of a larger network.
• More specifically, subnets are a logical partition of an IP network into
multiple, smaller network segments.
• Organizations will use a subnet to subdivide large networks into smaller,
more efficient subnetworks.
• When a bigger network is divided into smaller networks, in order to maintain
security, then that is known as Subnetting. so, maintenance is easier for
smaller networks.
What is the subnetwork address if the destination address is [Link]
and the subnet mask is [Link] ?
Solution:
Convert the given destination address into binary format.
[Link] = 11001000 00101101 00100010 00111000
Convert the given subnet mask into binary format.
[Link] = 11111111 11111111 11110000 00000000
Do the AND operation using destination address and subnet mask address.
[Link] = 11001000 00101101 00100010 00111000
[Link] = 11111111 11111111 11110000 00000000
11001000 00101101 00100000 00000000
subnetwork address is [Link]
Note:
Refer More Problems in word file.
Lecture 25
Classless Addressing and CIDR, Problems, Subnetting and Problems
LO1:Why classless addressing plays important role in network?
LO2:Illustrate the rules of CIDR block in detail
CLASSLESS ADDRESSING
In classless addressing, variable-length blocks are used that belong to no classes.
We can have a block of 1 address, 2 addresses, 4 addresses, 128 addresses, and
so on.
In classless addressing, the whole address space is divided into variable length
blocks.
The prefix in an address defines the block (network); the suffix defines the node
(device).
The number of addresses in a block needs to be a power of 2.
An organization can be granted one block of addresses.
Notation used in Classless Addressing
• The notation used in classless addressing is informally referred to as slash notation and
formally as classless inter-domain routing or CIDR.
• For example , [Link] /24 represents the IP address [Link] and, its subnet
mask [Link], which has 24 leading 1-bits.
CIDR Block
When a user asks for specific number of IP Addresses,
CIDR dynamically assigns a block of IP Addresses based on certain rules.
This block contains the required number of IP Addresses as demanded by the user.
This block of IP Addresses is called as a CIDR block.
Rules For Creating CIDR Block
A CIDR block is created based on the following 3 rules
Rule-01:
All the IP Addresses in the CIDR block must be contiguous.
Rule-02:
The size of the block must be presentable as power of 2.
Size of the block is the total number of IP Addresses contained in the block.
Size of any CIDR block will always be in the form 21, 22, 23, 24, 25 and so on.
Rule-03:
First IP Address of the block must be divisible by the size of the block.
Note:
Refer More Problems in word file.
Subnet Mask - [Link]
IP Address of ISP – [Link]/22
Start Address of 1024 address is – [Link] to [Link], [Link]
to [Link], to [Link] to [Link] to [Link] to
[Link].
Total – 1024 addresses
Network Address Translation (NAT)
• Network Address Translation (NAT) is a process in which one or more local IP address is translated into one or more
Global IP address and vice versa in order to provide Internet access to the local hosts.
• The technology allows a site to use a set of private addresses for internal communication and a set of global Internet
addresses (at least one) for communication with the rest of the world.
• The site must have only one connection to the global Internet through a NAT capable router that runs NAT software.
Addresses in a NAT
Address Translation
All of 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.
Translation Table
There may be tens or hundreds of private IP addresses, each belonging to one specific host.
The problem arises when we want to translate the source address to an external address. This is solved if the NAT
router has a translation table.
Lecture 26
DHCP and NAT
LO1:What is DHCP?
LO2:Explain NAT in detail.
DHCP – DYNAMIC HOST CONFIGURATION PROTOCOL
The dynamic host configuration protocol is used to simplify the installation and maintenance of
networked computers.
DHCP is derived from an earlier protocol called BOOTP.
Ethernet addresses are configured into network by manufacturer and they are unique.
IP addresses must be unique on a given internetwork but also must reflect the structure of the
internetwork.
The main goal of DHCP is to minimize the amount of manual configuration required for a host.
If a new computer is connected to a network, DHCP can provide it with all the necessary
information for full system integration into the network.
DHCP is based on a client/server model.
DHCP clients send a request to a DHCP server to which the server responds with an IP address.
There is at least one DHCP server for an administrative domain.
The DHCP server can function just as a centralized repository for host configuration information.
The DHCP server maintains a pool of available addresses that it hands out to hosts on demand.
DHCP – DYNAMIC HOST CONFIGURATION PROTOCOL
DHCP – DYNAMIC HOST CONFIGURATION PROTOCOL
Lecture 27
IPV6 Addressing,IPV6 Packet format, Transition from IPV4 to IPV6.
LO1: Show the IPV6 Address in proper format.
LO2: Outline the IPV6 Packet format in detail.
IPv6 ADDRESSING
The main reason for migration from IPv4 to IPv6 is the small size of the address space in IPv4.
In this section, we show how the huge address space of IPv6 prevents address depletion in the future.
Representation
A computer normally stores the address in binary, but it is clear that 128 bits cannot easily be handled by
humans.
Several notations have been proposed to represent IPv6 addresses when they are handled by humans. The
following shows two of these notations: binary and colon hexadecimal.
Abbreviated IPv6 addresses
Although an IPv6 address, even in hexadecimal format, is very long, many of the digits are zeros.
In this case, we can abbreviate the address. The leading zeros of a section can be omitted.
Using this form of abbreviation, 0074 can be written as 74, 000F as F, and 0000 as 0.
Note that 3210 cannot be abbreviated.
Cntd…
Further abbreviation, often called zero compression, can be applied to colon hex notation
if there are consecutive sections consisting of zeros only.
We can remove all the zeros and replace them with a double semicolon.
Address Space
The address space of IPv6 contains 2128 addresses. This address space is 296 times the IPv4 address—
definitely no address depletion—as shown, the size of the space is
To give some idea about the number of addresses, we assume that only 1/64 (almost 2 percent) of the
addresses in the space can be assigned to the people on planet Earth and the rest are reserved for special
purposes.
We also assume that the number of people on the earth is soon to be 234 (more than 16 billion). Address
depletion in this version is impossible.
THE IPv6 PROTOCOL
The next-generation IP, or IPv6, has some advantages over IPv4 that can be summarized as follows:
Larger address space: An IPv6 address is 128 bits long. Compared with the 32-bit address of IPv4, this is a
huge (2^96) increase in the address space.
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.
New options: IPv6 has new options to allow for additional functionalities.
Fragmentation at source only: Routers are not allowed to fragment packets. If a packet needs to be
fragmented, it must be done at the source.
Cntd…
Allowance for extension: IPv6 is designed to allow the extension of the protocol if required by
new technologies or applications.
Support for resource allocation: In IPv6, the type-of-service field has been removed, but two
new fields, traffic class and flow label, have 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.
Support for more security. The encryption and authentication options in IPv6 provide
confidentiality and integrity of the packet.
IPv6 Packet Format
Cntd…
Version: The 4-bit version field defines the version number of the IP. For IPv6, the value is 6.
Traffic class: The 8-bit traffic class field is used to distinguish different payloads with different delivery
requirements. It replaces the type-of-service field in IPv4.
Flow label: The flow label is a 20-bit field that is designed to provide special handling for a particular flow
of data.
Payload length: The 2-byte payload length field defines the length of the IP datagram excluding the base
header.
Next Header: The next header field identifies the type of extension header that follows the basic header.
The extension header is similar to the options field in IPv4 but is more flexible and efficient. Extension
headers are further discussed below.
Cntd…
Hop Limit: The hop limit field replaces the TTL field in IPv4.
Source address: The source address field is a 16-byte (128-bit) Internet address that identifies the original
source of the datagram.
Destination address: The destination address field is a 16-byte (128-bit) Internet address that usually
identifies the final destination of the datagram.
Hop-by-Hop Option: The hop-by-hop option is used when the source needs to pass information to all routers visited
by the datagram. For example, perhaps routers must be informed about certain management, debugging, or control
functions.
Source Routing: The source routing extension header combines the concepts of the strict source route and the loose
source route options of IPv4.
Cntd…
Fragmentation: IPv6 allows only a source host to perform fragmentation. Intermediate routers are forbidden to
fragment any packet.
Authentication: The authentication extension header has a dual purpose: it validates the message sender and ensures
the integrity of data.
Encrypted Security Payload: The encrypted security payload (ESP) is an extension that provides confidentiality
and guards against eavesdropping.
Destination Option: The destination option is used when the source needs to pass information to the destination
only. Intermediate routers are not permitted access to this information.
TRANSITION FROM IPv4 TO IPv6
Although we have a new version of the IP protocol, how can we make the transition to stop using IPv4 and
start using IPv6?
The first solution that comes to mind is to define a transition day on which every host or router should stop
using the old version and start using the new version. However, this is not practical; because of the huge
number of systems in the Internet, the transition from IPv4 to IPv6 cannot happen suddenly.
It will take a considerable amount of time before every system in the Internet can move from IPv4 to IPv6.
The transition must be smooth to prevent any problems between IPv4 and IPv6 systems.
Strategies
Three strategies have been devised for transition: dual stack, tunneling, and header translation.
One or all of these three strategies can be implemented during the transition period.
1. Dual Stack
It is recommended that all hosts, before migrating completely to version 6, have a dual stack of protocols
during the transition.
In other words, a station must run IPv4 and IPv6 simultaneously until all the Internet uses IPv6.
Figure below for the layout of a dual-stack configuration.
To determine which version to use when sending a packet to a destination, the source host queries the
DNS.
If the DNS returns an IPv4 address, the source host sends an IPv4 packet. If the DNS returns an IPv6
address, the source host sends an IPv6 packet.
Cntd….
2. Tunneling
Tunneling is a strategy used when two computers using IPv6 want to communicate with each other and the packet
must pass through a region that uses IPv4.
To pass through this region, the packet must have an IPv4 address. So the IPv6 packet is encapsulated in an IPv4
packet when it enters the region, and it leaves its capsule when it exits the region.
It seems as if the IPv6 packet enters a tunnel at one end and emerges at the other end.
Cntd….
3. Header Translation
Header translation is necessary when the majority of the Internet has moved to IPv6 but some systems
still use IPv4.
The sender wants to use IPv6, but the receiver does not understand IPv6.
Tunneling does not work in this situation because the packet must be in the IPv4 format to be understood
by the receiver.
In this case, the header format must be totally changed through header translation. The header of the
IPv6 packet is converted to an IPv4 header.
END OF MODULE 3.1