Class notes
Class notes
NETWORK LAYER
Network Layer:
The network Layer is the third layer in the OSI model of computer
networks. Its main function is to transfer network packets from the
source to the destination. It involves both the source host and the
destination host.
Key among these services are packetizing, routing, and forwarding.
Packetizing involves encapsulating data into packets suitable for
transmission. Routing determines the optimal path for these packets
through the network, ensuring they navigate through multiple nodes
and networks efficiently. Forwarding is the process of directing these
packets to their next hop along the selected path.
In this article, we will discuss these topics in detail, along with the
services provided by the network layer, etc.
Network:
1. Packetizing
The process of encapsulating the data received from the upper layers of
the network (also called payload) in a network layer packet at the source
and encapsulating the payload from the network layer packet at the
destination is known as packetizing.
The source host adds a header that contains the source and destination
address and some other relevant information required by the network
layer protocol to the payload received from the upper layer protocol and
delivers the packet to the data link layer.
The destination host receives the network layer packet from its data link
layer, encapsulates the packet, and delivers the payload to the
corresponding upper layer protocol. The routers in the path are not
allowed to change either the source or the destination address. The
routers in the path are not allowed to encapsulate the packets they
receive unless they need to be fragmented.
Packetizing
2. Routing
Routing is the process of moving data from one device to another device.
These are two other services offered by the network layer. In a network,
there are a number of routes available from the source to the
destination. The network layer specifies 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.
Routing
3. Forwarding
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 the case of multicast routing). Routers are used on the
network for forwarding a packet from the local network to the remote
network. So, the process of routing involves packet forwarding from an
entry interface out to an exit interface.
Forwarding
Forwarding is simply
defined as the action applied
Routing is the process of moving data from
by each router when a
one device to another device.
packet arrives at one of its
interfaces.
1. Error Control
Although it can be implemented in the network layer, it is usually not
preferred because the data packet in a network layer may be fragmented
at each router, which makes error-checking inefficient in the network
layer.
2. Flow Control
It regulates the amount of data a source can send without overloading
the receiver. If the source produces data at a very faster rate than the
receiver can consume it, the receiver will be overloaded with data. To
control the flow of data, the receiver should send feedback to the sender
to inform the latter that it is overloaded with data.
There is a lack of flow control in the design of the network layer. It does
not directly provide any flow control. The datagrams are sent by the
sender when they are ready, without any attention to the readiness of
the receiver.
3. Congestion Control
Congestion occurs when the number of datagrams sent by the source is
beyond the capacity of the network or routers. This is another issue in
the network layer protocol. If congestion continues, sometimes a
situation may arrive where the system collapses and no datagrams are
delivered. Although congestion control is indirectly implemented in the
network layer, still there is a lack of congestion control in the network
layer.
Routing:
Routing refers to the process of directing a data packet from one node to
another. It is an autonomous process handled by the network devices to
direct a data packet to its intended destination. Note that, the node here
refers to a network device called - 'Router'.
Routing is a crucial mechanism that transmits data from one location to
another across a network (Network type could be any like LAN, WAN, or
MAN). The process of routing involves making various routing decisions
to ensure reliable & efficient delivery of the data packet by finding the
shortest path using various routing metrics
Types of Routing
1. Static Routing
Static routing is also called as "non-adaptive routing". In this, routing
configuration is done manually by the network administrator. Let's say
for example, we have 5 different routes to transmit data from one node
to another, so the network administrator will have to manually enter the
routing information by assessing all the routes.
A network administrator has full control over the network, routing
the data packets to their concerned destinations
Routers will route packets to the destination configured manually by
the network administrator.
Although this type of routing gives fine-grained control over the
routes, it may not be suitable for large-scale enterprise networks.
2. Dynamic Routing
Dynamic Routing is another type of routing in which routing is an
autonomous procedure without any human intervention. Packets are
transmitted over a network using various shortest-path algorithms and
pre-determined metrics. This type of routing is majorly preferred in
modern networks as it offers more flexibility and versatile functionality.
It is also known as adaptive routing.
In this, the router adds new routes to the routing table based on any
changes made in the topology of the network.
The autonomous procedure of routing helps in automating every
routing operation from adding to removing a route upon updates or
any changes made to the network.
3. Default Routing
Default Routing is a routing technique in which a router is configured to
transmit packets to a default route that is, a gateway or next-hop device
if no specific path is defined or found. It is commonly used when the
network has a single exit point. The IP Router has the following address
as the default route: 0.0.0.0/0.
Routing Protocols
Routing protocols are essential for determining how data packets are
transferred across networks. They help routers communicate with each
other to find the most efficient paths for data to travel.
IGP and EGP Routing Protocols
Advantages
Simple to Use: Easy setup and operation.
Low Resource Usage: Requires minimal CPU and memory.
Automatic Updates: Handles network changes automatically.
Good for Small Networks: Works well in simple setups.
Disadvantages
Slow Convergence: Takes time to update routes after a network
change.
Limited Scalability: Not efficient for large networks.
High Bandwidth Use: Frequent updates may consume more
network bandwidth.
Less Accurate: Routes may not always be optimal.
Advantages
Faster Updates: Quickly adapts to network changes.
Accurate Routing: Provides optimal routes with a complete
network view.
Works for Large Networks: Suitable for big, complex networks.
Prevents Routing Loops: Avoids errors in route calculations.
More Reliable: Less prone to mistakes in routing.
Disadvanatges
High Resource Usage: Requires more memory and processing
power.
Complex Setup: More difficult to configure and maintain.
Increased Bandwidth: Uses more bandwidth for network updates.
Not Ideal for Small Networks: Overhead is unnecessary in small
setups.
3. Hybrid Protocol
It is also known as hybrid routing protocol which uses the concept of
both distance vector and link-state routing protocol. Enhanced Interior
Gateway Routing Protocol (EIGRP) is an example of this class of routing
protocol. EIGRP acts as a link-state routing protocol as it uses the
concept of Hello protocol for neighbor discovery and forming an
adjacency. Also, partial updates are triggered when a change occurs.
EIGRP acts as a distance-vector routing protocol as it learned routes
from directly connected neighbors.
Advanatages
Combines Strengths: Mixes benefits of distance vector and link
state routing.
Scalable: Works well in both small and large networks.
Quick Updates: Adapts fast to network changes.
Efficient Bandwidth: Uses less bandwidth than pure link state.
Better for Larger Networks: More suitable for bigger networks.
Disadvanatges
Complex Setup: Harder to configure and manage.
Higher Resource Use: Requires more memory and CPU.
Inconsistent Updates: Can sometimes lead to slower updates.
Virtual Circuit:
Virtual Circuit is the computer network providing connection-oriented
service. It is a connection-oriented network. In virtual circuit resource
are reserve for the time interval of data transmission between two
nodes. This network is a highly reliable medium of transfer. Virtual
circuits are costly to implement.
Datagram Networks
It is a connection-less service. There is no need for reservation of
resources as there is no dedicated path for a connection session.
All packets are free to use any available path. As a result,
intermediate routers calculate routes on the go due to dynamically
changing routing tables on routers.
Since every packet is free to choose any path, all packets must be
associated with a header with proper information about the source
and the upper layer data.
The connection-less property makes data packets reach the
destination in any order, which means that they can potentially be
received out of order at the receiver’s end.
Datagram networks are not as reliable as Virtual Circuits.
The major drawback of Datagram Packet switching is that a packet
can only be forwarded if resources such as the buffer, CPU, and
bandwidth are available. Otherwise, the packet will be discarded.
But it is always easy and cost-efficient to implement datagram
networks as there is no extra headache of reserving resources and
making a dedicated each time an application has to communicate.
It is generally used by the IP network, which is used for Data services
like the Internet.
Routing Algorithms
The main function of NL (Network Layer) is routing packets from
the source machine to the destination machine.
There are two processes inside router:
a) One of them handles each packet as it arrives, looking up the
outgoing line to use for it in the routing table. This process is
forwarding.
b) The other process is responsible for filling in and updating the
routing tables. That is where the routing algorithm comes
into play. This process is routing.
Initialization
Each node can know only the distance between itself and its
immediate neighbours, those directly connected to it. So for the
moment, we assume that each node can send a message to the
immediate neighbours and find the distance between itself and
these neighbours. Below fig shows the initial tables for each
node. The distance for any entry that is not a neighbour is
marked as infinite (unreachable).
Initialization of tables in distance vector routing
Sharing
The whole idea of distance vector routing is the sharing of
information between neighbours. Although node A does not
know about node E, node C does. So if node C shares its routing
table with A, node A can also know how to reach node E. On the
other hand, node C does not know how to reach node D, but
node A does. If node A shares its routing table with node C, node
C also knows how to reach node D. In other words, nodes A and
C, as immediate neighbors, can improve their routing tables if
they help each other.
NOTE: In distance vector routing, each node shares its routing
table with its immediate neighbors periodically and when there
is a change
Updating
When a node receives a two-column table from a neighbour, it
needs to update its routing table. Updating takes three steps:
1. The receiving node needs to add the cost between itself and
the sending node to each value in the second column. (x+y)
2. If the receiving node uses information from any row. The
sending node is the next node in the route.
3. The receiving node needs to compare each row of its old table
with the corresponding row of the modified version of the
received table.
a. If the next-node entry is different, the receiving node
chooses the row with the smaller cost. If there is a tie, the
old one is kept.
b. If the next-node entry is the same, the receiving node chooses
the new row.
Final Diagram
Link State Routing
Link state routing is based on the assumption that, although the
global knowledge about the topology is not clear, each node has
partial knowledge: it knows the state (type, condition, and cost) of
its links. In other words, the whole topology can be
compiled from the partial knowledge of each node
Initialization
Initial routing tables in path vector routing
Hierarchical Routing
As networks grow in size, the router routing tables grow
proportionally. Not only is router memory consumed by ever-
increasing tables, but more CPU time is needed to scan them
and more bandwidth is needed to send status reports about
them.
At a certain point, the network may grow to the point where it is
no longer feasible for every router to have an entry for every
other router, so the routing will have to be done hierarchically,
as it is in the telephone network.
When hierarchical routing is used, the routers are divided into
what we will call regions. Each router knows all the details about
how to route packets to destinations within its own region but
knows nothing about the internal structure of other regions.
For huge networks, a two-level hierarchy may be insufficient; it
may be necessary to group the regions into clusters, the clusters
into zones, the zones into groups, and so on, until we run out of
names for aggregations
Warning Bit
1. A special bit in the packet header is set by the router to warn
the source when congestion is detected.
2. The bit is copied and piggy-backed on the ACK and sent to the
sender.
3. The sender monitors the number of ACK packets it receives
with the warning bit set and adjusts its transmission rate
accordingly.
Choke Packets
1. A more direct way of telling the source to slow down.
2. A choke packet is a control packet generated at a
congested node and transmitted to restrict traffic flow.
3. The source, on receiving the choke packet must reduce its
transmission rate by a certain percentage.
4. An example of a choke packet is the
ICMP Source Quench Packet. Hop-by-
Hop Choke Packets
1. Over long distances or at high speeds choke packets are not very
effective.
2. A more efficient method is to send to choke packets hop-by-hop.
3. This requires each hop to reduce its transmission even
before the choke packet arrive at the source
Load Shedding
1. When buffers become full, routers simply discard packets.
2. Which packet is chosen to be the victim depends on the
application and on the error strategy used in the data
link layer.
3. For a file transfer, for, e.g. cannot discard older packets
since this will cause a gap in the received data.
4. For real-time voice or video it is probably better to throw
away old data and keep new packets.
5. Get the application to mark packets with discard priority.
Random Early Discard (RED)
1. This is a proactive approach in which the router discards one
or more packets before the buffer becomes completely full.
2. Each time a packet arrives, the RED algorithm computes the
average queue length, avg.
3. If avg is lower than some lower threshold, congestion is
assumed to be minimal or non- existent and the packet is
queued.
4. If avg is greater than some upper threshold, congestion is
assumed to be serious and the packet is discarded.
5. If avg is between the two thresholds, this might indicate
the onset of congestion. The probability of congestion is then
calculated.
Traffic Shaping
1. Another method of congestion control is to “shape” the traffic
before it enters the
network.
2. Traffic shaping controls the rate at which packets are sent
(not just how many). Used in ATM and Integrated Services
networks.
3. At connection set-up time, the sender and carrier negotiate a traffic
pattern (shape).