QUIC/UDT/SRT

  1. 谷歌推的 QUIC 方案(用于替代HTTP2.0)
    QUIC公共包头结构如下:
  • 1字节公共Flags
  • 8字节连接ID
  • 4字节QUIC版本号
  • 32字节多样化随机数(Nonce)
  • 1至6字节可变长度的Packet编号(Packet Number)
     0        1        2        3        4            8
+--------+--------+--------+--------+--------+---    ---+
| Public |    Connection ID (64)    ...                 | ->
|Flags(8)|      (optional)                              |
+--------+--------+--------+--------+--------+---    ---+

     9       10       11        12   
+--------+--------+--------+--------+
|      QUIC Version (32)            | ->
|         (optional)                |                           
+--------+--------+--------+--------+

    13       14       15        16      17       18       19       20
+--------+--------+--------+--------+--------+--------+--------+--------+
|                        Diversification Nonce                          | ->
|                              (optional)                               |
+--------+--------+--------+--------+--------+--------+--------+--------+

    21       22       23        24      25       26       27       28
+--------+--------+--------+--------+--------+--------+--------+--------+
|                   Diversification Nonce Continued                     | ->
|                              (optional)                               |
+--------+--------+--------+--------+--------+--------+--------+--------+

    29       30       31        32      33       34       35       36
+--------+--------+--------+--------+--------+--------+--------+--------+
|                   Diversification Nonce Continued                     | ->
|                              (optional)                               |
+--------+--------+--------+--------+--------+--------+--------+--------+

    37       38       39        40      41       42       43       44
+--------+--------+--------+--------+--------+--------+--------+--------+
|                   Diversification Nonce Continued                     | ->
|                              (optional)                               |
+--------+--------+--------+--------+--------+--------+--------+--------+

    45      46       47        48       49       50
+--------+--------+--------+--------+--------+--------+
|           Packet Number (8, 16, 32, or 48)          |
|                  (variable length)                  |
+--------+--------+--------+--------+--------+--------+

参考资料https://www.chromium.org/quic
原始表格来自谷歌文档
https://docs.google.com/document/d/1WJvyZflAO2pq77yOLbp9NsGjC1CHetAXV8I0fQe-B_U/edit
 (需要科学上网)
中文译者:hanpfei
中文链接:https://www.jianshu.com/p/b73912342ab8
QUIC/UDT/SRT_第1张图片

QUIC (Quick UDP Internet Connections)
维基百科词条 https://en.wikipedia.org/wiki/QUIC

  • 参考hanpfei的博客, 博客链接如下
    https://www.wolfcstech.com/tags/QUIC/
    https://hanpfei.github.io/tags/QUIC/

学术解决方案 UDT 和商业解决方案 SRT

  1. UDT(UDP-based Data Transfer)是一款开源工具包, 基于 UDP 协议实现可靠数据传输的 API 中间件. 作者 Yunhong Gu
    https://en.wikipedia.org/wiki/UDP-based_Data_Transfer_Protocol
    http://udt.sourceforge.net

UDT是什么

  • 参考WolfcsTech的博客1 https://www.jianshu.com/p/974d6c5590f6
    https://www.wolfcstech.com/categories/网络协议/page/4/

  • 参考CSDN开发者博客 http://blog.csdn.net/asdfghjkl1993/article/details/57417074

UDT是基于UDP的数据传输协议。UDT是开源软件,主要目的是针对“TCP在高带宽长距离网络上的传输性能差”的问题,尽可能全面支持UDP网络上的海量数据传输。
UDT是基于UDP的一种应用层协议。

  1. SRT(Secure Reliable Transport)是一款商业级别的开源工具包, 由 Haivision Systems 公司开源发布. 它在 UDT 的基础上进行了一些扩展和定制, 具备网络传输丢包检测/延迟控制/视频加密功能, 可用于商业化的 P2P 视频流传输.
    SRT is an open source video transport protocol that enables the delivery of high-quality and secure, low-latency video across the public Internet.
    • https://github.com/Haivision/srt/blob/master/docs/why-srt-was-created.md

Demo

  • 服务器端样例程序
    https://github.com/chadnickbok/srt/blob/966a4dfc8cae29703b040e9a3ff66dc374593587/apps/testcserver.c
  • 客户端样例程序
    https://github.com/Haivision/srt/blob/master/apps/testcapi.c
#include 
#include 
#include 
#include  // #define INADDR_LOOPBACK 0x7F000001

#include 

int main( int argc, char** argv )
{
    int ss, st;
    struct sockaddr_in sa;
    int yes = 1;
    const char message [] = "This message should be sent to the other side";

    sa.sin_port = htons(20000); // 对方端口号
    sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); // 对方IP地址

    srt_startup();

    ss = srt_socket(AF_INET, SOCK_DGRAM, 0);
    if(!ss)
    {
        goto CLEANUP;
    }
    srt_setsockflag(ss, SRTO_SENDER, &yes, sizeof yes);
    st = srt_connect(ss, (struct sockaddr*)&sa, sizeof sa);
    st = srt_sendmsg2(ss, message, sizeof message, NULL);
    st = srt_close(ss);

CLEANUP:
    srt_cleanup();
EXIT:
    return 0;
}

https://github.com/Haivision/srt/blob/master/srtcore/srt_c_api.cpp

你可能感兴趣的:(QUIC/UDT/SRT)