Unit Iii

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 59

Computer Networks

Unit-III

Network layer is the third layer in the OSI model of computer


networks. It is main function is to transfer network packets from the
source to the destination. It is involved both at the source host and the
destination host. 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.
Features :
1. Main responsibility of Network layer is to carry the data packets from
the source to the destination without changing or using it.
2. If the packets are too large for delivery, they are fragmented i.e.,
broken down into smaller packets.
3. It decides the route to be taken by the packets to travel from the
source to the destination among the multiple routes available in a
network (also called as routing).
4. The source and destination addresses are added to the data packets
inside the network layer.
The services which are offered by the network layer protocol are as
follows:

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.
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, decapsulates 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 decapsulate the packets they
receive unless they need to be fragmented.

2. Routing and Forwarding –


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 has some strategies which
find out the best possible route. This process is referred to as routing.
There are a number of routing protocols which 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.
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).

Advantages of Network Layer Services :


 Packetization service in network layer provides an ease of
transportation of the data packets.
 Packetization also eliminates single points of failure in data
communication systems.
 Routers present in the network layer reduce network traffic by
creating collision and broadcast domains.
 With the help of Forwarding, data packets are transferred from one
place to another in the network.

Disadvantages of Network Layer Services :


 There is a lack of flow control in the design of the network layer.
 Congestion occurs sometimes due to the presence of too many
datagrams in a network which are beyond the capacity of network or
the routers. Due to this, some routers may drop some of the datagrams
and some important piece of information maybe lost.
 Although indirectly error control is present in network layer, but there
is a lack of proper error control mechanisms as due to presence of
fragmented data packets, error control becomes difficult to
implement.

Switching techniques
In large networks, there can be multiple paths from sender to receiver.
The switching technique will decide the best route for data transmission.
Switching technique is used to connect the systems for making one-to-
one communication.

Classification of Switching Techniques

Circuit Switching
o Circuit switching is a switching technique that establishes a
dedicated path between sender and receiver.
o In the Circuit Switching Technique, once the connection is
established then the dedicated path will remain to exist until the
connection is terminated.
o Circuit switching in a network operates in a similar way as the
telephone works.
o A complete end-to-end path must exist before the communication
takes place.
o In case of circuit switching technique, when any user wants to send
the data, voice, video, a request signal is sent to the receiver then
the receiver sends back the acknowledgment to ensure the
availability of the dedicated path. After receiving the
acknowledgment, dedicated path transfers the data.
o Circuit switching is used in public telephone network. It is used for
voice transmission.
o Fixed data can be transferred at a time in circuit switching
technology.

Communication through circuit switching has 3 phases:

o Circuit establishment
o Data transfer
o Circuit Disconnect

Circuit Switching can use either of the two technologies:


Space Division Switches:
o Space Division Switching is a circuit switching technology in
which a single transmission path is accomplished in a switch by
using a physically separate set of crosspoints.
o Space Division Switching can be achieved by using crossbar
switch. A crossbar switch is a metallic crosspoint or semiconductor
gate that can be enabled or disabled by a control unit.
o The Crossbar switch is made by using the semiconductor. For
example, Xilinx crossbar switch using FPGAs.
o Space Division Switching has high speed, high capacity, and
nonblocking switches.

Space Division Switches can be categorized in two ways:

o Crossbar Switch
o Multistage Switch

Crossbar Switch
The Crossbar switch is a switch that has n input lines and n output lines.
The crossbar switch has n2 intersection points known as crosspoints.

Disadvantage of Crossbar switch:

The number of crosspoints increases as the number of stations is


increased. Therefore, it becomes very expensive for a large switch. The
solution to this is to use a multistage switch.

Multistage Switch
o Multistage Switch is made by splitting the crossbar switch into the
smaller units and then interconnecting them.
o It reduces the number of crosspoints.

o If one path fails, then there will be an availability of another path.

Advantages of Circuit Switching:


o In the case of Circuit Switching technique, the communication
channel is dedicated.
o It has fixed bandwidth.

Disadvantages of Circuit Switching:

o Once the dedicated path is established, the only delay occurs in the
speed of data transmission.
o It takes a long time to establish a connection approx 10 seconds
during which no data can be transmitted.
o It is more expensive than other switching techniques as a dedicated
path is required for each connection.
o It is inefficient to use because once the path is established and no
data is transferred, then the capacity of the path is wasted.
o In this case, the connection is dedicated therefore no other data can
be transferred even if the channel is free.

Message Switching
o Message Switching is a switching technique in which a message is
transferred as a complete unit and routed through intermediate
nodes at which it is stored and forwarded.
o In Message Switching technique, there is no establishment of a
dedicated path between the sender and receiver.
o The destination address is appended to the message. Message
Switching provides a dynamic routing as the message is routed
through the intermediate nodes based on the information available
in the message.
o Message switches are programmed in such a way so that they can
provide the most efficient routes.
o Each and every node stores the entire message and then forward it
to the next node. This type of network is known as store and
forward network.
o Message switching treats each message as an independent entity.

Advantages of Message Switching

o Data channels are shared among the communicating devices that


improve the efficiency of using available bandwidth.
o Traffic congestion can be reduced because the message is
temporarily stored in the nodes.
o Message priority can be used to manage the network.
o The size of the message which is sent over the network can be
varied. Therefore, it supports the data of unlimited size.

Disadvantages of Message Switching

o The message switches must be equipped with sufficient storage to


enable them to store the messages until the message is forwarded.
o The Long delay can occur due to the storing and forwarding
facility provided by the message switching technique.

Packet Switching
o The packet switching is a switching technique in which the
message is sent in one go, but it is divided into smaller pieces, and
they are sent individually.
o The message splits into smaller pieces known as packets and
packets are given a unique number to identify their order at the
receiving end.
o Every packet contains some information in its headers such as
source address, destination address and sequence number.
o Packets will travel across the network, taking the shortest path as
possible.
o All the packets are reassembled at the receiving end in correct
order.
o If any packet is missing or corrupted, then the message will be sent
to resend the message.
o If the correct order of the packets is reached, then the
acknowledgment message will be sent.

Approaches of Packet Switching:

There are two approaches to Packet Switching:

Datagram Packet switching:


o It is a packet switching technology in which packet is known as a
datagram, is considered as an independent entity. Each packet
contains the information about the destination and switch uses this
information to forward the packet to the correct destination.
o The packets are reassembled at the receiving end in correct order.

o In Datagram Packet Switching technique, the path is not fixed.

o Intermediate nodes take the routing decisions to forward the


packets.
o Datagram Packet Switching is also known as connectionless
switching.

Virtual Circuit Switching


o Virtual Circuit Switching is also known as connection-oriented
switching.
o In the case of Virtual circuit switching, a preplanned route is
established before the messages are sent.
o Call request and call accept packets are used to establish the
connection between sender and receiver.
o In this case, the path is fixed for the duration of a logical
connection.

Let's understand the concept of virtual circuit switching through a


diagram:

o In the above diagram, A and B are the sender and receiver


