0% found this document useful (0 votes)
20 views29 pages

Network Layer

The document discusses the network layer of the OSI model. It describes the main functions of the network layer including routing, logical addressing, internetworking and fragmentation. It also discusses network addressing, classful addressing and the different address classes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views29 pages

Network Layer

The document discusses the network layer of the OSI model. It describes the main functions of the network layer including routing, logical addressing, internetworking and fragmentation. It also discusses network addressing, classful addressing and the different address classes.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Network Layer

o The Network Layer is the third layer of the OSI model.


o It handles the service requests from the transport layer and further forwards the service
request to the data link layer.
o The network layer translates the logical addresses into physical addresses
o 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.
o 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:

o 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.
o 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.
o Internetworking: This is the main role of the network layer that it provides the logical
connection between different types of networks.
o 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

o Guaranteed delivery: This layer provides the service which guarantees that the packet will
arrive at its destination.
o Guaranteed delivery with bounded delay: This service guarantees that the packet will be
delivered within a specified host-to-host delay bound.
o In-Order packets: This service ensures that the packet arrives at the destination in the
order in which they are sent.
o 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.
o 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.

Network Addressing
o Network Addressing is one of the major responsibilities of the network layer.
o Network addresses are always logical, i.e., software-based addresses.
o 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.
o 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.
o 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.

· Let's understand through a simple example.

o In the above figure, a router has three interfaces labeled as 1, 2 & 3 and each router
interface contains its own IP address.
o Each host contains its own interface and IP address.
o 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.
o 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.

Classful Addressing
An IP address is 32-bit long. An IP address is divided into sub-classes:

o Class A
o Class B
o Class C
o Class D
o Class E

An ip address is divided into two parts:

o Network ID: It represents the number of networks.


o Host ID: It represents the number of hosts.

In the above diagram, we observe that each class have a specific range of IP addresses. The class of
IP address is used to determine the number of bits used in a class and number of networks and
hosts available in the class.

Class A

In Class A, an IP address is assigned to those networks that contain a large number of hosts.

o The network ID is 8 bits long.


o The host ID is 24 bits long.

In Class A, the first bit in higher order bits of the first octet is always set to 0 and the remaining 7
bits determine the network ID. The 24 bits determine the host ID in any network.

The total number of networks in Class A = 27 = 128 network address

The total number of hosts in Class A = 224 - 2 = 16,777,214 host address

Class B
In Class B, an IP address is assigned to those networks that range from small-sized to large-sized
networks.

o The Network ID is 16 bits long.


o The Host ID is 16 bits long.

In Class B, the higher order bits of the first octet is always set to 10, and the remaining14 bits
determine the network ID. The other 16 bits determine the Host ID.

The total number of networks in Class B = 214 = 16384 network address

The total number of hosts in Class B = 216 - 2 = 65534 host address

Class C

In Class C, an IP address is assigned to only small-sized networks.

o The Network ID is 24 bits long.


o The host ID is 8 bits long.

In Class C, the higher order bits of the first octet is always set to 110, and the remaining 21 bits
determine the network ID. The 8 bits of the host ID determine the host in a network.

The total number of networks = 221 = 2097152 network address

The total number of hosts = 28 - 2 = 254 host address

Class D
In Class D, an IP address is reserved for multicast addresses. It does not possess subnetting. The
higher order bits of the first octet is always set to 1110, and the remaining bits determines the host
ID in any network.

Class E
In Class E, an IP address is used for the future use or for the research and development purposes. It
does not possess any subnetting. The higher order bits of the first octet is always set to 1111, and
the remaining bits determines the host ID in any network.

Rules for assigning Host ID:


The Host ID is used to determine the host within any network. The Host ID is assigned based on
the following rules:

o The Host ID must be unique within any network.


o The Host ID in which all the bits are set to 0 cannot be assigned as it is used to represent
the network ID of the IP address.
o The Host ID in which all the bits are set to 1 cannot be assigned as it is reserved for the
multicast address.

Rules for assigning Network ID:


If the hosts are located within the same local network, then they are assigned with the same
network ID. The following are the rules for assigning Network ID:

o The network ID cannot start with 127 as 127 is used by Class A.


