websockets如何在TCP / IP和HTTP方面工作?(How websockets work in respect to TCP/IP and HTTP?)

编程入门 行业动态 更新时间:2024-10-26 16:27:30
websockets如何在TCP / IP和HTTP方面工作?(How websockets work in respect to TCP/IP and HTTP?)

大家好,我是新手,了解网络上使用的协议,需要一些帮助来理解websockets,TCP / IP和HTTP的基础知识。

我对TCP / IP和HTTP之间关系的理解是,连接所有网络都需要IP。 TCP是一种允许我们安全传输数据的机制,利用TCP传输数据的HTTP是Web服务器和客户端使用的特定协议。

这是否意味着您无法在没有TCP的情况下发送HTTP请求?

Websockets使用TCP层进行通信,客户端和服务器之间的连接通过HTTP建立,这称为握手过程。

websockets是否有自己的协议? 当您需要TCP执行HTTP请求时,如何发送http请求(握手过程)来建立TCP / IP。 我知道我错过了一些非常重要的东西,并且很高兴让我对这些协议的理解更加清晰!

Hi guys I'm new to understanding protocols used over the web and need some help in understanding the basics of websockets,TCP/IP and HTTP.

My understanding of the relation between TCP/IP and HTTP is that IP is required to connect all networks. TCP is a mechanism that allows us to transfer data safely and HTTP, which utilizes TCP to transfer its data, is a specific protocol used by Web servers and clients.

Does this mean you can't send a HTTP request without TCP?

Websockets communicate using TCP layer and a connection between client and server is established through HTTP which is known as the handshake process.

Does websockets have its own protocol? How can you send a http request(hand shake process) to establish TCP/IP when you need TCP to carry out an HTTP request. I know I am missing something really important here and would be great to get my understanding of these protocols sharpened!

最满意答案

首先,不一定要求IP连接所有网络。 然而,它是今天使用最广泛的(现在也是如此)。 诸如Appletalk,IPX和DECNet之类的旧网络协议都是传统的网络协议,不再使用它们,但它们仍然存在一定程度。 不要忘记在某些地方也存在IPv6,如果配置正确,可以通过IPv4网络。

当你说TCP是“安全的”时,我会再说一遍,那就是聪明的。 TCP是一种传输协议,是直接位于IPv4标头之后的标头。 TCP主要用于流量控制,并且在传输/接收传输/接收时,一部分数据包或数据包已经存在,因此在错误恢复方面变得非常有效。 虽然这对某些事务很有用,但错误控制需要额外的数据包开销。 有些应用程序,例如VoIP,对延迟,抖动(延迟变化)和拥塞非常敏感。 这就是它使用UDP的原因。

与TCP一样,UDP是传输协议,但是没有流控制。 可以这样想:当通过TCP发送数据包时,就像问另一端是否收到了你的消息。 如果他们这样做,他们会承认。 如果没有,您现在必须确定如何重新发送此信息。 UDP没有这个。 您将消息发送到另一方,并希望它到达那里。

现在,如果您想谈论“安全”协议,通常可以在网络层(IPSec)或应用层(SSL)上完成。 安全通常意味着安全。

通常的TCP三次握手如下所示:

发送SYN的人是客户端。 收到初始SYN的是服务器。

客户端发送SYN - >服务器

现在,如果服务器正在侦听,和/或没有防火墙阻止该服务(在这种情况下,您将从具有RST的服务器接收TCP帧,最可能设置ACK位),服务器将以SYN-ACK:

服务器发送SYN / ACK - >客户端

如果客户收到此数据包,他将确认收到了该数据包。 这样就完成了三次握手,这两者可以开始交换信息。

客户端发送ACK - >服务器

这是一个很好的网站,一些信息:

http://www.tcpipguide.com/free/index.htm

Firstly, IP is not necessarily required to connect all networks. However, it is the most widely used and adopted today (For now that is). Old network protocols such as Appletalk, IPX, and DECNet are all legacy network protocols that are not much used anymore, however they are still around to an extent. Don't forget IPv6 is out there as well, in some places, and can ride over IPv4 networks if your configuration is done properly.

When you say TCP being "safe", I would give it another word, and that would be intelligent. TCP is a transport protocol, and is the header that comes directly after the IPv4 header. TCP is primarily used for flow control and has become very efficient at error recovery in case a part of a packet or packets has been last when transferring/receiving. While this is great for some transactions, the error control requires an additional amount of overhead in the packet. Some applications, let's say VoIP for example, is very sensitive to delay, jitter (Variation in delay) and congestion. This is why it uses UDP.

Like TCP, UDP is a transport protocol, however there is no flow control. Think of it this way: When sending packets over TCP, it's like asking the other end if they received your message. If they did, they will acknowledge it. If not, you now have to determine how you will resend this information. UDP has none of this. You send your message to the other side, and hope it gets there.

Now if you want to talk about "safe" protocols, this is usually done at either the network layer (IPSec) or the application layer (SSL). Safe typically means secured.

A usual TCP three-way handshake looks like this:

Whoever sends the SYN is the client. Whoever receives that initial SYN is the server.

Client sends SYN --> Server

Now, if the server is listening, and/or there's not a firewall blocking the service (Which in that case you'd receive a TCP frame from the server with the RST,ACK bits set most likely), the server will respond with a SYN-ACK:

Server sends SYN/ACK --> Client

If the client received this packet, he will acknowledge he received it. This completes the three-way handshake and these two may begin exchanging information.

Client sends ACK --> Server

Here's a good site for some info:

http://www.tcpipguide.com/free/index.htm

更多推荐

本文发布于:2023-07-29 20:31:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1319523.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   工作   TCP   websockets   IP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!