计算机网络基础知识汇总学习

今天的网络技术的基本原理我们从以下的12个目录中了解:

  • 1. 网络层次划分
  • 2. OSI七层网络模型
  • 3. IP地址
  • 4. 子网掩码及网络划分
  • 5. ARP/RARP协议
  • 6. 路由选择协议
  • 7. TCP/IP协议
  • 8. UDP协议
  • 9. DNS协议
  • 10. NAT协议
  • 11. DHCP协议
  • 12. HTTP协议
  • 13. 一个举例

计算机网络学习的核心内容就是网络协议的学习。网络协议是为计算机网络中进行数据交换而建立的规则、标准或者说是约定的集合。因为不同用户的数据终端可能采取的字符集是不同的,两者需要进行通信,必须要在一定的标准上进行。一个很形象地比喻就是我们的语言,我们大天朝地广人多,地方性语言也非常丰富,而且方言之间差距巨大。A地区的方言可能B地区的人根本无法接受,所以我们要为全国人名进行沟通建立一个语言标准,这就是我们的普通话的作用。同样,放眼全球,我们与外国友人沟通的标准语言是英语,所以我们才要苦逼的学习英语。

计算机网络协议同我们的语言一样,多种多样。而ARPA公司与1977年到1979年推出了一种名为ARPANET的网络协议受到了广泛的热捧,其中最主要的原因就是它推出了人尽皆知的TCP/IP标准网络协议。目前TCP/IP协议已经成为Internet中的“通用语言”,下图为不同计算机群之间利用TCP/IP进行通信的示意图。

计算机网络基础知识汇总学习

1. 网络层次划分


为了使不同计算机厂家生产的计算机能够相互通信,以便在更大的范围内建立计算机网络,国际标准化组织(ISO)在1978年提出了“开放系统互联参考模型”,即著名的OSI/RM模型(Open System Interconnection/Reference Model)。

它将计算机网络体系结构的通信协议划分为七层,自下而上依次为:

  • 物理层(Physics Layer)
  • 数据链路层(Data Link Layer)
  • 网络层(Network Layer)
  • 传输层(Transport Layer)
  • 会话层(Session Layer)
  • 表示层(Presentation Layer)
  • 应用层(Application Layer)

其中第四层完成数据传送服务,上面三层面向用户。

除了标准的OSI七层模型以外,常见的网络层次划分还有TCP/IP四层协议以及TCP/IP五层协议,它们之间的对应关系如下图所示:

 

计算机网络基础知识汇总学习

2. OSI七层网络模型


TCP/IP协议毫无疑问是互联网的基础协议,没有它就根本不可能上网,任何和互联网有关的操作都离不开TCP/IP协议。不管是OSI七层模型还是TCP/IP的四层、五层模型,每一层中都要自己的专属协议,完成自己相应的工作以及与上下层级之间进行沟通。由于OSI七层模型为网络的标准层次划分,所以我们以OSI七层模型为例从下向上进行一一介绍。

计算机网络基础知识汇总学习

 

1)物理层(Physical Layer)

激活、维持、关闭通信端点之间的机械特性、电气特性、功能特性以及过程特性。该层为上层协议提供了一个传输数据的可靠的物理媒体。简单的说,物理层确保原始的数据可在各种物理媒体上传输。物理层记住两个重要的设备名称,中继器(Repeater,也叫放大器)和集线器。

2)数据链路层(Data Link Layer)

数据链路层在物理层提供的服务的基础上向网络层提供服务,其最基本的服务是将源自网络层来的数据可靠地传输到相邻节点的目标机网络层。为达到这一目的,数据链路必须具备一系列相应的功能,主要有:如何将数据组合成数据块,在数据链路层中称这种数据块为帧(frame),帧是数据链路层的传送单位;如何控制帧在物理信道上的传输,包括如何处理传输差错,如何调节发送速率以使与接收方相匹配;以及在两个网络实体之间提供数据链路通路的建立、维持和释放的管理。数据链路层在不可靠的物理介质上提供可靠的传输。该层的作用包括:物理地址寻址、数据的成帧、流量控制、数据的检错、重发等。

有关数据链路层的重要知识点:

  • 1> 数据链路层为网络层提供可靠的数据传输;
  • 2> 基本数据单位为帧;
  • 3> 主要的协议:以太网协议;
  • 4> 两个重要设备名称:网桥和交换机。

3)网络层(Network Layer)

网络层的目的是实现两个端系统之间的数据透明传送,具体功能包括寻址和路由选择、连接的建立、保持和终止等。它提供的服务使传输层不需要了解网络中的数据传输和交换技术。如果您想用尽量少的词来记住网络层,那就是“路径选择、路由及逻辑寻址”。

网络层中涉及众多的协议,其中包括最重要的协议,也是TCP/IP的核心协议——IP协议。IP协议非常简单,仅仅提供不可靠、无连接的传送服务。IP协议的主要功能有:无连接数据报传输、数据报路由选择和差错控制。与IP协议配套使用实现其功能的还有地址解析协议ARP、逆地址解析协议RARP、因特网报文协议ICMP、因特网组管理协议IGMP。具体的协议我们会在接下来的部分进行总结,有关网络层的重点为:

  1> 网络层负责对子网间的数据包进行路由选择。此外,网络层还可以实现拥塞控制、网际互连等功能;

  2> 基本数据单位为IP数据报;

  3> 包含的主要协议:

  IP协议(Internet Protocol,因特网互联协议);

  ICMP协议(Internet Control Message Protocol,因特网控制报文协议);

  ARP协议(Address Resolution Protocol,地址解析协议);

  RARP协议(Reverse Address Resolution Protocol,逆地址解析协议)。

  4> 重要的设备:路由器。

4)传输层(Transport Layer)

第一个端到端,即主机到主机的层次。传输层负责将上层数据分段并提供端到端的、可靠的或不可靠的传输。此外,传输层还要处理端到端的差错控制和流量控制问题。

传输层的任务是根据通信子网的特性,最佳的利用网络资源,为两个端系统的会话层之间,提供建立、维护和取消传输连接的功能,负责端到端的可靠数据传输。在这一层,信息传送的协议数据单元称为段或报文。

网络层只是根据网络地址将源结点发出的数据包传送到目的结点,而传输层则负责将数据可靠地传送到相应的端口。