o The Network ID in which all the bits are set to 0 cannot be assigned as it is used to specify
a particular host on the local network.
o The Network ID in which all the bits are set to 1 cannot be assigned as it is reserved for
the multicast address.

Classful Network Architecture

Clas Higher NET HOST No.of No.of Range


s bits ID ID networks hosts
bits bits per
network

A 0 8 24 27 224 0.0.0.0 to
127.255.255.255

B 10 16 16 214 216 128.0.0.0 to


191.255.255.255
C 110 24 8 221 28 192.0.0.0 to
223.255.255.255

D 1110 Not Not Not Not 224.0.0.0 to


Defined Defined Defined Defined 239.255.255.255

E 1111 Not Not Not Not 240.0.0.0 to


Defined Defined Defined Defined 255.255.255.255

Routing
o A Router is a process of selecting path along which the data can be transferred from
source to the destination. Routing is performed by a special device known as a router.
o A Router works at the network layer in the OSI model and internet layer in TCP/IP model
o A router is a networking device that forwards the packet based on the information
available in the packet header and forwarding table.
o The routing algorithms are used for routing the packets. The routing algorithm is nothing
but a software responsible for deciding the optimal path through which packet can be
transmitted.
o The routing protocols use the metric to determine the best path for the packet delivery.
The metric is the standard of measurement such as hop count, bandwidth, delay, current
load on the path, etc. used by the routing algorithm to determine the optimal path to the
destination.
o The routing algorithm initializes and maintains the routing table for the process of path
determination.

Routing Metrics and Costs


Routing metrics and costs are used for determining the best route to the destination. The factors
used by the protocols to determine the shortest path, these factors are known as a metric.

Metrics are the network variables used to determine the best route to the destination. For some
protocols use the static metrics means that their value cannot be changed and for some other
routing protocols use the dynamic metrics means that their value can be assigned by the system
administrator.

The most common metric values are given below:

o Hop count: Hop count is defined as a metric that specifies the number of passes through
internetworking devices such as a router, a packet must travel in a route to move from
source to the destination. If the routing protocol considers the hop as a primary metric
value, then the path with the least hop count will be considered as the best path to move
from source to the destination.
o Delay: It is a time taken by the router to process, queue and transmit a datagram to an
interface. The protocols use this metric to determine the delay values for all the links along
the path end-to-end. The path having the lowest delay value will be considered as the
best path.
o Bandwidth: The capacity of the link is known as a bandwidth of the link. The bandwidth is
measured in terms of bits per second. The link that has a higher transfer rate like gigabit is
preferred over the link that has the lower capacity like 56 kb. The protocol will determine
the bandwidth capacity for all the links along the path, and the overall higher bandwidth
will be considered as the best route.
o Load: Load refers to the degree to which the network resource such as a router or
network link is busy. A Load can be calculated in a variety of ways such as CPU utilization,
packets processed per second. If the traffic increases, then the load value will also be
increased. The load value changes with respect to the change in the traffic.
o Reliability: Reliability is a metric factor may be composed of a fixed value. It depends on
the network links, and its value is measured dynamically. Some networks go down more
often than others. After network failure, some network links repaired more easily than
other network links. Any reliability factor can be considered for the assignment of
reliability ratings, which are generally numeric values assigned by the system
administrator.

Types of Routing
Routing can be classified into three categories:

o Static Routing
o Default Routing
o Dynamic Routing

Static Routing

o Static Routing is also known as Nonadaptive Routing.


o It is a technique in which the administrator manually adds the routes in a routing table.
o A Router can send the packets for the destination along the route defined by the
administrator.
o In this technique, routing decisions are not made based on the condition or topology of
the networks
Advantages Of Static Routing

Following are the advantages of Static Routing:

o No Overhead: It has ho overhead on the CPU usage of the router. Therefore, the cheaper
router can be used to obtain static routing.
o Bandwidth: It has not bandwidth usage between the routers.
o Security: It provides security as the system administrator is allowed only to have control
over the routing to a particular network.

Disadvantages of Static Routing:

Following are the disadvantages of Static Routing:

o For a large network, it becomes a very difficult task to add each route manually to the
routing table.
o The system administrator should have a good knowledge of a topology as he has to add
each route manually.

Default Routing

