美文网首页直播
RTMP Handshake(握手协议)

RTMP Handshake(握手协议)

作者: FlyingPenguin | 来源:发表于2016-10-29 11:48 被阅读0次

    RTMP流播放的流程首先要进行握手操作,才能进行后续的connect和createStream等操作, 本文简单阐述握手基础知识.

    Handshake Diagram

    **Handshake Diagram in Adobe’s Real Time Messaging Protocol**

    wireshark分析握手基本流程

    用wireshark对rtmp的包进行抓包分析:


    rtmp点播流程

    可以看到前三个报文是握手协议:

    握手协议

    从以上可看出握手的实际流程为三个步骤:

    1. Client -> Server
      C0+C1
    2. Server -> Client
      S0+S1+S2
    3. Client -> Server
      C2
      可以看出握手的起点是Client(RMTP播放器)发送C0+C1, 结束是Server收到Client的C2.
      其中C0 C1 C2 S0 S1 S2的大小都是固定的.
      C2 S2属于用于确认(Ack)的包
    Step 1: C0 + C1

    C0 + C1一起发送.
    其中C0一个字节, 固定为03.
    C11536个字节.
    数据包总长度为:
    1 + 1536 = 1537

    In C0, this field identifies the RTMP version requested by the client.
    In S0, this field identifies the RTMP version selected by the server.
    The version defined by this specification is 3.
    0-2 are deprecated values used by earlier proprietary products;
    4-31 are reserved for future implementations;
    32-255 are not allowed (to allow distinguishing RTMP from text-based protocols, which always start with a printable character).

    C0 C1
    Step 2: S0+S1+S2

    S0+S1+S2一起发送.
    S0为1个字节,固定为03.
    S1S2都为1536个字节.
    整个数据包总长度为:
    1 + 1536 + 1536 = 3073

    S0 S1 S2
    Step 3: C2

    C2为1536个字节.
    RTMP Server接收到C2意味着握手成功结束.

    C2

    References:

    rtmp_specification_1.0.pdf

    相关文章

      网友评论

        本文标题:RTMP Handshake(握手协议)

        本文链接:https://www.haomeiwen.com/subject/freeuttx.html