有关网络层的重点:

  1> 传输层负责将上层数据分段并提供端到端的、可靠的或不可靠的传输以及端到端的差错控制和流量控制问题;

  2> 包含的主要协议:TCP协议(Transmission Control Protocol,传输控制协议)、UDP协议(User Datagram Protocol,用户数据报协议);

  3> 重要设备:网关。

5)会话层

会话层管理主机之间的会话进程,即负责建立、管理、终止进程之间的会话。会话层还利用在数据中插入校验点来实现数据的同步。

6)表示层

表示层对上层数据或信息进行变换以保证一个主机应用层信息可以被另一个主机的应用程序理解。表示层的数据转换包括数据的加密、压缩、格式转换等。

7)应用层

为操作系统或网络应用程序提供访问网络服务的接口。

会话层、表示层和应用层重点:

1> 数据传输基本单位为报文;

  2> 包含的主要协议:FTP(文件传送协议)、Telnet(远程登录协议)、DNS(域名解析协议)、SMTP(邮件传送协议),POP3协议(邮局协议),HTTP协议(Hyper Text Transfer Protocol)。

 

3. IP地址


今天发布的第二篇文章,是华为讲师讲解的IP子网如何划分视频,有兴趣的可以看下。
1)网络地址

IP地址由网络号(包括子网号)和主机号组成,网络地址的主机号为全0,网络地址代表着整个网络。

2)广播地址

广播地址通常称为直接广播地址,是为了区分受限广播地址。

广播地址与网络地址的主机号正好相反,广播地址中,主机号为全1。当向某个网络的广播地址发送消息时,该网络内的所有主机都能收到该广播消息。

3)组播地址

D类地址就是组播地址。

先回忆下A,B,C,D类地址吧:

A类地址以0开头,第一个字节作为网络号,地址范围为:0.0.0.0~127.255.255.255;(modified @2016.05.31)

B类地址以10开头,前两个字节作为网络号,地址范围是:128.0.0.0~191.255.255.255;

C类地址以110开头,前三个字节作为网络号,地址范围是:192.0.0.0~223.255.255.255。

D类地址以1110开头,地址范围是224.0.0.0~239.255.255.255,D类地址作为组播地址(一对多的通信);

E类地址以1111开头,地址范围是240.0.0.0~255.255.255.255,E类地址为保留地址,供以后使用。

注:只有A,B,C有网络号和主机号之分,D类地址和E类地址没有划分网络号和主机号。

4)255.255.255.255

该IP地址指的是受限的广播地址。受限广播地址与一般广播地址(直接广播地址)的区别在于,受限广播地址只能用于本地网络,路由器不会转发以受限广播地址为目的地址的分组;一般广播地址既可在本地广播,也可跨网段广播。例如:主机192.168.1.1/30上的直接广播数据包后,另外一个网段192.168.1.5/30也能收到该数据报;若发送受限广播数据报,则不能收到。

注:一般的广播地址(直接广播地址)能够通过某些路由器(当然不是所有的路由器),而受限的广播地址不能通过路由器。

5)0.0.0.0

常用于寻找自己的IP地址,例如在我们的RARP,BOOTP和DHCP协议中,若某个未知IP地址的无盘机想要知道自己的IP地址,它就以255.255.255.255为目的地址,向本地范围(具体而言是被各个路由器屏蔽的范围内)的服务器发送IP请求分组。

6)回环地址

127.0.0.0/8被用作回环地址,回环地址表示本机的地址,常用于对本机的测试,用的最多的是127.0.0.1。

7)A、B、C类私有地址

私有地址(private address)也叫专用地址,它们不会在全球使用,只具有本地意义。

A类私有地址:10.0.0.0/8,范围是:10.0.0.0~10.255.255.255

B类私有地址:172.16.0.0/12,范围是:172.16.0.0~172.31.255.255

C类私有地址:192.168.0.0/16,范围是:192.168.0.0~192.168.255.255

 

4. 子网掩码及网络划分


随着互连网应用的不断扩大,原先的IPv4的弊端也逐渐暴露出来,即网络号占位太多,而主机号位太少,所以其能提供的主机地址也越来越稀缺,目前除了使用NAT在企业内部利用保留地址自行分配以外,通常都对一个高类别的IP地址进行再划分,以形成多个子网,提供给不同规模的用户群使用。

这里主要是为了在网络分段情况下有效地利用IP地址,通过对主机号的高位部分取作为子网号,从通常的网络位界限中扩展或压缩子网掩码,用来创建某类地址的更多子网。但创建更多的子网时,在每个子网上的可用主机地址数目会比原先减少。

什么是子网掩码?

子网掩码是标志两个IP地址是否同属于一个子网的,也是32位二进制地址,其每一个为1代表该位是网络位,为0代表主机位。它和IP地址一样也是使用点式十进制来表示的。如果两个IP地址在子网掩码的按位与的计算下所得结果相同,即表明它们共属于同一子网中。

在计算子网掩码时,我们要注意IP地址中的保留地址,即“ 0”地址和广播地址,它们是指主机地址或网络地址全为“ 0”或“ 1”时的IP地址,它们代表着本网络地址和广播地址,一般是不能被计算在内的。

子网掩码的计算:

对于无须再划分成子网的IP地址来说,其子网掩码非常简单,即按照其定义即可写出:如某B类IP地址为 10.12.3.0,无须再分割子网,则该IP地址的子网掩码255.255.0.0。如果它是一个C类地址,则其子网掩码为 255.255.255.0。其它类推,不再详述。下面我们关键要介绍的是一个IP地址,还需要将其高位主机位再作为划分出的子网网络号,剩下的是每个子网的主机号,这时该如何进行每个子网的掩码计算。

下面总结一下有关子网掩码和网络划分常见的面试考题:

  1)利用子网数来计算

在求子网掩码之前必须先搞清楚要划分的子网数目,以及每个子网内的所需主机数目。

(1) 将子网数目转化为二进制来表示;

如欲将B类IP地址168.195.0.0划分成27个子网:27=11011;

(2) 取得该二进制的位数,为N;

该二进制为五位数,N = 5

(3) 取得该IP地址的类子网掩码,将其主机地址部分的的前N位置1即得出该IP地址划分子网的子网掩码。

将B类地址的子网掩码255.255.0.0的主机地址前5位置 1,得到 255.255.248.0

2)利用主机数来计算