respectively. 1 and 2 are the nodes.
o Call request and call accept packets are used to establish a
connection between the sender and receiver.
o When a route is established, data will be transferred.
o After transmission of data, an acknowledgment signal is sent by
the receiver that the message has been received.
o If the user wants to terminate the connection, a clear signal is sent
for the termination.

Differences b/w Datagram approach and Virtual Circuit approach

Datagram approach Virtual Circuit approach

Node takes routing Node does not take any routing


decisions to forward the decision.
packets.

Congestion cannot occur as Congestion can occur when the


all the packets travel in node is busy, and it does not
different directions. allow other packets to pass
through.

It is more flexible as all the It is not very flexible.


packets are treated as an
independent entity.

Advantages of Packet Switching:

o Cost-effective: In packet switching technique, switching devices


do not require massive secondary storage to store the packets, so
cost is minimized to some extent. Therefore, we can say that the
packet switching technique is a cost-effective technique.
o Reliable: If any node is busy, then the packets can be rerouted.
This ensures that the Packet Switching technique provides reliable
communication.
o Efficient: Packet Switching is an efficient technique. It does not
require any established path prior to the transmission, and many
users can use the same communication channel simultaneously,
hence makes use of available bandwidth very efficiently.

Disadvantages of Packet Switching:

o Packet Switching technique cannot be implemented in those


applications that require low delay and high-quality services.
o The protocols used in a packet switching technique are very
complex and requires high implementation cost.
o If the network is overloaded or corrupted, then it requires
retransmission of lost packets. It can also lead to the loss of critical
information if errors are nor recovered.

Logical addressing

Usually, computers communicate through the Internet. The packet(data)


transmitted by the sender computer may pass through several LANs or
WANs before reaching the destination computer. For this level of
communication, we need a global addressing scheme what we
call logical addressing. An IP address is used globally to refer to the
logical address in the network layer of the TCP/IP protocol.
The Internet addresses are 32 bits in length; this gives us a maximum
of 232 addresses. These addresses are referred to as IPv4 (IP version 4)
addresses or popularly as IP addresses.

IPV4 addresses

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. They are unique so that each address defines only one
connection to the Internet. Two devices on the Internet can never have
the same IPV4 address at the same time.
On the other hand, if a device operating at the network layer
has m connections to the Internet, it needs to have m addresses, for
example, a router.

The IPv4 addresses are universal in the sense that the addressing system
must be accepted by any host that wants to be connected to the Internet.
That means global addressing.

Address Space

IPv4 has a certain 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

IPv4 uses 32-bit address format, which means that the address space is
232 or 4,294,967,296

Notations

There are two notations to show an IPv4 address:

1. Binary notation
2. Dotted decimal notation

1) 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 a 4-byte address. The following is an example of
an IPv4 address in binary notation: 01110111 10010101 00000001
00000011

2) Dotted-Decimal Notation
IPV4 addresses are usually written in decimal form with a decimal
point (dot) separating the bytes since it’s more compatible. The
following is an example: 119.149.1.3 (above one and this one is same
just different notation)

IPV6 addresses

An IPv6 address is a 128-bit alphanumeric value that identifies an


endpoint device in an Internet Protocol Version 6 (IPv6) network. IPv6
is the successor to a previous addressing infrastructure, IPv4, which had
limitations IPv6 was designed to overcome. Notably, IPv6 has
drastically increased address space compared to IPv4.

The Internet Protocol (IP) is a method in which data is sent to different


computers over the internet. Each network interface, or computer, on the
internet will have at least one IP address that is used to uniquely identify
that computer. Every device that connects to the internet is assigned an
IP address. Which is why there was a concern with the number of IP
addresses in IPv4, and why the Internet Engineering Task Force (IETF)
defined the new IPv6 standard.

Operating systems (OSes) like Windows 10, macOS and Ubuntu support
IPv6. Currently, the use of address types is mixed. Devices in use now
will either use IPv6 or IPv4. Domain name systems (DNSes) have
supported IPv6 since 2008.

It has been a concern for some time that the IPv4 addressing scheme was
running out of potential addresses. The IPv6 format was created to
enable the trillions of new IP addresses to connect an ever-greater
number of computing devices and the rapidly expanding numbers of
items with embedded connectivity, thanks to the internet of things (IoT).
The number of potential IPv6 addresses has been calculated to be over
340 undecillion (or 340 trillion trillion trillion). According to Computer
History Museum docent Dick Guertin, that number allows an IPv6
address for each atom on the surface of the planet, with enough left over
for more than 100 more similar planets.

Format of an IPv6 address


In precise terms, an IPv6 address is 128 bits long and is arranged in eight
groups, each of which is 16 bits. Each group is expressed as
four hexadecimal digits and the groups are separated by colons.

An example of a full IPv6 address could be:

FE80:CD00:0000:0CDE:1257:0000:211E:729C

An IPv6 address is split into two parts: a network and a node


component. The network component is the first 64 bits of the address
and is used for routing. The node component is the later 64 bits and is
used to identify the address of the interface. It is derived from the
physical, or MAC address, using the 64-bit extended unique identifier
(EUI-64) format defined by the Institute of Electrical and Electronics
Engineers (IEEE).

The network node can be split even further into a block of 48 bits and a
block of 16 bits. The upper 48-bit section is used for global network
addresses. The lower 16-bit section is controlled by network
administrators and is used for subnets on an internal network.

Further, the example address can be shortened, as the addressing scheme


allows the omission of any leading zero, as well as any sequences
consisting of only zeros. The shortened version would look like:

FE80:CD00:0:CDE:1257:0:211E:729C
The specific layout of an IPv6 address may vary somewhat, depending
on its format. Three basic parts that make up the address are the routing
prefix, the subnet ID and the interface ID.

An example of the different segments of an IPv6 address.

Both the routing prefix and the subnet ID represent two main levels in
which the address is constructed -- either global or site-specific. The
routing prefix is the number of bits that can be subdivided -- typically,
decided by Internet Registries and Internet Service Providers (ISPs). If
you were to look at an IPv6 address, the leftmost set of numbers -- the
first 48 bits -- is called the site prefix. The subnet ID is the next 16 bits.
The subnet ID lays out site topology. The last 64-bits are called the
interface ID, which can be automatically or manually configured.

Types of IPv6 addresses


There are different types and formats of IPv6 addresses, of which, it's
notable to mention that there are no broadcast addresses in IPv6. Some
examples of IPv6 formats include:

 Global unicast. These addresses are routable on the internet and start
with "2001:" as the prefix group. Global unicast addresses are the
equivalent of IPv4 public addresses.
 Unicast address. Used to identify the interface of an individual node.
 Anycast address. Used to identify a group of interfaces on different
nodes.
 Multicast address. An address used to define multicast Multicasts
are used to send a single packet to multiple destinations at one time.
 Link local addresses. One of the two internal address types that are
not routed on the internet. Link local addresses are used inside an
internal network, are self-assigned and start with "fe80:" as the prefix
group.
 Unique local addresses. This is the other type of internal address that
