ovs视频流转发实验

 本实验实用平台cloudlab,cloudlab可以提供多台虚拟机/真机,是实验的物理载体

实验目的是让不同的tcp视频流通过switch1和switch2时被分流到不同的路径上(via node1/node2/node3)

实验前,我调查了收发/处理视频流的一些常用的工具,并看了前人做的一些实验,发现rtmp-nginx很适合本实验

表格一:linux处理视频流的相关软件:

名称

描述

是否适用

ffmpeg

多媒体视频处理工具,用于视频采集、视频格式处理、视频流化

后面会用

vlc

简单、快速、强大的流媒体播放器,无需安装解码器包的媒体播放器

不用

WebRTC

网页即时通信,支持网页浏览器进行实时语音对话或视频对话的api,google发起的实时通信解决方案,包括音视频采集、编解码、数据传输、音视频展示等功能,基于udp,可以代替rtmp,提供了一套api,可能需要二次开发,不支持cdn

不用

rtmp

主流的流媒体传输协议,基于tcp,协议简单,在各平台上容易实现,比较容易找到教程,支持cdn

适用

nginx

web-server,和rtmp配套使用

适用

(1)cloudlab上搭起topo

#每个节点在每个link上各有一个ip,switch节点有4个网卡,4个ip,node节点有两个网卡,两个ip

#client的ip是唯一的,是10.10.1.1

#server的ip是唯一的,是10.10.8.2

client(10.10.1.1) ————— switch1(10.10.1.2)

switch1(10.10.2.1) ————— node1(10.10.2.2)

switch1(10.10.3.1) ————— node2(10.10.3.2)

switch1(10.10.4.1) ————— node3(10.10.4.2)

node1(10.10.5.1) ————— switch2(10.10.5.2)

node2(10.10.6.2) ————— switch2(10.10.6.1)

node3(10.10.7.1) ————— switch2(10.10.7.2)

switch2(10.10.8.1) ————— server(10.10.8.2) 

(2)登陆"server"节点,把它设置为rtmp server

wget http://nginx.org/download/nginx-1.17.3.tar.gz
git clone https://github.com/arut/nginx-rtmp-module
tar -zxf nginx-1.17.3.tar.gz
cd nginx-1.17.3
./configure --add-module=/root/nginx-rtmp-module

#此时发生缺少pcre library错误
#需要:
apt-get update
apt-get install libpcre3 libpcre3-dev
apt-get install openssl libssl-dev
sudo apt-get install zlib1g-dev

#再重新执行configure文件
./configure --add-module=/root/nginx-rtmp-module
make
make install
cd /usr/local/nginx
cd conf
#在本地写好nginx.conf文件(代码见后面),并上传到server上,覆盖掉原来的nginx.conf文件
scp ~/Desktop/nginx.conf root@155.98.36.44:/usr/local/nginx/conf
cd ..
./sbin/nginx -c conf/nginx.conf
cd html
mkdir play

 #nginx.conf:

worker_processes  1;
events {
    worker_connections  1024;
}
rtmp {
    server {

        listen 1935;

        chunk_size 4000;

    application play {
            play /usr/local/nginx/html/play;
        }
    
    application hls {
            live on;
            hls on;
            hls_path /usr/local/nginx/html/hls;
        hls_fragment 1s;
        hls_playlist_length 4s;
        }
    
    application live {
            live on;
        }
    }
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       8000;
        server_name  localhost;
    location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            # XML stylesheet to view RTMP stats.
            # Copy stat.xsl wherever you want
            # and put the full directory path here
            root /usr/local/nginx-rtmp-module;
        }

        location /hls {
            # Serve HLS fragments
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            root /usr/local/nginx/html;
            add_header Cache-Control no-cache;
        }
    }
}

打开本地shell,将本地的mp4文件上传到rtmp server,作为视频流的视频

scp ~/Desktop/6mins.mp4 root@155.98.36.44:/usr/local/nginx/html/play
scp ~/Desktop/3mins.mp4 root@155.98.36.44:/usr/local/nginx/html/play

至此,rtmp server设置完成

(3) 登陆client节点,设置rtmp client

apt-get update
apt install rtmpdump
#设置完测试一下:
rtmpdump -r rtmp://10.10.8.1:1935/play/3mins.mp4
rtmpdump -r rtmp://10.10.8.1:1935/play/3mins.mp4

 使用rtmpdump测试一下能不能顺利接收到视频流

可以接收到:(可以在shell里看到乱码)

此时,有关rtmp的设置已经设置完成了,接下来设置ovs

(3)登陆switch1,switch2两个节点,在上面下载、安装software ovs

这里略,前面的博客里有写怎么安装

在switch1上搭起br1

#搭起switch(bridge)
ovs-vsctl add-br br1

#绑定四个物理端口,每个真机的物理
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值