Chapter VI illustrates the TCPIP --- --- transporting layer TCPUDP

Ha ha ha ha ha ha ha ha

TCPIP识别一个进行通信的应用需要5大要素

  • Source IP address
  • Destination IP Address
  • Source Port
  • Destination port
  • Agreement No.

0-1023 well-known port number
1024-49151 these ports are officially registered, but can be used for any communication
port numbers 49152-65535 operating system dynamic allocation of
some well-known port numbers are as follows

  • 20 ftp-data File Transfer [Deafult Data]
  • 21 ftp File Transfer [Control]
  • 22 ssh
  • 23 talent
  • 25 smtp Simple Mail Transfer Protocol
  • 43 nicname Who Is
  • 53 domain Domain Name Server
  • 80 http
  • 101 hostname NIC Host Name Server
  • 443 https

UDP

Often used in the following areas

  • Less total DNS SNMP packet communication, etc.
  • Audio and other multimedia video communications
  • Defined application communication to a particular network such as a LAN
  • Broadcast communication (broadcast and multicast)

TCP

The acknowledgment sequence number

TCP acknowledgment retransmission control connection management by checking window control mechanisms and reliable transmission of the sequence number

The acknowledgment ACK acknowledgement
negative acknowledgment response NACK negative acknowledgement

  • After transmitting the transmission data Q1 waits for the acknowledgment of the end of the end

    • A certain time does not wait until the acknowledgment the sender think that data has been lost retransmitted
      • Data not received confirmation of it may be lost in the middle of the return
      • There may be a delay in reaching the end acknowledgment
    • Mechanism according to repeat sending end但是对接收端可能重复收到数据 简直就是灾难 需要处理这种情况
  • A1 need for a mechanism to identify whether the received data can be judged whether the received

    • The confirm reply process control, etc. repeat retransmission control functions can 序列号be implemented sequence number 按顺序to each byte of the transmission data (8 bytes) are marked on the ID number
    • As shown below

    Here Insert Picture Description

Retransmission timeout

  • How Q1 timeout defined
  • A1 最好找到一个 确认应答一定时间内一定能在这个时间段内返回
  • Q2 TCP要求不论处在何种网络都提供高性能通信 并且无论网络拥堵情况发生何种变化 都必须保持这一特性
  • A2 每次发包时都计算往返时间及其偏差 往返时间和偏差(RTT时间波动的值 方差)相加 超时重发时间就是这个和在大一丢丢的
  • A3 在BSD的Unix以及Windows中 超时都是按0.5s为单位 偏差的最小值也是0.5 所以最小的重发时间时1s
  • A4 数据被重发之后若还是收不到则再次发送 超时等待时间会2倍 4倍函数延长 数据也不会无限反复的重复 到达一定的次数后如果仍没有任何确认应答 则会判断网络或对端主机异常 强制管理连接并通知应用程序
  • 如下图

Here Insert Picture Description

连接管理

三次握手 四次挥手

Here Insert Picture Description

MSS最大消息长度
TCP在传送大量消息时 是以MSS进行分割 重发也是也MSS为单位
MSS是在三次握手时计算出来的 在发送SYN请求时会在TCP首部写入MSS选项 会在两者中选一个比较小的值投入使用

Here Insert Picture Description

窗口

为每个数据包进行确认应答的缺点是包往返时间越长网络的吞吐量越差
引入窗口概念 窗口的滑动如下
Here Insert Picture Description

窗口控制和重发控制如下图 P211

Here Insert Picture Description

流控制

窗口大小这个字段是由接收端控制的 TCP首部中有一个字段通知窗口大小 具体过程如下
Here Insert Picture Description

拥塞控制 P213

通信刚开始就发送大量数据 可能存在隐藏问题
在网络拥堵时 如果突然出现一个较大量的数据可能导致网络瘫痪
TCP为了防止该问题 在通信一开始便会通过一个慢启动算法得出的数值对发送数据量进行控制
定义了一个拥塞窗口的概念

提高网络利用率的规范
  • Nagle算法 尽在下列任意一种条件满足才能发送数据 这个算法可能导致某种程度的延迟因此在窗口系统(X Window System)以及继续控制等领域中使用TCP时往往会关闭该算法的启用
    • 已发送的数据全部都已经收到确认应答
    • 可以发送最大段长度MSS的数据时
  • 延迟确认应答
    • 每次都立刻回复确认应答的话 可能会返回一个较小的窗口(因为刚接收完数据 缓冲区已满)在流控制一节可以看到接收端可以控制窗口大小
    • 延迟机制如下
      • 在没有收到2x最大段长度的数据为止不做确认应答(根据操作系统不同 有时不论数据大小 只要收到两个包就即可返回确认应答的情况) 总而言之就是各种机制延迟确认应答
      • 在其他情况下 最大延迟0.5s发送确认应答 很多操作系统设置为0.2s 延迟超过0.5时很有可能导致重发数据 这个时间越小 CPU的负荷越高性能也下降 时间越大越有可能触发发送主机的重发处理
  • 捎带应答
    • TCP的确认应答和回执数据一起返回通过一个包发送
    • Such as the connection control portion and the like SMTP POP email protocol of the file transfer protocol FTP is
    • 没有启动延迟确认应答(即接收数据后立刻返回确认应答)是无法实现捎带应答的
    • 因为捎带必须等待应用程序处理完数据并将作为回执的数据返回时才能进行捎带 哈哈哈

Other transport layer protocols P218

  • UDP-Lite
  • SCTP
  • DCCP
  • and many more

UDP-Lite

  • In reality, however some applications dropped in the face of this situation do not want to test the UDP-based communication and packet error received will appear discard all
  • If the test set and UDP are part of the data is invalid even if the destruction of the entire package will not waste but this method is not good if it is the IP address of the IP header is damaged or destroyed, and so the port number can have serious consequences
  • 为了解决这些问题 UDP-Lite出现了
  • UDP-Lite checksum calculation itself controlled by the application range may have such a mechanism可以只针对不允许发生错误的部分进行校验和的价差

UDP format

This nothing to say
Here Insert Picture Description

TCP format

Here Insert Picture Description
TCP中没有包长度和数据长度的字符串

  • Offset data representing the TCP data transmitted portion should be appreciated from the start to which portion of the TCP packet is a TCP header minister
  • 控制位 8位大小 每一位都有其意义 P223
  • 紧急指针只有在URG控制位为1时有效 P225
  • 可选项 P225

Calculating TCP UDP pseudo header checksum

Here Insert Picture Description
Here Insert Picture Description

Published 40 original articles · won praise 0 · Views 2503

Guess you like

Origin blog.csdn.net/u010571102/article/details/104238646