OSI Model Seven Layer Explained

Protocol Reference Model Introduction

Consider you as developing a network with your own devices specifications and software,  implemented in your home and you are going to connect your network with the friends Jacob’s network (in his he implemented according to his ideas) so interconnecting both network is a problem. For successfully connecting to each other's on network, you both have to discuss and negotiate some common terms. This what happened in mid-70’s the vendors developed their own protocols to implement in network so the other devices manufactured from different vendors cannot take part in network. ISO (International Standard Organization) came with OSI (Open System Interconnect) reference model in 1984. Therefore, in building the network we can use devices manufactured by different vendors
The two most recognized network reference models are:
  1.  Open Systems Interconnection (OSI) model
  2.  The Department of Defense (DoD) model
If there is no network reference model (also network blueprint) the organization should be using single vendor equipment thus the Internet would practically impossible.

Advantages of Protocol reference model

  1. Multiple vendor neutrality so we can use devices from different vendors.
  2. It makes networking in to granular pieces so it is easy to understand, designing and troubleshooting networks.
  3. The change in one layer does not affect other layers.
In this tutorial we are going to look deep in to seven layers of OSI model.

Introduction To OSI Model
Layer7: Application Layer
Layer6: Presentation Layer
Layer5: Session Layer
Layer4: Transport Layer
Layer3: Network Layer
Layer2: Data Link Layer
Layer1: Physical Layer
Encapsulation Of Data in OSI Model
OSI model Explained with Example
OSI Layer Model Conclusion

OSI Seven Layer Reference Model

7-layer-osi-modelOSI (Open System Interconnect) is conceptual framework for understanding relationship and guide to
vendors to make inter vendor operable devices. OSI is a logical model, to implementing standards for devices and software’s in the network.
In 1984, ISO formalized OSI. It is a seven-layered model. Application Layer (Layer 7), Presentation Layer (L6), Session Layer (L5), Transport Layer (L4), Network Layer (L3), Data Link Layer (L2) and Physical Layer (L1).
Top three layers focus on applications in the end devices and implemented in software and closest to the end user; it does not know anything about the how the data transmitted and the logical addressing schemes used.
The bottom layers defines how the data is transmitted and through which media. The physical layer and the data link layer are implemented on both hardware and software. The lowest layer, the physical layer, is closest to the physical network medium types and is responsible for actually placing information on the medium.

Layer 7: Application Layer

Layer seven of the OSI model, which is the only layer interacting with the user. Application layer is software defined. Therefore, we can think this layers as interface between the application program and underlying layers, which will make data to propagate through the protocol stack.
As its name is application it can misleads to think that programs such as excel, browser reside on this layer but actually this is not true, the services that support the application program resides in this layer. Example we all have mail clients Microsoft outlook which is not residing in application layer the protocols that support outlook POP3, SMTP they reside in this layer.

Functions of Application Layer:

  1. Identifies communication partners.
  2. Determines resource availability.
  3. Synchronizes communication.
Service advertisements of the application layer means it helps the other devices on the network to aware about the resources that the network has; consider that in our network we had a Wi-Fi enabled printer so all other devices on this network know about that printer only by the service advertisements that they produced.

Application Layer Protocols

Protocols in Application Layer Description
DHCP Dynamic Host Configuration Protocol; Assigns IP address, DNS
Server, default gateway addresses to hosts.
DNS Domain Naming System used to resolve domain address from domain name
FTP File Transfer Protocol used to send and retrieves all type of files
HTTP Hypertext Transfer Protocol) used to Browse web pages.
IMAP Internet Message Access Protocol for mail retrieve and storage alternate to POP
LDAP Lightweight Directory Access Protocol used to access and maintain distributed directories over internet.
NTP Network Time Protocol used to Synchronizes networked device clocks.
POP3 Post Office Protocol v3 used to retrieve mail from server
RTP Real time Transfer Protocol used in VOIP services.
RTSP Real Time Streaming Protocol used to connect with streaming media servers
SSH Secure Shell used to connect with remote host for managing through encrypted connection.
Telnet Provides connection and manage remote device.
TFTP Trivial File Transfer Protocol a simple, lightweight file transfer protocol
SIP Session Initiation Protocol used to signaling and controlling multimedia sessions mainly used over Internet telephone, video calls and instant messaging.
SNMP Simple Network Management Protocol Allows control of devices in the Network
SMTP Simple Mail Transfer Protocol used to send mail

Layer 6: Presentation Layer