is not routed on the internet. Unique local addresses are equivalent to
the IPv4 addresses 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16.
Difference between IPv4 and IPv6

IPv4 IPv6

IPv4 has a 32-bit address length IPv6 has a 128-bit address length

It Supports Manual and DHCP It supports Auto and renumbering


address configuration address configuration

In IPv4 end to end, connection In IPv6 end to end, connection


integrity is Unachievable integrity is Achievable

Address space of IPv6 is quite large


9
It can generate 4.29×10 address it can produce 3.4×1038 address
space space

The Security feature is IPSEC is an inbuilt security feature


dependent on application in the IPv6 protocol

Address representation of IPv4 is Address Representation of IPv6 is


in decimal in hexadecimal
IPv4 IPv6

Fragmentation performed by In IPv6 fragmentation performed


Sender and forwarding routers only by the sender

In IPv6 packet flow identification


In IPv4 Packet flow are Available and uses the flow
identification is not available label field in the header

In IPv4 checksum field is In IPv6 checksum field is not


available available

In IPv6 multicast and anycast


It has broadcast Message message transmission scheme is
Transmission Scheme available

In IPv4 Encryption and In IPv6 Encryption and


Authentication facility not Authentication are provided
provided

IPv6 has header of 40 bytes fixed


IPv4 has a header of 20-60 bytes.

Internet Protocol version 4 (IPv4) Header

IPv4 is a connectionless protocol used for packet-switched networks. It


operates on a best effort delivery model, in which neither delivery is
guaranteed, nor proper sequencing or avoidance of duplicate delivery is
assured. Internet Protocol Version 4 (IPv4) is the fourth revision of the
Internet Protocol and a widely used protocol in data communication
over different kinds of networks. IPv4 is a connectionless protocol used
in packet-switched layer networks, such as Ethernet. It provides a
logical connection between network devices by providing identification
for each device. There are many ways to configure IPv4 with all kinds
of devices – including manual and automatic configurations –
depending on the network type.
IPv4 is defined and specified in IETF publication RFC 791.
IPv4 uses 32-bit addresses for Ethernet communication in five classes:
A, B, C, D and E. Classes A, B and C have a different bit length for
addressing the network host. Class D addresses are reserved for
military purposes, while class E addresses are reserved for future use.
IPv4 uses 32-bit (4 byte) addressing, which gives 2 32 addresses. IPv4
addresses are written in the dot-decimal notation, which comprises of
four octets of the address expressed individually in decimal and
separated by periods, for instance, 192.168.1.5.

IPv4 Datagram Header


Size of the header is 20 to 60 bytes.

Version: Version of the IP protocol (4 bits), which is 4 for IPv4

Hlen: IP header length (4 bits), which is the number of 32 bit words in


the header. The minimum value for this field is 5 and the maximum is
15.

Type of service: Low Delay, High Throughput, Reliability (8 bits)


Total Length: Length of header + Data (16 bits), which has a
minimum value 20 bytes and the maximum is 65,535 bytes.

Identification: Unique Packet Id for identifying the group of fragments


of a single IP datagram (16 bits)
Flags: 3 flags of 1 bit each : reserved bit (must be zero), do not
fragment flag, more fragments flag (same order)

Fragment Offset: Represents the number of Data Bytes ahead of the


particular fragment in the particular Datagram. Specified in terms of
number of 8 bytes, which has the maximum value of 65,528 bytes.

Time to live: Datagram’s lifetime (8 bits), It prevents the datagram to


loop through the network by restricting the number of Hops taken by a
Packet before delivering to the Destination.

Protocol: Name of the protocol to which the data is to be passed (8


bits)

Header Checksum: 16 bits header checksum for checking errors in the


datagram header

Source IP address: 32 bits IP address of the sender

Destination IP address: 32 bits IP address of the receiver

Option: Optional information such as source route, record route. Used


by the Network administrator to check whether a path is working or
not.

Internet Protocol version 6 (IPv6) Header

IP version 6 is the new version of Internet Protocol, which is way better


than IP version 4 in terms of complexity and efficiency. Let’s look at
the header of IP version 6 and understand how it is different from the
IPv4 header.

IP version 6 Header Format

Version (4-bits): Indicates version of Internet Protocol which contains


bit sequence 0110.
Traffic Class (8-bits): The Traffic Class field indicates class or
priority of IPv6 packet which is similar to Service Field in IPv4 packet.
It helps routers to handle the traffic based on the priority of the packet.
If congestion occurs on the router then packets with the least priority
will be discarded.
As of now, only 4-bits are being used (and the remaining bits are under
research), in which 0 to 7 are assigned to Congestion controlled traffic
and 8 to 15 are assigned to Uncontrolled traffic.
Priority assignment of Congestion controlled traffic :
Uncontrolled data traffic is mainly used for Audio/Video data. So we
give higher priority to Uncontrolled data traffic.
The source node is allowed to set the priorities but on the way, routers
can change it. Therefore, the destination should not expect the same
priority which was set by the source node.
Flow Label (20-bits): Flow Label field is used by a source to label the
packets belonging to the same flow in order to request special handling
by intermediate IPv6 routers, such as non-default quality of service or
real-time service. In order to distinguish the flow, an intermediate
router can use the source address, a destination address, and flow label
of the packets. Between a source and destination, multiple flows may
exist because many processes might be running at the same time.
Routers or Host that does not support the functionality of flow label
field and for default router handling, flow label field is set to 0. While
setting up the flow label, the source is also supposed to specify the
lifetime of the flow.
Payload Length (16-bits): It is a 16-bit (unsigned integer) field,
indicates the total size of the payload which tells routers about the
amount of information a particular packet contains in its payload. The
payload Length field includes extension headers(if any) and an upper-
layer packet. In case the length of the payload is greater than 65,535
bytes (payload up to 65,535 bytes can be indicated with 16-bits), then
the payload length field will be set to 0 and the jumbo payload option is
used in the Hop-by-Hop options extension header.
Next Header (8-bits): Next Header indicates the type of extension
header(if present) immediately following the IPv6 header. Whereas In
some cases it indicates the protocols contained within upper-layer
packets, such as TCP, UDP.
Hop Limit (8-bits): Hop Limit field is the same as TTL in IPv4
packets. It indicates the maximum number of intermediate nodes IPv6
packet is allowed to travel. Its value gets decremented by one, by each
node that forwards the packet and the packet is discarded if the value
decrements to 0. This is used to discard the packets that are stuck in an
infinite loop because of some routing error.
Source Address (128-bits): Source Address is the 128-bit IPv6 address
of the original source of the packet.
Destination Address (128-bits): The destination Address field
indicates the IPv6 address of the final destination(in most cases). All
the intermediate nodes can use this information in order to correctly
route the packet.
Extension Headers: In order to rectify the limitations of the IPv4
Option Field, Extension Headers are introduced in IP version 6. The
extension header mechanism is a very important part of the IPv6
architecture. The next Header field of IPv6 fixed header points to the
first Extension Header and this first extension header points to the
second extension header and so on.

