Computer Networks: OSI layers, what are those?

Currently we have a huge variations of communication systems; cable internet, telephone networks (cellular or landline), starlink network, interplanetary communication networks and many more. Wide variation of hardware and software protocols are used to build these systems. Also different systems are designed for different use cases. For example, one engineer trying to design a walkie-talkie aims to transfer audio data in short distance with wireless technology while another engineer trying to design a internet network might have to worry about large distance communication and also reliability of data transfer.

Even though each communication system is targeted for different domain use cases, they share lots of common problems like,

  1. How can we send data reliably?
  2. How can we send data to a certain device? or send to all of the devices?
  3. What if we want to transfer sensitive data? how can we protect the data we sent through our communication channel?
  4. How do we make sure the data sent is accurately?

Be it the celluar network or the internet network, these common set of communication problems are applicable to all the networks/system that aims to achieve a data transfer. So, with the set of common problems and a single goal to achieve, OSI model was proposed as a theoritical model to group a set of functionalities required for a network system. OSI has classified the functionalities as 7 different groups/layers; each layers aim to solve certain class of problems. Also OSI is a theoritical model and not every network system fits/should fit in perfectly with OSI model.

So let's quickly revise 7 layers of OSI model and what kind of problems they address.

  1. Layer 7: Application layer

    The protocol in this layer is responsible for gathering data from user and represent the data as per application.

    The internet, the web browser is the Layer 7 application. Web browser is responsible for gathering data user inputs and convert it to a http request and it also gets to decide how to display the data/website from the http response. Http protocol works on this layer.
    Radio network(walkie-talkie), the driver software for speaker and microphone can be claimed as the Layer 7 protocols.

  2. Layer 6: Presentation Layer

    The protocol in this layer is responsible for following tasks:

    • how to represent the data we receive from the Layer 7.
    • also encrypt data to secure the data(optional)
    • compress data if desired(optional) 


    Cable internet, the data from http are represented either as text(ascii). however the compression and encryption are already handled in application layer by http protocol. so there is no really a different protocol at this layer for cable internet.
    Radio network(for Walkie-talkie), the data representation is a analog signal picked up by the microphone and we may want to further process that data to be noise resilient or maybe compress by downsampling. The protocol used to process the raw analog signal from microphone is the Layer 6 protocol.

  3. Layer 5: Session Layer

    OSI states that, this layer will have the responsibility of maintaining sessions; opening, closing and maintain connection between communicating nodes.

    Cable internet doesn't have a specific component that is in session layer. The advantage of having a session layer protocol is not much as compared to having separate communication stream. So this layer is unused in cable internet.
    Radio network (Walkie-talkie): Same for Walkie-talkie network, in my view we won't have any software that works on Layer 5

  4. Layer 4: Transport Layer

    This layer takes the data from Session layer, breaks it down to segments, pass the segments to Network layer(layer 3) to be transmitted. While on receiving end, it receives the segments from Network layer, check if segment is corrupted and optionally re-request if it is corrupted. This layer also includes a flow control mechanism to adjust transmission rate based on bandwidth available. 

    For cable internet, TCP or UDP protocols handles the transport layer work. The protocols takes care of packet re-transmission, error check and flow control.
    For radio network
    , it might as well use the TCP or UDP protocol or we can also develop another protocol on that can handle the re-transmission, flow control depending on use case.

  5. Layer 3: Network layer

    Now we have segments of data (and reliability of TCP) from Transport layer, Network layer deals with where to send the data or how to route it to the receiver. Network layer device/protocol is responsible for adding the destination address to each packet, and send it to Layer 2 protocol for transmission.


    For cable internet, IP protocol is the Network layer protocol, it adds IP addresses to data and sends it to Data Link layer device for transmission.
    For celluar network
    , every mobile device has a unique identifier. When we communicate from user1 to user2, I assume each packet data might be tagged with user2 as target and sent to layer 2 protocol for transmission on this layer.

  6. Layer 2: Data Link Layer

    Now our data packets have source and destinations attached, we now need to find the nearest node that can transmit the packet in direction of the destination. Data link layer facilitates the transfer of packets between two connected nodes. Devices are identified based on interfaces and physical MAC addresses on this layer. This layer adds physical address of nearest available node on top of layer 3 packet and sends to layer 1 for transmission.


    For cable internet, after OS generates the IP packets, it now attaches the MAC address(physical address) of nearest router and sends the appended packet to the NIC card for transmission. Layer 2 protocol on Router then removes the old layer 2 header and looks for another nearest router, attach nearest router's physical address(MAC address) and forwards the packet.
    For radio network, the communication language between two towers operates on this layer.

  7. Layer 1: Physical Layer

    Now we have data to transfer between two connected device on network, now we need a channel for transfer the signals and protocols to encode data to the signal. Physical layer deals with how we transfer the data; maybe using wifi protocol or bluetooth or fiber optics or electric signal via wire or other radio signals or lasers.

    For cable internet,
    NIC card generates electric pulses based on data from Data Link layer and sends it through cable.
    For radio network
    , the data gets converted to radio wave based on a Layer 1 protocol and the transmitter transmits the data using radio frequency signal to nearest tower. 

