CN Unit 3
CN Unit 3
Layer
Unit 3
Network Layer
• Network layer is the 3rd layer in the OSI model of computer
networks.
• It’s main function is to transfer network packets from the
source to the destination.
• Packets: All data sent over the Internet is broken down into
smaller chunks called "packets."
Cont..
• At the source, it accepts a packet from the transport
layer, encapsulates it in a datagram and then deliver the
packet to the data link layer so that it can further be
sent to the receiver.
• At the destination, the datagram is decapsulated, the
packet is extracted and delivered to the corresponding
transport layer.
• 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.
Cont..
Network Layer Functionalities:
• Routing: Devices which work on Network Layer mainly focus
on routing. Routing may include various tasks. (Network routing is
the process of selecting a path across one or more networks.)
• Logical Addressing: 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.
Network layer services
• The services which are offered by the network layer protocol are as
follows:
1.Packetizing
2. Routing and Forwarding
1.Packetizing
The process of encapsulating the data received from upper layers
of the network(also called as payload) in a network layer packet at the
source and decapsulating the payload from the network layer packet at
the destination is known as packetizing.
Cont..
2. Routing
• The network layer specifies has some strategies which find out the
best possible route. This process is referred to as routing.
• There are a number of routing protocols that are used in this process
and they should be run to help the routers coordinate with each
other and help in establishing communication throughout the
network.
3. Forwarding is simply defined as the action applied by each router
when a packet arrives at one of its interfaces.
• When a router receives a packet from one of its attached networks, it
needs to forward the packet to another attached network (unicast
routing) or to some attached networks(in case of multicast routing).
Packet Switching
• Packet switching is the transfer of small pieces of data
across various networks.
• These data chunks or “packets” allow for faster, more
efficient data transfer.
• 2 Types of Packet Switching
• 1. Datagram approach (Connectionless Packet
Switching)
• 2. Virtual Circuit approach (Connection-oriented
Packet Switching)
Cont..
Datagram approach (Connectionless Packet Switching)
• Each packet is independent
• Each packet contains all necessary addressing information such as
source address, destination address and port numbers, etc.
• Packets belonging to one flow may take different routes because
routing decisions are made dynamically, so the packets arrived at the
destination might be out of order. It has no connection setup.
R1 R2
R4
R3
R5
Cont..
Virtual Circuit approach (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.
• Virtual Circuit ID 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 numbers.
Cont..
Cont..
• Overall, three phases take place here-
• The setup (All address information is only transferred during the
setup phase)
• Data transfer and
• Tear down phase. (Disconnect the connection) virtual circuit identifier (VCI)
Port No 1,2,3
Cont..
Setup The destination sends an acknowledgment
to switch 3. The frame also carries VCI 77
Setup -
Acknowledgement
Network Layer Performance
The characteristics that measure the performance of a
network are :
• Bandwidth
• Throughput
• Latency (Delay)
• Packet Loss
• Jitter
Cont..
BANDWIDTH
• One of the most essential conditions of a website’s performance is
the amount of bandwidth allocated to the network.
• Bandwidth determines how rapidly the webserver is able to upload
the requested information.
• Bandwidth is characterized as the measure of data or information
that can be transmitted in a fixed measure of time.
• In the case of digital devices, the bandwidth is measured in bits per
second(bps) or bytes per second. In the case of analogue devices, the
bandwidth is measured in cycles per second, or Hertz (Hz).
Cont..
THROUGHPUT
• Throughput is the number of messages successfully transmitted per unit time.
• Bandwidth is the potential measurement of a link, whereas throughput is an actual
measurement of how fast we can send data.
• Throughput is measured by tabulating the amount of data transferred between
multiple locations during a specific period of time, usually resulting in the unit of bits
per second(bps), which has evolved to bytes per second(Bps), kilobytes per
second(KBps), megabytes per second(MBps) and gigabytes per second(GBps).
Cont..
LATENCY
• In a network, during the process of data communication, latency(also
known as delay) is defined as the total time taken for a complete message
to arrive at the destination,
• Latency=Propagation time+Transmission time+Queuing time+Processing
delay
• Eg:
• Propagation time: The first bit of the message reach to designation (B)
• Transmission time: Transmission delay is the time needed to push all the packet
bits on the transmission link.
• Queuing time: Between A and B various network devices also connected the delay
time in each device.
• Processing delay: It refers to the time taken by a router or switch to process a
packet of data before forwarding it to next node in the network.
• The network connections where small delays occur are called “Low-
Latency-Networks” and the network connections which suffer from long
delays are known as “High-Latency-Networks”.
Cont..
JITTER
• Jitter is another performance issue related to delay. In technical
terms, jitter is a “packet delay variance”.
• It can simply mean that jitter is considered as a problem when
different packets of data face different delays in a network and the
data at the receiver application is time-sensitive, i.e. audio or video
data.
• Eg: P1 (Video) and P2 (Audio), First packet P1 will reach to designation after
few seconds second packet P1 will reach to designation. So synchronization
problem occurs
• Jitter is measured in milliseconds(ms).
Cont..
• In the image, it can be noticed that the time it takes for packets to be
sent is not the same as the time in which he will arrive at the receiver
side. One of the packets faces an unexpected delay on its way and is
received after the expected time. This is jitter.
IPv4 Addresses
• IP stands for Internet Protocol and v4 stands for Version Four (IPv4).
• IPv4 was the primary version brought into action for production
within the ARPANET in 1983. (Advanced Research Projects Agency Network (ARPANET))
• IPv4 addresses are 32 bit-addresses and are divided into 4 octets(1
octet = 8 bits). They are usually represented in dotted decimals, but
binary representation is another way to represent them.
• Example- 192.168.1.152 could be an IPv4 address.
Octet=Range 0 to 255
Convert in to Binary
Number
11000000.10101000.00000001.10011000
Cont..
Cont..
• The IPv4 address works on the network layer which is responsible for
the transmission of data in the form of packets.
• IPv4 uses a 32-bit address space which provides 4,294,967,296 (232)
unique addresses, but large blocks are reserved for particular
networking purposes.
Different Types of Addressing Modes
In IPV4, Host can communicate one in 3 different ways
• Unicast addressing mode
• Broadcast addressing mode
• Multicast addressing mode
Cont..
Unicast addressing mode :
• As the name suggests, the data is
sent to only a single host(uni=one).
There is one source and one
Destination(receiver).
• Unicast addresses represent a
single LAN interface. A unicast
frame will be sent to a specific
device, not to a group of devices
on the LAN
Cont..
Broadcast addressing mode :
• In broadcast addressing mode, the data is sent to all the devices in
the network, i.e., multiple hosts.
• The destination address field of the packet consists of the IP address
called the Special Broadcast address which is represented by
255.255.255.255.
• The client then sends the packet
which is received by all other servers
on the network.
Cont..
Multicast addressing mode :
• In multicasting addressing mode, there is one source
and a group of destinations.
• The relationship between the source and the
destination is one too many. The destination address
consists of a special address starting with 224.x.x.x
• The class D addresses
(224.0.0.0 to 239.255.255.255) define the multicast
group.
Cont.. Netid is also called as prefix
Parts of IPv4 Hostid is also called as suffix
Class A (8 bits)
Here, each class has a fixed Class B (16 bits)
number of hostid and netid. Class C (24 bits)
Network part :
• The network part is also known
as net id which is used to classify
the network to which the host is
connected.
Host part :
• The host part is also known as
the host id which is the part of
the IP address which is used to
uniquely identify the host on a
network.
Network layer protocol: Internet Protocol(IP)
• The Internet Protocol
(IP) is a protocol, or
set of rules, for
routing and
addressing packets of
data so that they can
travel across networks
and arrive at the
correct destination.
• It is unreliable
datagram
protocol(post office)
Cont..
1. Version-
• Version is a 4 bit field that indicates the IP version used.
• The most popularly used IP versions are version-4 (IPv4) and version-6
(IPv6).
• Only IPv4 uses the above header.
• So, this field always contains the decimal value 4.
2. Header Length-
• Header length is a 4 bit field that contains the length of the IP header.
• It helps in knowing from where the actual data begins.
Cont..
3. Type Of Service-
• Type of service is a 8 bit field that is used for Quality of Service (QoS).
• TOS field categories different priorities of data, so that a network
device could process important data first and less important after
that.
Eg: 000 (0) – Routine, 001 (1) – Priority, 010 (2) – Immediate, etc
4. Total Length-
• Total length is a 16 bit field that contains the total length of the
datagram (in bytes).
Total length = Header length + Payload length
Cont..
5. Identification-
• Identification is a 16 bit field.
• It is used for the identification of the fragments of an original IP
datagram.
When an IP datagram is fragmented,
• Each fragmented datagram is assigned the same identification
number.
• This number is useful during the re-assembly of fragmented
datagrams.
• It helps to identify to which IP datagram, the fragmented datagram
belongs to.
Cont..
6. DF Bit-
• DF bit stands for Do Not Fragment bit.
• Its value may be 0 or 1.
When DF bit is set to 0,
• It grants the permission to the intermediate devices to fragment the datagram if
required.
When DF bit is set to 1,
• It indicates the intermediate devices not to fragment the IP datagram at any cost.
• If network requires the datagram to be fragmented to travel further but settings
does not allow its fragmentation, then it is discarded.
• An error message is sent to the sender saying that the datagram has been
discarded due to its settings.
Cont..
7. MF Bit-
• MF bit stands for More Fragments bit.
• Its value may be 0 or 1.
When MF bit is set to 0,
• It indicates to the receiver that the current datagram is either the last
fragment in the set or that it is the only fragment.
When MF bit is set to 1,
• It indicates to the receiver that the current datagram is a fragment of
some larger datagram.
• MF bit is set to 1 on all the fragments except the last one.
Cont..
8. Fragment Offset-
• Fragment Offset is a 13 bit field.
• It indicates the position of a fragmented datagram in the original
unfragmented IP datagram.
• The first fragmented datagram has a fragment offset of zero.
2. Non-Adaptive Algorithms –
These are the algorithms that do not change their routing
decisions once they have been selected.
Cont..
Adaptive Algorithms
• Isolated – During this technique, every node makes its routing
choices.
• It is an algorithm that obtains the routing information by using local
information rather than gathering information from other nodes.
• Centralized algorithm: It is also known as global routing algorithm as
it computes the least-cost path between source and destination by
using complete and global knowledge about the network.
• Distributed – During this technique, the node collects data from its
neighbors and then takes the choice concerning routing the packets.
Cont..
Non-Adaptive Algorithms
• Flooding: All the incoming packets will be transmitted to all outgoing
links
• Disadvantage: Multiple copies of packets
• Random walks: In case of random walks, a packet sent by the node to
one of its neighbors randomly.
• An advantage of using random walks is that it uses the alternative
routes very efficiently.
Cont..
Shortest Path Routing Algorithm:
• To Find the shortest path between a given pair of routes
• Dijkstra’s Shortest Path Algorithm
• A basic introduction to Graphs
• Graphs are pictorial representations of connections between pairs of elements. The
graphs in our case represent a network topology.
We have three types of graphs:
1.Undirected: You can move using the edges towards any direction.(without
arrows)
2.Directed: The direction you can move is specified and shown using arrows.
3.Weighted: The edges of weighted graphs denote a certain metric like
distance, time taken to move using the edges, etc.
Cont..
Cont..
{0}
We check the distances 0 -> 1 and 0 -> 2, which are 2 and 6,
respectively. We first update the distances from nodes 1 and 2 in the
table.
Cont..
Shortest path=0→1→3→4→6
Unicast Routing Protocols
Unicast – Unicast means the transmission from a single sender to a
single receiver.
There are two kinds of routing protocols available to route unicast
packets:
• Distance Vector Routing Protocol
• Link State Routing Protocol
Distance Vector Routing Protocol
• Distance Vector is simple routing protocol which takes routing
decision on the number of hops between source and destination.
• A route with less number of hops is considered as the best route.
• Ultimately, all routers build up their network topology based on the
advertisements of their peer routers
• For example Routing Information Protocol (RIP).
Cont..
Link State Routing Protocol
• Link State protocol is slightly complicated protocol than Distance
Vector.
• It takes into account the statuses of links of all the routers in a
network.
• This technique helps routes build a common graph of the entire
network.
• All routers then calculate their best path for routing purposes.
• for example, Open Shortest Path First (OSPF) and Intermediate
System to Intermediate System (ISIS).
Cont..
OSPF Messages – OSPF is a very complex protocol. It uses five different types of
messages. These are as follows:
1.Hello message (Type 1) – It is used by the routers to introduce themselves to the
other routers.
4.Link-state update message (Type 4) – It is the main OSPF message for building
Link-State Database.