The presentation layer is implemented on software, which will take the data from the application layer and formats; this layer ensure that the data transmitted from device would be readable by the application device of the other devices

Functions of Presentation Layer

Data Formatting

This layer formats data received from the application layer. ASCII (American Standard Code for Information Interchange) and EBCDIC (Extended Binary Code Decimal Interchange Code) developed by IBM, think that if one device is using ASCII and other uses EBCDIC;  So this layer converts one format to another  so that application layer data from device can be read on another .
Example of Presentation Layer Formats
  • Text - ASCII, EBCDIC, RTF
  • Audio - MP3, WAV, MIDI, WMA
  • Movies – MOV, MPEG, AVI,
  • Images - GIF, JPG, TIFF, PNG, BMP

Encoding

This provides us data encryption; data encrypted at the source device should be properly deciphered at the destination.

Compression

Data in sender device can be compressed; other end device should properly decompress data compressed at one end device.

Layer 5: Session Layer

Session layer is implemented on the software its function is to establishes, maintain and terminates the session; this layer maintain connection with the other end device. If a session is broken due to some errors, it can recover the session. Session layer synchronizes dialogue between the presentation layers of the end host and manages their data exchange.At session layer each session have identify number.
Communicating between various host on network fall under
  1. Simplex – one-way communication    
  2. Half-Duplex – two-way communication, not simultaneous
  3. Full-Duplex – simultaneous two-way communication

Session Layer Protocols

  • NetBIOS (Network Basic Input Output System) developed by IBM in 1983 for their LAN technology ‘PC Network’ but this protocol is not scalable which can support maximum 80 devices.
  • NetBEUI (Network Basic Extended Unique Interface) is the enhanced version of the NetBIOS.
Session layer will keep track of each user connecting with it helps it to maintain the session. Session layer can also send acknowledgments to provide reliable communication normally we do not do in session layer. When the session is terminating it, notifies the device and terminates the session.

Layer 4: Transport Layer

Transport layer is the middle layer of the OSI model and implemented on the software; it will maintain a responsible data flow between source and destination and maintain error-free communication. It will segment and reassembles data in to the single data stream. This layer maintain end-to-end data communication, it actually does not send any data but will maintain a reliable data transfer.
Communication of Transport Layer can be
  1. Connection-Oriented: In this communication, a virtual circuit is established between source and destination devices. The source device will start negotiating in the virtual circuit formation based on some parameters. Only after the formation of virtual circuit data transmission starts. This type of communication is reliable because it recipient will send acknowledgments for successful reception.  TCP (Transmission Control Protocol) reside here.
  2. Connectionless: This type communication does not form virtual circuit and transmit it just transmit the data when the source wants to transmit. UDP (User Datagram Protocol) is used.

Transport Layer Connection-Oriented Communication 

For a reliable data transfer transport layer uses Connection-Oriented protocols; now we are going to look how it establishes a session. For a reliable communication take only by starting virtual circuits between the hosts, consider that two end hosts are going to make reliable communication sender application sends the negotiation or synchronization (SYN). Now the destination will respond with Acknowledgments (ACK) and its rules to make a connection. An actual connection will be established between the devices when the sender reply with the ACK that notifies destination has agreed connection parameters.

Services provided by Connection-Oriented Protocol
  1. Reliable Connection (Three-way Handshake)
  2. Segmentation and Sequencing
  3. Flow Control
  4. Acknowledgments
  5. Three-way Handshake
tcp-three-way-handshake

Three-Way Handshake Steps for Connection-Oriented Communication

  1. Synchronization (SYN) sends by source to destination with connection parameters of the source.
  2. Acknowledge (ACK) and Synchronization (SYN) sends by the destination to source with its connection parameters.
  3. Finally, ACK sends by the source by agreeing connection parameters of the destination. Thus, connection is established between them.

Segmentation and Sequencing

Connection-Oriented Protocols segments data send from the Session layer. Segmentation is a process by which large file is broken in to small size called as segments, segmentation size chosen by the according to value of Maximum Segmentation Size (MSS) which is the field in TCP header. Segmentation of data only takes place in TCP not in UDP.
Consider that you are downloading a file of 100 Mb with an internet speed of 512 Kbps so the file will be segmented and give sequence number to each segment and it will transmit so after receive gets all segments it will rearrange and we get a single file.

Flow Control

