计算机网络(一)

243 阅读3分钟

现实世界中的计算机网络已经成为了一种基础设施,是支撑上层各种业务软件的重要资源。计算机网络是依靠抽象的概念,一层层架构起来的。标准的OSI七层模型就是非常有力的说明,虽然现实中主流的是TCP/IP协议栈结构,这也是因为在OSI出现之前,TCP/IP的应用已经广泛了。

在我们学习之前一定要明确的一点是:计算机网络是分层的,分层的,分层的。为什么分层呢?就是减少复杂度,在IT行业里,如果处理的问题非常复杂,那么抽象和封装是最好减少复杂度的工具。我们设想下,如果计算机网络不分层,那么我们在实现一个业务应用时,需要网络通信会怎么办?自己从物理层的光模信号转换一直到传输层的端口通信都需要自己来实现,那么这个过程的复杂度是不可想象的。那如果我们是依靠抽象呢?

每层只专注负责做自己的事情,每一层只需要向上一层暴露自己的接口,上层不必知道下层的技术实现细节,通过接口向上层提供service。而且上一层只能感知到下一层。

OSI模型

image.png

从上图可以看到我们OSI模型中7层结构,每层负责的service都不一样,标红的三层我们通常会在应用层次上实现。同样的我们的TCP/IP结构(其实是协议栈)也可以对应到OSI模型中。

我们的网络分层模型是一些接口规范,具体的协议是这些接口的实现,上层永远通过下层提供的原语来进行通信。

Differentiate between a layer’s service, interface and protocols.

  • The service is the what a layer offers to the one above (e.g., best effort next hop delivery service)
  • The interface is the set of primitives defining how the service is accessed
  • A protocol defines how the service is implemented. The protocol is the implementation of the service.

To implement its service(s) a layer adds control information(Typically takes the form of a header/trailer) to the payload passed down to it. The format and semantics of the latter define a Protocol Wrapping data in this way is known as Encapsulation

OSI和TCP/IP模型的对应关系

image.png

上图的模型对应关系就可以看出,我们的TCP/IP在应用层实现了OSI中的application,presentation,session三层,也就是在业务软件里实现的。

A user clicks on a link in their browser. Describe what happens with reference to our network model.

  • Use the primitives of the transport layer to create a connection to the web server
  • With connection established, construct HTTP GET message
  • Transport layer encapsulates HTTP GET in a TCP segment.
  • Transport layer then passes this to network layer
  • Network layer encapsulates TCP segment in IP datagram
  • Data link layer encapsulates IP datagram in an Ethernet frame.
  • This is passed to physical layer and propagates to the next hop

上面就是当用户在浏览器点击一个超链接后,从抽象层次来说会发生什么(一般是从server获取一个网页,也就是个文件)

计算机网络的学习,除开我们从宏观上了解网络的分层,其次就是学习各个层次的网络协议,这些网络协议是网络分层规范的具体实现.

以上内容是DCU CA647的学习笔记,仅供作者自己学习,如果有误,请友善指出。