Unit 5 - Presentation Layer
Unit 5 - Presentation Layer
PRESENTATION LAYER
The primary goal of this layer is to take care of the syntax and semantics of the information
exchanged between two communicating systems.
Languages(syntax) can be different of the two communicating systems. Under this condition
presentation layer plays a role translator.
1. Translation: Before being transmitted, information in the form of characters and numbers
should be changed to bit streams. The presentation layer is responsible for interoperability
between encoding methods as different computers use different encoding methods. It
translates data between the formats the network requires and the format the computer.
2. Encryption/Decryption: It carries out encryption at the transmitter and decryption at the
receiver. Encryption and decryption help protect the confidentiality of the data stored on
computer systems or wired over the internet or other computer networks. Nowadays,
modern-day encryption/decryption can provide not only confidentiality but also,
authentication and integrity.
3. Compression: It carries out data compression to reduce the bandwidth of the data to be
transmitted. The primary role of Data compression is to reduce the number of bits to be
transmitted. It is important in transmitting multimedia such as audio, video, text etc.
Compression is often used to maximize the use of bandwidth across a network or to
optimize disk space when saving data.
DATA COMPRESSION
Data compression implies sending or storing a smaller number of bits. Although many methods
are used for this purpose, in general these methods can be divided into two broad categories:
lossless and lossy methods
Lossless Compression:
In lossless data compression, the integrity of the data is preserved. The original data and the
data after compression and decompression are exactly the same because, in these methods, the
compression and decompression algorithms are exact inverses of each other: no part of the data
is lost in the process. Redundant data is removed in compression and added during
decompression. Lossless compression methods are normally used when we cannot afford to
lose any data.
1. Run-length encoding
Run-length encoding is probably the simplest method of compression. It can be used to
compress data made of any combination of symbols. It does not need to know the frequency
of occurrence of symbols and can be very efficient if data is represented as 0s and 1s.
The general idea behind this method is to replace consecutive repeating occurrences of a
symbol by one occurrence of the symbol followed by the number of occurrences. for
example, 0 and 1
2. Huffman coding
Huffman coding assigns shorter codes to symbols that occur more frequently and longer
codes to those that occur less frequently. For example, imagine we have a text file that uses
only five characters (A, B, C, D, E). Before we can assign bit patterns to each character,
we assign each character a weight based on its frequency of use.
A character’s code is found by starting at the root and following the branches that lead to that
character. The code itself is the bit value of each branch on the path, taken in sequence.
3. Lempel Ziv encoding
Lempel Ziv (LZ) encoding is an example of a category of algorithms called dictionary-
based encoding. The idea is to create a dictionary (a table) of strings used during the
communication session. If both the sender and the receiver have a copy of the dictionary,
then previously-encountered strings can be substituted by their index in the dictionary to
reduce the amount of information transmitted. In this phase there are two concurrent events:
building an indexed dictionary and compressing a string of symbols.
Compression occurs when the substring, except for the last character, is replaced with the
index found in the dictionary. The process then inserts the index and the last character of
the substring into the compressed string.
Decompression is the inverse of the compression process. The process extracts the
substrings from the compressed string and tries to replace the indexes with the
corresponding entry in the dictionary, which is empty at first and built up gradually. The
idea is that when an index is received, there is already an entry in the dictionary
corresponding to that index.
LOSSY COMPRESSION METHODS:
Lossy compression reduces a file by permanently eliminating certain information, especially
redundant information. When the file is uncompressed, only a part of the original information
is still there (although the user may not notice it).
Lossy compression is generally used for video and sound, where a certain amount of
information loss will not be detected by most users.
JPEG (Joint Photographic Experts Group) encoding is used to compress pictures and
graphics, MPEG (Moving Picture Experts Group) encoding is used to compress video, and
MP3 (MPEG audio layer 3) for audio compression.
1. JPEG: Image Compression
An image can be represented by a two-dimensional array (table) of picture elements
(pixels).
A grayscale picture of 307,200 pixels is represented by 2,457,600 bits, and a color picture
is represented by 7,372,800 bits.
In JPEG, a grayscale picture is divided into blocks of 8 × 8-pixel blocks to decrease the
number of calculations. (because, the number of mathematical operations for each picture
is the square of the number of units)
The whole idea of JPEG is to change the picture into a linear (vector) set of numbers that
reveals the redundancies. The redundancies (lack of changes) can then be removed using
one of the lossless compression methods.
Encryption/ Decryption
Decryption – reverses the original process to transform the message (ciphertext) back to its
original form (plaintext).
Encrytption/Decryption Keys
Asymmetric Keys -2 keys are needed (public key and private key); 1 key to encrypt, another
key to decrypt and vice versa.
Eg.: RSA and Diffie-Hellman
How Encryption Protects