Circuit switching is the method used in the traditional telephone system.
For data transfer to take place, the following has to happen :
包交换(分组交换) - 将用户传送的数据划分成一定的长度,每个部分叫做一个分组。每个分组的前面有一个分组头,用以指明该分组发往何地址,然后由交换机根据每个分组的地址标志,将他们转发至目的地,这一过程称为分组交换。
2层交换技术可以识别数据帧中的MAC地址信息,根据MAC地址进行转发,并将这些MAC地址与对应的端口,记录在自己内部的一个MAC地址表中。
2层交换机主要用在小型局域网中,机器数量在二、三十台以下,这样的网络环境下,广播包影响不大,2层交换机的快速交换功能、多个接入端口和低廉价格,为小型网络用户提供了完善的解决方案。
二层交换的流程:
在大规模局域网中,为了减小广播风暴的危害,必须把大型局域网按功能或地域等因素划分成多个小局域网,这样必然导致不同子网间的大量互访,而单纯使用第2层交换技术,却无法实现子网间的互访。
为了从技术上解决这个问题,网络厂商利用第3层交换技术开发了3层交换机,也叫做路由交换机,它是传统交换机与路由器的智能结合。
3层交换机是为IP设计的,接口类型简单,拥有很强的3层包处理能力,价格又比相同速率的路由器低得多,非常适用于大规模局域网络。
第7层交换技术通过逐层解开每一个数据包的每层封装,并识别出应用层的信息,以实现对内容的识别。
第7层交换技术通过应用层交换机实现了所有高层网络的功能,使网络管理者能够以更低的成本,更好地分配网络资源。
在Internet网、Intranet网和Extranet网,7层交换机都大有施展抱负的用武之地。比如企业到消费者的电子商务、联机客户支持,人事规划与建设、市场销售自动化,客户服务,防火墙负载均衡,内容过滤和带宽管理等。
互联网分层的好处:上层的变动完全不影响下层的结构
The packet-switching method allows data transmission without a circuit being established.
Data cannot be sent in a continuous stream.
Instead data is packaged in portions inside packets.
A packet consists of a header which contains instructions for delivery plus the data body.
there are two ways that the network can provide a service: connectionless service or connection-oriented service.
connectionless service - a packet is dispatched with no knowledge of whether or not the receiver is ready to accept the packet, and has no way of finding out if the transmission has succeeded.
connection-oriented service - the first packet sent includes a request for an acknowledgement.If the acknowledgement is received, the sender transmits further packets. If no acknowledgement is received, the sender tries again with the first packet.
protocol - it is a set of rules.
The set of rules that constitute a protocol must be agreed between the sender and the receiver for any communication transmitted over a network.
TCP/IP 是为使用互联网而开发制定的协议栈
OSI 七层网络协议 - TCP/IP 四层网络协议
每个分层中,都会对所发送的数据附加一个首部,在这个首部中包含了该层必要的信息,如发送的目标地址以及协议相关信息。通常,为协议提供的信息为包首部,所要发送的内容为数据。在下一层的角度看,从上一层收到的包全部都被认为是本层的数据。
网络中传输的数据包由两部分组成:一部分是协议所要用到的首部,另一部分是上一层传过来的数据。首部的结构由协议的具体规范详细定义。在数据包的首部,明确标明了协议应该如何读取数据。反过来说,看到首部,也就能够了解该协议必要的信息以及所要处理的数据。包首部就像协议的脸。
TCP/IP is the protocol suite underpinning Internet usage.
The TCP/IP suite comprises a number of protocols, including the following:
TCP 是面向连接的、可靠的流协议。流就是指不间断的数据结构,当应用程序采用 TCP 发送消息时,虽然可以保证发送的顺序,但还是犹如没有任何间隔的数据流发送给接收端。TCP 为提供可靠性传输,实行“顺序控制”或“重发控制”机制。此外还具备“流控制(流量控制)”、“拥塞控制”、提高网络利用率等众多功能。
UDP 是不具有可靠性的数据报协议。细微的处理它会交给上层的应用去完成。在 UDP 的情况下,虽然可以确保发送消息的大小,却不能保证消息一定会到达。因此,应用有时会根据自己的需要进行重发处理。
TCP 和 UDP 的优缺点无法简单地、绝对地去做比较:TCP 用于在传输层有必要实现可靠传输的情况;而在一方面,UDP 主要用于那些对高速传输和实时性有较高要求的通信或广播通信。TCP 和 UDP 应该根据应用的目的按需使用。
The protocol will transmit the user data to the transport layer.
The TCP protocol operating in the transport layer now has to take responsibility for ensuring the safe delivery of the ‘message’ to the receiver.
Each packet consists of a header plus the user data.
one item in the header is the port number which identifies the application layer protocol. The packet must also include the port number for the application layer protocol at the receiving end-system.
The TCP protocol is connection-oriented.
网络标识在数据链路的每个段配置不同的值。网络标识必须保证相互连接的每个段的地址不相重复。而相同段内相连的主机必须有相同的网络地址。IP 地址的“主机标识”则不允许在同一个网段内重复出现。由此,可以通过设置网络地址和主机地址,在相互连接的整个网络中保证每台主机的 IP 地址都不会相互重叠。即 IP 地址具有了唯一性。
IP 包被转发到途中某个路由器时,正是利用目标 IP 地址的网络标识进行路由。因为即使不看主机标识,只要一见到网络标识就能判断出是否为该网段内的主机。
The function of the network layer, and in particular of the IP, is to ensure correct routing over the Internet.
IP protocol takes the packet received from the transport layer and adds a further header. The header contains the IP addresses of both the sender and the receiver.
To find the IP address of the receiver, it is very likely to use the DNS service to find the address corresponding to the URL supplied in the user data.
The IP packet, which is usually called a ‘datagram’, is sent to the data-link layer and therefore to a different protocol suite.
IP functions as a connectionless service.
the frame sent by the data-link layer will arrive at a router during transmission (more likely at several routers).
It is now the function of the router software to choose the next target host in the transmission. The software has access to a routing table appropriate to that router.
The routing table for every router has details of any current problems with any of the options for the next transmission step.
The major distinction between a switch and a router as a node in a network is that when a frame arrives at a switch, it is transmitted on without any routing decision. A switch operates in the data-link layer but has no access to the network layer.
数据链路层包括LLC子层、MAC Control子层(可选)、MAC子层和RS子层。MAC层主要负责控制与连接物理层的物理介质。在发送数据时,MAC协议事先判断是否可以发送数据,如果可以发送,将给数据添加一些控制信息,最终将数据以及控制信息以规定的格式发送到物理层;在接收数据时,MAC协议首先判断输入的信息是否发生传输错误,如果没有错误,则去掉控制信息发送至LLC层。
Ethernet is a protocol suite designed for use in a local area network (LAN)
However, it is now almost inevitable that a LAN will be connected to the Internet and, therefore, a LAN’s protocol suite will support the protocol suite in use for the Internet.
TCP/IP protocol suite occupies the top three layers of the five-layer stack and is therefore supported by the lower two layers.
Logically the Ethernet suite can be viewed as comprising two sub-layers for each of the Data link and Physical layers.
The following points explain how Ethernet functions when supporting TCP/IP.
Both addresses in the Ethernet frame are examples of what are called physical or MAC addresses.
A MAC address is the one which uniquely defines one NIC
4A:30:12:24:1A:10
Because HTTP (HyperText Transfer Protocol) underpins the World Wide Web it has to be considered to be the most important application-layer protocol.
HTTP is a transaction-oriented, client–server protocol. The transaction involves the client sending a ‘request’ message and the server sending back a ‘response’ message.
<Method> <URL> <Version>CRLF
where CR and LF are the ASCII carriage return and line feed characters. The request line usually has GET as the method.
SMTP (Simple Mail Transfer Protocol) is a ‘push’ protocol whereas POP3 (Post Office Protocol version 3) is a ‘pull’ protocol.
There is a more recent alternative to POP3, which is IMAP (Internet Message Access Protocol).
The approach using POP3 is for emails to be downloaded onto the client computer. With IMAP the emails are not downloaded; they remain stored on the server but remain accessible from the client.
SMTP has been largely replaced by the use of web-based mail. A browser is used to access the email application, so HTTP is now the protocol used. However, SMTP remains in use for transfer between the mail servers.
FTP (File Transfer Protocol) is the application-layer protocol that can handle any file transfer between two end-systems.
P2P is an architecture that has no structure and no controlling mechanism. Peers act as both clients and servers and each peer is just one end-system. When a peer acts as a server it is called a ‘seed’.
How does a peer find others that have the wanted content?
Every content provider should provide a content description, called a torrent, which is a file that contains the name of the tracker (a server that leads peers to the content) and a list of the chunks that make up the content. The torrent file is at least three orders of magnitude smaller than the content so can be transferred quickly. The tracker is a server that maintains a list of all the other peers (the ‘swarm’) actively downloading and uploading the content.
How do peers replicate content to provide high-speed downloads for everyone?
Peers download and upload chunks at the same time, but peers have to exchange lists of chunks and aim to download rare chunks for preference. Each time a rare chunk is downloaded it automatically becomes less rare!
How do peers encourage other peers to provide content rather just using the protocol to download for themselves?
This requires dealing with the free-riders or ‘leechers’ who only download. The solution is for a peer to initially randomly try other peers but then to only continue to upload to those peers that provide regular downloads. If a peer is not downloading or only downloading slowly, the peer will eventually be isolated or ‘choked’.