You are currently viewing The OSI Model – Layer 6: Presentation

The OSI Model – Layer 6: Presentation

Last time, I explained the fundamentals of the fifth layer of the OSI framework: the session layer. The session layer establishes, manages, and terminates the connections between applications. It also sets up, coordinates, and terminates conversations, exchanges, and dialogues between the different applications at each end. It deals with session and connection coordination.

In this post, I will discuss the sixth layer of the model: the presentation layer. You can also see the presentation layer as the “translator” of a network. A “translator” might sound a bit odd, but I’ll show you how it works and why you can see it like this.  

Presentation layer fundamentals

The presentation layer encrypts data that you send across a network. It assures that the receiving end side understands the transmitted information effectively and efficiently. The presentation layer manages the abstract data structures. It provides safety to high-level secured data structures like banking records by defining them or exchanging them safely (encrypted). For encryption and decryption, you use specific protocols.

The layer also provides data compression to reduce the bandwidth of data that has to be transmitted, in which the primary goal of data compression is to reduce the number of bits you are sending. The presentation layer does this by specific sophisticated compression techniques that reduce the number of bytes of data that are required to represent the information that you sent over the network. There are two general types of compression: lossless compression and lossy compression.

Because different devices use different encoding methods, it is essential to translate the data between other devices: that is what the presentation layer does. The various systems also use different formats, and the presentation layer standardizes this into one standard format, creating an efficient, effective form of communication inside a network. You do this by serialization.

The presentation layer standardizes a message presented to an upper or lower layer into a proper format.

So the key features of layer six:

  • Encryption
  • Compression
  • Translation/Serialization

I will jump into more detail regarding these three key features in the remainder of this article.

Encryption

Because you transmit sensitive information over a network (in the case of the internet, a public network), it is crucial to ensure that only the intended receiver of the information can read it. You do this by adding encryption.

Encryption ciphers the data so only related nodes, systems, or devices can read this data. You reverse encryption by decryption, in which you transform encoded messages into their original form.

Encryption uses specific network protocols. The most important ones are AFP, LPP, NCP, NDR, XDR, TLS, and SSL, which I will briefly describe below.

Apple Filing Protocol (AFP)

This protocol offers services to the macOS or the classic macOS. It is the network file protocol for Apple (Mac) based platforms.

Lightweight Presentation Protocol (LPP)

You use this protocol to be able to provide ISO presentation services (Optical Disk Image/ISO image) on top of TCP/IP-based protocol standards.

NetWare Core Protocol (NCP)

You use this network protocol to access files, prints, directories, clock synchronizations, messaging, remote command executions, and other network service functions.

Network Data Representation (NDR)

The NDR is the implementation of the presentation layer in the OSI model. It provides or defines different types of primitive data, constructed data types, and several types of data representations.

External Data Representation (XDR)

The standard for description and encoding of data is XDR. It is helpful when you use this to transfer data between computer architectures and has been used to communicate data between very diverse devices/machines. When you convert from local representation to XDR, you call it “encoding.” When you convert XDR into a local model, you name it “decoding.”

Transport Layer Security (TLS)

This protocol is the successor of SSL: a security protocol used in the past. TLS has a lot of similarities with SSL but eliminates some weaknesses in SSL that third parties could exploit with bad intentions. TLS is encryption that you use to protect your data and information transfer. TLS and SSL are used interchangeably and are still widely used by the industry (although it is TLS).

Secure Socket Layer (SSL)

TLS replaced SSL, but as stated before, it is still commonly used by the industry. Like TLS, SSL uses encryption to protect the transfer of data and information. Because of some “holes” in the protocol that could lead to exploitation, network techs no longer use SSL.

Compression

You use compression to maximize bandwidth across a network or optimize disk space on your device when you save your data. You can split compression into two different categories: lossless compression and lossy compression.

Lossless compression

