OSI Layer

Data Flow and Encapsulation in OSI Layer

OSI (Open Systems Interconnection) is reference model for how applications can communicate over a network. A reference model is a conceptual framework for understanding relationships. The purpose of the OSI reference model is to guide vendors and developers so the digital communication products and software programs they create will interoperate, and to facilitate clear comparisons among communications tools.
 
Layer-7: Application Layer 

Data flow occurs when two devices are connected in a network with some kind of shared transmission medium. An application running on the source device creates some kind of data. This happens at the Application layer.

The Application layer (Layer-7) provides the interface between the user application and the network. A web browser and an email client are examples of user applications.
 

The user application itself does not reside at the Application layer - the protocol does. The user interacts with the application, which in turn interacts with the application protocol.
Examples of Application layer protocols include:
  • FTP, via an FTP client
  • HTTP, via a web browser
  • POP3 and SMTP, via an email client
  • Telnet
The Application layer provides a variety of functions:
  • Identifies communication partners
  • Determines resource availability
  • Synchronizes communication

Layer-6: Presentation Layer

In our case the application needs to add encryption to that data. This will be done at the Presentation layer. 
The Presentation layer (Layer-6) controls the formatting and syntax of user data for the application layer. This ensures that data from the sending application can be understood by the receiving application.

Standards have been developed for the formatting of data types, such as text, images, audio, and video. Examples of Presentation layer formats include:

  • Text - RTF, ASCII, EBCDIC
  • Images - GIF, JPG, TIF
  • Audio - MIDI, MP3, WAV
  • Movies - MPEG, AVI, MOV

If two devices do not support the same format or syntax, the Presentation layer can provide conversion or translation services to facilitate communication.

Additionally, the Presentation layer can perform encryption and compression of data, as required. However, these functions can also be performed at lower layers as well. For example, the Network layer can perform encryption, using IPSec.
 

 Layer-5: Session Layer

At the Session layer it appends the Session ID. At this point the information is still one block of data.

The Session layer (Layer-5) is responsible for establishing, maintaining, and ultimately terminating sessions between devices. If a session is broken, this layer can attempt to recover the session. Sessions communication falls under one of three categories:
  • Full-Duplex – simultaneous two-way communication
  • Half-Duplex – two-way communication, but not simultaneous
  • Simplex – one-way communication
Many modern protocol suites, such as TCP/IP, do not implement Session layer protocols. Connection management is often controlled by lower layers, such as the Transport layer.

The lack of true Session layer protocols can present challenges for high availability and failover. Reliance on lower-layer protocols for session management offers less flexibility than a strict adherence to the OSI model.


Layer-4 : Transport Layer

Next, data goes down to the Transport layer. The Transport layer breaks the data into blocks of data which we call Segments. Every Segment also gets the Port number to identify which upper layer application needs to receive the data on the destination device


The Transport layer (Layer-4) does not actually send data, despite its name. Instead, this layer is responsible for the reliable transfer of data, by ensuring that data arrives at its destination error-free and in order.

Transport layer communication falls under two categories:

  • Connection-oriented – requires that a connection with specific agreed-upon parameters be established before data is sent.
  • Connectionless – requires no connection before data is sent.

Connection-oriented protocols provide several important services:

  • Segmentation and sequencing – data is segmented into smaller pieces for transport. Each segment is assigned a sequence number, so that the receiving device can reassemble the data on arrival.
  • Connection establishment – connections are established, maintained, and ultimately terminated between devices.
  • Acknowledgments – receipt of data is confirmed through the use of acknowledgments. Otherwise, data is re-transmitted, guaranteeing delivery.
  • Flow control (or windowing) – data transfer rate is negotiated to prevent congestion.

The TCP/IP protocol suite incorporates two Transport layer protocols:

  • Transmission Control Protocol (TCP) – connection-oriented
  • User Datagram Protocol (UDP) - connectionless


 Layer-3: Network Layer

The Segment is then passed to the Network layer. The Network layer takes the Segment, which includes the Port number, and appends the source and destination IP address. At that point the Segment becomes a Packet.


The Network layer (Layer-3) controls inter-network communication, and has two key responsibilities:
  • Logical addressing – provides a unique address that identifies both the host, and the network that host exists on.
  • Routing – determines the best path to a particular destination network, and then routes data accordingly.
Two of the most common Network layer protocols are:
  • Internet Protocol (IP)
  • Novell’s Inter-network Packet Exchange (IPX).
IPX is almost entirely deprecated. IP version 4 (IPv4) and IP version 6 (IPv6) are covered in nauseating detail in other guides.
 

 Layer-2: Data Link Layer

The Packet is then passed to the Data Link layer where the source and destination MAC address and the CRC is added. At this point we have a Frame.

  • The Data Link layer is responsible for combining bits into bytes and bytes into frames. 

  • Frames are used at the Data Link layer to encapsulate packets handed down from the Network layer for transmission on a type of media access. 

There are three types of media access methods:
  1. Contention (Ethernet) 
  2. Token passing (Token Ring and FDDI)
  3. Polling (IBM Mainframes and 100VGAnylan)

While the Network layer is concerned with transporting data between networks, the Data-Link layer (Layer-2) is responsible for transporting data within a network.
The Data-Link layer consists of two sublayers:

  • Logical Link Control (LLC) sublayer
  • Media Access Con trol (MAC) sublayer
The LLC sublayer serves as the intermediary between the physical link and all higher layer protocols. It ensures that protocols like IP can function regardless of what type of physical technology is being used.

Additionally, the LLC sublayer can perform flow-control and error checking, though such functions are often provided by Transport layer protocols, such as TCP.
 

