quic协议实践

QUIC实践

环境Ubuntu14.x86_64 gcc4.8 python2.7

编译QUIC服务器和客户端

下载

git clone https://github.com/google/proto-quic.git

修改hosts

因为要从google官网下载一些包,需要通过修改hosts来FQ
将下面网站中的内容添加到本地hosts文件中(/etc/hosts)

https://github.com/racaljk/hosts/blob/master/hosts

依赖安装

argparse安装(未安装的话)
apt-get install python-argparse 
安装binutils
cd proto-quic  
export PROTO_QUIC_ROOT=`pwd`/src  
export PATH=$PATH:`pwd`/depot_tools  
./proto_quic_tools/sync.sh  
安装其它依赖库
./src/build/install-build-deps.sh --no-syms --no-arm --no-chromeos-fonts

编译生成服务器和客户端程序

cd src
gn gen out/Default && ninja -C out/Default quic_client quic_server net_unittests

编译完成后输出的文件在proto-quic/src/out/Default

运行服务器

准备测试数据

cd /tmp
wget -p --save-headers https://www.example.org

下载完测试数据后记得修改index.html文件中的内容,这块可以参考本文最后的第一个连接

生成证书

cd proto-quic/src/net/tools/quic/certs/
./generate-certs.sh

运行服务器

在src目录下执行下面的命令,如果服务器无法启动,尝试用root用户启动,或者加入sudo命令来启动

./out/Default/quic_server \
  --quic_response_cache_dir=/tmp/www.example.org \
  --certificate_file=net/tools/quic/certs/out/leaf_cert.pem \
  --key_file=net/tools/quic/certs/out/leaf_cert.pkcs8 \
  --v=1

服务器启动的成功后会查看6121端口

运行客户端

使用chromium导入CA证书,具体操作详见参考连接1。这里需要注意,Ubuntu只允许普通用户登陆,所以chromium导入证书时是以普通用户导入的。在运行客户端时也需要以普通用户来运行,否则会报证书无效的错误

sudo ./out/Default/quic_client --host=127.0.0.1 --port=6121 https://www.example.org/

客户端运行成功后将会看到前面准备的数据内容

编译时遇到的问题

问题1

/usr/bin/ld.gold: warning: ignoring --threads: /usr/bin/ld was compiled without thread support
/usr/bin/ld.gold: warning: ignoring --thread-count: /usr/bin/ld was compiled without thread support
出现上面的警告时说明不支持多线程,但是编译器会将warning直接视为error从而终止编译
修改 src/build/config/compiler/BUILD.gn,将fatal_linker_warnings的值修改为false
fatal_linker_warnings = false

参考

http://www.jianshu.com/p/f17b4a015e27
https://www.chromium.org/quic/playing-with-quic

posted @ 2017-05-10 21:31  被罚站的树  阅读(4899)  评论(0编辑  收藏  举报