IPv6 packet may contain zero, one or more extension headers but these
should be present in their recommended order:
Rule: Hop-by-Hop options header(if present) should always be placed
after the IPv6 base header.

Conventions :
1. Any extension header can appear at most once except Destination
Header because Destination Header is present two times in the above
list itself.
2. If Destination Header is present before Routing Header then it will
be examined by all intermediate nodes specified in the routing
header.
3. If Destination Header is present just above the Upper layer then it
will be examined only by the Destination node.
Given order in which all extension header should be chained in IPv6
packet and working of each extension header :

Network Address Translation (NAT)


To access the Internet, one public IP address is needed, but we can use a
private IP address in our private network. The idea of NAT is to allow
multiple devices to access the Internet through a single public address.
To achieve this, the translation of a private IP address to a public IP
address is required. Network Address Translation (NAT) is a process
in which one or more local IP address is translated into one or more
Global IP address and vice versa in order to provide Internet access to
the local hosts. Also, it does the translation of port numbers i.e. masks
the port number of the host with another port number, in the packet that
will be routed to the destination. It then makes the corresponding entries
of IP address and port number in the NAT table. NAT generally operates
on a router or firewall.

Network Address Translation (NAT) working –

Generally, the border router is configured for NAT i.e the router which
has one interface in the local (inside) network and one interface in the
global (outside) network. When a packet traverse outside the local
(inside) network, then NAT converts that local (private) IP address to a
global (public) IP address. When a packet enters the local network, the
global (public) IP address is converted to a local (private) IP address.
If NAT runs out of addresses, i.e., no address is left in the pool
configured then the packets will be dropped and an Internet Control
Message Protocol (ICMP) host unreachable packet to the destination is
sent.
Why mask port numbers ?

Suppose, in a network, two hosts A and B are connected. Now, both of


them request for the same destination, on the same port number, say
1000, on the host side, at the same time. If NAT does only translation of
IP addresses, then when their packets will arrive at the NAT, both of
their IP addresses would be masked by the public IP address of the
network and sent to the destination. Destination will send replies to the
public IP address of the router. Thus, on receiving a reply, it will be
unclear to NAT as to which reply belongs to which host (because source
port numbers for both A and B are the same). Hence, to avoid such a
problem, NAT masks the source port number as well and makes an entry
in the NAT table.
NAT inside and outside addresses –
Inside refers to the addresses which must be translated. Outside refers to
the addresses which are not in control of an organization. These are the
network Addresses in which the translation of the addresses will be
done.

 Inside local address – An IP address that is assigned to a host on the


Inside (local) network. The address is probably not an IP address
assigned by the service provider i.e., these are private IP addresses.
This is the inside host seen from the inside network.

 Inside global address – IP address that represents one or more inside


local IP addresses to the outside world. This is the inside host as seen
from the outside network.

 Outside local address – This is the actual IP address of the


destination host in the local network after translation.

 Outside global address – This is the outside host as seen from the
outside network. It is the IP address of the outside destination host
before translation.

Network Address Translation (NAT) Types –


There are 3 ways to configure NAT:
1. Static NAT – In this, a single unregistered (Private) IP address is
mapped with a legally registered (Public) IP address i.e one-to-one
mapping between local and global addresses. This is generally used
for Web hosting. These are not used in organizations as there are
many devices that will need Internet access and to provide Internet
access, a public IP address is needed.
Suppose, if there are 3000 devices that need access to the Internet, the
organization has to buy 3000 public addresses that will be very
costly.

2. Dynamic NAT – In this type of NAT, an unregistered IP address is


translated into a registered (Public) IP address from a pool of public
IP addresses. If the IP address of the pool is not free, then the packet
will be dropped as only a fixed number of private IP addresses can be
translated to public addresses.
Suppose, if there is a pool of 2 public IP addresses then only 2 private
IP addresses can be translated at a given time. If 3rd private IP
address wants to access the Internet then the packet will be dropped
therefore many private IP addresses are mapped to a pool of public IP
addresses. NAT is used when the number of users who want to access
the Internet is fixed. This is also very costly as the organization has to
buy many global IP addresses to make a pool.

3. Port Address Translation (PAT) – This is also known as NAT


overload. In this, many local (private) IP addresses can be translated
to a single registered IP address. Port numbers are used to distinguish
the traffic i.e., which traffic belongs to which IP address. This is most
frequently used as it is cost-effective as thousands of users can be
connected to the Internet by using only one real global (public) IP
address.

Advantages of NAT –
 NAT conserves legally registered IP addresses.

 It provides privacy as the device’s IP address, sending and receiving


the traffic, will be hidden.

 Eliminates address renumbering when a network evolves.

Disadvantage of NAT –

 Translation results in switching path delays.

 Certain applications will not function while NAT is enabled.

 Complicates tunneling protocols such as IPsec.

 Also, the router being a network layer device, should not tamper with
port numbers(transport layer) but it has to do so because of NAT.

Ip subnetting - the basic concepts

Subnetting
When we Subnet a network, we basically split it into smaller networks.
For example, when a set of IP Addresses is given to a company, e.g 254
they might want to "break" (the correct term is "partition") that one
network into smaller ones, one for each department. This way, their
Technical department and Management department can each have a
small network of their own. By subnetting the network we can partition
it to as many smaller networks as we need and this also helps reduce
traffic and hides the complexity of the network.
By default, all type of Classes (A, B and C) have a subnet mask, we call
it the "Default Subnet mask". You need to have one because:
1) All computers need the subnet mask field filled when configuring IP
2) You need to set some logical boundaries in your network
3) You should at least enter the default subnet mask for the Class you're
using

The table below shows clearly the subnet mask that applies for each
network Class.

When dealing with subnet masks in the real world, we are free in most
cases to use any type of subnet mask in order to meet our needs. If for
example we require one network which can contain up to 254
computers, then a Class C network with its default subnet mask will do
fine, but if we need more, then we might consider a Class B network
with its default subnet mask.
Note that the default subnet masks have been set by the IEEE
committee, the same guys that set and approve the different standards
and protocols.

Understanding the concept


The picture below shows our example network (192.168.0.0). All
computers here have been configured with the default Class C subnet
mask (255.255.255.0):
Because of the subnet mask we used, all these computers are part of the
one network marked in blue. This also means that any one of these hosts
(computers, router and server) can communicate with each other.
If we now wanted to partition this network into smaller segments, then
we would need to change the subnet mask appropriately so we can get
the desired result. Let's say we needed to change the subnet mask from
255.255.255.0 to 255.255.255.224 on each configured host.
The picture below shows us how the computers will see the network
once the subnet mask has changed:

In reality, we have just created 8 networks from the one large (blue)
network we had, but I am keeping things simple for now and showing
only 2 of these smaller networks because I want you to understand the
concept of subnetting and see how important the subnet mask is.
Internetworking
In real world scenario, networks under same administration are
generally scattered geographically. There may exist requirement of
connecting two different networks of same kind as well as of different
kinds. Routing between two networks is called internetworking.
Networks can be considered different based on various parameters such
as, Protocol, topology, Layer-2 network and addressing scheme.
In internetworking, routers have knowledge of each other’s address and
addresses beyond them. They can be statically configured go on
different network or they can learn by using internetworking routing
protocol.