o Default Routing is a technique in which a router is configured to send all the packets to
the same hop device, and it doesn't matter whether it belongs to a particular network or
not. A Packet is transmitted to the device for which it is configured in default routing.
o Default Routing is used when networks deal with the single exit point.
o It is also useful when the bulk of transmission networks have to transmit the data to the
same hp device.
o When a specific route is mentioned in the routing table, the router will choose the specific
route rather than the default route. The default route is chosen only when a specific route
is not mentioned in the routing table.

Dynamic Routing

o It is also known as Adaptive Routing.


o It is a technique in which a router adds a new route in the routing table for each packet in
response to the changes in the condition or topology of the network.
o Dynamic protocols are used to discover the new routes to reach the destination.
o In Dynamic Routing, RIP and OSPF are the protocols used to discover the new routes.
o If any route goes down, then the automatic adjustment will be made to reach the
destination.

The Dynamic protocol should have the following features:

o All the routers must have the same dynamic routing protocol in order to exchange the
routes.
o If the router discovers any change in the condition or topology, then router broadcast this
information to all other routers.
Advantages of Dynamic Routing:

o It is easier to configure.
o It is more effective in selecting the best route in response to the changes in the condition
or topology.

Disadvantages of Dynamic Routing:

o It is more expensive in terms of CPU and bandwidth usage.


o It is less secure as compared to default and static routing.

Network Layer Protocols


TCP/IP supports the following protocols:

ARP

o ARP stands for Address Resolution Protocol.


o It is used to associate an IP address with the MAC address.
o Each device on the network is recognized by the MAC address imprinted on the NIC.
Therefore, we can say that devices need the MAC address for communication on a local
area network. MAC address can be changed easily. For example, if the NIC on a particular
machine fails, the MAC address changes but IP address does not change. ARP is used to
find the MAC address of the node when an internet address is known.

Note: MAC address: The MAC address is used to identify the actual device.
IP address: It is an address used to locate a device on the network.

How ARP works


If the host wants to know the physical address of another host on its network, then it sends an ARP
query packet that includes the IP address and broadcast it over the network. Every host on the
network receives and processes the ARP packet, but only the intended recipient recognizes the IP
address and sends back the physical address. The host holding the datagram adds the physical
address to the cache memory and to the datagram header, then sends back to the sender.
Steps taken by ARP protocol
If a device wants to communicate with another device, the following steps are taken by the device:

o The device will first look at its internet list, called the ARP cache to check whether an IP
address contains a matching MAC address or not. It will check the ARP cache in command
prompt by using a command arp-a.

o If ARP cache is empty, then device broadcast the message to the entire network asking
each device for a matching MAC address.
o The device that has the matching IP address will then respond back to the sender with its
MAC address
o Once the MAC address is received by the device, then the communication can take place
between two devices.
o If the device receives the MAC address, then the MAC address gets stored in the ARP
cache. We can check the ARP cache in command prompt by using a command arp -a.

Note: ARP cache is used to make a network more efficient.

In the above screenshot, we observe the association of IP address to the MAC address.

There are two types of ARP entries:

o Dynamic entry: It is an entry which is created automatically when the sender broadcast its
message to the entire network. Dynamic entries are not permanent, and they are removed
periodically.
o Static entry: It is an entry where someone manually enters the IP to MAC address
association by using the ARP command utility.

RARP

o RARP stands for Reverse Address Resolution Protocol.


o If the host wants to know its IP address, then it broadcast the RARP query packet that
contains its physical address to the entire network. A RARP server on the network
recognizes the RARP packet and responds back with the host IP address.
o The protocol which is used to obtain the IP address from a server is known as Reverse
Address Resolution Protocol.
o The message format of the RARP protocol is similar to the ARP protocol.
o Like ARP frame, RARP frame is sent from one machine to another encapsulated in the data
portion of a frame.
ICMP

o ICMP stands for Internet Control Message Protocol.


o The ICMP is a network layer protocol used by hosts and routers to send the notifications
of IP datagram problems back to the sender.
o ICMP uses echo test/reply to check whether the destination is reachable and responding.
o ICMP handles both control and error messages, but its main function is to report the error
but not to correct them.
o An IP datagram contains the addresses of both source and destination, but it does not
know the address of the previous router through which it has been passed. Due to this
reason, ICMP can only send the messages to the source, but not to the immediate routers.
o ICMP protocol communicates the error messages to the sender. ICMP messages cause the
errors to be returned back to the user processes.
o ICMP messages are transmitted within IP datagram.
The Format of an ICMP message