The MAC sublayer controls access to the physical medium, serving as mediator if multiple devices are competing for the same physical link. Datalink layer technologies have various methods of accomplishing this - Ethernet uses Carrier Sense Multiple Access with Collision Detection (CSMA/CD), and Token Ring utilizes a token. 

The Data-link layer packages the higher-layer data into frames, so that the data can be put onto the physical wire. This packaging process is referred to as framing or encapsulation. The encapsulation type will vary depending on the underlying technology. Common Data-link layer technologies include following: 
  • Ethernet – the most common LAN data-link technology
  • Token Ring – almost entirely deprecated 
  • FDDI (Fiber Distributed Data Interface) 
  • 802.11 Wireless 
  • Frame-Relay 
  • ATM (Asynchronous Transfer Mode) 
The data-link frame contains the source and destination hardware (or physical) address. Hardware addresses uniquely identify a host within a network, and are often hard-coded onto physical network interfaces. However, hardware addresses contain no mechanism for differentiating one network from another, and can only identify a host within a network. The most common hardware address is the Ethernet MAC address. 


Layer-1: Physical Layer

The Frame then is sent to the physical device where it is translated into some kind of a signal, whether it's electrical, radio wave, light or other signal. This Frame then becomes some kind of a signal that represents a series of zeros and ones. This is why at the Physical layer we often call it Bits. The Network Interface Card (NIC) prepares those signals and sends it out on the transmission medium.

The Physical layer (Layer-1) controls the signaling and transferring of raw bits onto the physical medium. The Physical layer is closely related to the Data-link layer, as many technologies (such as Ethernet) contain both data link and physical functions.
 

The Physical layer provides specifications for a variety of hardware:
  • Cabling
  • Connectors and transceivers
  • Network interface cards (NICs)
  • Wireless radios
  • Hubs

OSI Encapsulation and Layers :
One important piece of information to keep in mind is that data flows 2 ways in the OSI model, DOWN (data encapsulation) and UP (data decapsulation).


The picture below is an example of a simple data transfer between 2 computers and shows how the data is encapsulated and decapsulated.





OSI Reference Model Example
A web browser serves as a good practical illustration of the OSI model and the TCP/IP protocol suite:


Τhe web browser serves as the user interface for accessing a website. The browser itself does not function at the Application layer. Instead, the web browser invokes the Hyper Text Transfer Protocol (HTTP) to interface with the remote web server, which is why http:// precedes every web address.

The Internet can provide data in a wide variety of formats, a function of the Presentation layer. Common formats on the Internet include HTML, XML, PHP, GIF, and JPEG. Any encryption or compression mechanisms used on a website are also considered a Presentation layer function.
 

The Session layer is responsible for establishing, maintaining, and terminating the session between devices, and determining whether the communication is half-duplex or full-duplex. However, the TCP/IP stack generally does not include session-layer protocols, and is reliant on lower-layer protocols to perform these functions.
 

HTTP utilizes the TCP Transport layer protocol to ensure the reliable delivery of data. TCP establishes and maintains a connection from the client to the web server, and packages the higher-layer data into segments. A sequence number is assigned to each segment so that datacan be reassembled upon arrival.
 

The best path to route the data between the client and the web server is determined by IP, a Network layer protocol. IP is also responsible for the assigned logical addresses on the client and server, and for encapsulating segments into packets.
 

Data cannot be sent directly to a logical address. As packets travel from network to network, IP addresses are translated to hardware addresses, which are a function of the Data-Link layer. The packets are encapsulated into frames to be placed onto the physical medium.
 

The data is finally transferred onto the network medium at the Physical layer, in the form of raw bits. Signaling and encoding mechanisms are defined at this layer, as is the hardware that forms the physical connection between the client and the web server. 


Data Exchange Process

In data exchange process, participating computers work in reverse mode. Layers on receiving computer perform the same task in reverse mode.
The receiving device takes delivery of, handles, and translates the data from the sending device at a particular layer. For example on sending computer presentation layer compress the data, same presentation layer on receiving computer decompress the data.

On sending computer

  • Sending application access the application layer.
  • Application provides data to the presentation layer.
  • Presentation layer format the data as per network requirement and forward it's to session layer.
  • Session layer initiate the connection and forward the data to the transport layer.
  • Transport layer broke down the large data file in smaller segments and add a header with control information, which are bits designated to describe how to determine whether the data is complete, uncorrupted, in the correct sequence, and so forth.
  • Segments are forwarded to the network layer. Network layer add its header, with logical address and convert it in packet. Network layer forwards packet to data link layer.
  • Data link layer attach its header and footer to the packet and convert it in frame.
  • Frames are forwarded to the physical layers that convert them in signals. These signals are loaded in media.

On receiving computer

  • Physical layer receive signals from media and convert them in frames. Frames are forwarded to the data link layer.
  • Data link layer check the frame. All tampered frame are dropped here. If frame is correct, data link layer strip down its header and footer from frame and hand over packet to network layer.
  • Network layer check the packet with its own implementations. If it's found everything fine with packet, it strips down its header from packet and hand over segment to transport layer.
  • Transport layer again do the same job. It verifies the segments with its own protocol rules. Only the verified segments are processed. Transport layer remove its header from verified segments and reassemble the segments in data. Data is handed over the session layer.
  • Session layer keep track of open connection and forwarded the receiving data to presentation layer.
  • Presentation form the data in such a way that application layer use it.
  • Application layer on receiving computer find the appropriate application from the computer and open data within particular application.

Conclusion

  • At the sending device, each layer breaks the data down into smaller packets and adds its own header.
  • At the receiving device, each layer strips off the header and builds the data packets into larger packets.
  • Each protocol layer is blind to the headers of any other protocol layer and cannot process them.

No comments:

Post a Comment