Routing protocols which are used within an organization or


administration are called Interior Gateway Protocols or IGP. RIP, OSPF
are examples of IGP. Routing between different organizations or
administrations may have Exterior Gateway Protocol, and there is only
one EGP i.e. Border Gateway Protocol.
Tunneling
If they are two geographically separate networks, which want to
communicate with each other, they may deploy a dedicated line
between or they have to pass their data through intermediate networks.
Tunneling is a mechanism by which two or more same networks
communicate with each other, by passing intermediate networking
complexities. Tunneling is configured at both ends.

When the data enters from one end of Tunnel, it is tagged. This tagged
data is then routed inside the intermediate or transit network to reach
the other end of Tunnel. When data exists the Tunnel its tag is removed
and delivered to the other part of the network.
Both ends seem as if they are directly connected and tagging makes
data travel through transit network without any modifications.
Packet Fragmentation
Most Ethernet segments have their maximum transmission unit (MTU)
fixed to 1500 bytes. A data packet can have more or less packet length
depending upon the application. Devices in the transit path also have
their hardware and software capabilities which tell what amount of data
that device can handle and what size of packet it can process.
If the data packet size is less than or equal to the size of packet the
transit network can handle, it is processed neutrally. If the packet is
larger, it is broken into smaller pieces and then forwarded. This is called
packet fragmentation. Each fragment contains the same destination and
source address and routed through transit path easily. At the receiving
end it is assembled again.
If a packet with DF (don’t fragment) bit set to 1 comes to a router
which can not handle the packet because of its length, the packet is
dropped.
When a packet is received by a router has its MF (more fragments) bit
set to 1, the router then knows that it is a fragmented packet and parts of
the original packet is on the way.
If packet is fragmented too small, the overhead is increases. If the
packet is fragmented too large, intermediate router may not be able to
process it and it might get dropped.
What is Congestion Control Algorithm?
Congestion causes choking of the communication medium. When too
many packets are displayed in a method of the subnet, the subnet's
performance degrades. Hence, a network's communication channel is
called congested if packets are traversing the path and experience delays
mainly over the path's propagation delay.
There is two congestion control algorithm which is as follows:
Leaky Bucket
The leaky bucket algorithm discovers its use in the context of network
traffic shaping or rate-limiting. The algorithm allows controlling the rate
at which a record is injected into a network and managing burstiness in
the data rate.
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 figure shows the leaky bucket algorithm.
In this algorithm, a bucket with a volume of, say, b bytes and a hole in
the Notes bottom is considered. If the bucket is null, it means b bytes are
available as storage. A packet with a size smaller than b bytes arrives at
the bucket and will forward it. If the packet's size increases by more than
b bytes, it will either be discarded or queued. It is also considered that
the bucket leaks through the hole in its bottom at a constant rate of r
bytes per second.
The outflow is considered constant when there is any packet in the
bucket and zero when it is empty. This defines that if data flows into the
bucket faster than data flows out through the hole, the bucket overflows.
The disadvantages compared with the leaky-bucket algorithm are the
inefficient use of available network resources. The leak rate is a fixed
parameter. In the case of the traffic, volume is deficient, the large area of
network resources such as bandwidth is not being used effectively. The
leaky-bucket algorithm does not allow individual flows to burst up to
port speed to effectively consume network resources when there would
not be resource contention in the network.
Token Bucket Algorithm
The leaky bucket algorithm has a rigid output design at the 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.
Thus, the token bucket algorithm adds a token to the bucket each 1 / r
seconds. The volume of the bucket is b tokens. When a token appears,
and the bucket is complete, the token is discarded. If a packet of n bytes
appears and n tokens are deleted from the bucket, the packet is
forwarded to the network.
When a packet of n bytes appears but fewer than n tokens are available.
No tokens are removed from the bucket in such a case, and the packet is
considered non-conformant. The non-conformant packets can either be
dropped or queued for subsequent transmission when sufficient tokens
have accumulated in the bucket.
They can also be transmitted but marked as being non-conformant. The
possibility is that they may be dropped subsequently if the network is
overloaded.
Address Resolution Protocol
Address Resolution Protocol (ARP) is a communication protocol that
works on the TCP/IP Layer 2.

 ARP helps to get the MAC address of the connected router or


gateway from the IP address.
 ARP is a request-response protocol in which one device sends a
request to another device asking for some information, the other
device will respond/reply with the required information.
 ARP packets are encapsulated by a link-layer and are distributed
only in a specific network. ARP is said to be a link-layer protocol.
How Does ARP Work?

 Before sending an IP packet, the sender must know the destination


MAC address.
 If the MAC address is not known, then the sender broadcasts the
ARP discovery packet, requesting the MAC address of the
intended destination.
 Every host inside that network will get the message, but only the
intended receiver host whose IP is associated will accept the IP
packet; all others will discard the packet.
 The receiver will send back a unicast packet with its MAC address
to the sender of the ARP discovery packet.
 The sender will receive the ARP reply and update the ARP check
and start sending a unicast message to the destination.

Format of an ARP Packet


The following diagram shows the format of an ARP packet.

Hardware Type Protocol

Hardware Length Protocol Length Operation ARP Request 1, ARP Reply


2

Sender Hardware Address(for example, 6 bytes for Ethernet)

Sender ProtocolAddress(for example, 4 bytes for IP)

Target Hardware Address(for example, 6 bytes for Ethernet. It is not filled in


a request)

Target Protocol Address(for example, 4 bytes for IP)


Let's now find out the role of each field in an ARP packet −

 Hardware Type: It is a 16-bit field that defines the type of


network in which the ARP is running.
 Protocol Type: It is a 16-bit field that defines protocol using ARP.

 Hardware Length: It is an 8-bit field it defines the length of a


physical address in bytes.
 Protocol Length: It is an 8-bit field that defines the length of IP
address in bytes.
 Operation: It is a 16-bits field that defines the type of packet:
(i)ARP Request and (ii) ARP Reply.
 Sender Hardware Address: It is a variable length that defines the
physical address of the target.
 Target Hardware Address: It is a variable-length field that
defines the logical address of the target.
Reserve Address Resolution Protocol (RARP)
RARP protocol is used by a device that knows its MAC address but does
not know its IP address in a local area network (LAN).

 A network administrator creates a table in a local area network


(LAN) gateway router that maps the physical machine addresses to
equivalent IP addresses.
 When a new machine is set up, then its RARP client requests the
IP address from the gateway router.
 Assuming that an entry has been set up in the router table, the
reserve ARP server will return the IP address to the machine which
can store it for future use.
The problem of getting an IP address from a MAC address can be
handled by the reserved address resolution protocol (RARP) which
works similar to ARP.
To obtain the IP address, the host first broadcasts a RARP request packet
containing its MAC address on the network. All the hosts in the network
will receive the packets but only the server responds to the host by
sending a RARP response packet containing the host MAC and IP
address.