Proper flow control will be maintained in order to have an error free communication, for this connection-oriented protocols uses
Flow control based on buffer
tcp-flow-control
If we have high speed source will be generating data traffic too much that the network can manage. Therefore, the destination will receive great number of segments than it can process so the receiver will place segments an allocated memory called buffer. This can’t be an ultimate solution the buffer can be filled up any time, so then when buffer is getting up filled with the unprocessed segments receiver will generate not ready signal this will stop transmission of further segments. Once the segments are processed, the receiver will initiate a Go signal then the source will resume the transmission.
Windowing
Consider in a reliable network for every successful segment transmitted we receives acknowledgment, and transmit the second segment on the reception of the acknowledgment for first segment (ACK1), do you think this is scalable we have wait for each ACK.  It will make the transmission slower. The quantity (in bytes) of segments that we can transmit without receiving acknowledgment is called window size. By windowing, we can transmit segments before receiving acknowledgments so we can reduce time for waiting acknowledgements. Window size is measured in bytes.

windowing-tcp
Window size is increased according to trustworthiness of the receiver usually starts with smaller window size and increases gradually according to the reliability of the network. So if there is error at starting only few packets has to retransmit. Note that window size is expressed in bytes.
Acknowledgments
For a reliable communication, acknowledgment plays an important role. By ACK, we can retransmit the dropped segments and ensure duplicate segment free data transmission. When we successfully transmit segment one we get an ACK2 because it is expecting for the next segment.
tcp-acknowledgment

Layer 3: Network Layer

Network is the third layer of OSI, and implemented on the software. This uses logical address (IP address) instead of physical address in this layer. Router is the device residing in this layer. Data of this layer is known as Packet. Routers interconnect networks of different broadcast domain and it will not forward broadcast or multicast packets from one broadcast domain to another by default.

Switching in Network Layer

Switching in Layer 3 means how the packets are forwarded from one device to another.  For this L3 device (Router) uses three methods.
Packet Switching
Packet switching is a process in which data stream is divided into packets and each packet logical source and destination address. Based on this logical address Router (L3 device) can determine the source and destination address and it will be forward this packet to the destined address.
Circuit Switching
Circuit Switching is similar to the telephone network when we dial to number a virtual connection is established between us. Thus, a temporary circuit will be setup if source and destination needed.
Message Switching
In message, switching data stream is divided in to messages and forwarded to destination may be through different path. In this immediate delivery is not guaranteed.

How Route is discovered and selected by L3 device

Router can be learned routes by
  1. Directly Connected: Router learns logical address of that device if we connect devices to the router.
  2. Statically Configured: Router can learn the logical address as we tell them about that this address is available through that port.
  3. Dynamically Configured: Router can learn logical IP address through the dynamic routing protocols such as RIP, EIGRP, OSPF, IS-IS and BGP. In the routers, we configured with these protocols interchange the logical address they have learned. 
When the router receives a packet it examines the destination ip address and compare with the logical address that have in the routing table (routing table is constructed by the L3 devices as it learn routes; it have ports that route resides and some parameters for selecting best routes) if it find matching ip address it will forward to that port through that it can reach the destination.

Types of packets used at Network Layer

  1. Data Packets: These types of packets are used to transmit user data through the network. Protocols that that supports this data traffic are known as routed protocols. Examples are IP and IPV6.
  2. Route Update Packets: We know that routes can be learned dynamically by protocols such as RIP, EIGRP, OSPF; Routes learned by one router is transmitted to neighboring routers with this route update packets.

Network Layer Protocols

Protocols in Network Layer Description
IPV4, IPV6 IP address of version 4 and 6
IPX Novell’s Internetwork Packet Exchange similar to IP now deprecated
ICMP Internet Connection Management Protocol. Supports Ping and
Trace route.
IGMP Internet Group Management Protocol used by hosts and near routers in IPv4 networks to form multicast memberships.
IPsec Cisco proprietary protocol used for security
RIP,
OSPF,
IGRP,
EIGRP,
IS-IS
Dynamic routing protocols

Layer 2: Data Link Layer

The data link layer is the second layer of OSI model, which is implemented in both hardware and software. This layer uses physical address (hardware address) in order to send traffic between end-to-end devices. Ethernet Switch operates based on this layer. The Protocol Data Unit (PDU) of this layer is known as frame.  These layers convert the packets from the Network layer into the bits for the Physical layer. Data link layer also ensures error free data transmission also; it has a logical topology of the network.

Sub Layers of Data Link Layers

Layer two of the OSI model is sub divided into two layers Logical Link Control (LLC) the upper sub layer and Media Access Control (MAC) the lower one.
sub-division-data-link-layer

Media Access Control (MAC)

