RFC 793 为什么要发送reset,什么情况下发送reset

本文详细阐述了TCP协议中重置(RST)段的生成与处理规则,包括连接不存在、非同步状态及同步状态下的处理方式,并针对不同情况如何响应进行了说明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  A variety of other cases are possible, all of which are accounted for
  by the following rules for RST generation and processing.

  Reset Generation

  As a general rule, reset (RST) must be sent whenever a segment arrives
  which apparently is not intended for the current connection.  A reset
  must not be sent if it is not clear that this is the case.

  There are three groups of states:

    1.  If the connection does not exist (CLOSED) then a reset is sent
    in response to any incoming segment except another reset.  In
    particular, SYNs addressed to a non-existent connection are rejected
    by this means.

    If the incoming segment has an ACK field, the reset takes its
    sequence number from the ACK field of the segment, otherwise the
    reset has sequence number zero and the ACK field is set to the sum
    of the sequence number and segment length of the incoming segment.
    The connection remains in the CLOSED state.

    2.  If the connection is in any non-synchronized state (LISTEN,
    SYN-SENT, SYN-RECEIVED), and the incoming segment acknowledges
    something not yet sent (the segment carries an unacceptable ACK), or
    if an incoming segment has a security level or compartment which
    does not exactly match the level and compartment requested for the
    connection, a reset is sent.

    If our SYN has not been acknowledged and the precedence level of the
    incoming segment is higher than the precedence level requested then
    either raise the local precedence level (if allowed by the user and
    the system) or send a reset; or if the precedence level of the
    incoming segment is lower than the precedence level requested then
    continue as if the precedence matched exactly (if the remote TCP
    cannot raise the precedence level to match ours this will be
    detected in the next segment it sends, and the connection will be
    terminated then).  If our SYN has been acknowledged (perhaps in this
    incoming segment) the precedence level of the incoming segment must
    match the local precedence level exactly, if it does not a reset
    must be sent.

    If the incoming segment has an ACK field, the reset takes its
    sequence number from the ACK field of the segment, otherwise the
    reset has sequence number zero and the ACK field is set to the sum
    of the sequence number and segment length of the incoming segment.
    The connection remains in the same state.



[Page 36]                                                               


September 1981                                                          
                                           Transmission Control Protocol
                                                Functional Specification



    3.  If the connection is in a synchronized state (ESTABLISHED,
    FIN-WAIT-1, FIN-WAIT-2, CLOSE-WAIT, CLOSING, LAST-ACK, TIME-WAIT),
    any unacceptable segment (out of window sequence number or
    unacceptible acknowledgment number) must elicit only an empty
    acknowledgment segment containing the current send-sequence number
    and an acknowledgment indicating the next sequence number expected
    to be received, and the connection remains in the same state.

    If an incoming segment has a security level, or compartment, or
    precedence which does not exactly match the level, and compartment,
    and precedence requested for the connection,a reset is sent and
    connection goes to the CLOSED state.  The reset takes its sequence
    number from the ACK field of the incoming segment.

  Reset Processing

  In all states except SYN-SENT, all reset (RST) segments are validated
  by checking their SEQ-fields.  A reset is valid if its sequence number
  is in the window.  In the SYN-SENT state (a RST received in response
  to an initial SYN), the RST is acceptable if the ACK field
  acknowledges the SYN.

  The receiver of a RST first validates it, then changes state.  If the
  receiver was in the LISTEN state, it ignores it.  If the receiver was
  in SYN-RECEIVED state and had previously been in the LISTEN state,
  then the receiver returns to the LISTEN state, otherwise the receiver
  aborts the connection and goes to the CLOSED state.  If the receiver
  was in any other state, it aborts the connection and advises the user