To summarize, we have following

OSI Layer Task Cable Internet Where is the protocol implemented
Layer 7: Application Layer
Format Data with respect to application
HTTP protocol
Application on top of OS
Layer 6: Presentation Layer
Encode, compress and encrypt data

Layer 5: Session Layer
Maintain session for a single connection

Layer 4: Transport Layer
Ensure data transmission is loss less, uncorrupted, reliable and within the limit of the bandwidth of channel
OS provides libraries
Layer 3: Network Layer Add source and target destination of final recipent
Layer 2: Data-link Layer
Add the source and target for nearest available network device
OS / Routers
Layer 1: Physical
Receive data from layer 2 and encode it as per transmission media
Routers/ Channel


So let's walk through a chat application application, what would our network architecture look like if we compare it with the OSI model ?

For an chat application, 

  1. First for the Application layer we can use normal text as a payload layer 7 on application layer, user sends or receives normal text, so text is the payload (payload: "Hello") 
  2. Layer 6 on presentation layer, we can write a program to encrypt and compress the payload from layer 7 (payload: "h930a") 
  3. Layer 5 on session layer, we can skip this layer.(payload: "h930a") 
  4. Layer 4 on Transport layer, now depending on our requirement we can choose to add TCP header or UDP header to the payload. it takes care of reliablility and flow control of the data (payload: (TCP headers + ("h930a"))) 
  5. Layer 3 on Network layer, now the data from layer 4 is broken down into transferable data chunks and ip headers are added to each chunks. IP headers adds the source/destination address to each packet (IP headers + (TCP headers + ("h930a"))) 
  6. Layer 2 on Data link layer, now we look for the nearest physical device and add the transimission data headers to send the data to that device (MAC header + (IP headers + (TCP headers + ("h930a")))) 
  7. Layer 1 Physical Layer: the data from layer 2 is received, converted to signals using layer 1 protocol and transmitted through wire to destination device(identified by MAC) 
  8. After the data reaches layer 1 to transmit the data to the desired client, we will have intermediate routers working on Layer 1 and Layer 2 to navigate the data until we reach the final destination. On reaching the destination the process is reveresed 
  9. Layer 1, Physical Layer, receives data (MAC header + (IP headers + (TCP headers + ("h930a")))) 
  10. Layer 2, DataLink Layer, removes MAC header from the payload (IP headers + (TCP headers + ("h930a"))) 
  11. Layer 3, Network Layer, removes the IP headers and waits for all the data packets to arrive (TCP headers + ("h930a")) 
  12. Layer 4, Transport Layer, removes the TCP headers and verify we receive all the data reliably ("h930a") 
  13. Layer 5, Session Layer, no used ("h930a") 
  14. Layer 6, Presentation Layer, decompress and decrypt data ("hello") 
  15. Layer 7, Application layer, receive the data and show it to user ("hello") 

A Chat application on top of Starlink Network 

If we want to use the Starlink Network to communicate, 

  1. We can still use Layer 3-7 to achieve the routing, flow control, reliability, data encryption and compression. 
  2. However Starlink Network will differ on Layer 1 and 2. In Layer 2, after we receive IP packet from Layer 3, now we have to find nearest satelite to communicate with, and add the physical address of that satelite to the IP packet. 
  3. Layer 1: now we use layer 1 protocol to convert data to signal and can use the narrow beam antennas to transmit the data to the satelite. 
  4. After Satelite receives the data, it can either choose satelite to satelite communication (using lasers) or satelite to base station communication(narrow band). Either way, satelite has to remove the layer2 header on the received data and add new layer2 header with next satelite to transmit it forward. 
  5. But finally one of the Satelite will choose to finally transmit it to ground station then the ground station can use the ground based routers to forward the package into the ground based internet using same protocols as cable internet. Here the satelite-to-satelite and satelite-to-ground communication protocol operates on Layer 1 and 2. ( Starlink network's architecture

OSI model for Interplanetary Communication (Preserverance mars rover)

The Interplanetary Communication network mainly consist of rovers, orbiters, and ground stations in earth. Rover collects the data sends it to orbiters and orbiter sends it to earth ground stations. Rovers can also establish direct link to earth stations to transfer the data. Different from normal network in earth, delay between the signal is huge in the Interplanetary Network, so we need different protocol that takes the delay in consideration. With the combined effort, CCSDS space link protocols have been used for the space communication. CCSDS includes improvement on the Layer 3, 2 and 1, to better suit the space communication and also have some improvements for the protocols above the Transport layer 4 to support the store-and-forward information network to address frequent disconnects, errors and delays. You can find more about the Interplanetary Communication here

No comments :

Post a Comment