o The first field specifies the type of the message.


o The second field specifies the reason for a particular message type.
o The checksum field covers the entire ICMP message.

Error Reporting
ICMP protocol reports the error messages to the sender.

Five types of errors are handled by the ICMP protocol:

o Destination unreachable
o Source Quench
o Time Exceeded
o Parameter problems
o Redirection

o Destination unreachable: The message of "Destination Unreachable" is sent from


receiver to the sender when destination cannot be reached, or packet is discarded when
the destination is not reachable.
o Source Quench: The purpose of the source quench message is congestion control. The
message sent from the congested router to the source host to reduce the transmission
rate. ICMP will take the IP of the discarded packet and then add the source quench
message to the IP datagram to inform the source host to reduce its transmission rate. The
source host will reduce the transmission rate so that the router will be free from
congestion.
o Time Exceeded: Time Exceeded is also known as "Time-To-Live". It is a parameter that
defines how long a packet should live before it would be discarded.

There are two ways when Time Exceeded message can be generated:

Sometimes packet discarded due to some bad routing implementation, and this causes the
looping issue and network congestion. Due to the looping issue, the value of TTL keeps on
decrementing, and when it reaches zero, the router discards the datagram. However, when the
datagram is discarded by the router, the time exceeded message will be sent by the router to the
source host.

When destination host does not receive all the fragments in a certain time limit, then the received
fragments are also discarded, and the destination host sends time Exceeded message to the source
host.

o Parameter problems: When a router or host discovers any missing value in the IP
datagram, the router discards the datagram, and the "parameter problem" message is sent
back to the source host.
o Redirection: Redirection message is generated when host consists of a small routing
table. When the host consists of a limited number of entries due to which it sends the
datagram to a wrong router. The router that receives a datagram will forward a datagram
to a correct router and also sends the "Redirection message" to the host to update its
routing table.

IGMP

o IGMP stands for Internet Group Message Protocol.


o The IP protocol supports two types of communication:

o Unicasting: It is a communication between one sender and one receiver.


Therefore, we can say that it is one-to-one communication.
o Multicasting: Sometimes the sender wants to send the same message to a large
number of receivers simultaneously. This process is known as multicasting which
has one-to-many communication.

o The IGMP protocol is used by the hosts and router to support multicasting.
o The IGMP protocol is used by the hosts and router to identify the hosts in a LAN that are
the members of a group.
o IGMP is a part of the IP layer, and IGMP has a fixed-size message.
o The IGMP message is encapsulated within an IP datagram.

The Format of IGMP message

Where,

Type: It determines the type of IGMP message. There are three types of IGMP message:
Membership Query, Membership Report and Leave Report.

Maximum Response Time: This field is used only by the Membership Query message. It
determines the maximum time the host can send the Membership Report message in response to
the Membership Query message.

Checksum: It determines the entire payload of the IP datagram in which IGMP message is
encapsulated.

Group Address: The behavior of this field depends on the type of the message sent.
o For Membership Query, the group address is set to zero for General Query and set to
multicast group address for a specific query.
o For Membership Report, the group address is set to the multicast group address.
o For Leave Group, it is set to the multicast group address.

IGMP Messages

o Membership Query message

o This message is sent by a router to all hosts on a local area network to determine
the set of all the multicast groups that have been joined by the host.
o It also determines whether a specific multicast group has been joined by the
hosts on a attached interface.
o The group address in the query is zero since the router expects one response
from a host for every group that contains one or more members on that host.

o Membership Report message

o The host responds to the membership query message with a membership report
message.
o Membership report messages can also be generated by the host when a host
wants to join the multicast group without waiting for a membership query
message from the router.
o Membership report messages are received by a router as well as all the hosts on
an attached interface.
o Each membership report message includes the multicast address of a single
group that the host wants to join.
o IGMP protocol does not care which host has joined the group or how many hosts
are present in a single group. It only cares whether one or more attached hosts
belong to a single multicast group.
o The membership Query message sent by a router also includes a "Maximum
Response time". After receiving a membership query message and before
sending the membership report message, the host waits for the random amount
of time from 0 to the maximum response time. If a host observes that some other
attached host has sent the "Maximum Report message", then it discards its
"Maximum Report message" as it knows that the attached router already knows
that one or more hosts have joined a single multicast group. This process is
known as feedback suppression. It provides the performance optimization, thus
avoiding the unnecessary transmission of a "Membership Report message".