如欲将B类IP地址168.195.0.0划分成若干子网,每个子网内有主机700台:

(1) 将主机数目转化为二进制来表示;

700=1010111100;

(2) 如果主机数小于或等于254(注意去掉保留的两个IP地址),则取得该主机的二进制位数,为N,这里肯定 N<8。如果大于254,则 N>8,这就是说主机地址将占据不止8位;

该二进制为十位数,N=10;

(3) 使用255.255.255.255来将该类IP地址的主机地址位数全部置1,然后从后向前的将N位全部置为 0,即为子网掩码值。

将该B类地址的子网掩码255.255.0.0的主机地址全部置1,得到255.255.255.255,然后再从后向前将后 10位置0,即为:11111111.11111111.11111100.00000000,即255.255.252.0。这就是该欲划分成主机为700台的B类IP地址 168.195.0.0的子网掩码。

3)还有一种题型,要你根据每个网络的主机数量进行子网地址的规划和计算子网掩码。这也可按上述原则进行计算。

比如一个子网有10台主机,那么对于这个子网需要的IP地址是:

10+1+1+1=13

注意:加的第一个1是指这个网络连接时所需的网关地址,接着的两个1分别是指网络地址和广播地址。

因为13小于16(16等于2的4次方),所以主机位为4位。而256-16=240,所以该子网掩码为255.255.255.240。

如果一个子网有14台主机,不少人常犯的错误是:依然分配具有16个地址空间的子网,而忘记了给网关分配地址。这样就错误了,因为14+1+1+1=17,17大于16,所以我们只能分配具有32个地址(32等于2的5次方)空间的子网。这时子网掩码为:255.255.255.224。

 

5. ARP/RARP协议


地址解析协议,即ARP(Address Resolution Protocol),是根据IP地址获取物理地址的一个TCP/IP协议。主机发送信息时将包含目标IP地址的ARP请求广播到网络上的所有主机,并接收返回消息,以此确定目标的物理地址;收到返回消息后将该IP地址和物理地址存入本机ARP缓存中并保留一定时间,下次请求时直接查询ARP缓存以节约资源。地址解析协议是建立在网络中各个主机互相信任的基础上的,网络上的主机可以自主发送ARP应答消息,其他主机收到应答报文时不会检测该报文的真实性就会将其记入本机ARP缓存;由此攻击者就可以向某一主机发送伪ARP应答报文,使其发送的信息无法到达预期的主机或到达错误的主机,这就构成了一个ARP欺骗。ARP命令可用于查询本机ARP缓存中IP地址和MAC地址的对应关系、添加或删除静态对应关系等。

ARP工作流程举例:

主机A的IP地址为192.168.1.1,MAC地址为0A-11-22-33-44-01;

主机B的IP地址为192.168.1.2,MAC地址为0A-11-22-33-44-02;

当主机A要与主机B通信时,地址解析协议可以将主机B的IP地址(192.168.1.2)解析成主机B的MAC地址,以下为工作流程:

(1)根据主机A上的路由表内容,IP确定用于访问主机B的转发IP地址是192.168.1.2。然后A主机在自己的本地ARP缓存中检查主机B的匹配MAC地址。

(2)如果主机A在ARP缓存中没有找到映射,它将询问192.168.1.2的硬件地址,从而将ARP请求帧广播到本地网络上的所有主机。源主机A的IP地址和MAC地址都包括在ARP请求中。本地网络上的每台主机都接收到ARP请求并且检查是否与自己的IP地址匹配。如果主机发现请求的IP地址与自己的IP地址不匹配,它将丢弃ARP请求。

(3)主机B确定ARP请求中的IP地址与自己的IP地址匹配,则将主机A的IP地址和MAC地址映射添加到本地ARP缓存中。

(4)主机B将包含其MAC地址的ARP回复消息直接发送回主机A。

(5)当主机A收到从主机B发来的ARP回复消息时,会用主机B的IP和MAC地址映射更新ARP缓存。本机缓存是有生存期的,生存期结束后,将再次重复上面的过程。主机B的MAC地址一旦确定,主机A就能向主机B发送IP通信了。

逆地址解析协议,即RARP,功能和ARP协议相对,其将局域网中某个主机的物理地址转换为IP地址,比如局域网中有一台主机只知道物理地址而不知道IP地址,那么可以通过RARP协议发出征求自身IP地址的广播请求,然后由RARP服务器负责回答。

RARP协议工作流程:

(1)给主机发送一个本地的RARP广播,在此广播包中,声明自己的MAC地址并且请求任何收到此请求的RARP服务器分配一个IP地址;

(2)本地网段上的RARP服务器收到此请求后,检查其RARP列表,查找该MAC地址对应的IP地址;

(3)如果存在,RARP服务器就给源主机发送一个响应数据包并将此IP地址提供给对方主机使用;

(4)如果不存在,RARP服务器对此不做任何的响应;

(5)源主机收到从RARP服务器的响应信息,就利用得到的IP地址进行通讯;如果一直没有收到RARP服务器的响应信息,表示初始化失败。

6. 路由选择协议


常见的路由选择协议有:RIP协议、OSPF协议。

  RIP协议 :底层是贝尔曼福特算法,它选择路由的度量标准(metric)是跳数,最大跳数是15跳,如果大于15跳,它就会丢弃数据包。

OSPF协议 :Open Shortest Path First开放式最短路径优先,底层是迪杰斯特拉算法,是链路状态路由选择协议,它选择路由的度量标准是带宽,延迟。

回到顶部

7. TCP/IP协议

TCP/IP协议是Internet最基本的协议、Internet国际互联网络的基础,由网络层的IP协议和传输层的TCP协议组成。通俗而言:TCP负责发现传输的问题,一有问题就发出信号,要求重新传输,直到所有数据安全正确地传输到目的地。而IP是给因特网的每一台联网设备规定一个地址。

IP层接收由更低层(网络接口层例如以太网设备驱动程序)发来的数据包,并把该数据包发送到更高层—TCP或UDP层;相反,IP层也把从TCP或UDP层接收来的数据包传送到更低层。IP数据包是不可靠的,因为IP并没有做任何事情来确认数据包是否按顺序发送的或者有没有被破坏,IP数据包中含有发送它的主机的地址(源地址)和接收它的主机的地址(目的地址)。

