资源描述
单击此处编辑母版标题样式,单击此处编辑母版文本样式,第二级,第三级,第四级,第五级,*,*,*,数据包的转发实例,Fa0/0,Fa0/1,Fa0/1,Fa0/0,Fa0/24,Fa0/24,Pc1,Pc2,Pc3,例举pc1 ping pc3的通信过程,sw1,sw2,R1,R2,第一步 应用程序生成数据,Pc1,Application,Presentation,Session,Transport,Network,Data Link,Physical,Data,第二步 调用传输层服务,Application,Presentation,Session,Transport,Network,Data Link,Physical,Pc1,DATA,TCP/UDP,Head,第三步 调用网络层服务,Application,Presentation,Session,Transport,Network,Data Link,Physical,Pc1,DATA,TCP/UDP,Head,DATA,TCP/UDP,Head,IP,Head,IP包头中的源地址由主机网卡中直接得到,目的ip则由我们在使用应用程序时输入得到,如果是基于域名,调用别一个通信过程DNS来获得目的ip,然后放入到ip包头中,则ip包头封装完成,第三步 查主机路由表,Application,Presentation,Session,Transport,Network,Data Link,Physical,Pc1,DATA,TCP/UDP,Head,DATA,TCP/UDP,Head,IP,Head,使用目的IP与PC机路由表进行比较,得下一跳ip地址和出接口。两种况:一是匹配真正的下一跳地址(主机上一般是默认网关);二是下一跳指向本机网卡地址。,第四步 通过arp表查找下一跳mac地址,Application,Presentation,Session,Transport,Network,Data Link,Physical,Pc1,DATA,TCP/UDP,Head,DATA,TCP/UDP,Head,IP,Head,当为第一种情况时,则查找下一跳mac地址,若为第二种情况则查找目的ip对应的mac地址。如果查找成功则封装第二层链路层地址。,第四步 发送arp请求,Application,Presentation,Session,Transport,Network,Data Link,Physical,Pc1,DATA,TCP/UDP,Head,DATA,TCP/UDP,Head,IP,Head,若查找没有成功,则发送arp请求报文,去获得下一跳或目标ip的mac地址。,Arp request,第四步 收到arp响应报文,Application,Presentation,Session,Transport,Network,Data Link,Physical,Pc1,DATA,TCP/UDP,Head,DATA,TCP/UDP,Head,IP,Head,加入arp表项中,同时使用得到的mac地址,进行数据链路层封装,Arp responses,Frame,Head,第五步 封装数据链路层包头并发送出接口,Application,Presentation,Session,Transport,Network,Data Link,Physical,Pc1,封装好第二层包头后,交由接口卡,发送数据包到交换机,DATA,TCP/UDP,Head,DATA,TCP/UDP,Head,IP,Head,Frame,Head,第六步 交换机1接收到数据包,Application,Presentation,Session,Transport,Network,Data Link,Physical,Pc1,检查链路层包头目的字段,查看是否为自己接口的mac址,或广播(0 xffffffffffff),若是其中之一则去掉链路层包头,并送上层协议处理。若不是,则交换机知道是需要进行转发的数据包,则查找mac地址表。,DATA,TCP/UDP,Head,DATA,TCP/UDP,Head,IP,Head,Frame,Head,sw1,Application,Presentation,Session,Transport,Network,Data Link,Physical,若从mac表中查到出接口,则直接转发数据包。若没成功,则需要在同一广播域内泛洪数据包,TCP/UDP,Head,DATA,TCP/UDP,Head,IP,Head,Frame,Head,第七步 查找mac地址表,Fa0/24,SW1,R1,R2,Application,Presentation,Session,Transport,Network,Data Link,Physical,检查链路层包头目的字段,查看是否为自己接口的mac址,或广播(0 xffffffffffff)或组播,是其中之一则去掉链路层包头,并送上层协议处理。否则丢弃数据包,TCP/UDP,Head,DATA,TCP/UDP,Head,IP,Head,Frame,Head,第八步 数据包到达路由器1接口,Fa0/24,SW1,R1,R2,Application,Presentation,Session,Transport,Network,Data Link,Physical,检查ip包头,若是目的ip是入接口ip或广播地址,则去掉ip包头,并送上层协议处理,若不是,则知道是需进行转发的包,查找路由表。,TCP/UDP,Head,DATA,TCP/UDP,Head,IP,Head,Frame,Head,第九步 解封装链路层包头,检查ip层,Fa0/24,Application,Presentation,Session,Transport,Network,Data Link,Physical,得到下一跳ip和出接口,则ip包头ttl值减1,重新封装数据链路层地址,查arp表,得到下一跳mac地址,同样如果arp表没有对应表项,则发arp请求。发出数据包。,第十步 封装链路层包头,发送数据包,Fa0/24,TCP/UDP,Head,DATA,TCP/UDP,Head,IP,Head,Frame,Head,SW1,R1,R2,重复第八、九、十步。,Fa0/24,TCP/UDP,Head,DATA,TCP/UDP,Head,IP,Head,Frame,Head,第十步 数据包到达路由器2,SW1,R1,R2,Fa0/24,Pc3,TCP/UDP,Head,DATA,TCP/UDP,Head,IP,Head,Frame,Head,第十一步 数据包到达交换机2,sw2,R2,重复第六、七步,Fa0/24,Pc3,TCP/UDP,Head,DATA,TCP/UDP,Head,IP,Head,Frame,Head,第十二步 数据包到达PC3,sw2,检查链路层包头目的字段,查看是否为自己接口的mac址,或广 播(0 xfffffffffff)、组播地mac,若是其中之一则去掉链路层地址,并送上层协议处理。若不是丢弃数据包,第十三步 送网络层处理,Fa0/24,Pc3,TCP/UDP,Head,DATA,TCP/UDP,Head,IP,Head,Frame,Head,sw2,去丢链路层地址,送网络层处理,Application,Presentation,Session,Transport,Network,Data Link,Physical,Pc3,TCP/UDP,Head,DATA,TCP/UDP,Head,IP,Head,sw2,若目的ip是接口ip,或广播、组播ip,则去掉ip包头,并且根据协议号送上层处理,Application,Presentation,Session,Transport,Network,Data Link,Physical,第十三步 送传输层处理,Pc3,TCP/UDP,Head,DATA,sw2,Application,Presentation,Session,Transport,Network,Data Link,Physical,第十四步 应用程序处理,
展开阅读全文