每天学点计算机网络——传输层

1. 传输层提供了哪些服务?

multiplexing/demultiplexing

reliable data transform (error detect)

congestion control (flow control)

2. UDP和TCP提供了哪些服务?

UDP: multiplexing/demultiplexing, error detect

TCP: multiplexing/demultiplexing, reliable data transform and congestion control

3. UDP和TCP由哪些特点?

UDP: only provide multiplexing/demultiplexing and error detect service, is connectionless, with no flow control

TCP: provide reliable data transform and congestion control services, is connection-oriented, with full-duplex connection, will execute 3 handshake to build connection

4. UDP和TCP的报文结构是怎样的?

UDP: 

Header:

- Source and destination Port number (16 bit per port#)

- Checksum (16 bit)

- Length (16 bit, indicate the length of header and data)

TCP:

Header:

- Source and destination Port (16 bit per port#)

- Sequence number (32 bit)

- Acknowledgement number (32 bit)

- Recieve window (16 bit)

- Internet Checksum (16 bit)

- Header length (4 bit)

- Unused (4 bit)

- Flag fields (1 bit per field, including Ack//Syn/Fin/Urg)

- Urgent data pointer (16 bit)

- Options (undefine length)

5. UDP和TCP有哪些应用?

UDP: is suitable for applications that can tolerate data loss and are desire for transform rate, such as Internet telephony, audio/video conference, DNS.

TCP: is suitable for applications that require reliable data transform (no loss and in correct sequence) such as web, email, file transform.

5. 怎么实现multiplexing/demultiplexing?

multiplexing: get data from correct socket, add header of transport layer to form transport segment then deliver the segment to network layer.

demultiplexing: extract segment from network layer datagram and deliver segment to correct socket.

6. 怎么实现reliable data transform?

Reliable data transform includes no data error or loss and in correct sequence.

The technology includes error detect (checksum), timer, sequence number, acknowdegement (ack) number, retransminssion.

Error detect can identify segment with error, timeout and 3 duplicate ack can indicate data loss, acknowledgement number can tell whether segment is recieved in correct sequence, when data error or loss hanppened, or segment not recieved in correct sequence, sender will retransmit the segment.

7. 怎么实现congestion control?

Congestion control includes congestion detect and rate adjustment.

The technology of congestion detect includes timer, acknowlegement.

The technology of rate adjustment includes congestion window, AIMD algorithm.

When timeout happened or 3 duplicated ack are recieved, the sender will regard the network as congested.

Sender can adjust the congestion window to control the transport rate, the congestion window will additionally increase when detect no congestion and multiplicatively decrease when detect congestion, namely, use AIMD algorithm to avoid congestion.

* The complete process for congestion window rate adjustment includes slow start, congestion avoidance (AIMD), fast recovery.

* Receive window和congestion window的关系

1) The congestion window size keeps increasing up to the maximum receiver window, or until the network reaches its limit

2) The amount of data that can be transmitted through a TCP connection is dependent on the congestion window, which is maintained by the source. The receiver window is maintained by the destination.

ref:https://blog.stackpath.com/glossary/cwnd-and-rwnd/

8. TCP运输过程是什么?

Establish connection: 3-way handshake

sender: SYI=1, Sequence # for sender=random #

receiver: SYI=1, Sequence # for receiver=random #, ACK=Sequence # for sender+1

sender: SYI=0, Sequence # for sender=random #+1, ACK=Sequence # for receiver+1

Data transform: 

sender: get data from corresponding socket, add transport layer header to form transport segment, send segment to network layer

receiver: extract segment from network layer, get data from segment and deliver the data to corresponding socket.

Close connection: 4-way handshake

sender: FYI=1

receiver: ACK

receiver: FYI=1

sender: ACK

Practice:

1. 使用wireshake抓TCP包,查看3次握手和4次握手

2. 用nmap查看端口

你可能感兴趣的:(每天学点计算机网络——传输层)