AMR在IP域中的编码(rfc3267,4867) 缩写解释 SID Silence Descriptor (Comfort Noise Frame) 1 AMR编码介绍 AMR编码是一种自适应多速率编码,根据传输信道的实际情况,调整编码模式、速率和纠错码位数来保证语音质量,在数据压缩和容错上面取得平衡。一般语音质量越高抗干扰能力越弱。在GSM网络,基站、基站控制器可根据网络质量和信号质量情况动态调整语音编码模式以提高不同网络状况下的语音质量。现在手机终端基本上都支持AMR编码,Nokia从2004年开始提供支持AMR的终端,目前所有的新型号终端都支持AMR。 AMR在IP域中的编码(rfc3267,4867) AMR算法 参考文档 (1) 3GPP TS26.190, AMR Wideband speech codec; Transcoding functions(Release 5). (2) 3GPP TS 26.194, Voice Activity Detection (VAD). (3) 3GPP TS 26.174, AMR wideband speech codec; Test sequences. (4) 3GPP TS 26.194, Frame Structure. 2 AMR在IP域中的净荷格式 RFC3267/4867协议描述AMR编码在RTP中的载荷格式,是其在IP域的存在形式。 对于每个RTP会话,AMR净荷有两种模式,分别为节省带宽模式和字节对齐模式,具体采用那种模式,由信令协商决定;采用后一模式可以后可以引入鲁棒排序、帧交叉编码和CRC校验等方式提高语音传输的质量。 以下三种场景分别为1IP域的终端进行会话、2非IP域终端通过网关和3IP域终端会话以及非IP域终端之间的通信场景,各个场景的特点见协议描述。 AMR和AMR-WB净荷格式 二者格式区别,a.帧类型;b.前者的采样频率为8KHZ,后者为16KH;c.模式不一样 净荷结构如下,包括净荷头,内容表和语音数据: +----------------+-------------------+---------------- | payload header | table of contents | speech data ... +----------------+-------------------+---------------- Payloads containing more than one speech frame-block are called compound payloads. 节省带宽模式Bandwidth-Efficient Mode a. 净荷头格式: 0 1 2 3 +-+-+-+-+ | CMR | +-+-+-+-+ CMR(codec mode request)编码模式请求,由发送者向接受者的请求发送者编码器将来的编码速率模式,保存帧类型索引,如果是AMR,取值范围为0-7,表示8种速率模式,如果为AMR-WB,取值范围为0-8,表示9种速率。取值15意味着当前是没有指定哪个模式的请求。 模式选定后,由于采样频率恒定,具体包的打包时长还是不变,不同速率只是净荷长度不一样,例如对于AMR模式0,其速率是4.75Kbit/s,净荷中包含的语音数据为95bits。 AMR的8种速率索引表,见[1] AMR在IP域中的编码(rfc3267,4867) AMR-WB的9种速率索引表,见[2] AMR在IP域中的编码(rfc3267,4867) b. 净荷内容表ToC(table of contents),第一项表示一个语音帧 0 1 2 3 4 5 +-+-+-+-+-+-+ |F| FT |Q| +-+-+-+-+-+-+ F:用于标志是否最后一个帧,0表示最后1帧.如果是多帧复用才有Toc才会有多项,否则只有1项。 FT:标志对音帧语音编码模式或舒适噪志的模式,取值范围同CMR取值,FT=14 (SPEECH_LOST, only available for AMR-WB) and FT=15 (NO_DATA),FT=15表示没有当前帧没有净荷;取值10-13该帧要丢弃。 Q:指示帧质量,为0表示对应帧被破坏,1表示未被破坏;如果该帧已被破坏,那么可以通过直接丢弃该帧来处理。 净荷内容表就是对帧内容的数据格式说明, c. 语音数据speech data 语音数据即为真正的语音帧或舒适噪声帧的数据,每帧数据的描述和ToC每一项对应起来,数据长度取决于对应模式ToC项中的FT标识的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-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |g(0) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | g(39)|h(0) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | h(176)|P|P|P|P|P|P|P| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 多通道多帧,见协议 字节对齐模式Octet-aligned Mode a. 净荷头格式 0 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +-+-+-+-+-+-+-+-+- - - - - - - - | CMR |R|R|R|R| ILL | ILP | +-+-+-+-+-+-+-+-+- - - - - - - - CMR:同上; R:保留位,区分节省带宽模式,这些保留位作用之一就是字节对齐; ILL:可选,指示交错长度(取值为L,交错长度即为L+1); ILP:可选,交错块的索引,取值范围为0到ILL,超过这个范围,该帧块应被丢弃。 b. ToC +---------------------+ | list of ToC entries | +---------------------+ | list of frame CRCs | (optional) - - - - - - - - - - - Note, for ToC entries with FT=14 or 15, there will be no corresponding speech frame or frame CRC present in the payload. 组成同节省带宽模式 ToC项:在该模式下,6位ToC也需要2位补齐。 CRC:CRC校验位可选,如果带外信令协商需要校验,则每项对应每个语音数据进行8位长度的校验。 语音数据 同节省带宽模式,只是要求每帧必须补0对齐;对于多帧的净荷,可以和节省模式一样,一帧顺序排,也可以所有帧以字节为单位交错排序,尽量把各个帧错误敏感位排前面。 示例: 单通道多帧 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | CMR=6 |R|R|R|R|1|FT#1=5 |Q|P|P|0|FT#2=5 |Q|P|P| f1(0..7) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | f1(8..15) | f1(16..23) | .... | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : ... : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ... |f1(152..158) |P| f2(0..7) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | f2(8..15) | f2(16..23) | .... | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : ... : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ... |f2(152..158) |P| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 多通道 3 AMR语音帧结构 AMR和AMR-WB的语音数据结构分别详见TS 26.101,26.201描述,这里介绍AMR-NB的语音数据编码结构。 语音数据位根据重要性分成类,A、B、C类,其对错误的敏感性和重要性依次为A>B>C,如下,4.75Kb模式的总的位数为95位,A类42位,B类53位。 AMR在IP域中的编码(rfc3267,4867) AMR净荷数据把重要的数据位放在前面,不重要的放在后面,为了把语音数据中重要的数据位放置A类,需要对编码器编出的比特位进行重排序,26.101把编码后数据位的位置和重排序的位置对应起来形成一张表供查询, - for j = 0 to K-1 //第0位到第K-1位全部重排 - d(j) := s(tablem(j)+1); //查对应模式的表找到重排后相应位置 例如下表6.7kb模式的排序表,共134位,第82位数据位排序后对应18位 AMR在IP域中的编码(rfc3267,4867) 上节节省带宽模式和字节对齐模式,d(i)均是排序后的数据。 下图示例相比上一节还加了8位CRC校验码。 4 AMR NB/WB信令协商参数 AMR常用如下 octet-align,是节省带宽模式还是字节对节模式,一般取值为1表示字节对齐,为0或不带默认表示为节省带宽模式; mode-set,一旦请求带了模式集,之后AMR媒体流只选择属于这个模式集的模式来发送; mode-change-period,模式改变周期; maxptime,最大支持的打包时长(ms); crc,净荷是否进行CRC校验,一般为1表示需要,媒体流会携带校验位; robust-sorting,是否进行鲁棒排序; interleaving,定义交错帧块数; ptime,指包时长; channels,音频通道数,例如采用左右通道数值则为2; AMR-WB常用参数同上 4 多帧复用 为了降低带宽,减少网络传输的RTP包数,把多帧的数据打包在1个RTP包里面进行传输。净荷里面用ToC表来管理多帧数据,说明模式等内容,这样也可根据网络状况灵活改变多帧的速率,例如,多帧中每个帧的速率不一定要一样。 采用多帧复用要注意关注RTP包的大小、时戳是否正确。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值