互联网框架五层模型详解

注:机翻,未校对。

What is the Five Layers Model? The Framework of the Internet Explained 五层模型互联网框架解释

Computer Networks are a beautiful, amazing topic. Networks involve so much knowledge from different fields, from physics to algorithms.
计算机网络是一个美丽而神奇的话题。网络涉及来自不同领域的大量知识,从物理学到算法。

When dealing with Computer Networks, there is one framework that puts everything into place – and that is the layers model.
在处理计算机网络时,有一个框架可以将所有内容都放在适当的位置,这就是层模型。

In this post you’ll learn why we need layers, as well as what the five layers model is. You will also understand the role of each layer in this model.
在这篇文章中,您将了解为什么我们需要层,以及什么是五层模型。您还将了解此模型中每个图层的作用。

Layers? 为什么选择层?

Imagine you are given the task to design and implement the Internet! Where do you start? What do we actually want from a network, and an important one such as the Internet?
想象一下,你的任务是设计和实现互联网!你从哪里开始?我们实际上想从网络中得到什么,以及像互联网这样的重要网络?

Well, we actually want quite a lot of things. To name a few:
好吧,我们实际上想要很多东西。仅举几例:

  • We want it to be fast – that is, allow fast communication. We don’t want to wait long for a message to get from one host to another.
    我们希望它快速 - 也就是说,允许快速通信。我们不想等待很长时间才能将消息从一台主机发送到另一台主机。

  • It should also be reliable – when sending a message, we want the receiver to actually receive it.
    它也应该是可靠的——在发送消息时,我们希望接收者能够实际接收它。

  • The network should be extendable – that is, allow more devices to join. We wouldn’t want to start with two computers, and then not bee able to add a third one.
    网络应该是可扩展的,也就是说,允许更多的设备加入。我们不想从两台计算机开始,然后无法添加第三台计算机。

  • The network should support different devices and connections – it should be able to connect a wired PC, wireless laptop, and a cellphone, for example.-
    网络应该支持不同的设备和连接——例如,它应该能够连接有线 PC、无线笔记本电脑和手机。

And this is just a partial list.
这只是一个部分列表。

So, how do we go about implementing the internet when we want to achieve so many different things?
那么,当我们想要实现这么多不同的事情时,我们如何去实施互联网呢?

image-58

Computer Networks are complex
计算机网络是复杂的

In order to simplify things and make networks flexible, the communication is divided into layers.
为了简化事情并使网络灵活,通信被划分为几层。

Each layer has its own responsibility. It provides services to an upper layer, and uses services provided by a lower layer.
每一层都有自己的责任。它向上层提供服务,并使用下层提供的服务。

Consider an example network consisting of three devices:
考虑一个由三个设备组成的示例网络:

image-51

An example network with three devices
一个包含三台设备的示例网络

We have two layers:
我们有两个层次:

Layer Alpha is responsible for transmitting data between hosts that are directly connected to each other. In the diagram above, it’s between hosts A and B, or between hosts B and C.
Layer Alpha 负责在彼此直接连接的主机之间传输数据。在上图中,它位于主机 A 和 B 之间,或主机 B 和 C 之间。

Layer Beta is responsible for transmitting data between distant hosts. In the diagram, it’s between hosts A and C.
Layer Beta 负责在远程主机之间传输数据。在图中,它位于主机 A 和 C 之间。

What did we gain from this division? We gained a lot of flexibility.
我们从这次分层中得到了什么?我们获得了很大的灵活性。

Each layer can be developed and implemented by different people. The upper layer doesn’t care about the implementation of the lower layer, and vice versa.
每一层都可以由不同的人开发和实现。上层不关心下层的实现,反之亦然。

For instance, the connection between hosts A and B could be a WiFi connection, while the connection between B and C could consist of a carrier pigeon. These are (completely) different implementations of Layer Alpha.
例如,主机 A 和 B 之间的连接可以是 WiFi 连接,而 B 和 C 之间的连接可以由信鸽组成。这些是 Layer Alpha 的(完全)不同实现。

