Lec12 13 14
Lec12 13 14
Lec12 13 14
Network Layer
What is Network Layer ?
• The Network Layer is the third layer of the OSI 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.
• The main functions performed by the network layer are:
• Routing: When a packet reaches the router's input link, the router will move the packets to the
router's output link. For example, a packet from S1 to R1 must be forwarded to the next router on
the path to S2.
• Logical Addressing: The data link layer implements the physical addressing and network layer
implements the logical addressing. Logical addressing is also used to distinguish between source
and destination system. The network layer adds a header to the packet which includes the logical
addresses of both the sender and the receiver.
• Internetworking: This is the main role of the network layer that it provides the logical connection
between different types of networks.
• Fragmentation: The fragmentation is a process of breaking the packets into the smallest
individual data units that travel through different networks.
Forwarding & Routing
• In Network layer, a router is used to forward the packets.
Every router has a forwarding table. A router forwards a
packet by examining a packet's header field and then using the
header field value to index into the forwarding table. The
value stored in the forwarding table corresponding to the
header field value indicates the router's outgoing interface link
to which the packet is to be forwarded.
• For example, the router with a header field value of 0111
arrives at a router, and then router indexes this header value
into the forwarding table that determines the output link
interface is 2. The router forwards the packet to the interface
2. The routing algorithm determines the values that are
inserted in the forwarding table. The routing algorithm can be
centralized or decentralized.
Services Provided by the Network Layer
• Guaranteed delivery: This layer provides the service which guarantees that the packet will arrive
at its destination.
• Guaranteed delivery with bounded delay: This service guarantees that the packet will be
delivered within a specified host-to-host delay bound.
• In-Order packets: This service ensures that the packet arrives at the destination in the order in
which they are sent.
• Guaranteed max jitter: This service ensures that the amount of time taken between two
successive transmissions at the sender is equal to the time between their receipt at the destination.
• Security services: The network layer provides security by using a session key between the source
and destination host. The network layer in the source host encrypts the payloads of datagrams
being sent to the destination host. The network layer in the destination host would then decrypt the
payload. In such a way, the network layer maintains the data integrity and source authentication
services.
Functions of the network layer
• The primary function of the network layer is to enable different
networks to be interconnected. It does this by forwarding packets to
network routers, which rely on algorithms to determine the best paths
for the data to travel. These paths are known as "virtual circuits." The
network layer relies on the Internet Control Message Protocol (ICMP)
for error control handling and diagnostics to ensure packets are sent
correctly. Quality of Service (QoS) is also available to permit certain
traffic to be prioritized over other traffic. The network layer can
support either connection-oriented or connectionless networks, but
such a network data transmission can only be of one type and not both.
Protocols at the network layer
• While IP is the most popular and widely used protocol at the network layer today,
there are plenty of other protocol examples to note. Network protocols at Layer 3
include those used for dynamic routing of networks, secure communications,
network translations and network redundancy. Here are a few examples:
• Open Shortest Path First (OSPF) is a dynamic routing protocol.
• Routing Information Protocol (RIP) is a dynamic routing protocol.
• Network Address Translation (NAT) translates and manages one IP address
into another.
• Internet Protocol Security (IPsec) is a secure network protocol suite that uses
authentication and data encryption.
• Hot Standby Router Protocol (HSRP) is a network path redundancy protocol.
• Virtual Router Redundancy Protocol (VRRP) is a network path redundancy
protocol.
Design Issues with Network Layer
• A key design issue is determining how packets are routed from source to destination. Routes
can be based on static tables that are wired into the network and rarely changed. They can also be
highly dynamic, being determined anew for each packet, to reflect the current network load.
• If too many packets are present in the subnet at the same time, they will get into one another's
way, forming bottlenecks. The control of such congestion also belongs to the network layer.
• Moreover, the quality of service provided(delay, transmit time, jitter, etc) is also a network layer
issue.
• When a packet has to travel from one network to another to get to its destination, many
problems can arise such as:
• The addressing used by the second network may be different from the first one.
• The second one may not accept the packet at all because it is too large.
• The protocols may differ, and so on.
• It is up to the network layer to overcome all these problems to allow heterogeneous networks to be
interconnected.
• Network
What is a Network
• Communication at the network layer is host-to-host (computer-to-
computer); a computer somewhere in the world needs to communicate
with another computer somewhere else in the world. Usually,
computers communicate through the Internet. The packet transmitted
by the sending computer may pass through several LANs or WANs
before reaching the destination computer.
• We know that in Network communication all devices communicate or
understand to each other with their IP. They don’t know to each other
with their names. If you know the IP address than you communicate in
network.
Types of Network
• A computer network is a group of
computers linked to each other that
enables the computer to
communicate with another
computer and share their
resources, data, and applications.
• A computer network can be
categorized by their size.
A computer network is mainly
of four types:
• LAN(Local Area Network)
• PAN(Personal Area Network)
• MAN(Metropolitan Area Network)
• WAN(Wide Area Network)
LAN(Local Area Network)
• Local Area Network is a group of computers
connected to each other in a small area such as
building, office.
• LAN is used for connecting two or more personal
computers through a communication medium such
as twisted pair, coaxial cable, etc.
• It is less costly as it is built with inexpensive
hardware such as hubs, network adapters, and
ethernet cables.
• The data is transferred at an extremely faster rate in
Local Area Network.
• Local Area Network provides higher security.
PAN(Personal Area Network)
• Personal Area Network is a network arranged
within an individual person, typically within a
range of 10 meters.
• Personal Area Network is used for connecting
the computer devices of personal use is known
as Personal Area Network.
• Thomas Zimmerman was the first research
scientist to bring the idea of the Personal Area
Network.
• Personal Area Network covers an area of 30
feet.
• Personal computer devices that are used to
develop the personal area network are the
laptop, mobile phones, media player and play
stations.
• There are two types of Personal Area
Network:
• Wired Personal Area Network
• Wireless Personal Area Network
• Wireless Personal Area Network: Wireless
Personal Area Network is developed by
simply using wireless technologies such as
WiFi, Bluetooth. It is a low range network.
• Wired Personal Area Network: Wired
Personal Area Network is created by using the
USB.
MAN(Metropolitan Area Network)
• A metropolitan area network is a network that covers a larger
geographic area by interconnecting a different LAN to form a larger
network.
• Government agencies use MAN to connect to the citizens and private
industries.
• In MAN, various LANs are connected to each other through a
telephone exchange line.
• The most widely used protocols in MAN are RS-232, Frame Relay,
ATM, ISDN, OC-3, ADSL, etc.
• It has a higher range than Local Area Network(LAN).
• ----------------------------------------------------------
• Uses Of Metropolitan Area Network:
• MAN is used in communication between the banks in a city.
• It can be used in an Airline Reservation.
• It can be used in a college within a city.
• It can also be used for communication in the military.
WAN(Wide Area Network)
• A Wide Area Network is a network that
extends over a large geographical area
such as states or countries.
• A Wide Area Network is quite bigger
network than the LAN.
• A Wide Area Network is not limited to a
single location, but it spans over a large
geographical area through a telephone
line, fibre optic cable or satellite links.
• The internet is one of the biggest WAN in
the world.
• A Wide Area Network is widely used in
the field of Business, government, and
education.
• Examples Of Wide Area Network:
• Mobile Broadband: A 4G network is widely used across a region or
country.
• Last mile: A telecom company is used to provide the internet services
to the customers in hundreds of cities by connecting their home with
fiber.
• Private network: A bank provides a private network that connects the
44 offices. This network is made by using the telephone leased line
provided by the telecom company.
• IP Addressing
IP Address Definition
• A unique string of characters that identifies each computer using the
Internet Protocol to communicate over a network.
What is an IP?
• An IP address is a string of numbers separated by periods. IP
addresses are expressed as a set of four numbers.
• An example address might be 192.158.1.38. Each number in the set
can range from 0 to 255. So, the full IP addressing range goes from
0.0.0.0 to 255.255.255.255.
How do IP addresses work
• Internet Protocol works the same way as any other language,
by communicating using set guidelines to pass information. All
devices find, send, and exchange information with other
connected devices using this protocol. By speaking the same
language, any computer in any location can talk to one another.
• The use of IP addresses typically happens behind the scenes. The process
works like this:
• Your device indirectly connects to the internet by connecting at first to a network
connected to the internet, which then grants your device access to the internet.
• When you are at home, that network will probably be your Internet Service
Provider (ISP). At work, it will be your company network.
• Your IP address is assigned to your device by your ISP.
• Your internet activity goes through the ISP, and they route it back to you, using
your IP address. Since they are giving you access to the internet, it is their role to
assign an IP address to your device.
• However, your IP address can change. For example, turning your modem or
router on or off can change it. Or you can contact your ISP, and they can change
it for you.
• When you are out and about – for example, traveling – and you take your device
with you, your home IP address does not come with you. This is because you will
be using another network (Wi-Fi at a hotel, airport, or coffee shop, etc.) to access
the internet and will be using a different (and temporary) IP address, assigned to
you by the ISP of the hotel, airport or coffee shop.
Types of IP addresses
• There are different categories of IP addresses, and within each
category, different types.
• Consumer IP Address.
• Private IP Address.
• Public IP Address.
• Public IP address further divided into two forms.
• Dynamic IP Address.
• Static IP Address.
Consumer IP addresses
• Every individual or business with an internet service plan will have
two types of IP addresses: their private IP addresses and their public
IP address. The terms public and private relate to the network location
— that is, a private IP address is used inside a network, while a public
one is used outside a network.
Private IP addresses
• Every device that connects to your internet network has a private IP
address. This includes computers, smartphones, and tablets but also
any Bluetooth-enabled devices like speakers, printers, or smart TVs.
With the growing internet of things, the number of private IP
addresses you have at home is probably growing. Your router needs a
way to identify these items separately, and many items need a way to
recognize each other. Therefore, your router generates private IP
addresses that are unique identifiers for each device that differentiate
them on the network.
Public IP addresses
• A public IP address is the primary address associated with your whole
network. While each connected device has its own IP address, they are
also included within the main IP address for your network. As
described above, your public IP address is provided to your router by
your ISP. Typically, ISPs have a large pool of IP addresses that they
distribute to their customers. Your public IP address is the address that
all the devices outside your internet network will use to recognize your
network.
Dynamic IP addresses
• Dynamic IP addresses change automatically and regularly. ISPs buy a
large pool of IP addresses and assign them automatically to their
customers. Periodically, they re-assign them and put the older IP
addresses back into the pool to be used for other customers. The
rationale for this approach is to generate cost savings for the ISP.
Automating the regular movement of IP addresses means they don’t
have to carry out specific actions to re-establish a customer's IP
address if they move home, for example. There are security benefits,
too, because a changing IP address makes it harder for criminals to
hack into your network interface.
Static IP addresses
• In contrast to dynamic IP addresses, static addresses remain consistent.
Once the network assigns an IP address, it remains the same. Most
individuals and businesses do not need a static IP address, but for
businesses that plan to host their own server, it is crucial to have one.
This is because a static IP address ensures that websites and email
addresses tied to it will have a consistent IP address.
IPV-4 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.
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). This means that, theoretically,
if there were no restrictions, more than 4 billion devices could be
connected to the Internet. We will see shortly that the actual number is
much less because of the restrictions imposed on the addresses.
Notations
• There are two prevalent notations to show an IPv4 address:
• Binary notation
• 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. 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.
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:
Dotted-Decimal Notation
• Picture 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.
Example
• 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
and add dots for separation.
• a. 129.11.11.239
• b. 193.131.27.255
Example
• 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.
• A. 01101111 00111000 00101101 01001110
• B. 11011101 00100010 00000111 01010010
Example
• 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.
• Addressing
• Network Addresses
• A very important concept in IP addressing is the network
address. 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 address in
the class, however, is normally (not always) treated as a special
address. The first address is called the network address and
defines the organization network. It defines the organization
itself to the rest of the world.
• The organization network is connected to the Internet via a
router. The router has two addresses. One belongs to the
granted block; the other belongs to the network that is at the
other side of the router.
• Network Addressing is one of the major responsibilities of the network layer.
• Network addresses are always logical, i.e., software-based addresses.
• A host is also known as end system that has one link to the network. The boundary
between the host and link is known as an interface. Therefore, the host can have only one
interface.
• A router is different from the host in that it has two or more links that connect to it. When a
router forwards the datagram, then it forwards the packet to one of the links. The
boundary between the router and link is known as an interface, and the router can have
multiple interfaces, one for each of its links. Each interface is capable of sending and
receiving the IP packets, so IP requires each interface to have an address.
• Each IP address is 32 bits long, and they are represented in the form of "dot-decimal
notation" where each byte is written in the decimal form, and they are separated by the
period. An IP address would look like 193.32.216.9 where 193 represents the decimal
notation of first 8 bits of an address, 32 represents the decimal notation of second 8 bits
of an address.
• In the picture, a router has three
interfaces labeled as 1, 2 & 3 and each
router interface contains its own IP
address.
• Each host contains its own interface and
IP address.
• All the interfaces attached to the LAN 1 is
having an IP address in the form of
223.1.1.xxx, and the interfaces attached
to the LAN 2 and LAN 3 have an IP
address in the form of 223.1.2.xxx and
223.1.3.xxx respectively.
• Each IP address consists of two parts.
The first part (first three bytes in IP
address) specifies the network and
second part (last byte of an IP address)
specifies the host in the network.
IP Addressing
• There are two types of IP address.
• IPv4 & IPv6
• IPv4 addressing, used the concept of classes. This architecture is
called class-full addressing.
• In class-full addressing, the address space is divided into five classes:
A, B, C, D, and E. Each class occupies some part of the address space.
Class-full Addressing
• We can find the class of an
address when given the address
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. If
the address is given in decimal-
dotted notation, the first byte
defines the class.
Example
• 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 (between 0 and 127); the class is A.
• d. The first byte is 252 (between 240 and 255); the class is E.
• The classfull addressing concepts
divide the address space into a
fixed number of blocks and each
block has a fixed number of
hosts. In IPv4 addresses of class
A, B & C the first part of the
address is considered as net-id
(Network id) and the second part
of the address is called host-id.
The size of these parts varies
with the classes.
• Net-id: The net-id denotes the address of the network.
Host-id: The hoist-id denotes the address of the host attached to the
corresponding network.
• In Class A, the net-id is defined by the first byte of the address. And
the rest 3 bytes defines the host-id.
In Class B, the first two bytes of the address defines the network
address and the rest two bytes defines the host-id.
In Class C the first three bytes defines the network address and
the last byte defines the host-id.
Class A
• In a class A address, the first bit of
the first octet is always ‘0’. Thus,
class A addresses range from
0.0.0.0 to 127.255.255.255(as
01111111 in binary converts to 127
in decimal). The first 8 bits or the
first octet denote the network
portion and the rest 24 bits or the 3
octets belong to the host portion.
• Therefore, the actual range of class
A addresses is: 1.0.0.0 to
126.255.255.255
Class B
• In a class B address, the first
octet would always start with
’10’. Thus, class B addresses
range from 128.0.0.0 to
191.255.255.255. The first 16
bits or the first two octets denote
the network portion and the
remaining 16 bits or two octets
belong to the host portion.
Class C
• In a class C address, the first
octet would always start with
‘110’. Thus, class C addresses
range from 192.0.0.0 to
223.255.255.255. The first 24
bits or the first three octets
denote the network portion and
the rest 8 bits or the remaining
one octet belong to the host
portion.
Class D
• Class D is used for multicast
addressing and in a class D
address the first octet would
always start with ‘1110’. Thus,
class D addresses range from
224.0.0.0 to 239.255.255.255.