The MAC layer of the data link layers is doing physical addressing, Logical topology and how it can use the media.
Physical Addressing
Physical address or mac address will identify unique device in the network. That means end devices can only have one physical address were as interconnecting device such as router can have multiple data link addresses.MAC address are 48 bits in length and represented by 12 hexadecimal numbers. This mac address should have to be unique so it is divided into two parts.
mac-address
In this first six hexadecimal is administered by IEEE and assigned to manufacture and last six hexadecimal is administered by the vendor this make mac address unique. Since MAC, address is burned in to the RAM, it is also known by Burned in Addresses (BIAs).
Logical Topology
In data link layer, it has a complete logical network map about how to send traffic in the network. It means it have a logical traffic data flow patterns. For example we know that using hub in a network is a start topology physically, but it work in the same way as a bus topology by using CSMA/CD it means logically it is a bus topology.
Method of using media for collision resolution
For transmitted media can be utilized by circulating a logical token and devices get this logical token will circulate the data this is how media is used in Token Ring networks. In Ethernet, hubs transmission media used based on the CSMA/CD. This type of service is done MAC sub layer of data link layer. For full duplex link, this collision resolution is not needed.

Logical Link Control

LLC sub layer of data link layer can do services on connection and synchronizing the transmissions.
Connection Services
What we mean by connection services is that it can control flow and errors in the data transmission. That means LLC can optionally provide reliable frame transmission by flow control. And it can support connection less protocols.
Multiplexing and De-multiplexing Network Layer Protocols
When data link layer receive a frame from physical layer LLC sub layer will looks into L3 protocol type and handover to correct L3 protocol this process is referred as de-multiplexing. Similarly if it transmitting a packets from network layer to physical layer LLC layer fill L3 protocol type in the LLC header and hands over frame to the MAC layer.
Synchronizing Transmission
Before transmitting data the devices should be synchronized, they should have proper clocking and sender have to transmit data inside START and STOP bits. These can be done in three ways
  • Isochronous: In this device receive the external clocking and in the empty time slot data is transmitted
  • Asynchronous: The end stations uses reference with internal clocks. To indicate beginning and ending of data it uses START and STOP bits. Parity bit is used check errors. Parity can be even or odd. 
frame-synchronization

 In the above figure data bits is 10101101 if we are using even parity the grant total of one's should be even , so here in data it have five ones so we have to add one to parity we get grant total as even. If we are using odd parity, we have to add zero to parity then we get grant total as odd. However, this have a problem if a couple of errors occurred it will not show error.
  • Synchronous: In this both end device will share a common clock over the channel and for error checking they uses CRC (Cyclic Redundant Code).

Data Link Layer Protocols

Protocols Used in Data Link Layer Description
ARP Address Resolution Protocol to find mac address if IP address known
CDP Cisco Proprietary protocol to discover neighboring devices
HDLC High Level data Link Control used in bit oriented synchronous transmission
ATM Asynchronous Transfer Mode used in DSL
FDDI Fiber Distributed Data Interface used in LAN for data transmission
Frame Relay L2 WAN technology working based on Virtual Circuits
MPLS Multiprotocol Label Switching a wan technology
PPP Point to Point Protocol used for L2 encapsulation in serial connection
STP Spanning Tree Protocol used to prevent L2 loops

Layer 1: Physical Layer

The Physical layer of OSI model is purely implemented on hardware. It receives frame from data link layer and convert them to bits. This defines how bits can be represented on the media, wiring standards, multiplexing schemes and physical topology.

Representation of bits in the Media

W can represent bits in binary form in the physical medium. This is done by current state modulation and state transition modulation.
Current State Modulation
We know that the media can fiber optic or copper cables. Representation of bits means  the presence of voltage is binary one and absence of voltage is binary zero. This is known as current state modulation.
current-state-modulation

Presence of voltage is considered as binary one even though it is voltage is negative it's considered as binary one. In order to maintain electrical characteristic of channel Alternate Mark Inversion (AMI) is used that means it alternatively using positive and negative voltages to represent data.
State Transition Modulation
In state transition instead of looking current voltage level it compares with the previous voltage level and if there is change in its binary one. If there is no change in voltage level, it is represented as binary zero.
state-transmission-media

Wiring Standard

Physical layer would have complete wiring standard a specifications needed. For example, use of RJ-45 connector and color of wire used and its impedance all this specification is per physical layer.

Physical Topology

Physical layer also instruct about the physical topologies how to connect devices each other for example the star topology.

Synchronizing bits

