Computer Network - Transport Layer

First, the role

  Two hosts communicate, not only requires an IP address, and the port, it is accurate to say that should be the application process on the host to communicate. Achieve multiplexing and demultiplexing functions

Multiplexing: All applications in the application layer through the transport layer, network layer then transmitted to

Demultiplexing: The transport layer receives data of the respective applications sent from the network layer, and then delivered separately specified in each application

Second, the difference between the network layer and the transport layer

1, the network layer provides a logical communication between a host

Logical communication 2, the transport layer provides end to end between the application of the

Third, the port number

  The port number is 16, so the maximum is 65535, the port number has only local significance

Port number used by the server:

  1, is well known (system) port number 0-1023

  2, the port number register: 1024-49151

  3, the port number used by the client: 49152-65535

Four, UDP

  UDP is the User Datagram Protocol

4.1 Features:

  1, before the connection does not need to belong to the transmission, the transmission data does not require any confirmation, it does not guarantee reliable delivery.

  2, message oriented: how much an application layer to the UDP packets sent directly UDP. So the message to the right size, too long, too much can lead to decreased efficiency of the IP layer.

  3, there is no congestion control

  4, support one to one, one to many, many to one, many to many interactive communication.

  5, the header overhead small, only 8byte, shorter than the TCP 20byte.

 

User Datagram UDP has two fields: a data field and a header field

4.2, header fields:

  8byte, four fields, each field is a length 2byte, source port, destination port, a length, and testing

UDP Port communication needs, but because it is connectionless, it is not necessary to use a socket

4.3, the pseudo-header:

  In order to test and add just temporary, and not to pass up and down

Five, TCP

  Transmission Control Protocol provides a connection-oriented service

5.1 Features:

  1, must establish a connection before transmitting data, to be released after the end of the connection, can only point to point connection

  2, to provide reliable service delivery, TCP data transmission, no difference, is not lost, not repeat, arrive out of order.

  3、全双工通信:TCP允许通信双方的应用程序在任何时候都能发送数据。client和server都设有发送缓存和接收缓存,用来临时存放

双向通信的数据

  4、面向字节流


5.2、TCP使用场景:

  1、聊天消息传输

  2、单人语音、视频聊天等

  3、几乎UDP能做的TCP都能做到,只是要考虑复杂性、性能问题

  4、无法进行广播、多播等操作

5.3、发送报文:

  TCP不关心应用程序一次把多长的报文发送到TCP的缓存中,而是根据对方返回的窗口值和当前网络的拥塞程度来决定一个报文段应该包含

多少字节,而UDP的报文长度是应用程度决定的。每一条TCP连接都有两个连接点,这个连接点称为套接字(socket)或插口。

套接字的表示:

  端口号拼接到IP地址,例如192.168.22.37:8080

5.4、可靠性传输:

  TCP发送的报文段交给网络层发送,IP层不能保证可靠性传递,所以需要TCP提供可靠性传递

  5.4.1、停止等待协议:

    传输的数据单元称为分组,每发送一个分组就停止发送,知道得到对方的确认,然后再发送下一个分组

  5.4.2、超时重传:

    为每个发送的分组设置一个超时计数器,A只要经过一段时间没有收到确认,就认为刚才的分组丢失,重新发送刚才的分组

  5.4.3、确认丢失:

    确认丢失了,A没有收到,重新发送给B一个分组,B又收到重传的分组M1,要采用两个行动:

    1).丢弃这个重复的分组

    2).向A发送确认

  5.4.4、确认迟到:

    A收到重复的确认立马丢弃,B收到重复的分组,也要丢弃,并且重新确认分组

  上述的可靠性传输协议就是自动重传请求ARQ Automatic Repeat reQuest

总结:

  重传的请求是自动进行的,接收方不需要主动要求发送方重传某个错误的分组

  停止等待协议优点就是简单,但是信道利用率太低,为了提高利用率,发送方可以不使用等待停止协议,采用流水线传输,

就需要了解连续ARQ协议和滑动窗口协议

5.5、连续ARQ协议:

  位于发送窗口中的每个分组都可以按顺序连续发送出去,不需要等待对方的确认,这样信道的利用率就提高了

  发送方:每收到一个确认,发送窗口向前滑动一个分组的位置

  接收方:不必对收到每个分组逐个发送确认,而是在收到几个分组后,对按次序到达的最后一个分组发送确认,就表示:到这个分组为

止之前的所有分组都收到了,这就是累计确认

优点:

  容易实现,即使确认丢失也不用重传,但是如果有分组丢失,就需要将丢失的分组进行重传,称为Go-back-N

缺点:

  不能向发送方反馈所有收到的正确分组的信息

 

Guess you like

Origin www.cnblogs.com/huigelaile/p/10938457.html
Recommended