Unit 4 CN
Unit 4 CN
o Distributed: It is distributed in that each node receives information from one or more
of its directly attached neighbors, performs calculation and then distributes the result
back to its neighbors.
o Asynchronous: It does not require that all of its nodes operate in the lock step with
each other.
o Knowledge about the whole network: Each router shares its knowledge through the entire
network. The Router sends its collected knowledge about the network to its neighbors.
o Routing only to neighbors: The router sends its knowledge about the network to only those
routers which have direct links. The router sends whatever it has about the network through
the ports. The information is received by the router and uses the information to update its own
routing table.
o Information sharing at regular intervals: Within 30 seconds, the router sends the
information to the neighboring routers.
Note: In Distance vector algorithm, node x update its table when it either see any cost change in one
directly linked nodes or receives any vector update from some neighbor.
o In the above figure, each cloud represents the network, and the number inside the cloud
represents the network ID.
o All the LANs are connected by routers, and they are represented in boxes labeled as A, B, C,
D, E, F.
o Distance vector routing algorithm simplifies the routing process by assuming the cost of every
link is one unit. Therefore, the efficiency of transmission can be measured by the number of
links to reach the destination.
In the above figure, we observe that the router sends the knowledge to the immediate neighbors. The
neighbors add this knowledge to their own knowledge and sends the updated table to their own
neighbors. In this way, routers get its own information plus the new information about the neighbors.
Routing Table
Initially, the routing table is created for each router that contains atleast three types of information
such as Network ID, the cost and the next hop.
o NET ID: The Network ID defines the final destination of the packet.
o Cost: The cost is the number of hops that packet must take to get there.
For Example:
o When A receives a routing table from B, then it uses its information to update the table.
o The routing table of B shows how the packets can move to the networks 1 and 4.
o The B is a neighbor to the A router, the packets from A to B can reach in one hop. So, 1 is
added to all the costs given in the B's table and the sum will be the cost to reach a particular
network.
o After adjustment, A then combines this table with its own table to create a combined table.
o The combined table may contain some duplicate data. In the above figure, the combined table
of router A contains the duplicate data, so it keeps only those data which has the lowest cost.
For example, A can send the data to network 1 in two ways. The first, which uses no next
router, so it costs one hop. The second requires two hops (A to B, then B to Network 1). The
first option has the lowest cost, therefore it is kept and the second one is dropped.
o The process of creating the routing table continues for all routers. Every router receives the
information from the neighbors, and update the routing table.
Since the Bellman-Ford algorithm is unable to prevent loops, the fundamental problem with Distance
Vector Routing (DVR) protocols is Routing Loops. The Count to Infinity Problem is brought on by
this routing loop in the DVR network. When two routers deliver updates simultaneously or when an
interface goes down, routing loops frequently happen.
Count to Infinity:
Distance-vector routing has the drawback that while cost increases (bad news) propagate slowly, cost
decreases (positive news) propagate quickly. Distance-vector routing takes some time for all other
routers to become aware of a broken connection (cost becomes infinity), which is necessary for a
routing protocol to function properly. Counting to infinity is the name given to the issue. A broken
link's cost may not always be registered as infinite by all routers until numerous updates have passed.
The two-node loop issue is an example of count to infinity. Let's examine the case shown in Figure to
better grasp the issue.
o A system with three nodes is depicted in the figure. Only the elements of the forwarding table
required for our discussion have been displayed. Nodes A and B are first able to connect to
node X. However, the connection between A and X abruptly breaks down. The table of Node
A is altered. Everything will be good if A can quickly transmit its table to B. If B, instead of
waiting for A to transmit its forwarding table, sends its forwarding table to A first, the system
becomes unstable.
o When Node A receives the update, it instantly updates its forwarding table in the event that B
has managed to connect to X. A has just updated B and sent it a fresh message. B has now
updated its forwarding table as it believes that something has changed around A. Until it
approaches infinity, the price of getting to X rises gradually. Both A and B are aware that X
cannot be reached at this time. In contrast, the system is unstable at the present time.
o Node A believes that node B is the path to X, while node B believes that node A is the way to
X. When A gets a packet intended for X, the packet first travels to B before returning to A.
Similar to this, if B receives a packet meant for X, it travels to A before returning to B. A two-
node loop problem is caused by packets bouncing between A and B. There are a few remedies
that have been suggested for this form of instability.
Link state routing is a technique in which each router shares the knowledge of its neighborhood with
every other router in the internetwork.
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.
Reliable Flooding
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 k th iteration of the
algorithm, the least cost paths are well known for k destination nodes.
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.
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 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.
1. v = B, w = D
3. = min( 2, 1+2)>
4. = min( 2, 3)
1. v = C, w = D
3. = min( 5, 1+3)
4. = min( 5, 4)
5. The minimum value is 4. Therefore, the currently shortest path from A to C is 4.</p>
c) Calculating shortest path from A to E
1. v = E, w = D
3. = min( ∞, 1+1)
4. = min(∞, 2)
Note: The vertex D has no direct link to vertex E. Therefore, the value of D(F) is infinity.
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.
1. v = B, w = E
3. = min( 2 , 2+ ∞ )
4. = min( 2, ∞)
1. v = C, w = E
3. = min( 4 , 2+1 )
4. = min( 4,3)
1. v = F, w = E
3. = min( ∞ , 2+2 )
4. = min(∞ ,4)
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.
1. v = C, w = B
3. = min( 3 , 2+3 )
4. = min( 3,5)
1. v = F, w = B
3. = min( 4, ∞)
4. = min(4, ∞)
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.
1. v = F, w = C
3. = min( 4, 3+5)
4. = min(4,8)
5 ADEBC 4,E
Final table:
5 ADEBC 4,E
6 ADEBCF
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.
TCP stands for Transmission Control Protocol. It is a transport layer protocol that facilitates the
transmission of packets from source to destination. It is a connection-oriented protocol that means it
establishes the connection prior to the communication that occurs between the computing devices in a
network. This protocol is used with an IP protocol, so together, they are referred to as a TCP/IP.
The main functionality of the TCP is to take the data from the application layer. Then it divides the
data into a several packets, provides numbering to these packets, and finally transmits these packets to
the destination. The TCP, on the other side, will reassemble the packets and transmits them to the
application layer. As we know that TCP is a connection-oriented protocol, so the connection will
remain established until the communication is not completed between the sender and the receiver.
o Reliable:TCP is a reliable protocol as it follows the flow and error control mechanism. It also
supports the acknowledgment mechanism, which checks the state and sound arrival of the
data. In the acknowledgment mechanism, the receiver sends either positive or negative
acknowledgment to the sender so that the sender can get to know whether the data packet has
been received or needs to resend.
o Order of the data is maintained:This protocol ensures that the data reaches the intended
receiver in the same order in which it is sent. It orders and numbers each segment so that the
TCP layer on the destination side can reassemble them based on their ordering.
o Full duplex:It is a full-duplex means that the data can transfer in both directions at the same
time.
Working of TCP
In TCP, the connection is established by using three-way handshaking. The client sends the segment
with its sequence number. The server, in return, sends its segment with its own sequence number as
well as the acknowledgement sequence, which is one more than the client sequence number. When the
client receives the acknowledgment of its segment, then it sends the acknowledgment to the server. In
this way, the connection is established between the client and the server.
Advantages of TCP
o It provides a connection-oriented reliable service, which means that it guarantees the delivery
of data packets. If the data packet is lost across the network, then the TCP will resend the lost
packets.
o It provides error detection by using checksum and error control by using Go Back or ARP
protocol.
o It eliminates the congestion by using a network congestion avoidance algorithm that includes
various schemes such as additive increase/multiplicative decrease (AIMD), slow start, and
congestion window.
Disadvantage of TCP: It increases a large amount of overhead as each segment gets its own TCP
header, so fragmentation by the router increases the overhead.
o Source port: It defines the port of the application, which is sending the data. So, this field
contains the source port address, which is 16 bits.
o Destination port: It defines the port of the application on the receiving side. So, this field
contains the destination port address, which is 16 bits.
o Sequence number: This field contains the sequence number of data bytes in a particular
session.
o Acknowledgment number: When the ACK flag is set, then this contains the next sequence
number of the data byte and works as an acknowledgment for the previous data received. For
example, if the receiver receives the segment number 'x', then it responds 'x+1' as an
acknowledgment number.
o HLEN: It specifies the length of the header indicated by the 4-byte words in the header. The
size of the header lies between 20 and 60 bytes. Therefore, the value of this field would lie
between 5 and 15.
o Reserved: It is a 4-bit field reserved for future use, and by default, all are set to zero.
o Flags
There are six control bits or flags:
o URG: It represents an urgent pointer. If it is set, then the data is processed urgently.
o ACK: If the ACK is set to 0, then it means that the data packet does not contain an
acknowledgment.
o PSH: If this field is set, then it requests the receiving device to push the data to the
receiving application without buffering it.
o FIN: It is used to release a connection, and no further data exchange will happen.
o Window size
It is a 16-bit field. It contains the size of data that the receiver can accept. This field is used
for the flow control between the sender and receiver and also determines the amount of buffer
allocated by the receiver for a segment. The value of this field is determined by the receiver.
o Checksum
It is a 16-bit field. This field is optional in UDP, but in the case of TCP/IP, this field is
mandatory.
o Urgent pointer
It is a pointer that points to the urgent data byte if the URG flag is set to 1. It defines a value
that will be added to the sequence number to get the sequence number of the last urgent byte.
o Options
It provides additional options. The optional field is represented in 32-bits. If this field
contains the data less than 32-bit, then padding is required to obtain the remaining bits.
User Datagram Protocol (UDP) is a Transport Layer protocol. UDP is a part of the Internet Protocol
suite, referred to as UDP/IP suite. Unlike TCP, it is an unreliable and connectionless protocol. So,
there is no need to establish a connection before data transfer. The UDP helps to establish low-latency
and loss-tolerating connections over the network. The UDP enables process-to-process
communication.
UDP Header
UDP header is an 8-byte fixed and simple header, while for TCP it may vary from 20 bytes to 60
bytes. The first 8 Bytes contain all necessary header information and the remaining part consists of
data. UDP port number fields are each 16 bits long, therefore the range for port numbers is defined
from 0 to 65535; port number 0 is reserved. Port numbers help to distinguish different user requests or
processes.
UDP Header
Source Port: Source Port is a 2 Byte long field used to identify the port number of the source.
Destination Port: It is a 2 Byte long field, used to identify the port of the destined packet.
Length: Length is the length of UDP including the header and the data. It is a 16-bits field.
Checksum: Checksum is 2 Bytes long field. It is the 16-bit one’s complement of the one’s
complement sum of the UDP header, the pseudo-header of information from the IP header,
and the data, padded with zero octets at the end (if necessary) to make a multiple of two
octets.
Notes – Unlike TCP, the Checksum calculation is not mandatory in UDP. No Error control or flow
control is provided by UDP. Hence UDP depends on IP and ICMP for error reporting. Also UDP
provides port numbers so that is can differentiate between users requests.
Applications of UDP
Used for simple request-response communication when the size of data is less and hence there
is lesser concern about flow and error control.
UDP is used for some routing update protocols like RIP(Routing Information Protocol).
Normally used for real-time applications which can not tolerate uneven delays between
sections of a received message.
VoIP (Voice over Internet Protocol) services, such as Skype and WhatsApp, use UDP for real-
time voice communication. The delay in voice communication can be noticeable if packets
are delayed due to congestion control, so UDP is used to ensure fast and efficient data
transmission.
DNS (Domain Name System) also uses UDP for its query/response messages. DNS queries
are typically small and require a quick response time, making UDP a suitable protocol for this
application.
DHCP (Dynamic Host Configuration Protocol) uses UDP to dynamically assign IP addresses
to devices on a network. DHCP messages are typically small, and the delay caused by packet
loss or retransmission is generally not critical for this application.
o BOOTP, DHCP.
o Trace Route
o Record Route
o Timestamp
UDP takes a datagram from Network Layer , attaches its header, and sends it to the user. So, it
works fast.
TCP vs UDP
TCP provides extensive error-checking UDP has only the basic error-
Error checking mechanisms. It is because it provides flow checking mechanism using
mechanism control and acknowledgment of data. checksums.
Acknowledgme
An acknowledgment segment is present. No acknowledgment segment.
nt
There is no retransmission of
Retransmission of lost packets is possible in
lost packets in the User
TCP, but not in UDP.
Retransmission Datagram Protocol (UDP).
TCP has a (20-60) bytes variable length UDP has an 8 bytes fixed-length
Header Length header. header.
Handshaking Uses handshakes such as SYN, ACK, SYN- It’s a connectionless protocol
Techniques ACK i.e. No handshake
Advantages of UDP
Speed: UDP is faster than TCP because it does not have the overhead of establishing a
connection and ensuring reliable data delivery.
Lower latency: Since there is no connection establishment, there is lower latency and faster
response time.
Simplicity: UDP has a simpler protocol design than TCP, making it easier to implement and
manage.
Broadcast support: UDP supports broadcasting to multiple recipients, making it useful for
applications such as video streaming and online gaming.
Smaller packet size: UDP uses smaller packet sizes than TCP, which can reduce network
congestion and improve overall network performance.
User Datagram Protocol (UDP) is more efficient in terms of both latency and bandwidth.
Disadvantages of UDP
No reliability: UDP does not guarantee delivery of packets or order of delivery, which can
lead to missing or duplicate data.
No congestion control: UDP does not have congestion control, which means that it can send
packets at a rate that can cause network congestion.
Limited use cases: UDP is not suitable for applications that require reliable data delivery, such
as email or file transfers, and is better suited for applications that can tolerate some data loss,
such as video streaming or online gaming.
Congestion Control
Congestion control is a crucial concept in computer networks. It refers to the methods used to prevent
network overload and ensure smooth data flow. When too much data is sent through the network at
once, it can cause delays and data loss. Congestion control techniques help manage the traffic, so all
users can enjoy a stable and efficient network connection. These techniques are essential for
maintaining the performance and reliability of modern networks.
What is Congestion?
Congestion in a computer network happens when there is too much data being sent at the same time,
causing the network to slow down. Just like traffic congestion on a busy road, network congestion
leads to delays and sometimes data loss. When the network can’t handle all the incoming data, it gets
“clogged,” making it difficult for information to travel smoothly from one place to another.
Improved Network Stability: Congestion control helps keep the network stable by
preventing it from getting overloaded. It manages the flow of data so the network doesn’t
crash or fail due to too much traffic.
Reduced Latency and Packet Loss: Without congestion control, data transmission can
slow down, causing delays and data loss. Congestion control helps manage traffic better,
reducing these delays and ensuring fewer data packets are lost, making data transfer faster and
the network more responsive.
Enhanced Throughput: By avoiding congestion, the network can use its resources more
effectively. This means more data can be sent in a shorter time, which is important for
handling large amounts of data and supporting high-speed applications.
Fairness in Resource Allocation: Congestion control ensures that network resources are
shared fairly among users. No single user or application can take up all the bandwidth,
allowing everyone to have a fair share.
Better User Experience: When data flows smoothly and quickly, users have a better
experience. Websites, online services, and applications work more reliably and without
annoying delays.
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.
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:
When host wants to send packet, packet is thrown into the bucket.
The bucket leaks at a constant rate, meaning the network interface transmits packets at a
constant rate.
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..
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:
If there is a ready packet, a token is removed from the bucket, and the packet is 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.
Advantages
Stable Network Operation: Congestion control ensures that networks remain stable and
operational by preventing them from becoming overloaded with too much data traffic.
Less Data Loss: By regulating the amount of data in the network at any given time,
congestion control reduces the likelihood of data packets being lost or discarded.
Optimal Resource Utilization: It helps networks use their resources efficiently, allowing for
better throughput and ensuring that users can access data and services without interruptions.
Disadvantages
Overhead: Some congestion control techniques introduce additional overhead, which can
consume network resources and affect overall performance.
Resource Allocation Issues: Fairness in resource allocation, while a benefit, can also pose
challenges when trying to prioritize critical applications over less essential ones.
The bucket holds tokens generated at regular When the host has to send a packet , packet is
intervals of time. thrown in bucket.
If there is a ready packet , a token is removed Bursty traffic is converted into uniform traffic
from Bucket and packet is send. by leaky bucket.
If there is no token in the bucket, then the In practice bucket is a finite queue outputs at
packet cannot be sent. finite rate.
Computer network security consists of measures taken by business or some organizations to monitor
and prevent unauthorized access from the outside attackers.
Network Administrator controls access to the data and software on the network. A network
administrator assigns the user ID and password to the authorized person.
o Network security is essential for safeguarding client data and information, maintaining the
security of shared data, guaranteeing dependable network performance, and defending against
online attacks.
o An effective network security solution lowers overhead costs and protects businesses from
significant losses brought on by a data breach or other security event.
o Ensuring appropriate access to systems, applications, and data facilitates company operations
and customer service.
o Message Integrity: Data integrity means that the data must arrive at the receiver exactly as it
was sent. There must be no changes in the data content during transmission, either
maliciously or accident, in a transit. As there are more and more monetary exchanges over the
internet, data integrity is more crucial. The data integrity must be preserved for secure
communication.
o End-point authentication: Authentication means that the receiver is sure of the sender?s
identity, i.e., no imposter has sent the message.
o Non-Repudiation: Non-Repudiation means that the receiver must be able to prove that the
received message has come from a specific sender. The sender must not deny sending a
message that he or she send. The burden of proving the identity comes on the receiver. For
example, if a customer sends a request to transfer the money from one account to another
account, then the bank must have a proof that the customer has requested for the transaction.
In the modern environment, no method can guarantee complete security. However, measures may be
taken to protect data when it is sent across an unprotected network or the internet. The most popular
method is cryptography. Encrypting plain-text data using cryptography makes it more difficult to
decipher and understand. Today, a variety of cryptographic algorithms are accessible, as follows:
The sender and the receiver share one secret key. The data is encrypted at the sender's end using this
secret key. Data is encrypted before being transferred to the recipient via a public network. The
recipient may readily decipher the encrypted data packets because they are both aware of and possess
the Secret Key.
The Data Encryption Standard (DES) is an illustration of secret key encryption. It is challenging to
administer Secret Key encryption since each computer on the network needs a unique key.
3. Message Digest
In this approach, a hash value is computed and delivered in place of actual data. The second end user
generates its hash value and contrasts it with the most recent one. It is approved if both hash values
match; otherwise, it is refused.
Message Digest example using MD5 hashing. It is mostly utilized in authentication processes when
server passwords are compared against user passwords.
Privacy
The concept of how to achieve privacy has not been changed for thousands of years: the message
cannot be encrypted. The message must be rendered as opaque to all the unauthorized parties. A good
encryption/decryption technique is used to achieve privacy to some extent. This technique ensures
that the eavesdropper cannot understand the contents of the message.
Encryption/Decryption
Encryption: Encryption means that the sender converts the original information into another form
and sends the unintelligible message over the network.
Decryption: Decryption reverses the Encryption process in order to transform the message back to
the original form.
The data which is to be encrypted at the sender site is known as plaintext, and the encrypted data is
known as ciphertext. The data is decrypted at the receiver site.
Advertisement
o The sender uses the secret key and encryption algorithm to encrypt the data; the receiver uses
this key and decryption algorithm to decrypt the data.
o In Secret Key Encryption/Decryption technique, the algorithm used for encryption is the
inverse of the algorithm used for decryption. It means that if the encryption algorithm uses a
combination of addition and multiplication, then the decryption algorithm uses a combination
of subtraction and division.
o The secret key encryption algorithm is also known as symmetric encryption algorithm
because the same secret key is used in bidirectional communication.
o In secret key encryption/decryption algorithm, the secret code is used by the computer to
encrypt the information before it is sent over the network to another computer.
o The secret key requires that we should know which computers are talking to each other so
that we can install the key on each computer.
o The Data Encryption Standard (DES) was designed by IBM and adopted by the U.S.
government as the standard encryption method for nonmilitary and nonclassified use.
o The Data Encryption Standard is a standard used for encryption, and it is a form of
Secret Key Cryptography.
Advantage
Efficient: The secret key algorithms are more efficient as it takes less time to encrypt the message
than to encrypt the message by using a public key encryption algorithm. The reason for this is that the
size of the key is small. Due to this reason, Secret Key Algorithms are mainly used for encryption and
decryption.
o Each pair of users must have a secret key. If the number of people wants to use this method in
the world is N, then there are N(N-1)/2 secret keys. For example, for one million people, then
there are half billion secret keys.
o The distribution of keys among different parties can be very difficult. This problem can be
resolved by combining the Secret Key Encryption/Decryption with the Public Key
Encryption/Decryption algorithm.
o There are two keys in public key encryption: a private key and a public key.
o The private key is given to the receiver while the public key is provided to the public.
In the above figure, we see that A is sending the message to user B. 'A' uses the public key to encrypt
the data while 'B' uses the private key to decrypt the data.
o In public key Encryption/Decryption, the public key used by the sender is different from the
private key used by the receiver.
o The public key is available to the public while the private key is kept by each individual.
o The main restriction of private key encryption is the sharing of a secret key. A third party
cannot use this key. In public key encryption, each entity creates a pair of keys, and they keep
the private one and distribute the public key.
o The number of keys in public key encryption is reduced tremendously. For example, for one
million users to communicate, only two million keys are required, not a half-billion keys as in
the case of secret key encryption.
o Speed: One of the major disadvantage of the public-key encryption is that it is slower than
secret-key encryption. In secret key encryption, a single shared key is used to encrypt and
decrypt the message which speeds up the process while in public key encryption, different
two keys are used, both related to each other by a complex mathematical process. Therefore,
we can say that encryption and decryption take more time in public key encryption.
o Authentication: A public key encryption does not have a built-in authentication. Without
authentication, the message can be interpreted or intercepted without the user's knowledge.
o Inefficient: The main disadvantage of the public key is its complexity. If we want the method
to be effective, large numbers are needed. But in public key encryption, converting the
plaintext into ciphertext using long keys takes a lot of time. Therefore, the public key
encryption algorithms are efficient for short messages not for long messages.
It is also known as
It is also known as
Other name Asymmetric Key
Symmetric Key encryption.
Encryption.
Digital Signature
The Digital Signature is a technique which is used to validate the authenticity and integrity of the
message. We know that there are four aspects of security: privacy, authentication, integrity, and non-
repudiation. We have already discussed the first aspect of security and other three aspects can be
achieved by using a digital signature.
The basic idea behind the Digital Signature is to sign a document. When we send a document
electronically, we can also sign it. We can sign a document in two ways: to sign a whole document
and to sign a digest.
o In Digital Signature, the private key is used for encryption while the public key is used for
decryption.
o Integrity: The Digital Signature preserves the integrity of a message because, if any
malicious attack intercepts a message and partially or totally changes it, then the decrypted
message would be impossible.
o Authentication: We can use the following reasoning to show how the message is
authenticated. If an intruder (user X) sends a message pretending that it is coming from
someone else (user A), user X uses her own private key to encrypt the message. The message
is decrypted by using the public key of user A. Therefore this makes the message unreadable.
Encryption with X's private key and decryption with A's public key results in garbage value.
Note: Digital Signature does not provide privacy. If there is a need for privacy, then another layer of
encryption/decryption is applied.
o Public key encryption is efficient if the message is short. If the message is long, a public key
encryption is inefficient to use. The solution to this problem is to let the sender sign a digest
of the document instead of the whole document.
o The sender creates a miniature version (digest) of the document and then signs it, the receiver
checks the signature of the miniature version.
o The hash function is used to create a digest of the message. The hash function creates a fixed-
size digest from the variable-length message.
o The two most common hash functions used: MD5 (Message Digest 5) and SHA-1 (Secure
Hash Algorithm 1). The first one produces 120-bit digest while the second one produces a
160-bit digest.
o The miniature version (digest) of the message is created by using a hash function.
o After the digest is encrypted, then the encrypted digest is attached to the original message and
sent to the receiver.
o The receiver receives the original message and encrypted digest and separates the two. The
receiver implements the hash function on the original message to create the second digest, and
it also decrypts the received digest by using the public key of the sender. If both the digests
are same, then all the aspects of security are preserved.