Notice that this way also enables us to have different specializations and expertise – an expert in training carrier pigeons does not necessarily have to be qualified at building solid WiFi network cards, or vice versa.
请注意,这种方式还使我们能够拥有不同的专业化和专业知识 —— 一个擅长训练信鸽的专家不一定需要在构建稳固的 WiFi 网卡上具备资质,反之亦然。

“Carrier pigeon” ,信鸽。在这里是一种比喻,用来表示一种不常见或老的通信方式。( 斐夷所非 注释

image-52

The Alpha Layer may have different implementations on the same network
Alpha 层在同一网络中可能有不同的实现

Developers of Layer Beta don’t need to bother themselves with this difference. At this layer, host A needs to know that in order to reach host C, it first needs to send his message to host B, rather than, say, host D. Then, host B will forward it to host C.
Layer Beta 的开发人员无需为这种差异而烦恼。在此层,主机 A 需要知道,为了到达主机 C,它首先需要向主机 B 发送消息,而不是向主机 D 发送消息。然后,主机 B 会将其转发给主机 C。

This way, Layer Beta is only responsible for finding the route to send the message. It uses the service provided by Layer Alpha – transmitting data between directly connected hosts.
这样,Layer Beta 只负责查找发送消息的路由。它使用 Layer Alpha 提供的服务——在直接连接的主机之间传输数据。

In general, networks are very complicated, and have various requirements. Dividing the communication into layers will allow us to simplify things and make communication more flexible.
一般来说,网络非常复杂,并且有各种要求。将沟通分成几层将使我们能够简化事情并使沟通更加灵活。

Now that you understand why we need layers, we can go on to learn about the layers that are actually used in networks.
现在您已经了解了我们为什么需要层,我们可以继续了解网络中实际使用的层。

What is the Five Layers Model? 什么是五层模型?

There have been a few layer models proposed along the years – most notably, the five layers model, the 7 layers model (aka OSI model), or the 4 layers model (aka the TCP/IP model).
多年来,已经提出了一些层模型,其中最著名的是五层模型、七层模型(又名 OSI 模型)或四层模型(又名 TCP/IP 模型)。
在这里插入图片描述

They are way more similar than different, and I choose to focus on the five layers model as it is the most practical of all – and best describes the way the Internet actually works.
它们的相似之处多于不同之处,我选择关注五层模型,因为它是最实用的,并且最能描述互联网的实际工作方式。

在这里插入图片描述

The First Layer – The Physical Layer 第一层 – 物理层

The first layer is responsible for transmitting a single bit – 0 or 1 – over the network.
第一层负责通过网络传输单个比特(0 或 1)。

To get some intuition as to what this layer is responsible for, consider the time of transmission. Assume that we have some kind of cable to transmit our data, and we use +5 Voltage to transmit 1, and -5 Voltage to transmit 0. What bits does the following diagram represent?
要获得有关该层负责什么的直觉,请考虑传输时间。假设我们有某种电缆来传输数据,我们使用 +5 电压传输 1,使用 -5 电压传输 0。下图表示哪些位?

image-53

A physical layer implementation encoding 1 as +5 Voltage and 0 as -5 Voltage

Well, it might be 1001. That is the case if it takes this long to transmit a single bit (demonstrated by the dashed orange line in the diagram below):
好吧,它可能是 1001。如果传输一个比特需要这么长时间(如下图中的橙色虚线所示),就是这种情况:

image-54

An example bitstream encoded by this signal

However, it might also represent other bit streams. For instance, if it only takes half the time to transmit a single bit (demonstrated by the dashed green line below), then the bit stream might be 11000011:
但是,它也可能表示其他位流。例如,如果传输一个比特只需要一半的时间(由下图的绿色虚线表示),则比特流可能是 11000011

image-55

Another possible bitstream encoded by the same signal

The difference lies in the time dedicated for transmitting a single bit. This is called the bitrate – that is, the number of bits that are conveyed per unit of time.
区别在于用于传输单个比特的时间。这称为比特率,即每单位时间传输的位数

Of course, achieving a high bitrate is preferable, as it means we can send many bits in a short timeframe. But it is hard to achieve high bitrates without getting many errors.
当然,实现高比特率是可取的,因为这意味着我们可以在短时间内发送许多比特。但是很难在不出现很多错误的情况下实现高比特率。

This is only one of the things that the first layer needs to take into consideration. The important thing for now is the goal of this layer: to transmit and receive a single bit.
这只是第一层需要考虑的事情之一。现在重要的是这一层的目标:发送和接收单个比特。

The Second Layer – The Data Link Layer 第二层 – 数据链路层

The second layer is responsible for transmitting data between two hosts that are directly linked, despite possible errors.
第二层负责在直接链接的两台主机之间传输数据,尽管可能存在错误。

What do we mean by “directly linked”? For now, imagine that there is no device in between the two devices. So, if we have two computers here – computer A and computer B, and they are connected via computer M – then computer A and computer B are NOT directly linked. But computer A and computer M are directly linked, and so are computer M and computer B.
我们所说的“直接链接”是什么意思?现在,假设两个设备之间没有设备。因此,如果我们这里有两台计算机——计算机 A 和计算机 B,并且它们通过计算机 M 连接——那么计算机 A 和计算机 B 不是直接链接的。但是计算机 A 和计算机 M 是直接链接的,计算机 M 和计算机 B 也是直接链接的。

image-56

Two remote hosts connected via another device

Another way to put it is that computer A and computer M are one hop away from one another, whereas computer A and computer B are two hops away.
另一种说法是,计算机 A 和计算机 M 彼此相距一跳,而计算机 A 和计算机 B 相距两跳。

That is, in order to get from computer A to computer B we need two “hops” – one hop from A to M, and another hop from M to B.
也就是说,为了从计算机 A 到计算机 B,我们需要两个“跃点”——一个从 A 跳到 M,另一个从 M 跳到 B。

image-57

Every direct connection is called a Hop

Going back to the second layer’s responsibility – we mentioned it is responsible for transmitting data between two hosts that are directly linked, despite possible errors.
回到第二层的职责——我们提到它负责在两个直接链接的主机之间传输数据,尽管可能存在错误。

What do we mean by errors? The physical layer might provide erroneous data. For example, 1 instead of 0. So a stream of bits such as 000110, might be received as 001110.
我们所说的错误是什么意思?物理层可能会提供错误的数据。例如,1 而不是 0。因此,像 000110 这样的位流可能被接收为 001110

Many reasons might cause these kind of errors. For instance, we can think of a truck literally running over the wire where the bits are transmitted, causing some problem. Regardless of the reason, the second layer must handle the communication despite these errors.
许多原因可能会导致此类错误。例如,我们可以想象一辆卡车从字面上碾过传输比特的电线,从而导致一些问题。无论出于何种原因,尽管存在这些错误,第二层仍必须处理通信。

The second layer sends data in datagrams, that is, in chunks. Datagrams in this layer are called Frames. Frames will usually contain MAC addresses, which are physical addresses, one identifying the sender, and another identifying the receiver.
第二层以数据报的形式发送数据,即以块的形式发送数据。此层中的数据报称为帧。帧通常包含MAC地址,这些地址是物理地址,一个标识发送方,另一个标识接收方。

Why would we need a MAC address?

为什么我们需要MAC地址?

First, the receiving devices would like to know whether the frame is intended for them. The receiver wouldn’t like to waste precious time reading data intended for someone else. If the frame contains a MAC address that doesn’t belong to a receiver’s device, that device can simply ignore this frame.
首先,接收设备想知道帧是否适合它们。接收者不想浪费宝贵的时间来读取用于其他人的数据。如果帧包含不属于接收器设备的 MAC 地址,则该设备可以简单地忽略此帧。

Second, for privacy reasons - we would like messages to arrive only at intended receivers, so only they can read the data.
其次,出于隐私原因 - 我们希望消息只到达预期的接收者,因此只有他们才能读取数据。

Third, the sender would like the receiver to know who sent the frame. That way, the receiver will be able to send their response back to the sender, and not to someone else.
第三,发送方希望接收方知道是谁发送了帧。这样,接收者将能够将他们的响应发送回发送者,而不是其他人。

Note that we would like these addresses to be unique. That is, we want one address to identify a single device. That way, we know that if we send a message to a specific address it will be sent to the intended device only.
请注意,我们希望这些地址是唯一的。也就是说,我们需要一个地址来标识单个设备。这样,我们知道,如果我们向特定地址发送消息,它只会发送到预期的设备。

The Third Layer – The Network Layer 第三层 – 网络层

The third layer is responsible for routing – that is, determining the path where the data will “travel”.
第三层负责路由,即确定数据将“传输”的路径。

You can think of this layer as the successful routing app, Google Maps. When you get in the car and use Google Maps, you tell the app your destination, and Google Maps finds out the best route for you to drive in.
您可以将此图层视为成功的路径应用程序 Google Maps。当你上车并使用谷歌地图时,你告诉应用程序你的目的地,谷歌地图就会为你找到最好的开车路线。

Notice that Google Maps is dynamic – it won’t necessarily pick the same route each time. Sometimes, one path will have a traffic jam, so Google Maps will prefer another route.
请注意,谷歌地图是动态的——它不一定每次都选择相同的路线。有时,一条路径会出现交通拥堵,因此谷歌地图会更喜欢另一条路线。

We said that the second layer has physical addresses, called MAC addresses. The third layer is responsible for logical addresses, such as IP addresses.
我们说第二层有物理地址,称为MAC地址。第三层负责逻辑地址,例如 IP 地址。

In this layer, datagrams are called packets.
在此层中,数据报称为数据包。

Consider the following network diagram:
请参考以下网络图:
image-59

A network diagram with Computer A in France, Computer B in the US, and 10 routers in between

We have two computers here – one in France, and one in the United States. Of course, they are not directly linked. Rather, they are linked via third layer devices called routers.
我们这里有两台电脑,一台在法国,一台在美国。当然,它们没有直接联系。相反,它们通过称为路由器的第三层设备进行链接。

Which layer is responsible for each connection?
哪个层负责每个连接?

Consider the connection between Computer A and Router 1. The second layer is responsible for this connection. Right, again, this is the second layer. The same applies for each connection between two directly linked devices.
考虑计算机 A 和路由器 1 之间的连接。第二层负责此连接。对,再说一遍,这是第二层。这同样适用于两个直接链接设备之间的每个连接。

What about the connection between Router 2 and Router 5?
路由器 2 和路由器 5 之间的连接情况如何?

The third layer is responsible for defining the route – that the message sent from Computer A to Computer B will go through Routers 1, 2, 5, 8 and 10, and not in another way.
第三层负责定义路由——从计算机 A 发送到计算机 B 的消息将通过路由器 1、2、5、8 和 10,而不是以其他方式。

Note that there may be different implementations for each layer. For instance, we may have different implementations of the second layer. So while the connection between computer A and Router 1 might be over an Ethernet cable, the connection between Router 1 and 2 might be wireless and use WiFi. The connection between Router 2 and Router 5 might use a carrier pigeon, while the connection between router 5 and 9 will also use WiFi.
请注意,每一层可能有不同的实现。例如,我们可能有不同的第二层实现。因此,虽然计算机 A 和路由器 1 之间的连接可能通过以太网电缆连接,但路由器 1 和路由器 2 之间的连接可能是使用无线 WiFi 的 。路由器 2 和路由器 5 之间的连接可能使用信鸽,而路由器 5 和 9 之间的连接也将使用 WiFi。
image-61

The second layer may be implemented differently on every link

The third layer does not care about these changes, but the second layer definitely does. If the carrier pigeon that transmits data from Router 2 to Router 5 is sick, the second layer will have to handle it. The data link layer will also have to make sure the data transmitted over the air between routers 1 and 5 is valid and without errors.
第三层不关心这些变化,但第二层肯定关心。如果将数据从路由器 2 传输到路由器 5 的信鸽生病了,则第二层将不得不处理它。数据链路层还必须确保路由器 1 和 5 之间通过无线传输的数据有效且没有错误。

Interim Summary 中期摘要

So far we have covered three of the five layers. To recap:
到目前为止,我们已经涵盖了五层中的三层。 回顾一下:

  • The physical layer is responsible for transmitting a single bit, 1 or 0, over the network.
    物理层负责通过网络传输单个位 10

  • The data link layer is responsible for transmitting data between directly linked devices, that is – devices connected via a single hop.
    数据链路层负责在直接链接的设备之间传输数据,即通过单跳连接的设备。

  • The third layer is responsible for transferring data between hosts that are connected via multiple hops. It determines the route, the path that the packets will travel.
    第三层负责在通过多个跃点连接的主机之间传输数据。它决定了路由,即数据包将经过的路径。

The Fourth Layer – The Transportation Layer 第四层 – 运输层

The fourth layer is an end-to-end layer. That is, it is responsible for communication from the source, all the way to the ultimate destination.
第四层是端到端层。也就是说,它负责从源头一直到最终目的地的通信。

It allows multiplexing of multiple services. For example, one server may serve as a Web server, as well as a Mail server. When a client turns to that server, the client should be able to specify which service it would like to access. While the third layer specifies the address of the server, the transport layer identifies which service is relevant for the current communication.
它允许多个服务的多路复用。例如,一台服务器既可以用作 Web 服务器,也可以用作邮件服务器。当客户端转向该服务器时,客户端应该能够指定它要访问的服务。第三层指定服务器的地址,而传输层则标识与当前通信相关的服务。

In addition, the transport layer may ensure reliability. So when this layer receives data from the upper layer, it splits it into chunks, sends them, and makes sure that all those chunks arrive correctly at the other end.
此外,传输层可以确保可靠性。因此,当这一层从上层接收数据时,它会将其拆分为块,发送它们,并确保所有这些块都正确到达另一端。

Notice that the network layer is usually not reliable. Packets may arrive in incorrect order, they can arrive with incorrect data, or even not arrive at all. A reliable transportation layer makes sure that the data is correctly received.
请注意,网络层通常不可靠。数据包可能以不正确的顺序到达,它们可能以不正确的数据到达,甚至根本没有到达。可靠的传输层可确保正确接收数据。

In this layer, datagrams are called segments.
在此层中,数据报称为段。

Consider the following network diagram once more:
再次参考以下网络图:
image-59

Which layer is responsible for what?

各层负责什么?

We have already said that the network layer is responsible for the route, that is, the path in which the packets travel. We also mentioned that the second layer is responsible for the transmission of the data between two, directly connected devices. For example, the link between Router 1 and Router 2.
我们已经说过,网络层负责路由,即数据包传输的路径。我们还提到,第二层负责在两个直接连接的设备之间传输数据。例如,路由器 1 和路由器 2 之间的链路。

The fourth layer views all of this network diagram as an abstract cloud. It doesn’t know the routers, and it doesn’t care about the structure of the network, or the routing. It assumes that the network can send a packet from one end to another:
第四层将所有这些网络图视为一个抽象的云。它不知道路由器,也不关心网络的结构或路由。它假设网络可以从一端向另一端发送数据包:
image-62

The fourth layer sees the network as an abstract cloud

The transportation layer makes sure that the endpoints can communicate over different services – for example, web and email. In addition, it might make sure that the connection is reliable.
传输层确保端点可以通过不同的服务(例如 Web 和电子邮件)进行通信。此外,它可以确保连接可靠

One example would be to acknowledge every received segment. For instance, when computer A sends a segment to computer B, computer B will send a special Acknowledgement segment, announcing that it has received the packet.
一个示例是确认每个收到的段。例如,当计算机 A 向计算机 B 发送分段时,计算机 B 将发送一个特殊的确认分段,宣布它已收到数据包。

The Fifth Layer – The Application Layer 第五层 – 应用层

Last but definitely not least, we have the fifth layer, or Application Layer. This layer provides the service to the user’s application – web service, Voice over IP (VoIP), network games, streaming, and so on.
最后但并非最不重要的一点是,我们有第五层,或应用层。此层为用户的应用程序提供服务 - Web 服务、IP 语音 (VoIP)、网络游戏、流媒体等。

According to the layers model, the fifth layer doesn’t care at all about the network. It relies on the fourth layer, as well as the lower layers, to transmit the data from one endpoint to another. The fifth layer will use this service for the various needs of the application.
根据层模型,第五层根本不关心网络。它依赖于第四层以及更低的层,将数据从一个端点传输到另一个端点。第五层将使用此服务来满足应用程序的各种需求。

Different protocols will be used for different applications. For instance, HTTP protocol is commonly used for serving web pages on the World Wide Web. SMTP is a protocol used for emails, FTP for exchanging files, and there are many, many more.
不同的协议将用于不同的应用。例如,HTTP协议通常用于在万维网上提供网页。SMTP是一种用于电子邮件的协议,用于交换文件的FTP,还有很多很多。

Summary 总结

In this post you learned what the five layers model is and why we need layers. You should now understand what each layer is responsible for, and you can fit every topic you encounter in Computer Networks into this model.
在这篇文章中,您了解了什么是五层模型以及为什么我们需要层。现在,您应该了解每一层负责什么,并且可以将计算机网络中遇到的每个主题都放入此模型中。


via: Omer Rosenbaum OCTOBER, 2022

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/762464.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

[OHOS_ERROR]: Please call hb utilities inside ohos source directory

当执行hb set报如下错误时:原因时重新拉取了源码,且源码路径被改了 [OHOS_ERROR]: Please call hb utilities inside ohos source directory 【解决办法】 卸载hb并在源码路径下重新安装 python3 -m pip uninstall ohos-build 安装hb python3 -m pi…

python-逻辑语句

if else语句 不同于C:else if range语句: continue continue的作用是: 中断所在循环的当次执行,直接进入下一次 continue在嵌套循环中的应用 break 直接结束所在的循环 break在嵌套循环中的应用 continue和break,在…

力扣:LCR 024. 反转链表(Java)

目录 题目描述:示例 1:示例 2:代码实现: 题目描述: 给定单链表的头节点 head ,请反转链表,并返回反转后的链表的头节点。 示例 1: 输入:head [1,2,3,4,5] 输出&#x…

【嵌入式DIY实例】- LCD ST7735显示DHT11传感器数据

LCD ST7735显示DHT11传感器数据 文章目录 LCD ST7735显示DHT11传感器数据1、硬件准备与接线2、代码实现本文介绍如何将 ESP8266 NodeMCU 板 (ESP-12E) 与 DHT11 (RHT01) 数字湿度和温度传感器连接。 NodeMCU 从 DHT11 传感器读取温度(以 C 为单位)和湿度(以 rH% 为单位)值,…

1.5 Canal 数据同步工具详细教程

欢迎来到我的博客,很高兴能够在这里和您见面!欢迎订阅相关专栏: ⭐️ 全网最全IT互联网公司面试宝典:收集整理全网各大IT互联网公司技术、项目、HR面试真题. ⭐️ AIGC时代的创新与未来:详细讲解AIGC的概念、核心技术、…

【你也能从零基础学会网站开发】关系型数据库中的表(Table)设计结构以及核心组成部分

🚀 个人主页 极客小俊 ✍🏻 作者简介:程序猿、设计师、技术分享 🐋 希望大家多多支持, 我们一起学习和进步! 🏅 欢迎评论 ❤️点赞💬评论 📂收藏 📂加关注 关系型数据库中…

FTP 文件传输协议:概念、工作原理;上传下载操作步骤

目录 FTP 概念 工作原理 匿名用户 授权用户 FTP软件包 匿名用户上传下载实验步骤 环境配置 下载 上传 wget 授权用户上传下载步骤 root用户登录FTP步骤 监听 设置端口号范围 修改用户家目录 匿名用户 授权用户 FTP 概念 FTP(File Transfer Prot…

C语言之线程的学习

线程属于某一个进程 共同点:都能并发 线程共享变量,进程不共享。 多线程任务中,其中某一个线程调用了exit了,其他线程会跟着一起退出 如果是特定的线程就调用pthread_exit 失败返回的是错误号 下面也是

VSCode无法识别 node、npm

一、前提 电脑新安装了node.js,在cmd查看node和npm版本没有问题,但是在VSCode无法识别 1.cmd查看版本: 2.VSCode报错信息: 无法将“npm”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果…

C#——Property属性详情

属性 属性(Property)是类(class)、结构体(structure)和接口(interface)的成员,类或结构体中的成员变量称为字段,属性是字段的扩展,使用访问器&am…

视频转音频:怎样提取视频中的音频?6个提取音频的小技巧(建议收藏)

怎样提取视频中的音频?当我们想从视频中提取出声音时,通常会遇到很多问题。无论是想单独提取出视频里的音频,还是把它转成方便储存或者分享的音频格式,这都会涉及到视频转音频的一个需求。因此,在这篇指南里&#xff0…

如何编写高质量更优雅的代码(Java)

1、函数式接口—FunctionalInterface 好处:高逼格、代码收拢、解藕、统一处理 适用范围:具有共性的接口调用代码 举个栗子: 在我们平时的微服务开发中,调用其他服务的接口,通常要把接口调用部分做异常处理(try catch…

为何交易价格可能超出预期?

当你尝试执行订单时,如果收到“报价超出”的提示,这通常意味着交易无法按你的预期价格成交。对于某些交易者来说,这可能会带来一些困扰,但在外汇等流动性极高的市场中,这种情况是相当常见的。 外汇市场之所以吸引众多…

Python系统教程01

Python 是一门解释性语言,相对更简单、易学,它可以用于解决数学问题、获取与分 析数据、爬虫爬取网络数据、实现复制数学算法等等。 1、print()函数: print()书写时注意所有的符号都是英文符号。print()输出内容时,若要输出字符…

A股低开高走,近3000点,行情要启动了吗?

A股低开高走,近3000点,行情要启动了吗? 今天的A股,让人瞪目结舌了,你们知道是为什么吗?盘面上出现2个重要信号,一起来看看: 1、今天两市低开高走,银行板块护盘指数&…

如何使用AI学习一门编程语言?

无论你是软件开发新手还是拥有几十年的丰富经验,总是需要学习新知识。TIOBE Index追踪50种最受欢迎的编程语言,许多生态系统为职业发展和横向转型提供了机会。鉴于现有技术具有的广度,抽空学习一项新技能并有效运用技能可能困难重重。 最近我…

Linux启动elasticsearch,提示权限不够

Linux启动elasticsearch,提示权限不够,如下图所示: 解决办法: 设置文件所有者,即使用户由权限访问文件 sudo chown -R 用户名[:新组] ./elasticsearch-8.10.4 //切换到elasticsearch-8.10.4目录同级 chown详细格式…

关于vue创建项目失败报错(镜像过期)的解决方案

在新建vue项目时出现以下错误: 原因: npm.taobao.org和registry.npm.taobao.org旧域名于2021年官方公告域名更换事件,已于2022年05月31日零时起停止服务,域名HTTPS证书于2024年1月22日正式到期,不可再用。 解决方案:…

昇思MindSpore学习总结七——模型训练

1、模型训练 模型训练一般分为四个步骤: 构建数据集。定义神经网络模型。定义超参、损失函数及优化器。输入数据集进行训练与评估。 现在我们有了数据集和模型后,可以进行模型的训练与评估。 2、构建数据集 首先从数据集 Dataset加载代码&#xff0…

gdb及其使用

gdb调试一&#xff1a; 首先进入gdb&#xff0c;确定好进程&#xff0c;输入进程号 确定要调试哪个文件&#xff0c;然后输入&#xff1a;&#xff08;b为打断点&#xff09; (gdb) b serialization_protobuffer.h:write<ros::serialization::OStream>(ros::serializat…
最新文章