Which OSI layer does WebSocket Protocol lay on?
Asked Answered
M

4

30

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

Misfeasance answered 3/1, 2013 at 5:17 Comment(6)
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.Hama
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.Hama
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.Hama
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.Hama
WS should really be on par of HTTP (or higher), but HTTP is traditionally #7 (and #8 is the user), so...Hama
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 :-)Hama
B
22

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.

Bisectrix answered 24/6, 2013 at 14:50 Comment(1)
I don't agree with Wikipedia about layer 6. To me the only thing that ever fitted into layer 6 would have been 3270, if IBM had used OSI, which they didn't. You could make an argument about XDR, ASN.1, and things of that nature, but the fact is that like 3270 they are all application-layer protocols.Proclaim
C
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.

Codicodices answered 2/7, 2013 at 3:2 Comment(1)
Taken from Wiki(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 LayerStenophyllous
P
5

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.

Proclaim answered 2/7, 2013 at 3:8 Comment(0)
S
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

Stefa answered 14/12, 2016 at 18:45 Comment(1)
Layer 7. TCP itself is layer 4, or it would be if it fitted the OSI model, which it doesn't.Proclaim

© 2022 - 2024 — McMap. All rights reserved.