9

I'm wondering to know how session layer works. In my understanding session layer is to establish active communication sessions between two devices. Based on the OSI layer model, it works layer by layer meaning that the data is generated from application and passed to presentation -> session layer and so on, but my concern is how session layer establishes a connection before the physical layer because the medium is not formed yet. Or maybe I misunderstand how the OSI layer works. Can someone explained to me, I'm still new in networking.

Before reaching the physical layer, how it is possible for a session layer to establish a connection between the two devices because session layer is all about connection establishment, session management, session termination.... right, so how it is possible or I misunderstand the concept please help me to get the point?

I want to know the solution in detail ,Hope someone can help me out of this.

4
  • 5
    I wish they would stop teaching the OSI model -- it causes more confusion than it helps. The OSI model is just an abstraction to describe connections between logical functions. It does not describe how data is actually transmitted or received.
    – Ron Trunk
    Dec 20, 2022 at 13:21
  • 1
    When we say there is a connection between the session layers, we mean the data contained in the session layer PDU is processed by the session layer functions in the receiver. The lower layers consider this data as simply "payload."
    – Ron Trunk
    Dec 20, 2022 at 13:26
  • 1
    When the session layer process of the sender wants to send information to the receiver's session processes, it puts that information into the session layer PDU. That PDU is encapsulated by the lower layers and sent to the receiver, who de-encapsulates it and then provides it to its session layer functions. IRL, it's just bits on the wire. Packets, addresses, fields, headers, flags, etc are just logical abstractions.
    – Ron Trunk
    Dec 20, 2022 at 13:59
  • 2
    The OSI model really only makes sense if you're implementing them using the OSI protocols, and nobody has seriously tried to do that since about the 1980s. The Internet diverges from the OSI model somewhere around layer 4.
    – Mark
    Dec 21, 2022 at 3:37

7 Answers 7

10

The OSI model is just a model, and OSes do not implement the OSI model. Modern OSes are much closer to the IP Services model, but it, too, is just a model, and things in the real world do not always adhere to any model.

OSes will leave it up to applications to implement anything above the transport layer, so the session, presentation, and applications layers are all the responsibility of an application, and they are collectively called the application layer in the IP Services model.

Unfortunately, anything above the transport layer is off-topic here, as are specific host implementations of the network protocols.

10

The session layer sits on top of the transport layer. In the case of a connection-oriented services, the transport service is responsible for providing reliable flow-controlled end-to-end data transfer and the session layer is responsible for providing the following additional services:

  • (Re-)synchronization (using tokens and/or synchronization points)
  • Structuring the dialogue (using dialogue units and activities)
  • Negotiation

What most people don't realize is that there is a stack of standardized protocols that implement all 7 layers of the OSI reference model. Back in the 90s these protocols were actually implemented and used in production networks, although by now they have been almost completely replaced by the TCP/IP stack which does not have a proper session layer.

