前前后后23工作日,调通了rtmfp握手过程

前面花了11工作日,搭建了一个rtmfp的demo:第一个连接上的flash节点,从cdn取数据;后面所有的flash节点,都从第一个flash节点取数据。

后面又花了12工作日,看了rtmfp协议,rtmplite和cumulus,准备把cumulus替换成我们自己的服务器。cumulus的能力不是很高。这12个工作日,调试rtmplite的握手过程,基本握手已经搞清楚了。

rtmplite
http://www.sunchangming.com/blog/?p=4596
http://blog.csdn.net/linyanwen99/article/details/8664626

还有rtmfp标准协议。

我就只看了这些。

 秀一下日志:

[winlin@dev6 rtmfp.server]$ ./objs/server 
RTMFP server(1.0.2)
port: 1936
max_udp_packet_size: 2048
[info][0] st_set_eventsys use linux epoll success
[info][0] st_init success
[trace][100] server main cid=100
[trace][100] system initialize ok
[info][100] create linux socket success. fd=4
[info][100] setsockopt reuse-addr success. fd=4
[info][100] bind socket success. fd=4
[info][100] st open socket success. fd=4
[trace][100] listen at udp 1936 ok
[trace][100] srand initialized the random.
[info][100] got packet 192.168.1.194:54360 68B
[trace][100] session 0
[info][100] AES set decrypt key ok.
[info][100] AES decrypt ok.
[info][100] AES decrypt 64B ok.
[info][100] decrypt rtmfp packet ok
[info][100] genereated checksum 23713
[info][100] demux rtmfp packet ok
[info][100] decode rtmfp packet ok, size=62
[info][100] maker: TC 0, TCR 0, rsv 0, TS 0x1, TSE 0, MOD 0x3
[info][100] got chunk packet, tm=41092, type=0x30, size=46
[info][100] ihello, ignore=0x1c, epd=29B, type=0xa
[trace][100] cookie 1000: 0xe8 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x69 0x00 0x00 0x41 0x00 0x00 0x00 0x00 0x00 0x00 0x2e 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x6e 0x00 0x00 0x6d 0x77 0x00 0x00 0x00 0x41 0x00 0x00 0x00 0x36 0x2a 0x00 0x65 0x00 0x00 0x00 0x00 0xb5 0x00 0xa5 0x19 0x2f 0x00 0x00 0x00 0x29 0x76 0x00 0x00 0x00 0x2f 0x00 
[info][100] cookie work thread ok.
[info][100] enqueue packet, queue size 1
[info][100] enqueue ihello packet ok.
[trace][100] handle chunk packet ok, tm=41092, type=0x30, size=46
[trace][101] session cycle start.
[info][101] got IHello ok.
[info][101] genereated checksum 7026
[info][101] AES set encrypt key ok.
[info][101] AES encrypt ok.
[info][101] AES encrypt 176B ok.
[info][101] encrypt rtmfp packet ok
[info][101] mux rtmfp packet ok.
[info][101] encode packet ok.
[info][101] encode ssid ok.
[info][101] send RHello ok, size=180
[info][100] got packet 192.168.1.194:54360 308B
[trace][100] session 0
[info][100] AES set decrypt key ok.
[info][100] AES decrypt ok.
[info][100] AES decrypt 304B ok.
[info][100] decrypt rtmfp packet ok
[info][100] genereated checksum 64942
[info][100] demux rtmfp packet ok
[info][100] decode rtmfp packet ok, size=302
[info][100] maker: TC 0, TCR 0, rsv 0, TS 0x1, TSE 0, MOD 0x3
[info][100] got chunk packet, tm=41092, type=0x38, size=281
[info][100] got cookie 1000, far_id=0x2000000
[info][100] enqueue packet, queue size 1
[info][100] enqueue iikeying packet ok.
[trace][100] handle chunk packet ok, tm=41092, type=0x38, size=281
[info][101] got IIKeying ok.
[info][101] rikeying build digest ok, near_id=0xf6 0x67 0x7d 0x5a 0x87 0x8e 0xb1 0x41 0xb6 0x6c 0x96 0x00 0x2e 0xf8 0xec 0xb5 0xde 0x91 0x05 0x73 0xec 0xf4 0xf6 0x87 0x1a 0x2d 0x90 0x62 0x48 0x62 0xff 0x73 
[info][101] compute 128B key ok.
[info][101] compute asymetric keys ok
[info][101] add ssid 0x1 ok, handlers 2
[info][101] add session ok, ssid=0x1
[info][101] system time updated, startup=1407485729051255us, now=1407485729153638us
[info][101] genereated checksum 17427
[info][101] AES set encrypt key ok.
[info][101] AES encrypt ok.
[info][101] AES encrypt 160B ok.
[info][101] encrypt rtmfp packet ok
[info][101] mux rtmfp packet ok.
[info][101] encode packet ok.
[info][101] encode ssid ok.
[info][101] send RHello ok, size=164
[info][101] create session ok.
[info][101] cycle ok.
[info][100] got packet 192.168.1.194:54360 356B
[trace][100] session 1

    /**
    * Source-Consumer Peer WorkFlow:
    * Cumulus: the rtmfp server, cumulus.
    * SRS: the http server which provides the flv for source peer.
    * Tracker: the api server, @see tracker/api.server.py
    * Peer: the flash player, RtmfpPlayer.swf, it is a Source or Consumer peer.
    * Source: the source flash peer, get flv from http server(SRS).
    * Consumer: the consumer flash peer, get flv from source peer.
    *  
    *   +---------+
    *   |   Peer  |
    *   +----+----+
    *        |                        +---------+
    *        |                        | Tracker |
    *        |                        +----+----+
    *        |                             |
    *        +----trackerGetPeers()->------+
    *        |                             |
    *        +--<------response(peers)-----+
    *        | peer change to:             |
    *        |  Source: if peers is empty 
    *        |  Consumer: if not empty    
    *        |
    *        |                        +---------+
    *        |                        | Cumulus |
    *        |                        +----+----+
    *        |                             |
    *        +----rtmfpConnect()---->------+
    *        |                             |
    *        +--<------response(evt)-------+
    *        | evt.info.code maybe:
    *        |  NetConnection.Connect.Success ok, nearID use to identify the peer.
    *        |
    *        |                        +---------+
    *        |                        | Tracker |
    *        |                        +----+----+
    *        |                             |
    *        +--trackerCreatePeer()->------+
    *        |                             |
    *        |
    *        |  +-----------------------------------+
    *        +--+  enter Source/Consumer workflow.  |
    *           +-----------------------------------+
    *  
    *  
    *   +---------+
    *   |  Source |
    *   +----+----+
    *        |                        +---------+
    *        |                        |   SRS   |
    *        |                        +----+----+
    *        |                             |
    *        +--HTTP GET /source.flv-->----+
    *        |                             |
    *        +--<-----response(flv bytes)--+
    *        |
    *        +--NetStream.appendBytes(flv)
    *        |
    *        +--p2pstream(NetStream.DIRECT_CONNECTIONS)
    *        +--p2pstream.publish(nearID)
    *        |
    *        +--startRtmfpHeartbeat()
    *           for all consumers, call the onHeartbeat method.
    *  
    *  
    *   +---------+                   +----------+                       +---------+
    *   |  Source |                   | Consumer |                       | Cumulus |
    *   +----+----+                   +----+-----+                       +----+----+
    *        |                             |                                  |
    *        |                             +----NetStream(source.nearID)--->--+
    *        |                             |    which will do NAT traverse for source and consumer,
    *        |                             |    to enable source and consumer to call each other.
    *        |                             |
    *        +-onRtmfpConsumerEvent()      |
    *        |  which get the consumer.    |
    *        |                             |
    *        +-onSourceReady()(1-N)----->--+
    *        |  retry call 1-N times       |
    *        |  for udp may drop packets   |
    *        |                             |
    *        +--<--onConsumerReady()(1+)---+
    *        |  retry >=1 times            |
    *        |                             |
    *        +---onFlvData(flv)--------->--+--NetStream.appendBytes(flv) 
    *        |  send flv data to consumer  |  start play the flv got from source peer.
    *        |                             |
    *        +--onHeartbeat()-->-----------+
    */



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

winlinvip

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值