o Leave Report
When the host does not send the "Membership Report message", it means that the host
has left the group. The host knows that there are no members in the group, so even when
it receives the next query, it would not report the group.

Routing algorithm
o In order to transfer the packets from source to the destination, the network layer must
determine the best route through which packets can be transmitted.
o Whether the network layer provides datagram service or virtual circuit service, the main
job of the network layer is to provide the best route. The routing protocol provides this
job.
o The routing protocol is a routing algorithm that provides the best path from the source to
the destination. The best path is the path that has the "least-cost path" from source to the
destination.
o Routing is the process of forwarding the packets from source to the destination but the
best route to send the packets is determined by the routing algorithm.

Classification of a Routing algorithm


The Routing algorithm is divided into two categories:

o Adaptive Routing algorithm


o Non-adaptive Routing algorithm

Adaptive Routing algorithm


o An adaptive routing algorithm is also known as dynamic routing algorithm.
o This algorithm makes the routing decisions based on the topology and network traffic.
o The main parameters related to this algorithm are hop count, distance and estimated
transit time.

An adaptive routing algorithm can be classified into three parts:

o 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. This algorithm takes the connectivity between the nodes and link cost
as input, and this information is obtained before actually performing any calculation. Link
state algorithm is referred to as a centralized algorithm since it is aware of the cost of
each link in the network.
o Isolation algorithm: It is an algorithm that obtains the routing information by using local
information rather than gathering information from other nodes.
o Distributed algorithm: It is also known as decentralized algorithm as it computes the
least-cost path between source and destination in an iterative and distributed manner. In
the decentralized algorithm, no node has the knowledge about the cost of all the network
links. In the beginning, a node contains the information only about its own directly
attached links and through an iterative process of calculation computes the least-cost
path to the destination. A Distance vector algorithm is a decentralized algorithm as it
never knows the complete path from source to the destination, instead it knows the
direction through which the packet is to be forwarded along with the least cost path.

Non-Adaptive Routing algorithm

o Non Adaptive routing algorithm is also known as a static routing algorithm.


o When booting up the network, the routing information stores to the routers.
o Non Adaptive routing algorithms do not take the routing decision based on the network
topology or network traffic.

The Non-Adaptive Routing algorithm is of two types:

Flooding: In case of flooding, every incoming packet is sent to all the outgoing links except the
one from it has been reached. The disadvantage of flooding is that node may contain several
copies of a particular packet.

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.

Differences b/w Adaptive and Non-Adaptive Routing


Algorithm

Basis Of Adaptive Non-Adaptive


Comparison Routing Routing
algorithm algorithm

Define Adaptive Routing The Non-Adaptive


algorithm is an Routing algorithm
algorithm that is an algorithm
constructs the that constructs the
routing table static table to
based on the determine which
network node to send the
conditions. packet.

Usage Adaptive routing The Non-Adaptive


algorithm is used Routing algorithm
by dynamic is used by static
routing. routing.

Routing Routing decisions Routing decisions


decision are made based are the static
on topology and tables.
network traffic.

Categorization The types of The types of Non


adaptive routing Adaptive routing
algorithm, are algorithm are
Centralized, flooding and
isolation and random walks.
distributed
algorithm.

Complexity Adaptive Routing Non-Adaptive


algorithms are Routing
more complex. algorithms are
simple.

What is congestion?
A state occurring in network layer when the message traffic is so heavy that it slows down
network response time.

Effects of Congestion
 As delay increases, performance decreases.
 If delay increases, retransmission occurs, making situation worse.

Congestion control algorithms


 Congestion Control is a mechanism that controls the entry of data packets into the
network, enabling a better use of a shared network infrastructure and avoiding
congestive collapse.
 Congestive-Avoidance Algorithms (CAA) are implemented at the TCP layer as the
mechanism to avoid congestive collapse in a network.
 There are two congestion control algorithm which are as follows:

 Leaky Bucket Algorithm


 The leaky bucket algorithm discovers its use in the context of network traffic shaping or