The OSI session service is defined in standard ITU-T X.215 (https://www.itu.int/rec/T-REC-X.215/_page.print)

The connection-orientend OSI session protocol is defined in standard ITU-T X.225 (https://www.itu.int/rec/T-REC-X.225-199511-I/en)

The connectionless OSI session protocol is defined in standard ITU-T X.235 (https://www.itu.int/rec/T-REC-X.235)

5

OSI's session and presentation layers are ill-presented in the practical Internet protocol suite. Most often they don't really exist, and if they do they are implemented within the application layer.

how session layer establish connection before the physical layer because the medium is not form yet.

Now there's a misunderstanding. Connection concepts only exist on some layers, and they're independent of each other. The physical layer connects/attaches to a medium, forming the basis for data traveling from one interface to the next. The transport layer may use a logical connection (like TCP) or not (like UDP). The application layer often uses a session concept (absent a pronounced session layer) but that's about it.

Instead, layers are a way of organizing the huge complexity of networking. Layer implementations are often interchangeable and make networking modular - IPv6 may replace IPv4, UDP may replace TCP (changing the communication parameters, but essentially doing the same or a very similar job). Each layer has its distinctive tasks and uses the layer below, roughly:

  • the physical layer moves bits and bytes from interface to interface; interfaces attach to a medium
  • the data link layer forms frames out of bytes and directs traffic within a closed network (segment)
  • the network layer uses frames to transport packets that cross network boundaries and directs those packets between networks/segments
  • the transport layer uses network-layer packets and forms sockets to transport data between processes or applications; it may use a connection concept
  • the application layer uses transport layer sockets to do application-specific things; in practice it also takes care of data representation and session concepts, where used
5

Just to add to other great answers: even on the abstract model level there is no contradiction. Each layer uses the services of the lower layer. Thus, the session layer may use the transport layer to establish a physical connection.

Actually the same happens lower in the stack: how would the transport layer establish a TCP connection without access to the IP or the physical medium?

Before reaching the physical layer, how it is possible for a session layer to establish a connection between the two devices because session layer is all about connection establishment, session management, session termination.... right, so how it is possible or I misunderstand the concept please help me to get the point?

The session layer does not have to establish a connection before reaching the physical layer. On the contrary, when the session layer is tasked with establishing a session it actively uses the transport layer, which then uses the other layers to establish a physical connection.

4

OSI layers request services from lower layers ,and lower layers offer service to higher layers. The session layer is responsible for establishing and maintaining a session between two hosts, just like the Network layer is responsible for routing decisions. This does not mean that the session layer manages to establish a session between two hosts before the lower layers actually manage to offer services to a satisfactory level to the session layer. To simplify things, the session layer requires some services from the transport layer. For our purposes, we can say that the session layer expects a bidirectional bit flow to and from the peer. Before this flow is established, the session layer cannot proceed. Similarly, the transport layer requires a datagram service from the network layer. The network layer requires Data Link layer services from the Data Link layer, etc. None of the above layers can proceed to do their own job until all lower layers do theirs and deliver the service they are supposed to deliver.

Another way to think about this: Your web browser is responsible for sending HTTP requests to the web server and rendering the returned webpage. Your web browser cannot do this job before and unless all lower functions function properly and deliver the services they are supposed to deliver to the browser. If you unplug the Ethernet cable from your computer (severing the L1 link), then the web browser (a software implementing L7 functions) will fail to deliver the services it is supposed to deliver. This does not change the intended functional description of the web browser (it still remains a piece of software that implements L7 functions and delivers a pre-defined service to the end-user).

0

I want to add my to cents to the other answers. My understanding of session layer (and presentation layer) in TCP/IP is that it is very hard to design a single session layer for any application that can be sent over the Internet. If you take a certain class of applications - e.g., in VoIP there is a concept of what a session layer is. Also for some reason, some sources say that TLS is a session layer, although I think the only reason is that TLS works "above" layer 4, so it must be layer 5 ><.

Now, to the other part of your question. Basically session would be similar to connection in a sense that it is results in state maintained at the communicating systems. I will try to explain the concept of connection.

Connection (between two systems A and B) is essentially a state maintained at both A and B. You obviously can't store anything in the wires, so it has to be in the systems attached to the wires. Which systems these are, depends on the protocol. In TCP/IP protocols, connections can exist at some data link layers (e.g., wifi between AP and wireless device) or in transport layer (e.g., TCP between two end-systems). In circuit switched networks, there is layer 3 state, which is maintained at each host between sender and receiver as well.

Now, how this state comes to be. Let's take TCP as example. One of the systems, let's call it initiator, decides to initiate a connection to the responder. At the initiator the state is created locally - e.g., open a TCP socket, which signals the OS to open a connection to the responder. The state is however incomplete, because the responder does not know of the connection yet. Thus, the first step is that the initiator signals the responder that it wishes to start the connection. In TCP this is the task of TCP handshake. TCP handshake are TCP packets with special meaning. First thing that the initiator does is to send SYN packet. This TCP packet is encapsulated into an IP datagramm, which is encapsulated into data link frame, which can be sent over physical layer as bits. It travels to the responder as any other IP datagram would. At the responder the SYN packet is processed layer by layer: first physical/data link layer, then IP layer, then transport layer. When the SYN packet reaches transport layer, if the responder is accepting connections on that port, the packet will be processed and the corresponding state will be created as well[1]. The other two handshake packets are sent similarly, and the data packets are sent similarly.

So, in TCP there are special signalling packets, that have special meaning to TCP layer and are opaque to the layers below. These signalling packets are used to establish or tear down the connection. They are sent by lower layers as any other packets. The connection state at the initiator and responder is created by exchanging signalling packets and does not exist until signaling takes place.

In any connection oriented protocol there is a similar signalling mechanism for the sole purpose of establishing the connection - i.e., establishing state on connection endpoints (and on each of the other systems involved).


[1] This is not exactly true. Although the responder can create state at this point, it is usually done after the third handshake packet, as a defense against so called SYN flood attack.

-1

Many good answers here but I would add that in modern networks (TCP/IP) the Session layer is handled by the TCP three-way handshake when using TCP, when using UDP there really is no session building.

2
  • 2
    Not exactly. For instance, a TCP connection really has nothing to do with a session/connection for something like a Web connection/session that is an above the transport layer. The Web application implements the session, presentation, and application layers of the OSI model. TCP is just the transport protocol, and it may be used by the application session/connection while using many different TCP connections for a single Web session/connection. Do not confuse the transport protocol connections with the session layer.
    – Ron Maupin
    Dec 19, 2022 at 0:33
  • 1
    @user3123429 A transport-layer connection is just that and a session can encompass multiple L4 connections. The concept of a session is more prominent with session cookies for HTTP.
    – Zac67
    Dec 19, 2022 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.