Bootstrap Protocol (BOOTP)

The bootstrapping protocol and how it plays its important role in


maintaining the protocol between connected devices on a network.
Bootstrap Protocol (BOOTP) is a networking protocol which is used
by networking administration to give IP addresses to each member of
that network for participating with other networking devices by the
main server.
Important Features of Bootstrap Protocol :

Here, we will discuss the features of Bootstrap Protocol as follows.


 Bootstrap Protocol (BOOTP) is a basic protocol that automatically
provides each participant in a network connection with a unique IP
address for identification and authentication as soon as it connects to
the network. This helps the server to speed up data transfers and
connection requests.
 BOOTP uses a unique IP address algorithm to provide each system
on the network with a completely different IP address in a fraction of
a second.
 This shortens the connection time between the server and the client.
It starts the process of downloading and updating the source code
even with very little information.
 BOOTP uses a combination of DHCP (Dynamic Host Configuration
Protocol) and UDP (User Datagram Protocol) to request and receive
requests from various network-connected participants and to handle
their responses.
 In a BOOTP connection, the server and client just need an IP address
and a gateway address to establish a successful connection.
Typically, in a BOOTP network, the server and client share the same
LAN, and the routers used in the network must support BOOTP
bridging.
 A great example of a network with a TCP / IP configuration is the
Bootstrap Protocol network. Whenever a computer on the network
asks for a specific request to the server, BOOTP uses its unique IP
address to quickly resolve them.

How Bootstrap Protocol differs from DHCP :

DHCP network servers have much broader use than


a BOOTP network server. It may be used for the purpose when a user
gives request to the server for a particular IP address and it gives the
response of that particular IP address only, hence, time is not wasted
for monitoring other addresses. BOOTP uses UDP (User Datagram
Protocol) through an IPv4 address connection to identify and
authenticate each network user. Also, a BOOTP connection has a stable
static database of IP addresses which serves the client immediately with
the required IP address.
Working of Bootstrap Protocol :

Here, we will discuss the Working steps of Bootstrap Protocol as


follows.
 At the very beginning, each network participant does not have an IP
address. The network administrator then provides each host on the
network with a unique IP address using the IPv4 protocol.
 The client installs the BOOTP network protocol using TCP / IP
Intervention on its computer system to ensure compatibility with all
network protocols when connected to this network.
 The BOOTP network administrator then sends a message that
contains a valid unicast address. This unicast address is then
forwarded to the BOOTP client by the master server.

Uses of Bootstrap Protocol :

Here, we will discuss the uses of Bootstrap Protocol as follows.


1. Bootstrap (BOOTP) is primarily required to check the system on a
network the first time you start your computer. Records the BIOS
cycle of each computer on the network to allow the computer’s
motherboard and network manager to efficiently organize the data
transfer on the computer as soon as it boots up.
2. BOOTP is mainly used in a diskless environment and requires no
media as all data is stored in the network cloud for efficient use.
3. BOOTP is the transfer of a data between a client and a server to send
and receive requests and corresponding responses by the networking
server.
4. BOOTP supports the use of motherboards and network managers, so
no external storage outside of the cloud network is required.

Network Routing Algorithm


A routing algorithm is a procedure that lays down the route or path to
transfer data packets from source to the destination. They help in
directing Internet traffic efficiently. After a data packet leaves its source,
it can choose among the many different paths to reach its destination.
Routing algorithm mathematically computes the best path, i.e. “least –
cost path” that the packet can be routed through.
Types of Routing Algorithms
Routing algorithms can be broadly categorized into two types, adaptive
and nonadaptive routing algorithms. They can be further categorized as
shown in the following diagram −
Adaptive Routing Algorithms
Adaptive routing algorithms, also known as dynamic routing algorithms,
makes routing decisions dynamically depending on the network
conditions. It constructs the routing table depending upon the network
traffic and topology. They try to compute the optimized route depending
upon the hop count, transit time and distance.
The three popular types of adaptive routing algorithms are −
 Centralized algorithm − It finds the least-cost path between
source and destination nodes by using global knowledge about the
network. So, it is also known as global routing algorithm.
 Isolated algorithm − This algorithm procures the routing
information by using local information instead of gathering
information from other nodes.
 Distributed algorithm − This is a decentralized algorithm that
computes the least-cost path between source and destination
iteratively in a distributed manner.
Non – Adaptive Routing Algorithms
Non-adaptive Routing algorithms, also known as static routing
algorithms, construct a static routing table to determine the path through
which packets are to be sent. The static routing table is constructed
based upon the routing information stored in the routers when the
network is booted up.
The two types of non – adaptive routing algorithms are −
 Flooding − In flooding, when a data packet arrives at a router, it is
sent to all the outgoing links except the one it has arrived on.
Flooding may be uncontrolled, controlled or selective flooding.
 Random walks − This is a probabilistic algorithm where a data
packet is sent by the router to any one of its neighbours randomly.

Unicast Routing – Link State Routing

Unicast – Unicast means the transmission from a single sender to a


single receiver. It is a point-to-point communication between sender and
receiver. There are various unicast protocols such as TCP, HTTP, etc.
 TCP is the most commonly used unicast protocol. It is a connection-
oriented protocol that relies on acknowledgement from the receiver
side.
 HTTP stands for HyperText Transfer Protocol. It is an object-oriented
protocol for communication.

There are three major protocols for unicast routing:


1. Distance Vector Routing
2. Link State Routing
3. Path-Vector Routing

Link State Routing –


Link state routing is the second family of routing protocols. While
distance-vector routers use a distributed algorithm to compute their
routing tables, link-state routing uses link-state routers to exchange
messages that allow each router to learn the entire network topology.
Based on this learned topology, each router is then able to compute its
routing table by using the shortest path computation.
Features of link state routing protocols –
 Link state packet – A small packet that contains routing
information.

 Link state database – A collection of information gathered from the


link-state packet.

 Shortest path first algorithm (Dijkstra algorithm) – A calculation


performed on the database results in the shortest path

 Routing table – A list of known paths and interfaces.

Calculation of shortest path –


To find the shortest path, each node needs to run the famous Dijkstra
algorithm. This famous algorithm uses the following steps:
 Step-1: The node is taken and chosen as a root node of the tree, this
creates the tree with a single node, and now set the total cost of each
node to some value based on the information in Link State Database
 Step-2: Now the node selects one node, among all the nodes not in
the tree-like structure, which is nearest to the root, and adds this to the
tree. The shape of the tree gets changed.
 Step-3: After this node is added to the tree, the cost of all the nodes
not in the tree needs to be updated because the paths may have been
changed.
 Step-4: The node repeats Step 2. and Step 3. until all the nodes are
added to the tree
Link State protocols in comparison to Distance Vector protocols have:
1. It requires a large amount of memory.

2. Shortest path computations require many CPU circles.


3. If a network uses little bandwidth; it quickly reacts to topology
changes

4. All items in the database must be sent to neighbors to form link-state


packets.

