::: center
计算机网络参考模型
:::
- 路由器:帮助设备高速转发数据
- 交换机:提供更多的网络接口(网口)) ,让更多的机器加入局域网中来
分层思想 osi七层参考模型
定义:“OSI模型,即开放式通信系统互联参考模型(Open System Interconnection Reference Model),是国际标准化组织(ISO)提出的一个试图使各种计算机在世界范围内互连为网络的标准框架,简称OSI。
::: center
| 层级 | osi模型7层 | 5层模型 |常用协议 |
| ------ | ------ | ------ | ------ |
| 7 | 应用层 | 应用层 | !!#ff0000 http!! https ftp tftp|
| 6 | 表示层 | 应用层| .. |
| 5 | 会话层 | 应用层 | ..|
| 4 | 传输层 | 传输层 | !!#ff0000 tcp!!/dup|
| 3 | 网络层 | 网络层 | icmp !!#ff0000 ip!! ARP|
| 2 | 数据链路层 |数据链路层 | |
| 1 |物理层 | 物理层 | 光纤 等|
:::
::: center
:::
通俗表达:
A发起方
应用层:输入高级语言的指令 (打开微信 输入聊天的话语 人和程序之间的交流平台)
表示层: 将人类使用的高级语言编译成二进制语言
会话层:管理多个会话 保证消息正确到达 指定主机
传输层: tcp :传数据的时候慢 但是很稳定 udp:传数据的时候很快 但是不稳定 直播 作用:确定传输协议 端口号 (在网络传输中通过端口号的不同 来区分应用)
网络层:选择数据的最佳传输路线 (ip地址)
数据链路层: 二次确认数据是否正确到达 mac地址 (全球唯一)
物理层 :插上网线 定义了一些物理接口的标准 将二进制数据转换成电信号
B接收方
物理层 :将电信号转换成二进制
数据链路层: 对比自己的mac地址 和数据包mac地址 一致则接收 否则丢弃
网络层: 再次对比ip地址
传输层: 通过端口号找对应的程序
会话层: 通过特定的会话通道 到达表达层
表示层: 将二进制语言转换为高级语言
应用层: 显示在应用程序中
::: center
常用协议说明:
:::
::: center
|协议 |说明 |
| ------ | ------ |
| http | 超文本传输协议 明文传输 |
|https | http+ssl协议 超文本加密版 |
| ftp | 文件传输协议 |
| tftp | 简单文件 默认使用udp协议 |
| icmp | ping trcert 检测主机双向联通性 |
|ARP |地址解析 将IP地址 转换成mac地址的协议 |
|ip|
:::
::: center
!!#ff0000 数据封装过程!!
{data-type=drawio data-xml=%3CmxGraphModel%20dx=%22746%22%20dy=%22407%22%20grid=%221%22%20gridSize=%2210%22%20guides=%221%22%20tooltips=%221%22%20connect=%221%22%20arrows=%221%22%20fold=%221%22%20page=%221%22%20pageScale=%221%22%20pageWidth=%22827%22%20pageHeight=%221169%22%20background=%22none%22%3E%3Croot%3E%3CmxCell%20id=%220%22/%3E%3CmxCell%20id=%221%22%20parent=%220%22/%3E%3CmxCell%20id=%222%22%20value=%22data%20%EF%BC%88%E7%9C%9F%E5%AE%9E%E6%95%B0%E6%8D%AE%EF%BC%89%22%20style=%22rounded=1;whiteSpace=wrap;html=1;fillColor=#99FF99;%22%20vertex=%221%22%20parent=%221%22%3E%3CmxGeometry%20x=%22200%22%20y=%2220%22%20width=%22120%22%20height=%2260%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%223%22%20value=%22data%20%EF%BC%88%E7%9C%9F%E5%AE%9E%E6%95%B0%E6%8D%AE%EF%BC%89%22%20style=%22rounded=1;whiteSpace=wrap;html=1;fillColor=#99FF99;%22%20vertex=%221%22%20parent=%221%22%3E%3CmxGeometry%20x=%22320%22%20y=%22105%22%20width=%22120%22%20height=%2260%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%224%22%20value=%22tcp/ip%E5%8D%8F%E8%AE%AE+%E5%A4%B4%E9%83%A8%22%20style=%22rounded=1;whiteSpace=wrap;html=1;fillColor=#99FF99;%22%20vertex=%221%22%20parent=%221%22%3E%3CmxGeometry%20x=%22200%22%20y=%22105%22%20width=%22120%22%20height=%2260%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%225%22%20value=%22tcp/ip%E5%8D%8F%E8%AE%AE+%E5%A4%B4%E9%83%A8%22%20style=%22rounded=1;whiteSpace=wrap;html=1;fillColor=#99FF99;%22%20vertex=%221%22%20parent=%221%22%3E%3CmxGeometry%20x=%22320%22%20y=%22205%22%20width=%22120%22%20height=%2260%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%226%22%20value=%22data%20%EF%BC%88%E7%9C%9F%E5%AE%9E%E6%95%B0%E6%8D%AE%EF%BC%89%22%20style=%22rounded=1;whiteSpace=wrap;html=1;fillColor=#99FF99;%22%20vertex=%221%22%20parent=%221%22%3E%3CmxGeometry%20x=%22440%22%20y=%22205%22%20width=%22120%22%20height=%2260%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%227%22%20value=%22ip%E5%A4%B4%E9%83%A8%22%20style=%22rounded=1;whiteSpace=wrap;html=1;fillColor=#99FF99;%22%20vertex=%221%22%20parent=%221%22%3E%3CmxGeometry%20x=%22200%22%20y=%22205%22%20width=%22120%22%20height=%2260%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%228%22%20value=%22tcp/ip%E5%8D%8F%E8%AE%AE+%E5%A4%B4%E9%83%A8%22%20style=%22rounded=1;whiteSpace=wrap;html=1;fillColor=#99FF99;%22%20vertex=%221%22%20parent=%221%22%3E%3CmxGeometry%20x=%22440%22%20y=%22310%22%20width=%22120%22%20height=%2260%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%229%22%20value=%22data%20%EF%BC%88%E7%9C%9F%E5%AE%9E%E6%95%B0%E6%8D%AE%EF%BC%89%22%20style=%22rounded=1;whiteSpace=wrap;html=1;fillColor=#99FF99;%22%20vertex=%221%22%20parent=%221%22%3E%3CmxGeometry%20x=%22560%22%20y=%22310%22%20width=%22120%22%20height=%2260%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%2210%22%20value=%22ip%E5%A4%B4%E9%83%A8%22%20style=%22rounded=1;whiteSpace=wrap;html=1;fillColor=#99FF99;%22%20vertex=%221%22%20parent=%221%22%3E%3CmxGeometry%20x=%22320%22%20y=%22310%22%20width=%22120%22%20height=%2260%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%2211%22%20value=%22mac%E5%A4%B4%E9%83%A8%22%20style=%22rounded=1;whiteSpace=wrap;html=1;fillColor=#99FF99;%22%20vertex=%221%22%20parent=%221%22%3E%3CmxGeometry%20x=%22200%22%20y=%22310%22%20width=%22120%22%20height=%2260%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%2212%22%20value=%22%E6%95%B0%E6%8D%AE%E6%A0%A1%E9%AA%8C%E4%BD%8D%22%20style=%22rounded=1;whiteSpace=wrap;html=1;fillColor=#99FF99;%22%20vertex=%221%22%20parent=%221%22%3E%3CmxGeometry%20x=%22680.2130342371323%22%20y=%22310%22%20width=%22120%22%20height=%2260%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%2213%22%20value=%22%22%20style=%22group%22%20vertex=%221%22%20connectable=%220%22%20parent=%221%22%3E%3CmxGeometry%20x=%2240%22%20y=%2225%22%20width=%2280%22%20height=%22340%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%2214%22%20value=%22%E5%BA%94%E7%94%A8%E5%B1%82%22%20style=%22shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;fillColor=#FFD966;size=8;%22%20vertex=%221%22%20parent=%2213%22%3E%3CmxGeometry%20width=%2280%22%20height=%2250%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%2215%22%20value=%22%E4%BC%A0%E8%BE%93%E5%B1%82%22%20style=%22shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;fillColor=#FFD966;size=8;%22%20vertex=%221%22%20parent=%2213%22%3E%3CmxGeometry%20y=%2285%22%20width=%2280%22%20height=%2250%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%2216%22%20value=%22%E7%BD%91%E7%BB%9C%E5%B1%82%22%20style=%22shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;fillColor=#FFD966;size=8;%22%20vertex=%221%22%20parent=%2213%22%3E%3CmxGeometry%20y=%22185%22%20width=%2280%22%20height=%2250%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%2217%22%20value=%22%E6%95%B0%E6%8D%AE%E9%93%BE%E8%B7%AF%E5%B1%82%22%20style=%22shape=note;whiteSpace=wrap;html=1;backgroundOutline=1;darkOpacity=0.05;fillColor=#FFD966;size=8;%22%20vertex=%221%22%20parent=%2213%22%3E%3CmxGeometry%20y=%22290%22%20width=%2280%22%20height=%2250%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%2218%22%20value=%22%22%20style=%22shape=link;html=1;jettySize=auto;orthogonalLoop=1;%22%20edge=%221%22%20parent=%2213%22%3E%3CmxGeometry%20width=%22100%22%20relative=%221%22%20as=%22geometry%22%3E%3CmxPoint%20y=%22257%22%20as=%22sourcePoint%22/%3E%3CmxPoint%20x=%22680%22%20y=%22255%22%20as=%22targetPoint%22/%3E%3C/mxGeometry%3E%3C/mxCell%3E%3CmxCell%20id=%2219%22%20value=%22%E4%BA%92%E7%9B%B8%E7%8B%AC%E7%AB%8B%22%20style=%22text;html=1;resizable=0;points=%5B%5D;align=center;verticalAlign=middle;labelBackgroundColor=#ffffff;%22%20vertex=%221%22%20connectable=%220%22%20parent=%2218%22%3E%3CmxGeometry%20x=%220.0321%22%20y=%22-3%22%20relative=%221%22%20as=%22geometry%22%3E%3CmxPoint%20as=%22offset%22/%3E%3C/mxGeometry%3E%3C/mxCell%3E%3CmxCell%20id=%2220%22%20value=%22%E6%95%B0%E6%8D%AE%E5%8C%85%22%20style=%22shape=callout;whiteSpace=wrap;html=1;perimeter=calloutPerimeter;fillColor=#99FF99;position2=0;base=7;%22%20vertex=%221%22%20parent=%221%22%3E%3CmxGeometry%20x=%22557%22%20y=%22205%22%20width=%22120%22%20height=%2255%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%2221%22%20value=%22%E6%95%B0%E6%8D%AE%E5%B8%A7%22%20style=%22shape=callout;whiteSpace=wrap;html=1;perimeter=calloutPerimeter;fillColor=#99FF99;position2=0.47;base=7;%22%20vertex=%221%22%20parent=%221%22%3E%3CmxGeometry%20x=%22740%22%20y=%22255%22%20width=%22120%22%20height=%2255%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3CmxCell%20id=%2222%22%20value=%22%22%20style=%22shape=link;html=1;jettySize=auto;orthogonalLoop=1;%22%20edge=%221%22%20parent=%221%22%3E%3CmxGeometry%20width=%22100%22%20relative=%221%22%20as=%22geometry%22%3E%3CmxPoint%20x=%2240%22%20y=%22183.5%22%20as=%22sourcePoint%22/%3E%3CmxPoint%20x=%22720%22%20y=%22181.5%22%20as=%22targetPoint%22/%3E%3C/mxGeometry%3E%3C/mxCell%3E%3CmxCell%20id=%2223%22%20value=%22%E4%BA%92%E7%9B%B8%E7%8B%AC%E7%AB%8B%22%20style=%22text;html=1;resizable=0;points=%5B%5D;align=center;verticalAlign=middle;labelBackgroundColor=#ffffff;%22%20vertex=%221%22%20connectable=%220%22%20parent=%2222%22%3E%3CmxGeometry%20x=%220.0563%22%20y=%222%22%20relative=%221%22%20as=%22geometry%22%3E%3CmxPoint%20as=%22offset%22/%3E%3C/mxGeometry%3E%3C/mxCell%3E%3CmxCell%20id=%2224%22%20value=%22%22%20style=%22shape=link;html=1;jettySize=auto;orthogonalLoop=1;%22%20edge=%221%22%20parent=%221%22%3E%3CmxGeometry%20width=%22100%22%20relative=%221%22%20as=%22geometry%22%3E%3CmxPoint%20x=%2260%22%20y=%2292%22%20as=%22sourcePoint%22/%3E%3CmxPoint%20x=%22740%22%20y=%2290%22%20as=%22targetPoint%22/%3E%3C/mxGeometry%3E%3C/mxCell%3E%3CmxCell%20id=%2225%22%20value=%22%E4%BA%92%E7%9B%B8%E7%8B%AC%E7%AB%8B%22%20style=%22text;html=1;resizable=0;points=%5B%5D;align=center;verticalAlign=middle;labelBackgroundColor=#ffffff;%22%20vertex=%221%22%20connectable=%220%22%20parent=%2224%22%3E%3CmxGeometry%20x=%22-0.0717%22%20relative=%221%22%20as=%22geometry%22%3E%3CmxPoint%20as=%22offset%22/%3E%3C/mxGeometry%3E%3C/mxCell%3E%3CmxCell%20id=%2226%22%20value=%22%E6%95%B0%E6%8D%AE%E6%AE%B5%22%20style=%22shape=callout;whiteSpace=wrap;html=1;perimeter=calloutPerimeter;fillColor=#99FF99;position2=0;base=7;%22%20vertex=%221%22%20parent=%221%22%3E%3CmxGeometry%20x=%22440%22%20y=%22107.5%22%20width=%22120%22%20height=%2255%22%20as=%22geometry%22/%3E%3C/mxCell%3E%3C/root%3E%3C/mxGraphModel%3E} :::
::: center
多层原理的典型设备
:::
- 2层原理 -----交换机-----数据链路层------根据mac地址转发数据
- 3层原理-----路由器------网络层------------根据IP地址转发数据
- 4层原理-----防火墙------传输层------------根据协议和端口号