TCP是面向连接的通信协议,通过三次握手建立连接,通讯完成时要拆除连接,由于TCP是面向连接的所以只能用于端到端的通讯。TCP提供的是一种可靠的数据流服务,采用“带重传的肯定确认”技术来实现传输的可靠性。TCP还采用一种称为“滑动窗口”的方式进行流量控制,所谓窗口实际表示接收能力,用以限制发送方的发送速度。

TCP报文首部格式:

TCP协议的三次握手和四次挥手:

 

  注:seq:”sequance”序列号;ack:”acknowledge”确认号;SYN:”synchronize”请求同步标志;;ACK:”acknowledge”确认标志”FIN:”Finally”结束标志。

TCP连接建立过程:首先Client端发送连接请求报文,Server段接受连接后回复ACK报文,并为这次连接分配资源。Client端接收到ACK报文后也向Server段发生ACK报文,并分配资源,这样TCP连接就建立了。

TCP连接断开过程:假设Client端发起中断连接请求,也就是发送FIN报文。Server端接到FIN报文后,意思是说”我Client端没有数据要发给你了”,但是如果你还有数据没有发送完成,则不必急着关闭Socket,可以继续发送数据。所以你先发送ACK,”告诉Client端,你的请求我收到了,但是我还没准备好,请继续你等我的消息”。这个时候Client端就进入FIN_WAIT状态,继续等待Server端的FIN报文。当Server端确定数据已发送完成,则向Client端发送FIN报文,”告诉Client端,好了,我这边数据发完了,准备好关闭连接了”。Client端收到FIN报文后,”就知道可以关闭连接了,但是他还是不相信网络,怕Server端不知道要关闭,所以发送ACK后进入TIME_WAIT状态,如果Server端没有收到ACK则可以重传。“,Server端收到ACK后,”就知道可以断开连接了”。Client端等待了2MSL后依然没有收到回复,则证明Server端已正常关闭,那好,我Client端也可以关闭连接了。Ok,TCP连接就这样关闭了!

为什么要三次挥手?

在只有两次“握手”的情形下,假设Client想跟Server建立连接,但是却因为中途连接请求的数据报丢失了,故Client端不得不重新发送一遍;这个时候Server端仅收到一个连接请求,因此可以正常的建立连接。但是,有时候Client端重新发送请求不是因为数据报丢失了,而是有可能数据传输过程因为网络并发量很大在某结点被阻塞了,这种情形下Server端将先后收到2次请求,并持续等待两个Client请求向他发送数据…问题就在这里,Cient端实际上只有一次请求,而Server端却有2个响应,极端的情况可能由于Client端多次重新发送请求数据而导致Server端最后建立了N多个响应在等待,因而造成极大的资源浪费!所以,“三次握手”很有必要!

为什么要四次挥手?

试想一下,假如现在你是客户端你想断开跟Server的所有连接该怎么做?第一步,你自己先停止向Server端发送数据,并等待Server的回复。但事情还没有完,虽然你自身不往Server发送数据了,但是因为你们之前已经建立好平等的连接了,所以此时他也有主动权向你发送数据;故Server端还得终止主动向你发送数据,并等待你的确认。其实,说白了就是保证双方的一个合约的完整执行!

使用TCP的协议:FTP(文件传输协议)、Telnet(远程登录协议)、SMTP(简单邮件传输协议)、POP3(和SMTP相对,用于接收邮件)、HTTP协议等。

8. UDP协议


UDP用户数据报协议,是面向无连接的通讯协议,UDP数据包括目的端口号和源端口号信息,由于通讯不需要连接,所以可以实现广播发送。UDP通讯时不需要接收方确认,属于不可靠的传输,可能会出现丢包现象,实际应用中要求程序员编程验证。

UDP与TCP位于同一层,但它不管数据包的顺序、错误或重发。因此,UDP不被应用于那些使用虚电路的面向连接的服务,UDP主要用于那些面向查询—应答的服务,例如NFS。相对于FTP或Telnet,这些服务需要交换的信息量较小。

每个UDP报文分UDP报头和UDP数据区两部分。报头由四个16位长(2字节)字段组成,分别说明该报文的源端口、目的端口、报文长度以及校验值。UDP报头由4个域组成,其中每个域各占用2个字节,具体如下:
  (1)源端口号;

(2)目标端口号;

(3)数据报长度;

(4)校验值。

使用UDP协议包括:TFTP(简单文件传输协议)、SNMP(简单网络管理协议)、DNS(域名解析协议)、NFS、BOOTP。

TCP  UDP 的区别:TCP是面向连接的,可靠的字节流服务;UDP是面向无连接的,不可靠的数据报服务。

9. DNS协议


DNS是域名系统(DomainNameSystem)的缩写,该系统用于命名组织到域层次结构中的计算机和网络服务,可以简单地理解为将URL转换为IP地址。域名是由圆点分开一串单词或缩写组成的,每一个域名都对应一个惟一的IP地址,在Internet上域名与IP地址之间是一一对应的,DNS就是进行域名解析的服务器。DNS命名用于Internet等TCP/IP网络中,通过用户友好的名称查找计算机和服务。

回到顶部

10. NAT协议


  NAT网络地址转换(Network Address Translation)属接入广域网(WAN)技术,是一种将私有(保留)地址转化为合法IP地址的转换技术,它被广泛应用于各种类型Internet接入方式和各种类型的网络中。原因很简单,NAT不仅完美地解决了lP地址不足的问题,而且还能够有效地避免来自网络外部的攻击,隐藏并保护网络内部的计算机。

11. DHCP协议


DHCP动态主机设置协议(Dynamic Host Configuration Protocol)是一个局域网的网络协议,使用UDP协议工作,主要有两个用途:给内部网络或网络服务供应商自动分配IP地址,给用户或者内部网络管理员作为对所有计算机作中央管理的手段。

12. HTTP协议


超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议。所有的WWW文件都必须遵守这个标准。

  HTTP 协议包括哪些请求?

GET:请求读取由URL所标志的信息。

POST:给服务器添加信息(如注释)。

PUT:在给定的URL下存储一个文档。

DELETE:删除给定的URL所标志的资源。

  HTTP 中, POST  GET 的区别

1)Get是从服务器上获取数据,Post是向服务器传送数据。

2)Get是把参数数据队列加到提交表单的Action属性所指向的URL中,值和表单内各个字段一一对应,在URL中可以看到。