rate-limiting.
 A leaky bucket execution and a token bucket execution are predominantly used for
traffic shaping algorithms.
 This algorithm is used to control the rate at which traffic is sent to the network and shape
the burst traffic to a steady traffic stream.
 The disadvantages compared with the leaky-bucket algorithm are the inefficient use of
available network resources.
 The large area of network resources such as bandwidth is not being used effectively.

Let us consider an example to understand

Imagine a bucket with a small hole in the bottom.No matter at what rate water enters the
bucket, the outflow is at constant rate.When the bucket is full with water additional water
entering spills over the sides and is lost.

Similarly, each network interface contains a leaky bucket and the following steps are
involved in leaky bucket algorithm:
1. When host wants to send packet, packet is thrown into the bucket.
2. The bucket leaks at a constant rate, meaning the network interface transmits packets at
a constant rate.
3. Bursty traffic is converted to a uniform traffic by the leaky bucket.
4. In practice the bucket is a finite queue that outputs at a finite rate.
 Token bucket Algorithm
 The leaky bucket algorithm has a rigid output design at an average rate independent of
the bursty traffic.
 In some applications, when large bursts arrive, the output is allowed to speed up. This
calls for a more flexible algorithm, preferably one that never loses information.
Therefore, a token bucket algorithm finds its uses in network traffic shaping or rate-
limiting.
 It is a control algorithm that indicates when traffic should be sent. This order comes
based on the display of tokens in the bucket.
 The bucket contains tokens. Each of the tokens defines a packet of predetermined size.
Tokens in the bucket are deleted for the ability to share a packet.
 When tokens are shown, a flow to transmit traffic appears in the display of tokens.
 No token means no flow sends its packets. Hence, a flow transfers traffic up to its peak
burst rate in good tokens in the bucket.

Need of token bucket Algorithm:-

The leaky bucket algorithm enforces output pattern at the average rate, no matter how
bursty the traffic is. So in order to deal with the bursty traffic we need a flexible algorithm so
that the data is not lost. One such algorithm is token bucket algorithm.
Steps of this algorithm can be described as follows:

1. In regular intervals tokens are thrown into the bucket. ƒ


2. The bucket has a maximum capacity. ƒ
3. If there is a ready packet, a token is removed from the bucket, and the packet is sent.
4. If there is no token in the bucket, the packet cannot be sent.

Let’s understand with an example,

In figure (A) we see a bucket holding three tokens, with five packets waiting to be
transmitted. For a packet to be transmitted, it must capture and destroy one token. In figure
(B) We see that three of the five packets have gotten through, but the other two are stuck
waiting for more tokens to be generated.

Ways in which token bucket is superior to leaky bucket: The leaky bucket algorithm
controls the rate at which the packets are introduced in the network, but it is very
conservative in nature. Some flexibility is introduced in the token bucket algorithm. In the
token bucket, algorithm tokens are generated at each tick (up to a certain limit). For an
incoming packet to be transmitted, it must capture a token and the transmission takes place
at the same rate. Hence some of the busty packets are transmitted at the same rate if
tokens are available and thus introduces some amount of flexibility in the system.

Formula: M * s = C + ? * s where S – is time taken M – Maximum output rate ? – Token


arrival rate C – Capacity of the token bucket in byte
Let’s understand with an example,

IPv4 vs IPv6

What is IP?
An IP stands for internet protocol. An IP address is assigned to each device connected to a
network. Each device uses an IP address for communication. It also behaves as an identifier as this
address is used to identify the device on a network. It defines the technical format of the packets.
Mainly, both the networks, i.e., IP and TCP, are combined together, so together, they are referred to
as a TCP/IP. It creates a virtual connection between the source and the destination.

We can also define an IP address as a numeric address assigned to each device on a network. An IP
address is assigned to each device so that the device on a network can be identified uniquely. To
facilitate the routing of packets, TCP/IP protocol uses a 32-bit logical address known as
IPv4(Internet Protocol version 4).

An IP address consists of two parts, i.e., the first one is a network address, and the other one is a
host address.

There are two types of IP addresses:

o IPv4
o IPv6

What is IPv4?

