TCP/IP协议分析-协议分层[1]

摘抄:http://net.csai.cn/Router_TCP_IP/200707091516311924.htm
 <nobr id="key0" style="border-bottom: 2px dotted; text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" οnclick="return kwC();" target="_blank" οncοntextmenu="return false;" οnmοuseοver="kwE(event,0, this);" οnmοuseοut="kwL(event, this);" οnmοusemοve="kwM(0);">协议</nobr>分层

  正如OSI七层模型定义的一样,TCP/IP协议也根据不同的通信功能分为不同的层次,TCP/IP通常被认为是一个四层协议系统,TCP/IP的四层跟OSI的七层对应关系如表1-2所示。

  表1-2 TCP/IP协议与OSI七层模型的对应关系

OSI七层模型<o:p></o:p>

TCP/IP协议<o:p></o:p>

应用层<o:p></o:p>

应用层(Application<o:p></o:p>

表示层<o:p></o:p>

会话层<o:p></o:p>

传输层<o:p></o:p>

传输层(Transport<o:p></o:p>

<nobr id="key3" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" οnclick="return kwC();" target="_blank" οncοntextmenu="return false;" οnmοuseοver="kwE(event,3, this);" οnmοuseοut="kwL(event, this);" οnmοusemοve="kwM(3);">网络</nobr>层<o:p></o:p>

网络层(Internet<o:p></o:p>

数据链路层<o:p></o:p>

网络接口层(Network<o:p></o:p>

物理层<o:p></o:p>

<o:p> </o:p>

  1、网络接口层

  也叫数据链路层,通常包括操作系统中的设备驱动程序和计算机中对应的网络接口卡,它们一起处理与传输媒介的物理接口细节。上表中TCP/IP协议没有相应的层次对应OSI七层模型中的物理层,正是因为TCP/IP协议的这种特性,使得其构筑的Internet被广泛的应用。

  2、网络层

  也叫互联网层,处理路由选择等分组在网络中的活动。在TCP/IP协议组件中,网络层协议包括IP协议(Internet Protocol,网际协议)、ICMP协议(Internet互联网控制报文协议),以及IGMP协议(Internet组<nobr id="key4" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" οnclick="return kwC();" target="_blank" οncοntextmenu="return false;" οnmοuseοver="kwE(event,4, this);" οnmοuseοut="kwL(event, this);" οnmοusemοve="kwM(4);">管理</nobr>协议)。

  3、传输层

  主要功能是为两台主机上的应用程序提供端到端的通信。在TCP/IP协议组件中,有两个互不相同的传输协议:TCP(传输控制协议)和UDP(用户数据报协议)。

  TCP为两台主机提供高可靠性的数据<nobr id="key5" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" οnclick="return kwC();" target="_blank" οncοntextmenu="return false;" οnmοuseοver="kwE(event,5, this);" οnmοuseοut="kwL(event, this);" οnmοusemοve="kwM(5);">通信</nobr>。它所做的工作包括把应用程序交给它的数据分成合适的小块交给下面的网络层、确认接收到的分组、设置发送最后确认分组的超时时钟等。

  另一方面,UDP为应用层提供一种非常简单的服务。它只是把数据报从一台主机发送到另一台主机,但并不保证该<nobr id="key7" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" οnclick="return kwC();" target="_blank" οncοntextmenu="return false;" οnmοuseοver="kwE(event,11, this);" οnmοuseοut="kwL(event, this);" οnmοusemοve="kwM(11);">数据</nobr>报能到达另一端。

  TCP提供了高可靠性,因此不需要应用层去考虑,UDP则把所有必需的的可靠性交给应用层自己解决。

  4、应用层

  应用层负责处理特定的应用程序TCP/IP提供了大量的应用程序,下面几种是最为通用的:WWW <nobr id="key2" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" οnclick="return kwC();" target="_blank" οncοntextmenu="return false;" οnmοuseοver="kwE(event,2, this);" οnmοuseοut="kwL(event, this);" οnmοusemοve="kwM(2);">国际</nobr>互联网、Telnet 远程登录、FTP 文件传输协议、SMTP 用于电子邮件的简单邮件传输协议、SNMP 简单网络管理协议。

  表1-3 TCP/IP协议层与对应的服务

TCP/IP协议<o:p></o:p>

对应的服务<o:p></o:p>

应用层<o:p></o:p>

WWWSMTPFTPTelnetGopherSNMP<o:p></o:p>

SocketNetBIOS<o:p></o:p>

传输层<o:p></o:p>

TCPUDP<o:p></o:p>

网络层<o:p></o:p>

IPARPRARPICMP<o:p></o:p>

网络接口层<o:p></o:p>

EthernetX.25PPPSLIP<o:p></o:p>

  如表1-3所示,FTP是一种应用层协议,TCP是一种传输层协议,IP是一种网络层协议,而以太网协议则应用于网络接口层上。TCP/IP协 议组件是一组不同的协议组合在一起构成的协议族。尽管通常称该协议组件为TCP/IP,但TCP和IP只是其中的两种协议而已。

  在TCP/IP协议组件中,网络层IP提供的是一种不可靠的<nobr id="key6" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" οnclick="return kwC();" target="_blank" οncοntextmenu="return false;" οnmοuseοver="kwE(event,7, this);" οnmοuseοut="kwL(event, this);" οnmοusemοve="kwM(7);">服务</nobr>。也就是说,它只是尽可能快地把分组从源结点送到目的结点,但是并不提供任何可靠性保证。而另一方面,TCP在不可靠的IP层上提供了一个可靠的传输层。为了提供这种可靠的服务,TCP采用了超时重传,发送和接收端到端的确认分组等机制。

  TCP和UDP是两种最为著名的传输层协议,二者都使用IP作为网络层协议。

  如前面所说的,TCP采用的超时重传、确认分组机制,使得可以提供可靠的服务。UDP不提供可靠性:它把应用程序传给IP层的数据发送出去,但 是并不保证它们能到达目的地。UDP是一个简单的面向数据报的传输层协议:进程的每个输出操作都正好产生一个UDP数据报,并组装成一份待发送的IP数据 报。IP数据报的长度如果如果超过网络的MTU,那么就要对IP数据报进行分片。

  IP是网络层上的主要协议,同时被TCP和UDP使用。TCP和UDP的每组数据都通过端系统和每个中间路由器中的IP层在互连网中进行传输。

  ICMP是IP协议的附属协议,它用来把一个UDP数据报多播到多个主机。IP层用它来与其他主机或路由器交换错误报文和其他重要信息。ICMP主要被IP使用,应用程序也有可能访问它。Ping和Traceroute是我们经常要使用的诊断工具,它们就是使用的ICMP。

  ICMP包括了各种类型的ICMP报文,报文的类型由类型字段和<nobr id="key1" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" οnclick="return kwC();" target="_blank" οncοntextmenu="return false;" οnmοuseοver="kwE(event,1, this);" οnmοuseοut="kwL(event, this);" οnmοusemοve="kwM(1);">代码</nobr>字段共同决定。

  ARP(地址解析协议)和RARP(逆地址解析协议)是某些网络接口(如以太网和令牌环网)使用的特殊协议,用来转换IP层和网络接口层使用的地址。


TCP/IP协议分析-协议分层[2]

以下是我们在Microsoft Windows 2000中输入ARP命令返回的结果:

C:\>arp<o:p></o:p>

<o:p> </o:p>

Displays and modifies the IP-to-Physical address translation tables used <o:p></o:p>

by address resolution protocol (ARP).<o:p></o:p>

//显示和修改由地址解析<nobr οnmοusemοve="kwM(0);" οnmοuseοut="kwL(event, this);" οnmοuseοver="kwE(event,0, this);" οncοntextmenu="return false;" target="_blank" οnclick="return kwC();" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" id="key0">协议</nobr>使用的IP物理地址表<o:p></o:p>

<o:p> </o:p>

ARP -s inet_addr eth_addr [if_addr]<o:p></o:p>

ARP -d inet_addr [if_addr]<o:p></o:p>

ARP -a [inet_addr] [-N if_addr]<o:p></o:p>

<o:p> </o:p>

  -a            Displays current ARP entries by interrogating the current<o:p></o:p>

                protocol data.  If inet_addr is specified, the IP and Physical<o:p></o:p>

                addresses for only the specified computer are displayed. If<o:p></o:p>

                more than one network interface uses ARP, entries for each <o:p></o:p>

ARP table are displayed.<o:p></o:p>

//显示询问当前协议数据的ARP当前入口,如果指定了//inet_addr,则只显示指定计算机的IP地址和物理地址;如//果有不只一个网卡<nobr οnmοusemοve="kwM(3);" οnmοuseοut="kwL(event, this);" οnmοuseοver="kwE(event,3, this);" οncοntextmenu="return false;" target="_blank" οnclick="return kwC();" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" id="key3">使用</nobr>ARP,则显示每一个网卡的ARP//表。<o:p></o:p>

<o:p> </o:p>

  -g         Same as -a. //类似于-a<o:p></o:p>

<o:p> </o:p>

  inet_addr   Specifies an internet address.<o:p></o:p>

             //指定一个Internet<nobr οnmοusemοve="kwM(4);" οnmοuseοut="kwL(event, this);" οnmοuseοver="kwE(event,4, this);" οncοntextmenu="return false;" target="_blank" οnclick="return kwC();" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" id="key4">地址</nobr><o:p></o:p>

<o:p> </o:p>

  -N if_addr   Displays the ARP entries for the network interface specified<o:p></o:p>

             by if_addr.<o:p></o:p>

             //显示由if_addr指定的网卡的ARP入口<o:p></o:p>

<o:p> </o:p>

  -d         Deletes the host specified by inet_addr. inet_addr may be<o:p></o:p>

             wildcarded with * to delete all hosts.<o:p></o:p>

             //删除由inet_addr指定的主机,如果inet_addr是通配符*,则删<o:p></o:p>

//除所有主机<o:p></o:p>

<o:p> </o:p>

  -s         Adds the host and associates the Internet address inet_addr<o:p></o:p>

             with the Physical address eth_addr.  The Physical address <o:p></o:p>

is given as 6 hexadecimal bytes separated by hyphens. The <o:p></o:p>

entry is permanent.<o:p></o:p>

//增加主机,并把Internet地址inet_addr和<nobr οnmοusemοve="kwM(5);" οnmοuseοut="kwL(event, this);" οnmοuseοver="kwE(event,5, this);" οncοntextmenu="return false;" target="_blank" οnclick="return kwC();" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" id="key5">物理</nobr>地址eth_addr<o:p></o:p>

//进行关联,物理地址是6个以连字符号“-”隔开的16进制<o:p></o:p>

//位,这个入口是永久的<o:p></o:p>

<o:p> </o:p>

  eth_addr    Specifies a physical address.<o:p></o:p>

             //指定物理地址<o:p></o:p>

<o:p> </o:p>

  if_addr      If present, this specifies the Internet address of the<o:p></o:p>

              interface whose address translation table should be modified.<o:p></o:p>

              If not present, the first applicable interface will be used.<o:p></o:p>

              //如果出现,则代表网卡的Internet地址,该地址的地址转换表<o:p></o:p>

              //将要修改。如果不出现,则使用第一个可用的<nobr οnmοusemοve="kwM(2);" οnmοuseοut="kwL(event, this);" οnmοuseοver="kwE(event,2, this);" οncοntextmenu="return false;" target="_blank" οnclick="return kwC();" style="border-bottom: 1px dotted rgb(102, 0, 255); text-decoration: underline; color: rgb(102, 0, 255); background-color: transparent;" id="key2">接口</nobr><o:p></o:p>

Example:<o:p></o:p>

  > arp -s 157.55.85.212   00-aa-00-62-c6-09  .... Adds a static entry.<o:p></o:p>

                                           //增加一个静态入口<o:p></o:p>

<o:p> </o:p>

  > arp -a                                .... Displays the arp table.<o:p></o:p>

                                          // 显示 ARP

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值