一,数据链路层的三个基本问题
基本概念
结点:主机,路由器
链路:网络中两个结点之间的物理通道
数据链路:网络中两个结点之间的逻辑通道
帧:链路层的协议数据单元,封装网络层数据报
封装成帧
![](https://img-blog.csdnimg.cn/img_convert/e5d96d1a5c7c4e509e39c4abbc59287c.png)
透明传输
![](https://img-blog.csdnimg.cn/img_convert/aaab31a947c3b491080508c69f65dc0b.png)
字符计数法
![](https://img-blog.csdnimg.cn/img_convert/952e9d8c528b144b5154314cd1376dad.png)
字符填充法
![](https://img-blog.csdnimg.cn/img_convert/12689b2724a98eb1e479a87a7f70f67b.png)
差错控制
![](https://img-blog.csdnimg.cn/img_convert/4e0a2f9d6f2ce5e4b19f95c950d4f84c.png)
二,CRC的计算
![](https://img-blog.csdnimg.cn/img_convert/90089dd454fe5e5c1566231eeaa1e9fb.png)
![](https://img-blog.csdnimg.cn/img_convert/f3218df1565221a840d29d35dff72ada.png)
![](https://img-blog.csdnimg.cn/img_convert/f661f07cbbc3a09c0ac74d018cb89b86.png)
![](https://img-blog.csdnimg.cn/img_convert/6136aa8cd1049bcd4654e41da4407f58.png)
![](https://img-blog.csdnimg.cn/img_convert/f573ae7319cd652a152e3131570a2f91.png)
三,PPP协议的比特填充算法
![](https://img-blog.csdnimg.cn/img_convert/a6700bccd1685a4bd6aec98e808c5178.png)
四,CSMA/CD协议(求最短有效帧长)
1.CSMA/CD基础概念
CSMA/CD (Carrier Sense Multiple Access with Collision Detection) :载波监听多点接入 / 碰撞检测。
MA:多点接入:说明这是总线型网络。许多计算机以多点接入的方式连接在一根总线上。
CS:载波监听:即“边发送边监听”。不管在想要 发送数据之前,还是在发送数据之中,每个站都必须不停地检测信道。
CD:碰撞检测:适配器 边发送数据,边检测信道上的信号电压的变化情况。电压摆动值超过一定的门限值时,就认为总线上至少有两个站同时在发送数据,表明产生了碰撞(或冲突)
![](https://img-blog.csdnimg.cn/img_convert/9a6f2e60ba542db3df96a27d6496f96f.png)
2.传播时延影响
![](https://img-blog.csdnimg.cn/img_convert/9fc1b9108810a8d48cfd77e421d72499.png)
![](https://img-blog.csdnimg.cn/img_convert/21f9f1854506aea7a2d91c151c6662af.png)
eg:
![](https://img-blog.csdnimg.cn/img_convert/d4849924678795a27a5ac5e49afcb5db.png)
例题1:
![](https://img-blog.csdnimg.cn/img_convert/90f040cede9bc8a0eda0f05912c60ba8.png)
答案:0~1023之间选一个随机数
3.最短有效帧问题
![](https://img-blog.csdnimg.cn/img_convert/544acff7973905dfdc23937f04c8cd29.png)
五,以太网,网卡作用,MAC地址,MAC帧数格式
以太网
![](https://img-blog.csdnimg.cn/img_convert/f56ecb7f68ace0f60eb21a99da11a3a4.png)
以太网提供无连接,不可靠的服务
无连接:发送方和接收方之间无握手过程
不可靠:不对发送方的数据帧 编号,接收方不向发送方进行 确认,差错帧直接丢弃,差错帧纠正由高层负责
以太网只实现无差错接受,不实现可靠传输
![](https://img-blog.csdnimg.cn/img_convert/285e56fb39274f25e750bb92111fc10d.png)
适配器与MAC地址
![](https://img-blog.csdnimg.cn/img_convert/1b31f76851a16130acd6bc15347caa45.png)
![](https://img-blog.csdnimg.cn/img_convert/c7a0291ad431708f4b673dee325d7549.png)
类型字段用来标志上一层使用的是什么协议,
以便把收到的 MAC 帧的数据上交给上一层的这个协议。
数据字段的正式名称是 MAC 客户数据字段。
最小长度 64 字节 - 18 字节的首部和尾部 = 数据字段的最小长度(46字节)
FCS:当数据字段的长度小于 46 字节时,应在数据字段的后面加入整数字节的填充字段,以保证以太网的 MAC 帧长不小于 64 字节。
六,集线器,以太网交换机(VLAN)
集线器
![](https://img-blog.csdnimg.cn/img_convert/ceb76634632ad9a03b2f1162ddc97f4f.png)
![](https://img-blog.csdnimg.cn/img_convert/03ee5669fe7bd6ba72a1baca9f2d8186.png)
![](https://img-blog.csdnimg.cn/img_convert/529c2c3775093c2b00aaf1f81701e172.png)
交换机
![](https://img-blog.csdnimg.cn/img_convert/8e6290a00d7ab8a9c19e642c26b71d47.png)
![](https://img-blog.csdnimg.cn/img_convert/24426fee739d0572011b97f5b0d15241.png)
![](https://img-blog.csdnimg.cn/img_convert/cc2f15b82fab14a4770f63f1f61e69d9.png)
eg
![](https://img-blog.csdnimg.cn/img_convert/09f97f87e0edc4f8aec3ca146a444435.png)
4个冲突域(左边3个右边1个),一个广播域
七,10Base-T,100Base-T
![](https://img-blog.csdnimg.cn/img_convert/d80cfe728250666b7a716eef833b9a66.png)
![](https://img-blog.csdnimg.cn/img_convert/509b983d3361840a27cf0b507ac2dcf8.png)
八,重点课后习题
![](https://img-blog.csdnimg.cn/img_convert/6c799455cf383f4fa865c5eb38208d60.png)
![](https://img-blog.csdnimg.cn/img_convert/f6277b9d61d1278939f48f1942f617ed.png)
适配器(即网卡)来实现数据链路层和物理层这两层协议的硬件和软件
网络适配器工作在TCP/IP协议中的网络接口层(OSI中的数据链路层和物理层)
![](https://img-blog.csdnimg.cn/img_convert/f7f8df852b2973bb14c49351c0bedbde.png)
作二进制除法,除数为1001,被除数为10111000,添加在数据后面的余数为011
![](https://img-blog.csdnimg.cn/img_convert/13df780dcf0497530a8bf2499703706b.png)
10:表示信号在电缆上的传输速率是10MB/S
BASE:表示电缆上的信号是基带信号
T:表示双绞线星形线
![](https://img-blog.csdnimg.cn/img_convert/5870707dd425902a44fb8eba70b70c90.png)
单程传播时间=1Km/200000km=5微秒
来回=5*2=10
10*1Gb/S(换算单位为1000b/us)=10000位或1250字长