26

I was wondering if it is layer 7 for websocket as the application is actually the browser.

TheBoyan
  • 6,802
  • 3
  • 45
  • 61
TheOneTeam
  • 25,806
  • 45
  • 116
  • 158
  • 3
    The OSI model doesn't really work above #4. It's more of what protocols can stack together and what protocols offer what. Note that Osi#6 (charset encoding, data encoding...) is normally built on top of HTTP (usually regarded as belonging to OSI#7. – John Dvorak Jan 03 '13 at 05:23
  • The Web sockets and HTTP should really be OSI#4 (transport layer) in my opinion, but it relies on a transport-layer protocol (TCP) itself. – John Dvorak Jan 03 '13 at 05:25
  • OSI#6 (presentation layer) should be responsible for data encryption, but wikipedia throws SSL/TLS into OSI#5(session layer) because keeping a session what SSL _also_ does. – John Dvorak Jan 03 '13 at 05:29
  • 1
    Moving HTTP to #4 doesn't really work either, since technically, HTTP can stack on top of SSL, not vice versa, but SSL belongs to #5 or #6; definitely not #4. – John Dvorak Jan 03 '13 at 05:32
  • WS should really be on par of HTTP (or higher), but HTTP is traditionally #7 (and #8 is the user), so... – John Dvorak Jan 03 '13 at 05:33
  • 1
    Also note that you can tunnel anything through anything (although tunelling ethernet frames through HTTP/SSL could be inefficient) which kinda shakes the OSI model once again. With some effort, you could even tunnel OSI#1 (the physical layer) through HTTP - digital oscilloscopes are not _that_ expensive :-) – John Dvorak Jan 03 '13 at 05:38

5 Answers5

19

Websocket depends on TCP (OSI#4) and only the handshake phase is initialized by HTTP (OSI#7) 1. Although it uses TCP port 80 only.

According to the runtime behavior, I have to say WebSocket should be a special OSI#7 protocol. Then we can put SSL/TLS into OSI#6 (see wikipedia), and the implementation inside browser into OSI#5.

Community
  • 1
  • 1
shawnzhu
  • 7,233
  • 4
  • 35
  • 51
5

It is better to understand the layer using TCP/IP model rather than OSI model. WebSocket layers on top of TCP, considered as transport layer in TCP/IP model, and one can layer application layer protocol on top of WebSocket.

  • Taken from Wiki(https://en.wikipedia.org/wiki/WebSocket): "WebSocket is distinct from HTTP. Both protocols are located at layer 7 in the OSI model and depend on TCP at layer 4." So Application Layer not Transport Layer – BabyishTank Jun 29 '23 at 20:25
3

HTTP, SSL, HTTPS, WebSockets, etc. are all application layer protocols.

But the OSI protocol stack doesn't apply to TCP/IP, which has its own layer model: same names, different functions. It isn't helpful to keep using the obsolete OSI stack as though it actually reflected any reality. It doesn't.

user207421
  • 305,947
  • 44
  • 307
  • 483
0

Only the Handshake is interpreted by https server by upgrade request. Apart from that Websocket is independent TCP-based protocol. So i would say host layer #4 and #7. https://www.rfc-editor.org/rfc/rfc6455#page-11

Community
  • 1
  • 1
Ananda
  • 477
  • 5
  • 8
0

L1 does not have a map where a cable is digged in the soil (how deep, where), nor in wich cable certain wires delivering information is flowing, or where is is layed in cable self, nor it dictates how cable is marked. L1 is only physical layer, not where and how the wires are layed. So L0 is needed.

L1: "The physical layer is responsible for the transmission and reception of unstructured raw data between a device and a physical transmission medium. It converts the digital bits into electrical, radio, or optical signals. Layer specifications define characteristics such as voltage levels, the timing of voltage changes, physical data rates, maximum transmission distances, modulation scheme, channel access method and physical connectors. This includes the layout of pins, voltages, line impedance, cable specifications, signal timing and frequency for wireless devices. Bit rate control is done at the physical layer and may define transmission mode as simplex, half duplex, and full duplex. The components of a physical layer can be described in terms of a network topology. Physical layer specifications are included in the specifications for the ubiquitous Bluetooth, Ethernet, and USB standards. An example of a less well-known physical layer specification would be for the CAN standard."

HarriL
  • 96
  • 2