Lossless compression compresses data so that when you decompress it again, the data will be the same as before you compressed it. There is no loss of data; lossless

You use this form of compression in cases where the original and decompressed data must be the same or where differences from the original data would not be favorable. Examples of this are executable programs, text documents, and source code. Also, images like PNG or GIFs use this form of compression.

Sending uncompressed and lossless files across the internet uses a lot of bandwidth. It can take quite a while (and eat up a lot of bandwidth) when you want to upload/download lossless data packs like .PNG or .GIF files.’

ZIP is the most commonly used compression method out there. There are two common ways of compressing: dictionary encoding and run-length encoding.

Dictionary encoding is called substitution coding and searches for matches between a message you want to send and the messages in the dictionary. If you use the complete English dictionary as the dictionary and want to compress the contents of a book, you replace each word with the word’s location in the dictionary. This way, you only have to store a reference, reducing the file size. When you decompress the message, it works oppositely, and the word in that location replaces it.

Run-length encoding is an algorithm that replaces a subset of data repeated many times with the data subset and a number that represents the number of repetitions. You can compare this type of compression with a fax machine. Faxes are white sheets with some black text. A run-length encoding scheme takes each line and transmits a code for the white on the paper and then the number of pixels. After that, the code for black, the number of pixels, and so on. Because most of the fax is white, it greatly reduces the length of the message that the fax transmits. Be very careful with this type of compression if you don’t have a lot of redundant data. In that case, the run-length encoding scheme might increase the size of a file.

If you have to archive files, edit files, or where professional standards demand the highest quality of data, you use no compression or lossless techniques.

Lossy compression

Because sending uncompressed and lossless files over the network takes up a lot of bandwidth, lossy techniques are available. These techniques achieve high levels of compressions with no noticeable loss of quality. The only downside is that the data is not precisely the same. Sometimes, this is not a problem because you don’t notice the difference. Examples of lossy compression files are JPEG, MP3, and MPEG files, and the minor degeneration in data is not noticeable. If data transmission or computer performance is essential, then lossy techniques are beneficial.

Serialization

Serialization allows you to save an object’s state into bytes. When you serialize an object into bytes, you can transfer the object to a database, memory, or file. After the transfer, you can recreate the object as needed, providing storage of objects and data exchange. You reverse the process: deserialization.

You can use serialization for:

  • Persisting data onto files. Persisting data onto files happens mostly in language-neutral formats such as CSV or XML. Most languages allow objects to be serialized directly into binary using APIs such as the serializable interface in Java, fstream class in C++, or the Pickle module in Python.
  • Storing data into a Database. Program objects are converted into byte streams and stored in databases, such as Java JDBC (Java Database Connectivity).
  • Transferring data through the network. For instance, web applications and mobile apps pass objects from client to server and vice versa.
  • Remote Method Invocation (RMI). This method passes serialized objects as parameters to functions running on a remote machine as if invoked on a local device. You transmit the data across domains through firewalls. 
  • Sharing data in a Distributed Object Model. Programs written in different languages (running on other platforms) must share object data over a distributed network. SOAP and REST APIs can do this.

There is no one-size-fits-all serialization format. The best structure depends on factors like the type/amount of serialized data and the software that will be reading this. The most popular serialization languages are CSV, JSON, XML, Protobuf, and BSON.

Final Thoughts

Layer six gives independence from differences in the representation of (encrypted) data. Layer six does this by translating from application to network format and the other way around. Layer six structures and encrypts data that is sent across a network and eliminates the risk of compatibility problems. The layer transforms data into the form that an application accepts and understands. Sometimes this layer is also called the “syntax” layer. The syntax is a computer term defined as a computer language’s structure of statements. It encrypts the data and sends it across a network, providing freedom from compatibility problems.

Feel free to contact me if you have questions or in case you have any additional advice/tips about this subject. If you want to keep in the loop if I upload a new post, feel free to subscribe to receive a notification by email.

Leave a Reply