Similar to data link layer physical layer also have synchronization of bits that means usage-clocking stat and stop bits.

Multiplexing Schemes

In order to connect devices or user simultaneously physical layer uses FDM (Frequency Division Multiplexing), TDM (Time Division Multiplexing).

Encapsulation in OSI Model

On a sender device as the user, data propagates through each layer; from transport, layer to down layer it add layer header to the user data. In the data link layer, it also adds trailer and header. These headers are known as PDU (Protocol Data Units). Switches are L2 devices so it have an L2 header and trailer the header consist of physical address. Moreover, routers deal with the packet, which have logical address as header. In following figure, we can discuss about how encapsulation occurs in an OSI layer. This is also same to TCP/IP stack encapsulation also.   
osi-data-encapsulation

During encapsulation on the Sender device
  1. User Application data is handed off to the Transport layer (through Application, Presentation and Session)
  2. The L4 adds a header containing protocol-specific information, and then handover the segment to the Network layer.
  3. The L3 layer adds a header containing end-to-end logical addresses, and then hand down the packet to the Data-Link layer.
  4. The Data-Link layer adds a header and trailer-containing source and destination mac addresses. This Ethernet frame is handed down layer.
  5. Physical layer and this frame is transmitted over medium as electrical corresponding to bits.

Decapsulation occurs on the receiving device
  1.  The L2 frame is received from the physical medium.
  2.  The Data-Link layer processes its header, strips it off L2header and trailer, and then hands over to the Network layer.
  3.  The Network layer processes its L3header and tears down then hands over to the Transport layer.
  4.  The Transport layer processes its L4header, strips it off, and then hands the data to the user application.

OSI Reference Model Example

To help you to remember all the function of OSI model we can consider an example how to relate OSI layer functions when we browse the internet.
  1. The web browser act as a user interface between Application layer and user. So when we use browser invokes HTTP to interface the remote web browser and it also uses DNS to resolve the address of web page.
  2. The browser handles the presentation layer to convert the files stored in the server. In addition, display it to the user.
  3. Session layer is responsible for establishing, monitoring and terminating the session between devices, and determining whether the communication is half-duplex or full duplex.
  4. Transport layer protocol to ensure the reliable delivery of data. TCP establishes and maintains a connection from the end user and the server. It also segments the webpage and sequences the segments.
  5. Network layer is responsible for assigning logical addresses on the client and server, and encapsulating segments into packets. In addition, find the best routes between end-to-end devices. Both server and host have logical address. Routers are used to interconnect different networking schemes.
  6. IP addresses are translated to hardware addresses (mac address), which are a function of the Data-Link layer. The packets are encapsulated into frames to be placed onto the physical medium. 
  7. Data is finally transferred onto the network medium at the Physical layer, in the form of raw its. Signaling and encoding mechanisms are implemented on this layer. The hardware that forms the physical connection between the client and the web server are defined in this layer. Physical are meant to send web request to the default gateway.

Summarization of OSI Layer

OSI model is a conceptual blueprint about networking, It is seven layered architecture each layer have protocols controls the function of that layer and combining all layers we get framework about the network.

Layer Description PDU Protocols Devices
Application Provide User Interface Data DHCP,DNS,FTP,HTTP,
IMAP,LDAP,NTP,POP3,
RTP,RTSP,
SSH,Telnet,TFTP,
SIP,SNMP
Presentation Data formatting
Encryption & Decryption
Data Text - ASCII, EBCDIC,
Audio - MP3, WAV, WMA,
Movies – MOV, MPEG, AVI,
Images - GIF, JPG, TIFF, PNG, BMP
Session Establishes
Monitor and terminate connection session
Data NetBIOS, NetBEUI
Transport Flow control and error recovering Segment/Datagram TCP and UDP
Network Logical addressing
Switching
Packet IPV4, IPV6, IPX, ICMP, IGMP, IPsec, RIP,OSPF,IGRP,EIGRP,IS-IS Router
Data Link
LLC&MAC
Physical Addressing
logical topology
synchronizing transmission
Multiplexing/De-multiplexing L3protocols
Frame ARP,CDP,HDLC,ATM,FDDI, MPLS,PPP,STP Switch, Bridge
Physical Representing bits in media, Encoding and Decoding signals Bits DSL, ISDN, Wi-Fi, Bluetooth,
Ethernet
Hub, Repeater
Lastly network model is not a physical entity so there no OSI device. Vendors do not always strictly follow the conceptual architecture. Some protocols can function across multiple layers.
Previous
Next Post »