5. All neighbors must be trusted in the topology.

6. Authentication mechanisms can be used to avoid undesired adjacency


and problems.

7. No split horizon techniques are possible in the link-state routing.


 Open Shortest Path First (OSPF) is a unicast routing protocol
developed by a working group of the Internet Engineering Task
Force (IETF).
 It is an intradomain routing protocol.
 It is an open-source protocol.
 It is similar to Routing Information Protocol (RIP)
 OSPF is a classless routing protocol, which means that in its
updates, it includes the subnet of each route it knows about, thus,
enabling variable-length subnet masks. With variable-length
subnet masks, an IP network can be broken into many subnets of
various sizes. This provides network administrators with extra
network configuration flexibility. These updates are multicasts at
specific addresses (224.0.0.5 and 224.0.0.6).
 OSPF is implemented as a program in the network layer using the
services provided by the Internet Protocol
 IP datagram that carries the messages from OSPF sets the value of
the protocol field to 89
 OSPF is based on the SPF algorithm, which sometimes is referred
to as the Dijkstra algorithm
 OSPF has two versions – version 1 and version 2. Version 2 is
used mostly
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.

2. Database description message (Type 2) – It is normally sent in


response to the Hello message.

3. Link-state request message (Type 3) – It is used by the routers that


need information about specific Link-State packets.

4. Link-state update message (Type 4) – It is the main OSPF message


for building Link-State Database.

5. Link-state acknowledgement message (Type 5) – It is used to


create reliability in the OSPF protocol.

Distance Vector Routing (DVR) Protocol

It protocol requires that a router inform its neighbors of topology


changes periodically. Historically known as the old ARPANET routing
algorithm (or known as Bellman-Ford algorithm).
Bellman Ford Basics – Each router maintains a Distance Vector table
containing the distance between itself and ALL possible destination
nodes. Distances, based on a chosen metric, are computed using
information from the neighbors’ distance vectors.
Information kept by DV router -
 Each router has an ID
 Associated with each link connected to a router,
 there is a link cost (static or dynamic).
 Intermediate hops

Distance Vector Table Initialization -


 Distance to itself = 0
 Distance to ALL other routers = infinity number.
Distance Vector Algorithm –
1. A router transmits its distance vector to each of its neighbors in a
routing packet.
2. Each router receives and saves the most recently received distance
vector from each of its neighbors.
3. A router recalculates its distance vector when:
 It receives a distance vector from a neighbor containing different
information than before.
 It discovers that a link to a neighbor has gone down.
The DV calculation is based on minimizing the cost to each destination
Dx(y) = Estimate of least cost from x to y
C(x,v) = Node x knows cost to each neighbor v
Dx= [Dx(y): y ∈ N ] = Node x maintains distance vector
Node x also maintains its neighbors' distance vectors
– For each neighbor v, x maintains Dv = [Dv(y): y ∈N ]
Note –
 From time-to-time, each node sends its own distance vector estimate
to neighbors.
 When a node x receives new DV estimate from any neighbor v, it
saves v’s distance vector and it updates its own DV using B-F
equation:
 Dx(y) = min { C(x,v) + Dv(y), Dx(y) } for each node y ∈ N

Example – Consider 3-routers X, Y and Z as shown in figure. Each


router have their routing table. Every routing table will contain distance
to the destination nodes.
Consider router X , X will share it routing table to neighbors and
neighbors will share it routing table to it to X and distance from node X
to destination will be calculated using bellmen- ford equation.
Dx(y) = min { C(x,v) + Dv(y)} for each node y ∈ N
As we can see that distance will be less going from X to Z when Y is
intermediate node(hop) so it will be update in routing table X.
Similarly for Z also –

Finally the routing table for all –

Advantages of Distance Vector routing –


 It is simpler to configure and maintain than link state routing.
Disadvantages of Distance Vector routing –
 It is slower to converge than link state.
 It is at risk from the count-to-infinity problem.
 It creates more traffic than link state since a hop count
change must be propagated to all routers and processed on
each router. Hop count updates take place on a periodic basis,
even if there are no changes in the network topology, so
bandwidth-wasting broadcasts still occur.
 For larger networks, distance vector routing results in larger
routing tables than link state since each router must know
about all other routers. This can also lead to congestion on
WAN links.

Link State Routing

Link state routing is a technique in which each router shares the


knowledge of its neighborhood with every other router in the
internetwork.

The three keys to understand the Link State Routing algorithm:

o Knowledge about the neighborhood: Instead of sending its


routing table, a router sends the information about its
neighborhood only. A router broadcast its identities and cost of the
directly attached links to other routers.
o Flooding: Each router sends the information to every other router
on the internetwork except its neighbors. This process is known as
Flooding. Every router that receives the packet sends the copies to
all its neighbors. Finally, each and every router receives a copy of
the same information.
o Information sharing: A router sends the information to every
other router only when the change occurs in the information.

Link State Routing has two phases:


Reliable Flooding
o Initial state: Each node knows the cost of its neighbors.

o Final state: Each node knows the entire graph.


Route Calculation

Each node uses Dijkstra's algorithm on the graph to calculate the optimal
routes to all nodes.

o The Link state routing algorithm is also known as Dijkstra's


algorithm which is used to find the shortest path from one node to
every other node in the network.
o The Dijkstra's algorithm is an iterative, and it has the property that
after kth iteration of the algorithm, the least cost paths are well
known for k destination nodes.

Let's describe some notations:


o c( i , j): Link cost from node i to node j. If i and j nodes are not
directly linked, then c(i , j) = ∞.
o D(v): It defines the cost of the path from source code to destination
v that has the least cost currently.
o P(v): It defines the previous node (neighbor of v) along with
current least cost path from source to v.
o N: It is the total number of nodes available in the network.

Algorithm
Initialization
N = {A} // A is a root node.
for all nodes v
if v adjacent to A
then D(v) = c(A,v)
else D(v) = infinity
loop
find w not in N such that D(w) is a minimum.
Add w to N
Update D(v) for all v adjacent to w and not in N:
D(v) = min(D(v) , D(w) + c(w,v))
Until all nodes in N

In the above algorithm, an initialization step is followed by the loop. The


number of times the loop is executed is equal to the total number of
nodes available in the network.

35.7M
645
Prime Ministers of India | List of Prime Minister of India (1947-2020)

Let's understand through an example:

In the above figure, source vertex is A.

Step 1:
The first step is an initialization step. The currently known least cost
path from A to its directly attached neighbors, B, C, D are 2,5,1
respectively. The cost from A to B is set to 2, from A to D is set to 1 and
from A to C is set to 5. The cost from A to E and F are set to infinity as
they are not directly linked to A.

Step N D(B),P(B) D(C),P(C) D(D),P(D) D(E),P(E) D(F),P(F)

1 A 2,A 5,A 1,A ∞ ∞

Step 2:
In the above table, we observe that vertex D contains the least cost path
in step 1. Therefore, it is added in N. Now, we need to determine a least-
cost path through D vertex.

a) Calculating shortest path from A to B