IPv4 is a version 4 of IP. It is a current version and the most commonly used IP address. It is a 32-bit
address written in four numbers separated by 'dot', i.e., periods. This address is unique for each
device.

For example, 66.94.29.13

The above example represents the IP address in which each group of numbers separated by
periods is called an Octet. Each number in an octet is in the range from 0-255. This address can
produce 4,294,967,296 possible unique addresses.

In today's computer network world, computers do not understand the IP addresses in the standard
numeric format as the computers understand the numbers in binary form only. The binary number
can be either 1 or 0. The IPv4 consists of four sets, and these sets represent the octet. The bits in
each octet represent a number.

Each bit in an octet can be either 1 or 0. If the bit the 1, then the number it represents will count,
and if the bit is 0, then the number it represents does not count.

Representation of 8 Bit Octet

The above representation shows the structure of 8- bit octet.

Now, we will see how to obtain the binary representation of the above IP address, i.e., 66.94.29.13

Step 1: First, we find the binary number of 66.


To obtain 66, we put 1 under 64 and 2 as the sum of 64 and 2 is equal to 66 (64+2=66), and the
remaining bits will be zero, as shown above. Therefore, the binary bit version of 66 is 01000010.

Step 2: Now, we calculate the binary number of 94.

To obtain 94, we put 1 under 64, 16, 8, 4, and 2 as the sum of these numbers is equal to 94, and
the remaining bits will be zero. Therefore, the binary bit version of 94 is 01011110.

Step 3: The next number is 29.

To obtain 29, we put 1 under 16, 8, 4, and 1 as the sum of these numbers is equal to 29, and the
remaining bits will be zero. Therefore, the binary bit version of 29 is 00011101.

Step 4: The last number is 13.

To obtain 13, we put 1 under 8, 4, and 1 as the sum of these numbers is equal to 13, and the
remaining bits will be zero. Therefore, the binary bit version of 13 is 00001101.

Drawback of IPv4

Currently, the population of the world is 7.6 billion. Every user is having more than one device
connected with the internet, and private companies also rely on the internet. As we know that IPv4
produces 4 billion addresses, which are not enough for each device connected to the internet on a
planet. Although the various techniques were invented, such as variable- length mask, network
address translation, port address translation, classes, inter-domain translation, to conserve the
bandwidth of IP address and slow down the depletion of an IP address. In these techniques, public
IP is converted into a private IP due to which the user having public IP can also use the internet.
But still, this was not so efficient, so it gave rise to the development of the next generation of IP
addresses, i.e., IPv6.

What is IPv6?

IPv4 produces 4 billion addresses, and the developers think that these addresses are enough, but
they were wrong. IPv6 is the next generation of IP addresses. The main difference between IPv4
and IPv6 is the address size of IP addresses. The IPv4 is a 32-bit address, whereas IPv6 is a 128-bit
hexadecimal address. IPv6 provides a large address space, and it contains a simple header as
compared to IPv4.

It provides transition strategies that convert IPv4 into IPv6, and these strategies are as follows:

o Dual stacking: It allows us to have both the versions, i.e., IPv4 and IPv6, on the same
device.
o Tunneling: In this approach, all the users have IPv6 communicates with an IPv4 network
to reach IPv6.
o Network Address Translation: The translation allows the communication between the
hosts having a different version of IP.

This hexadecimal address contains both numbers and alphabets. Due to the usage of both the
numbers and alphabets, IPv6 is capable of producing over 340 undecillion (3.4*10 38) addresses.

IPv6 is a 128-bit hexadecimal address made up of 8 sets of 16 bits each, and these 8 sets are
separated by a colon. In IPv6, each hexadecimal character represents 4 bits. So, we need to convert
4 bits to a hexadecimal number at a time

Address format

The address format of IPv4:

The address format of IPv6:

The above diagram shows the address format of IPv4 and IPv6. An IPv4 is a 32-bit decimal address.
It contains 4 octets or fields separated by 'dot', and each field is 8-bit in size. The number that each
field contains should be in the range of 0-255. Whereas an IPv6 is a 128-bit hexadecimal address. It
contains 8 fields separated by a colon, and each field is 16-bit in size.
Differences between IPv4 and IPv6

Ipv4 Ipv6

Address length IPv4 is a 32-bit IPv6 is a 128-bit