3)Get传送的数据量小,不能大于2KB;Post传送的数据量较大,一般被默认为不受限制。

4)根据HTTP规范,GET用于信息获取,而且应该是安全的和幂等的。

I. 所谓 安全的 意味着该操作用于获取信息而非修改信息。换句话说,GET请求一般不应产生副作用。就是说,它仅仅是获取资源信息,就像数据库查询一样,不会修改,增加数据,不会影响资源的状态。

II. 幂等 的意味着对同一URL的多个请求应该返回同样的结果。

 

13. 一个举例


  在浏览器中输入 www.baidu.com  后执行的全部过程

现在假设如果我们在客户端(客户端)浏览器中输入http://www.baidu.com,而baidu.com为要访问的服务器(服务器),下面详细分析客户端为了访问服务器而执行的一系列关于协议的操作:

1)客户端浏览器通过DNS解析到www.baidu.com的IP地址220.181.27.48,通过这个IP地址找到客户端到服务器的路径。客户端浏览器发起一个HTTP会话到220.161.27.48,然后通过TCP进行封装数据包,输入到网络层。

2)在客户端的传输层,把HTTP会话请求分成报文段,添加源和目的端口,如服务器使用80端口监听客户端的请求,客户端由系统随机选择一个端口如5000,与服务器进行交换,服务器把相应的请求返回给客户端的5000端口。然后使用IP层的IP地址查找目的端。

3)客户端的网络层不用关系应用层或者传输层的东西,主要做的是通过查找路由表确定如何到达服务器,期间可能经过多个路由器,这些都是由路由器来完成的工作,不作过多的描述,无非就是通过查找路由表决定通过那个路径到达服务器。

4)客户端的链路层,包通过链路层发送到路由器,通过邻居协议查找给定IP地址的MAC地址,然后发送ARP请求查找目的地址,如果得到回应后就可以使用ARP的请求应答交换的IP数据包现在就可以传输了,然后发送IP数据包到达服务器的地址。

未经允许不得转载:杨永博客 » 计算机网络基础知识汇总学习

赞 (0)