1. v = B, w = D
2. D(B) = min( D(B) , D(D) + c(D,B) )
3. = min( 2, 1+2)>
4. = min( 2, 3)
5. The minimum value is 2. Therefore, the currently shortest path from A t
o B is 2.

b) Calculating shortest path from A to C

1. v = C, w = D
2. D(B) = min( D(C) , D(D) + c(D,C) )
3. = min( 5, 1+3)
4. = min( 5, 4)
5. The minimum value is 4. Therefore, the currently shortest path from A t
o C is 4.</p>

c) Calculating shortest path from A to E


1. v = E, w = D
2. D(B) = min( D(E) , D(D) + c(D,E) )
3. = min( ∞, 1+1)
4. = min(∞, 2)
5. The minimum value is 2. Therefore, the currently shortest path from A t
o E is 2.
Note: The vertex D has no direct link to vertex E. Therefore, the value of
D(F) is infinity.
Step N D(B),P(B) D(C),P(C) D(D),P(D) D(E),P(E) D(F),P(F)

1 A 2,A 5,A 1,A ∞ ∞

2 AD 2,A 4,D 2,D ∞

Step 3:
In the above table, we observe that both E and B have the least cost path
in step 2. Let's consider the E vertex. Now, we determine the least cost
path of remaining vertices through E.

a) Calculating the shortest path from A to B.

1. v = B, w = E
2. D(B) = min( D(B) , D(E) + c(E,B) )
3. = min( 2 , 2+ ∞ )
4. = min( 2, ∞)
5. The minimum value is 2. Therefore, the currently shortest path from A t
o B is 2.

b) Calculating the shortest path from A to C.

1. v = C, w = E
2. D(B) = min( D(C) , D(E) + c(E,C) )
3. = min( 4 , 2+1 )
4. = min( 4,3)
5. The minimum value is 3. Therefore, the currently shortest path from A t
o C is 3.

c) Calculating the shortest path from A to F.

1. v = F, w = E
2. D(B) = min( D(F) , D(E) + c(E,F) )
3. = min( ∞ , 2+2 )
4. = min(∞ ,4)
5. The minimum value is 4. Therefore, the currently shortest path from A t
o F is 4.
Step N D(B),P(B) D(C),P(C) D(D),P(D) D(E),P(E) D(F),P(F)

1 A 2,A 5,A 1,A ∞ ∞

2 AD 2,A 4,D 2,D ∞

3 ADE 2,A 3,E 4,E

Step 4:
In the above table, we observe that B vertex has the least cost path in
step 3. Therefore, it is added in N. Now, we determine the least cost path
of remaining vertices through B.

a) Calculating the shortest path from A to C.

1. v = C, w = B
2. D(B) = min( D(C) , D(B) + c(B,C) )
3. = min( 3 , 2+3 )
4. = min( 3,5)
5. The minimum value is 3. Therefore, the currently shortest path from A t
o C is 3.
b) Calculating the shortest path from A to F.

1. v = F, w = B
2. D(B) = min( D(F) , D(B) + c(B,F) )
3. = min( 4, ∞)
4. = min(4, ∞)
5. The minimum value is 4. Therefore, the currently shortest path from A t
o F is 4.
Step N D(B),P(B) D(C),P(C) D(D),P(D) D(E),P(E) D(F),P(F)

1 A 2,A 5,A 1,A ∞ ∞

2 AD 2,A 4,D 2,D ∞

3 ADE 2,A 3,E 4,E

4 ADEB 3,E 4,E

Step 5:

In the above table, we observe that C vertex has the least cost path in
step 4. Therefore, it is added in N. Now, we determine the least cost path
of remaining vertices through C.

a) Calculating the shortest path from A to F.

1. v = F, w = C
2. D(B) = min( D(F) , D(C) + c(C,F) )
3. = min( 4, 3+5)
4. = min(4,8)
5. The minimum value is 4. Therefore, the currently shortest path from A t
o F is 4.
Step N D(B),P( D(C),P(C) D(D),P(D D(E),P(E D(F),P(F
B) ) ) )

1 A 2,A 5,A 1,A ∞ ∞

2 AD 2,A 4,D 2,D ∞

3 ADE 2,A 3,E 4,E

4 ADEB 3,E 4,E

5 ADEB 4,E
C

Step N D(B),P(B) D(C),P(C) D(D),P(D) D(E),P(E) D(F),P(F)

1 A 2,A 5,A 1,A ∞ ∞

2 AD 2,A 4,D 2,D ∞

3 ADE 2,A 3,E 4,E

4 ADEB 3,E 4,E

5 ADEBC 4,E

6 ADEBCF
Final table:
Disadvantage:

Heavy traffic is created in Line state routing due to Flooding. Flooding


can cause an infinite looping, this problem can be solved by using Time-
to-leave field

Border Gateway Protocol

BGP stands for Border Gateway Protocol. It is a standardized gateway


protocol that exchanges routing information across autonomous systems
(AS). When one network router is linked to other networks, it cannot
decide which network is the best network to share its data to by itself.
Border Gateway Protocol considers all peering partners that a router has
and sends traffic to the router closest to the data’s destination. This
communication is possible because, at boot, BGP allows peers to
communicate their routing information and then stores that information
in a Routing Information Base (RIB).
The main goal of BGP is to find any path to the destination that is loop-
free. This is different from intradomain routing protocols’ common
goals: finding an optimal route to the destination based on a specific link
metric.
The routers that connect other ASs are called border gateways. The task
of the border gateways is to forward packets between ASs. Each AS has
at least one BGP speaker. BGP speakers exchange reachability
information among ASs.
Path-Vector Routing
RIP (Routing Information Protocol) and OSPF (Open Shortest Path
First) are not applicable for interdomain routing protocols. Distance
vector routing can send data to each of a router’s neighbours, and then
every router develops up a routing database. Routing is not familiar with
the identity of routers in any specific direction.
Every router sends its connection cost to all various routers and then
starts routing computations. Two problems can emerge in link-state
routing. First, different independent systems can use multiple costs and
have multiple drawbacks.
The link-state protocol enables a router to create the topology, and its
metrics can be different for each independent system. In this method, it
is impossible to generate a reliable routing algorithm. Second, when
flood routing appears, the use of an interdomain routing protocol across
the independent system can be ambiguous.
Types
The types of BGP are as follows −
Internal BGP
Routes are exchanged, and traffic is transmitted over the Internet using
external BGP or eBGP. Autonomous systems can also use an internal
BGP version to route through their internal networks, known as internal
BGP.
It should be noted that using internal BGP is NOT a requirement for
using external BGP. Autonomous systems can choose from several
internal protocols to connect the routers on their internal network.
External BGP
External BGP is like international shipping; some specific standards and
guidelines need to be followed when shipping a piece of mail
internationally. Once that piece of mail reaches its destination country, it
has to go through its local mail service to reach its final destination.
Each country has its internal mail service that doesn’t necessarily follow
the same guidelines as other countries. Similarly, each autonomous
system can have its internal routing protocol for routing data within its
network.

You might also like