osi模型:七层模型介绍
The Open Systems Interconnection Model or OSI Model is an ISO (International Organization of Standards) conceptual model to standardize the communications of systems. It aims to remain agnostic to the underlying architecture or technology as much as possible. OSI can be viewed as an abstraction of networking from the physical layer all the way up to the end user application. Many networking and system administration certifications reference, or at least build off of, the OSI Model since it provides a way to approach networking which is clear and concise without focusing on the actual technology being used. A layer 2 switch is a layer 2 switch whether it uses ethernet or 802.11.
开放系统互连模型或OSI模型是用于标准化系统通信的ISO (国际标准组织)概念模型。 它旨在尽可能不了解底层架构或技术。 OSI可以看作是从物理层一直到最终用户应用程序的网络抽象。 许多网络和系统管理认证都引用或至少建立在OSI模型的基础上,因为它提供了一种清晰,简洁的方法来实现网络连接,而无需关注实际使用的技术。 第2层交换机是第2层交换机,无论它使用以太网还是802.11。
The OSI layer approach is also extremely useful for troubleshooting. If a lower level is impacted, looking higher won’t do anything. A broken ethernet cable means you shouldn’t bother delving into the router’s configuration to solve the issue. If a session can’t be established, there probably isn’t a point looking at SSL. If you can find what’s broken (i.e. which layer), you just have to look down the chain and not up.
OSI层方法对于故障排除也非常有用。 如果较低的水平受到影响,则较高的水平将无济于事。 断开的以太网电缆意味着您不必费心研究路由器的配置来解决问题。 如果无法建立会话,则可能没有必要关注SSL。 如果您可以找到损坏的部分(即哪一层),则只需向下看链而不是向上。
OSI与TCP / IP (OSI vs. TCP/IP)
Unfortunately, OSI lost the standardization war with TCP/IP for all intents and purposes. Basically everything is built using TCP/IP. Virtually no one uses the OSI protocols in their stack.
不幸的是,OSI出于所有意图和目的都输掉了使用TCP / IP进行的标准化之战。 基本上,所有内容都是使用TCP / IP构建的。 几乎没有人在其堆栈中使用OSI协议。
So, why learn about the OSI model in the first place then?
那么,为什么要首先了解OSI模型呢?
OSI arguably set the standard for the modern networking stack. Even though no one really cares about OSI protocols in the real world, the concept has bled over into TCP/IP (despite RFC3439 [section 3.]). There are layer 2 and layer 3 switches, and what they do is substantially different. A lot of higher end equipment advertises where it can be on the OSI model.
OSI可以说是现代网络堆栈的标准。 即使没有人真正关心现实世界中的OSI协议,但该概念已渗入TCP / IP(尽管有RFC3439 [第3节])。 有第2层和第3层交换机,它们的工作方式大不相同。 许多高端设备在OSI模型上做广告。
If you’re going for certs, understanding OSI is a must. Understanding the general concepts will help with both networking and system administration. Keep in mind though, OSI is good and useful, but it shouldn’t trump the practical implementations of whatever you’re working for. Many devices don’t adhere strictly to OSI (nor should they).
如果您要获取证书,则必须了解OSI。 了解一般概念将有助于网络和系统管理。 但是请记住,OSI既好又有用,但是它不应该胜过您正在从事的工作的实际实现。 许多设备不严格遵守OSI(也不应该)。
OSI层 (OSI Layers)
Th OSI model divides the network into 7 layers, they are the: Physical Layer, Data Link Layer, Network Layer, Transport Layer (the magic layer), Session Layer, Presentation Layer, and Application Layer. The Transport Layer is the magic layer which corresponds to our Datagram or packets (in TCP/IP). It marks where we go from the network back towards the individual node.
OSI模型将网络分为7层,分别是:物理层,数据链路层,网络层,传输层(魔术层),会话层,表示层和应用程序层。 传输层是魔术层,它对应于我们的数据报或数据包 (在TCP / IP中)。 它标志着我们从网络回到单个节点的位置。
1.物理层-符号 (1. Physical Layer — Symbol)
The physical layer is the actual physical hardware we’re running everything on. Ethernet is the physical layer, token ring is the physical layer, the actual connection for 802.11 wireless (PHY) is the physical layer. How you get your bits or symbol across is the physical layer.
物理层是我们要在其上运行的实际物理硬件。 以太网是物理层,令牌环是物理层,802.11无线(PHY)的实际连接是物理层。 物理层是如何获取位或符号的 。
Our symbol is how we turn our bit into something which goes across our medium, be it a voltage spike or a radio wave. The layer specification includes things like effective range, pinouts, voltages, timing, etc. How does your data get from A to B? The physical hardware that makes it happen is the physical layer.
我们的标志是如何将我们的比特变成跨越我们的介质的东西,无论是电压尖峰还是无线电波。 层规范包括诸如有效范围,引脚排列,电压,时序等信息。您的数据如何从A到B ? 实现这一目标的物理硬件是物理层。
2.数据链路层-框架 (2. Data Link Layer — Frame)
The data link layer abstracts a layer above the physical layer. How does data get from A to B over our physical medium, and how do we account for it reaching its target? The data link layer has some level of error correction and establishes node to node communications. The MAC and LLC portion of 802.11 operates at this level, as do most dumb switches.
数据链路层在物理层之上抽象了一层。 数据如何通过我们的物理介质从A传输到B ,以及我们如何解释达到目标的数据? 数据链路层具有一定程度的错误校正,并建立了节点到节点的通信。 802.11的MAC和LLC部分以及大多数哑交换机都在此级别上运行。
We communicate with frames in the data link layer. A frame is the total encapsulated packet of data encapsulated with what it takes to get from A to B before the actual physical transmission of bits over our medium. In TCP/IP, this will be our packet with some padding so that the device knows what to do with it and has a standardized frame of data to work with (preamble, destination, source MAC, CRC checksum, etc.).
我们在数据链路层中与帧进行通信。 帧是封装的总数据包,其中包含在通过介质实际进行物理位传输之前从A到B所需要的数据。 在TCP / IP中,这将是带有某些填充的数据包 ,以便设备知道如何处理它,并具有可使用的标准化数据帧 (前导,目标,源MAC,CRC校验和等)。
Frames are everything which is necessary to get our actual parts we care about between nodes. It is the most basic, and also most complete piece of networking data.
框架是获取节点之间我们关心的实际零件所必需的一切。 它是最基本,也是最完整的网络数据。
3.网络层—数据包 (3. Network Layer — Packet)
Before we were just concerned with nodes physically connected to each other being able to communicate. The network layer is where we actually route our traffic and focus on the unit of the packet. Routers and the majority of the 802.11 protocol work at this layer. Devices talk to each other and know how to send data to other things outside the immediate device. We want node a to talk to node b even though we might have to jump from device A to device B to do so. Node a also shouldn’t talk to node c. The network layer makes this possible.
在我们只关心物理上相互连接的节点之间能够进行通信之前。 网络层是我们实际路由流量并集中处理数据包单位的地方。 路由器和大多数802.11协议都在此层工作。 设备互相交谈,并且知道如何将数据发送到直接设备之外的其他事物。 即使我们可能必须从设备A跳到设备B ,我们也希望节点a与节点b对话。 节点a也不应与节点c对话。 网络层使这成为可能。
The network layer operates on packets. Nodes or devices are allocated addresses so that anything at the network layer can have a way to send a packet so that another device can respond on behalf of that address. If we have switch A and switch B, the actual routing will allow them to talk. This layer is responsible for making sure that the data being sent follows the specifications for a packet, so data may be split up as necessary.
网络层对数据包进行操作 。 节点或设备被分配了地址,因此网络层的任何内容都可以使用一种方式发送数据包,以便另一个设备可以代表该地址进行响应。 如果我们有交换机A和交换机B ,那么实际的路由将允许他们通话。 该层负责确保发送的数据符合数据包的规范,因此可以根据需要拆分数据。
This can be thought of as IP in the TCP/IP scheme.
这可以在TCP / IP方案被认为是IP。
4.传输层-数据报 (4. Transport Layer — Datagram)
The transport layer is the magic layer; this is where TCP, UDP, etc. exist in the OSI model. The transport layer is also considered the magic layer because it is where we get the transition from the physical data and how it gets around the network to actually doing things with the nodes. This is where we from the network back into a system.
传输层是魔术层; 这就是OSI模型中存在TCP,UDP等的地方。 传输层也被认为是不可思议的层,因为它是我们从物理数据以及它如何在网络中过渡到实际与节点进行事务的过渡。 这是我们从网络回到系统的地方。
Every layer up until now was focused on just talking to things, but this is the first layer where we have direction and a way to actually say something. The network layer lets us find and pass data to a node, but this is where we let the nodes actually communicate.
到目前为止,每一层都只专注于交谈。但这是第一层,我们有方向和一种实际说话的方式。 网络层允许我们查找数据并将其传递到节点,但这是我们让节点进行实际通信的地方。
The transport layer uses datagrams. Datagrams are the actual data bits embedded in the packet. For TCP/IP, IP gives us the packet, TCP gives us a way to actually use these packets to establish connections. We can send a packet down the line, but our process here allows us to tell the other node we received it and create an actual state for our connection. We perform our handshake with SYN, SYN-ACK, ACK in TCP here.
传输层使用数据报 。 数据报是嵌入在数据包中的实际数据位。 对于TCP / IP,IP为我们提供了数据包,TCP为我们提供了一种实际使用这些数据包建立连接的方法。 我们可以沿行发送数据包,但是这里的过程允许我们告诉接收到它的另一个节点,并为连接创建实际状态。 我们在这里使用TCP中的SYN,SYN-ACK和ACK执行握手。
5.会话层-数据 (5. Session Layer — Data)
From this point on, we only deal with data for the actual nodes to handle. Now that we can establish a state, we can establish a session. The session layer is where we actually get nodes talking to each other at a higher level. The lower levels should be handled by the OS and networking hardware.
从这一点开始,我们只处理实际节点要处理的数据。 现在我们可以建立状态,我们可以建立会话。 会话层实际上是使节点在更高层次上互相交谈的地方。 较低的级别应由操作系统和网络硬件处理。
Sockets are the most common way to deal with the session layer in TCP/IP. Raw sockets basically establish our TCP connection and allow the devices to create a session and talk to each other as necessary. At this point, each node will just see raw data going back and forth. Is it encrypted or is it plain data? What are we dealing with? It’s up to them to establish the connection to spit data back and forth at the session layer, not necessarily to work with it.
套接字是处理TCP / IP中会话层的最常见方法。 原始套接字基本上建立了我们的TCP连接,并允许设备在必要时创建会话并相互交谈。 此时,每个节点将只看到来回的原始数据。 它是加密的还是纯数据? 我们在处理什么? 由他们来建立连接以在会话层上来回吐出数据,而不必与之一起使用。
6.表示层-数据 (6. Presentation Layer — Data)
After we establish our session, we establish context at the presentation layer. Node a is talking to node b, now it needs to tell node b we’re about to use a secure connection, here is the handshake, or maybe it tells node b it’s about to send over a PDF of x bytes. This is where TLS/SSL, and MIME is in the TCP/IP stack. This can also be something like a compression header or similar as well. We’re presenting what we’re about to send to the node. Without this layer, how would the endpoint know what data is coming without it being predetermined (which means some kind of proprietary protocol in the old days)?
建立会话后,我们在表示层建立上下文。 节点a正在与节点b进行通信 ,现在它需要告诉节点b我们将要使用安全连接,这是握手,或者也许它告诉节点b它即将通过x字节的PDF发送。 这是TLS / SSL和MIME在TCP / IP堆栈中的位置。 这也可以是类似压缩头之类的东西。 我们正在展示将要发送到节点的内容。 如果没有这一层,端点将如何知道未预先确定的数据(这意味着过去会使用某种专有协议)?
7.应用层-数据 (7. Application Layer — Data)
This is where we finally have our applications handling data. The actual implementation and handling of this is all independent of the protocol. All that matters here is that our program does what it’s supposed to with the data it’s provided. Everything above the transport layer is handled on the node itself, the transport layer is the glue between the node and the network, and all of the lower layers are handled by the network.
这是我们最终让我们的应用程序处理数据的地方。 实际的实现和处理都与协议无关。 这里最重要的是,我们的程序会使用所提供的数据执行应有的功能。 传输层上方的所有内容都是在节点本身上处理的,传输层是节点与网络之间的胶水,所有较低的层均由网络处理。
应用OSI进行故障排除 (Applying OSI For Troubleshooting)
If you run into a networking issue, where should you look? Some people say to look at ping or telnet among other tools. But, why do these tools work?
如果遇到网络问题,应该去哪里看? 有人说要在其他工具中使用ping或telnet 。 但是,为什么这些工具起作用?
One of the first goals of figuring out why something isn’t working is to look at where it’s breaking down. Are we having issues with the actual network or the endpoint? It doesn’t matter how fault resilient a protocol is if it can’t find the address it’s trying to connect to. There’s no point trying to debug an application if the session can’t be established.
弄清某事为什么不起作用的首要目标之一是看它在哪里分解。 我们在实际网络或端点方面是否有问题? 如果找不到协议要尝试连接的地址,协议的容错性无关紧要。 如果无法建立会话,尝试调试应用程序没有任何意义。
Track down where the network breaks down. Tools like ping tell us if we can route to something in most cases (assuming ICMP isn’t blocked and all of that). telnet lets us see if we can establish a socket at all (for most modern uses). Tools like trace route let us see if we can route to the item and where the breakdown might be by trying to connect to everything along the way. None of these tools tell us much if the breakdown is a bad port or similar, but they help us narrow down the ultimate cause.
跟踪网络出现故障的位置。 像ping这样的工具会告诉我们在大多数情况下是否可以路由到某些设备(假设ICMP未被阻止,而所有这些都被阻止)。 telnet让我们看看是否可以建立一个套接字(用于大多数现代用途)。 诸如跟踪路由之类的工具使我们可以查看是否可以路由至该项目,以及通过尝试连接到此过程中的所有内容来进行细分。 这些工具都无法告诉我们故障是由于端口不良还是类似原因,但它们可以帮助我们缩小最终原因。
The trick is to start somewhere and work towards the problem. If you can ping the server and telnet on the requisite port, is it going to be a routing issue? Probably not. If you can’t find the IP on the network, then you probably don’t need to mess with the settings in the program on the node itself. Once you figure out which layer is breaking, you know you don’t need to go any higher.
诀窍是从某个地方开始并努力解决问题。 如果可以在必需的端口上ping服务器和telnet,这将是路由问题吗? 可能不是。 如果在网络上找不到IP,则可能无需弄乱节点本身上程序中的设置。 一旦弄清楚哪一层破裂了,就知道不需要再走了。
结论 (Conclusion)
Though TCP/IP won the war, the marks of OSI are left all over the network stack. A layered approach is useful for both troubleshooting and conceptualization. Don’t get too married to the model since TCP/IP is a bit more fluid than OSI.
尽管TCP / IP赢得了战争,但OSI的标记仍然留在整个网络堆栈中。 分层方法对于故障排除和概念化都是有用的。 不要太喜欢这个模型,因为TCP / IP比OSI更灵活。
Apply the OSI model to troubleshooting to help track down where things are breaking down. A layer 2 device is going to do absolutely nothing to help with routing. Working on you layer 3 device won’t fix a broken cable. Each part of the network has its own function. Learn what they are and why they matter so you can understand networking theory better, as well as troubleshoot what is breaking and why.
将OSI模型应用于故障排除,以帮助跟踪发生故障的地方。 第2层设备将完全无助于路由。 在第3层设备上工作不会解决电缆断开的问题。 网络的每个部分都有其自己的功能。 了解它们是什么以及它们为什么重要,以便您可以更好地理解网络理论,并对故障和原因进行故障排除。
Originally published at https://somedudesays.com.
最初在 https://somedudesays.com上 发布 。
翻译自: https://medium.com/swlh/a-introduction-to-the-osi-model-1be83b128d3
osi模型:七层模型介绍