评论 116

  • 昵称 (必填)
  • 邮箱(必填)
  • 网址(选填)
  1. why not find out moreI simply want to say I am newbie to blogs and truly loved this blog. Probably I’m planning to bookmark your blog . You amazingly have outstanding articles. Thank you for revealing your web page.回复
  2. Travel & LeisureI haven¡¦t checked in here for a while since I thought it was getting boring, but the last few posts are great quality so I guess I¡¦ll add you back to my everyday bloglist. You deserve it my friend 🙂回复
  3. Travel & Leisurenaturally like your web site however you have to take a look at the spelling on several of your posts. Many of them are rife with spelling issues and I in finding it very bothersome to inform the truth on the other hand I will certainly come back again.回复
  4. Travel & LeisureI have been absent for a while, but now I remember why I used to love this web site. Thank you, I will try and check back more often. How frequently you update your website?回复
  5. Travel & LeisureI am not sure where you're getting your info, but good topic. I needs to spend some time learning much more or understanding more. Thanks for fantastic info I was looking for this info for my mission.回复
  6. Travel & LeisureHi there, just became aware of your blog through Google, and found that it is really informative. I’m gonna watch out for brussels. I will appreciate if you continue this in future. Lots of people will be benefited from your writing. Cheers!回复
  7. Travel & Leisurewhoah this blog is fantastic i love studying your articles. Stay up the good work! You realize, lots of persons are looking round for this info, you could help them greatly.回复
  8. Home Warranty CompaniesNeeded to create you a little bit of word to help say thank you the moment again for your personal great views you have provided in this case. It was simply incredibly open-handed with people like you to give freely all that most of us could have offered as an electronic book to help with making some profit for their own end, chiefly considering that you could have done it if you ever desired. The smart ideas as well worked to provide a great way to be certain that the rest have similar dream much like my own to find out great deal more in terms of this condition. I know there are many more enjoyable instances in the future for folks who browse through your blog.回复
  9. Homeserve Usa Customer ServiceI must convey my respect for your generosity supporting women who actually need assistance with your matter. Your personal commitment to passing the solution all-around became extraordinarily valuable and have in every case encouraged girls much like me to get to their endeavors. Your amazing interesting guideline denotes this much to me and a whole lot more to my office colleagues. Regards; from everyone of us.回复
  10. Home ServiceI am commenting to make you know of the fabulous encounter my friend's girl went through going through your site. She figured out numerous issues, including how it is like to possess a very effective teaching mindset to make certain people completely master specific extremely tough things. You really exceeded visitors' desires. I appreciate you for presenting these informative, healthy, educational and as well as unique thoughts on this topic to Jane.回复
  11. RenovationWow, incredible blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your website is fantastic, let alone the content!回复
  12. Home WarrantyHello.This article was really remarkable, especially because I was searching for thoughts on this topic last Monday.回复
  13. Homeserve UsaHello There. I found your blog using msn. This is a really well written article. I will make sure to bookmark it and return to read more of your useful information. Thanks for the post. I will certainly return.回复
  14. HealthierI was just looking for this info for some time. After 6 hours of continuous Googleing, finally I got it in your web site. I wonder what's the lack of Google strategy that don't rank this kind of informative web sites in top of the list. Generally the top sites are full of garbage.回复
  15. TechnologySomebody necessarily assist to make critically posts I'd state. This is the first time I frequented your website page and so far? I amazed with the research you made to create this actual put up amazing. Great process!回复
  16. home improvementHey, you used to write magnificent, but the last few posts have been kinda boring… I miss your great writings. Past several posts are just a bit out of track! come on!回复
  17. Healthierwhoah this blog is fantastic i really like reading your posts. Keep up the great work! You recognize, lots of people are looking round for this info, you could aid them greatly.回复
  18. TechnologyWhat i do not understood is if truth be told how you are now not really much more neatly-appreciated than you may be right now. You are so intelligent. You already know therefore considerably in relation to this topic, produced me in my view believe it from so many various angles. Its like men and women don't seem to be fascinated unless it is something to accomplish with Woman gaga! Your individual stuffs outstanding. At all times take care of it up!回复
  19. home improvementI just couldn't leave your web site before suggesting that I extremely loved the standard information a person provide for your guests? Is gonna be back regularly to inspect new posts.回复
  20. Health ProductsSimply want to say your article is as surprising. The clarity in your post is just nice and i can assume you are an expert on this subject. Well with your permission allow me to grab your RSS feed to keep up to date with forthcoming post. Thanks a million and please keep up the gratifying work.回复
  21. Health StoreYou made some clear points there. I did a search on the subject matter and found most persons will consent with your website.回复
  22. knoxcountyky.comI in addition to my pals have already been going through the excellent helpful tips found on the website then unexpectedly I had a terrible suspicion I never expressed respect to the site owner for those tips. Those young men came totally passionate to study them and have in fact been making the most of these things. Thanks for turning out to be very kind and for selecting this sort of fine things millions of individuals are really desirous to know about. Our honest regret for not expressing appreciation to you sooner.回复
  23. lucyhounsom.comThank you so much for giving everyone such a memorable chance to read from here. It is often so pleasant and full of a good time for me and my office fellow workers to search your website at the very least three times every week to find out the fresh guidance you have got. Of course, I am actually contented with your superb pointers you give. Some 2 tips on this page are really the simplest I have had.回复
  24. OpportunityI¡¦ve been exploring for a little for any high quality articles or blog posts in this kind of area . Exploring in Yahoo I eventually stumbled upon this website. Studying this information So i am satisfied to convey that I've an incredibly good uncanny feeling I found out exactly what I needed. I so much surely will make sure to don¡¦t disregard this website and give it a look regularly.回复
  25. HealthyI do consider all of the ideas you've introduced to your post. They're very convincing and can definitely work. Nonetheless, the posts are too short for novices. May you please extend them a bit from subsequent time? Thanks for the post.回复
  26. galaxymage.orgI'm still learning from you, as I'm trying to reach my goals. I definitely love reading all that is posted on your blog.Keep the tips coming. I enjoyed it!回复
  27. solitaireaz.comI must express my appreciation to this writer just for bailing me out of such a problem. After surfing throughout the world wide web and meeting things which are not productive, I was thinking my life was gone. Existing minus the answers to the issues you have sorted out as a result of your short article is a serious case, as well as those which might have in a wrong way affected my career if I hadn't come across your website. Your own personal ability and kindness in touching every part was priceless. I don't know what I would've done if I hadn't encountered such a point like this. It's possible to now look forward to my future. Thanks a lot so much for this professional and results-oriented guide. I won't be reluctant to suggest the blog to any individual who wants and needs guidelines about this situation.回复
  28. Business PlanKeep functioning ,splendid job!回复
  29. Business NewsThank you for the sensible critique. Me and my neighbor were just preparing to do some research on this. We got a grab a book from our local library but I think I learned more clear from this post. I'm very glad to see such great info being shared freely out there.回复
  30. http://www.xpertseoservices.comWow, marvelous blog layout! How long have you been blogging for? you made blogging look easy. The overall look of your site is magnificent, let alone the content!回复
  31. BusinessI will right away snatch your rss feed as I can't find your email subscription link or newsletter service. Do you've any? Please permit me recognise so that I may just subscribe. Thanks.回复
  32. WomenSimply wanna tell that this is very helpful , Thanks for taking your time to write this.回复
  33. TravelI conceive you have noted some very interesting details , appreciate it for the post.回复
  34. Web DesignHello my friend! I wish to say that this article is amazing, great written and come with approximately all important infos. I would like to see more posts like this.回复
  35. Career And JobsI have read several good stuff here. Certainly worth bookmarking for revisiting. I surprise how so much effort you put to make this type of excellent informative website.回复
  36. PetsWe are a group of volunteers and starting a new scheme in our community. Your web site provided us with valuable info to work on. You've done a formidable job and our entire community will be grateful to you.回复
  37. Starting a BusinessThanks a bunch for sharing this with all folks you actually understand what you're talking approximately! Bookmarked. Kindly also consult with my site =). We could have a hyperlink exchange arrangement among us!回复
  38. Small BusinessIt's appropriate time to make some plans for the future and it's time to be happy. I have read this post and if I could I desire to suggest you few interesting things or suggestions. Maybe you can write next articles referring to this article. I desire to read even more things about it!回复
  39. PetsI really enjoy reading through on this internet site , it has got superb blog posts. "It is easy to be nice, even to an enemy - from lack of character." by Dag Hammarskjld.回复
  40. Web DesignSome really fantastic information, Gladiola I noticed this. "The outer conditions of a person's life will always be found to reflect their inner beliefs." by James Allen.回复
  41. Web DesignI simply could not go away your site before suggesting that I extremely loved the standard information an individual supply for your visitors? Is gonna be back incessantly in order to check out new posts.回复
  42. TechnologySimply want to say your article is as amazing. The clearness in your post is just excellent and i could assume you're an expert on this subject. Fine with your permission let me to grab your feed to keep updated with forthcoming post. Thanks a million and please keep up the gratifying work.回复
  43. Home ServiceI needed to write you that very little word to say thank you once again relating to the pleasing secrets you have featured on this website. It was simply strangely open-handed with people like you to convey publicly all that most of us would've marketed as an e-book to make some cash on their own, certainly since you could possibly have tried it in case you wanted. These solutions additionally worked as a good way to realize that the rest have the same passion just as mine to learn more and more pertaining to this condition. I believe there are several more fun periods in the future for many who scan your blog.回复
  44. TravelI conceive you have noted some very interesting details , thanks for the post.回复
  45. healthI carry on listening to the newscast lecture about getting free online grant applications so I have been looking around for the finest site to get one. Could you advise me please, where could i find some?回复
  46. Home Servicewhoah this weblog is excellent i like reading your articles. Keep up the great work! You realize, lots of individuals are hunting round for this information, you could aid them greatly.回复
  47. marketingThis is really interesting, You're a very skilled blogger. I have joined your rss feed and look forward to seeking more of your great post. Also, I have shared your web site in my social networks!回复
  48. business ethicsMagnificent site. Lots of useful information here. I¡¦m sending it to a few friends ans additionally sharing in delicious. And of course, thank you in your sweat!回复
  49. EducationI am very happy to read this. This is the kind of manual that needs to be given and not the accidental misinformation that's at the other blogs. Appreciate your sharing this best doc.回复
  50. DatingThanks, I've recently been looking for information about this topic for a long time and yours is the best I have found out till now. However, what concerning the bottom line? Are you certain about the source?回复
  51. TechnologyYou actually make it seem so easy with your presentation but I find this topic to be really something which I think I would never understand. It seems too complex and very broad for me. I'm looking forward for your next post, I’ll try to get the hang of it!回复
  52. Shoppingyou are in point of fact a good webmaster. The website loading speed is amazing. It kind of feels that you are doing any distinctive trick. Furthermore, The contents are masterwork. you have done a magnificent job in this matter!回复
  53. Home ImprovementI like what you guys are up too. Such smart work and reporting! Keep up the superb works guys I have incorporated you guys to my blogroll. I think it will improve the value of my web site :).回复
  54. Health NewsI've been absent for some time, but now I remember why I used to love this blog. Thanks , I will try and check back more often. How frequently you update your website?回复
  55. Health MagazineIt¡¦s actually a great and helpful piece of info. I¡¦m glad that you shared this useful information with us. Please stay us informed like this. Thanks for sharing.回复
  56. Health NewsYou are a very bright person!回复
  57. healthI and my pals happened to be reading through the good strategies on your website and then at once I had a horrible feeling I had not expressed respect to the web site owner for them. All of the ladies ended up totally joyful to see all of them and already have simply been having fun with those things. We appreciate you really being so thoughtful and for picking out these kinds of ideal subject matter most people are really needing to be informed on. My personal sincere regret for not expressing gratitude to you earlier.回复
  58. LegalI have been surfing online more than 3 hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my view, if all web owners and bloggers made good content as you did, the web will be much more useful than ever before.回复
  59. Whole Food VitaminsThank you for the good writeup. It in fact was a amusement account it. Look advanced to more added agreeable from you! By the way, how can we communicate?回复
  60. Department Of HealthI do not even know how I ended up here, but I thought this post was good. I don't know who you are but certainly you're going to a famous blogger if you aren't already 😉 Cheers!回复
  61. TravelMy brother recommended I might like this blog. He was totally right. This post truly made my day. You can not imagine simply how much time I had spent for this info! Thanks!回复
  62. Business WebsiteThank you for the good writeup. It in fact was a amusement account it. Look advanced to more added agreeable from you! However, how could we communicate?回复
  63. BusinessI like this post, enjoyed this one appreciate it for putting up. "Fear not for the future, weep not for the past." by Percy Bysshe Shelley.回复
  64. Business IdeasYou really make it seem really easy along with your presentation but I to find this matter to be actually something that I think I'd by no means understand. It seems too complicated and extremely extensive for me. I am having a look forward for your subsequent publish, I¡¦ll attempt to get the hang of it!回复
  65. OpportunityThanks for some other fantastic post. Where else may anyone get that type of info in such a perfect way of writing? I've a presentation subsequent week, and I am on the look for such information.回复
  66. ProfitabilityI don’t even know how I ended up here, but I thought this post was great. I don't know who you are but definitely you're going to a famous blogger if you are not already 😉 Cheers!回复
  67. Health FoodI’m not sure where you are getting your information, but good topic. I needs to spend some time learning more or understanding more. Thanks for excellent info I was looking for this info for my mission.回复
  68. SportsIt¡¦s actually a nice and helpful piece of info. I am satisfied that you just shared this helpful information with us. Please keep us up to date like this. Thanks for sharing.回复
  69. Dow Jones IndexI think this is among the most vital information for me. And i am glad reading your article. But wanna remark on few general things, The website style is perfect, the articles is really great : D. Good job, cheers回复
  70. Bad CreditI simply could not go away your site prior to suggesting that I actually enjoyed the standard info a person supply for your guests? Is gonna be again ceaselessly in order to check up on new posts回复
  71. Business & FinanceI will immediately grasp your rss as I can't to find your e-mail subscription hyperlink or e-newsletter service. Do you've any? Please allow me recognize in order that I could subscribe. Thanks.回复
  72. Stock MarketMy wife and i ended up being now happy John could do his inquiry using the precious recommendations he discovered out of your web page. It's not at all simplistic to simply possibly be freely giving helpful tips that some people have been making money from. And we keep in mind we've got the website owner to give thanks to for that. Most of the illustrations you have made, the simple site navigation, the friendships your site help to promote - it is mostly terrific, and it's letting our son and us reason why this theme is pleasurable, which is tremendously serious. Thank you for the whole thing!回复
  73. FinanceI wish to show appreciation to the writer just for rescuing me from this particular crisis. Right after surfing through the search engines and meeting thoughts that were not beneficial, I was thinking my life was done. Being alive without the presence of solutions to the issues you have resolved by way of your post is a critical case, and ones that could have adversely damaged my entire career if I hadn't discovered your site. Your own talents and kindness in dealing with every part was excellent. I don't know what I would've done if I hadn't discovered such a thing like this. I can also now look ahead to my future. Thank you very much for this specialized and result oriented guide. I will not think twice to refer the sites to any individual who should have assistance on this subject matter.回复
  74. Bad CreditLovely site! I am loving it!! Will come back again. I am bookmarking your feeds also回复
  75. Us Stock MarketI savor, lead to I found just what I was looking for. You have ended my four day long hunt! God Bless you man. Have a great day. Bye回复
  76. Healthy NutritionI precisely wanted to say thanks all over again. I am not sure the things that I would have used in the absence of the concepts shared by you directly on that situation. It seemed to be a very difficult concern for me personally, but finding out this specialised manner you handled the issue made me to jump with happiness. I am just thankful for this advice and even hope you comprehend what a powerful job that you are undertaking teaching most people with the aid of a web site. I am sure you haven't come across all of us.回复
  77. BusinessA person essentially help to make critically articles I would state. This is the first time I frequented your website page and up to now? I amazed with the research you made to make this actual post incredible. Excellent process!回复
  78. TravelHello, you used to write wonderful, but the last few posts have been kinda boring… I miss your tremendous writings. Past few posts are just a little out of track! come on!回复
  79. Web DesignI was suggested this website by my cousin. I'm not sure whether this post is written by him as nobody else know such detailed about my trouble. You are incredible! Thanks!回复
  80. Homeservice ClubWonderful paintings! That is the type of information that should be shared around the web. Disgrace on the search engines for not positioning this put up higher! Come on over and discuss with my site . Thanks =)回复
  81. HealthIts excellent as your other content : D, thankyou for posting . "The rewards for those who persevere far exceed the pain that must precede the victory." by Ted W. Engstrom.回复
  82. Home Services MovingHello there, You've done an incredible job. I’ll definitely digg it and personally recommend to my friends. I am sure they will be benefited from this site.回复
  83. HealthI conceive you have remarked some very interesting points , thankyou for the post.回复
  84. Hvac ServiceExcellent beat ! I wish to apprentice while you amend your website, how could i subscribe for a blog site? The account aided me a acceptable deal. I had been a little bit acquainted of this your broadcast offered bright clear idea回复
  85. FashionVery interesting information!Perfect just what I was searching for!回复
  86. Home ImprovementI have not checked in here for some time as I thought it was getting boring, but the last few posts are great quality so I guess I will add you back to my everyday bloglist. You deserve it my friend 🙂回复
  87. Download knowing brosYou can definitely see your expertise within the paintings you write. The sector hopes for more passionate writers such as you who aren't afraid to say how they believe. At all times follow your heart.回复
  88. TravelMerely wanna state that this is extremely helpful, Thanks for taking your time to write this.回复
  89. FashionDead composed content , thanks for entropy.回复
  90. NewsGreat goods from you, man. I have understand your stuff previous to and you are just too magnificent. I really like what you have acquired here, really like what you are saying and the way in which you say it. You make it entertaining and you still take care of to keep it smart. I can not wait to read far more from you. This is actually a wonderful site.回复
  91. OpportunityThanks a bunch for sharing this with all people you really know what you're talking approximately! Bookmarked. Please also consult with my web site =). We could have a link trade agreement between us!回复
  92. NewsI really appreciate this post. I have been looking everywhere for this! Thank goodness I found it on Bing. You've made my day! Thank you again!回复
  93. NewsYou can definitely see your expertise within the paintings you write. The sector hopes for more passionate writers like you who are not afraid to say how they believe. Always follow your heart. "In order to preserve your self-respect, it is sometimes necessary to lie and cheat." by Robert Byrne.回复
  94. NewsPretty nice post. I just stumbled upon your blog and wanted to say that I've truly enjoyed browsing your blog posts. After all I will be subscribing to your rss feed and I hope you write again very soon!回复
  95. NewsI have recently started a website, the info you offer on this site has helped me greatly. Thank you for all of your time & work. "There can be no real freedom without the freedom to fail." by Erich Fromm.回复
  96. FashionI have been browsing online more than three hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my view, if all website owners and bloggers made good content as you did, the net will be much more useful than ever before.回复
  97. Abstract ArtWow! This could be one particular of the most useful blogs We've ever arrive across on this subject. Basically Great. I am also a specialist in this topic so I can understand your hard work.回复
  98. Economic NewsI wish to express my love for your generosity giving support to all those that have the need for help with the situation. Your personal commitment to passing the message all over came to be really powerful and has usually helped workers like me to realize their objectives. Your entire warm and friendly publication means a great deal a person like me and extremely more to my colleagues. Best wishes; from each one of us.回复
  99. Abstract PaintingDefinitely believe that which you stated. Your favorite reason appeared to be on the internet the easiest thing to be aware of. I say to you, I definitely get irked while people consider worries that they plainly do not know about. You managed to hit the nail upon the top as well as defined out the whole thing without having side effect , people can take a signal. Will probably be back to get more. Thanks回复
  100. NewsI believe you have mentioned some very interesting points , regards for the post.回复
  101. NewsSomebody essentially help to make seriously posts I might state. That is the very first time I frequented your web page and to this point? I amazed with the analysis you made to create this particular submit incredible. Wonderful job!回复
  102. OpportunityDefinitely, what a great blog and informative posts, I surely will bookmark your blog.Best Regards!回复
  103. NewsI have to express my gratitude for your generosity supporting those people who absolutely need help on in this area. Your real dedication to getting the message along ended up being incredibly productive and has truly encouraged professionals like me to achieve their targets. Your new warm and helpful guide implies a great deal to me and additionally to my office workers. Thanks a lot; from everyone of us.回复
  104. Financial Newsmagnificent put up, very informative. I'm wondering why the other experts of this sector do not realize this. You must proceed your writing. I am sure, you have a huge readers' base already!回复
  105. NewsHello very cool web site!! Guy .. Beautiful .. Wonderful .. I will bookmark your blog and take the feeds also…I'm happy to seek out so many useful info right here in the submit, we need work out more techniques in this regard, thank you for sharing.回复
  106. MoneyYou are a very intelligent individual!回复
  107. FashionF*ckin' remarkable issues here. I am very satisfied to see your post. Thank you a lot and i'm looking ahead to touch you. Will you kindly drop me a e-mail?回复
  108. Home ImprovementRattling nice style and design and excellent content , very little else we need : D.回复
  109. Home ImprovementIts excellent as your other content : D, thanks for putting up. "Say not, 'I have found the truth,' but rather, 'I have found a truth.'" by Kahlil Gibran.回复
  110. Home ImprovementAs soon as I found this internet site I went on reddit to share some of the love with them.回复
  111. Family Law AttorneyI as well as my buddies have been reading the great tips and hints from your web site then suddenly I had a horrible feeling I never thanked the blog owner for those secrets. Most of the guys became as a result glad to read through all of them and have quite simply been using these things. Thanks for indeed being indeed kind as well as for picking out such cool subject matter millions of individuals are really desirous to be aware of. My sincere apologies for not saying thanks to you sooner.回复
  112. NewsHi, Neat post. There is an issue together with your site in web explorer, could check this… IE still is the marketplace chief and a good section of folks will miss your great writing due to this problem.回复
  113. Apple VacationsKeep functioning ,great job!回复
  114. Home ImprovementGreat – I should definitely pronounce, impressed with your website. I had no trouble navigating through all tabs as well as related info ended up being truly easy to do to access. I recently found what I hoped for before you know it in the least. Quite unusual. Is likely to appreciate it for those who add forums or something, site theme . a tones way for your customer to communicate. Excellent task.回复
  115. Profitabilityyou're in point of fact a just right webmaster. The site loading pace is amazing. It seems that you're doing any distinctive trick. Furthermore, The contents are masterwork. you have performed a magnificent job in this subject!回复
  116. HealthYou could certainly see your skills in the paintings you write. The sector hopes for more passionate writers such as you who are not afraid to say how they believe. All the time follow your heart. "Billy Almon has all of his inlaw and outlaws here this afternoon." by Jerry Coleman.回复