address. address.

Fields IPv4 is a numeric IPv6 is an


address that alphanumeric
consists of 4 address that
fields which are consists of 8
separated by dot fields, which are
(.). separated by
colon.

Classes IPv4 has 5 IPv6 does not


different classes contain classes
of IP address that of IP addresses.
includes Class A,
Class B, Class C,
Class D, and Class
E.

Number of IP IPv4 has a limited IPv6 has a large


address number of IP number of IP
addresses. addresses.

VLSM It supports VLSM It does not


(Virtual Length support VLSM.
Subnet Mask).
Here, VLSM
means that Ipv4
converts IP
addresses into a
subnet of
different sizes.
Address It supports It supports
configuration manual and manual, DHCP,
DHCP auto-
configuration. configuration,
and
renumbering.

Address space It generates 4 It generates 340


billion unique undecillion
addresses unique
addresses.

End-to-end In IPv4, end-to- In the case of


connection end connection IPv6, end-to-end
integrity integrity is connection
unachievable. integrity is
achievable.

Security In IPv4, security In IPv6, IPSEC is


features depends on the developed for
application. This security
IP address is not purposes.
developed in
keeping the
security feature in
mind.

Address In IPv4, the IP In IPv6, the


representation address is representation of
represented in the IP address in
decimal. hexadecimal.

Fragmentation Fragmentation is Fragmentation is


done by the done by the
senders and the senders only.
forwarding
routers.

Packet flow It does not It uses flow label


identification provide any field in the
mechanism for header for the
packet flow packet flow
identification. identification.

Checksum field The checksum The checksum


field is available field is not
in IPv4. available in IPv6.

Transmission IPv4 is On the other


scheme broadcasting. hand, IPv6 is
multicasting,
which provides
efficient network
operations.

Encryption and It does not It provides


Authentication provide encryption and
encryption and authentication.
authentication.

Number of It consists of 4 It consists of 8


octets octets. fields, and each
field contains 2
octets. Therefore,
the total number
of octets in IPv6
is 16.

In the context of networking, a "point-to-point network" refers to a type of network


configuration where there is a direct connection between two nodes, typically for the
purpose of communication between those specific nodes. This configuration is often
contrasted with a broadcast or multi-access network, where multiple nodes share a
common communication medium.

In the network layer of the OSI model or the Internet Protocol Suite (TCP/IP), point-
to-point networks can be implemented using various technologies and protocols.
Here's how point-to-point communication works at the network layer:

.
Addressing: Each node in a point-to-point network is typically assigned a unique
network layer address. In the context of IP networks, this is often an IP address. These
addresses are used to identify the source and destination of data packets as they
traverse the network.
.
.
Routing: In a point-to-point network, routing decisions are relatively straightforward
since there are only two nodes involved. Typically, a routing table or routing protocol
is used to determine the path that packets should take from the source node to the
destination node. In many cases, this path consists of a single link or hop.
.
.
Encapsulation: When a node in a point-to-point network sends a data packet to
another node, the packet is encapsulated with appropriate network layer headers.
These headers include information such as the source and destination addresses, as
well as any other necessary control information.
.
.
Transmission: The encapsulated packet is then transmitted over the physical link
connecting the two nodes. This could be a wired connection, such as a point-to-point
leased line, or a wireless connection, such as a point-to-point microwave link.
.
.
Decapsulation: When the packet reaches the destination node, it is decapsulated,
meaning that the network layer headers are removed. The node then processes the
packet based on the information contained within.
.

Examples of point-to-point network technologies and protocols include:

 Point-to-Point Protocol (PPP): A data link protocol used to establish a direct connection between two
nodes over various physical media, such as serial cables, DSL lines, or dial-up connections.
 Point-to-Point Protocol over Ethernet (PPPoE): A network protocol used to encapsulate PPP frames
within Ethernet frames, commonly used in DSL connections.
 Virtual Private Networks (VPNs): VPNs can be implemented as point-to-point connections between
two network nodes, typically using tunneling protocols like IPsec or SSL/TLS to create secure
communication channels over public networks.

In summary, point-to-point networks in the network layer provide a direct, dedicated


communication path between two nodes, making them suitable for scenarios where a
secure, reliable connection is required between specific endpoints.

You might also like