A scenario for rtsp-simple-server and rtsp-simple-proxy

 

Based on rtsp-simple-server and rtsp-simple-proxy, I wrote this lab. You can download the code and related files from here.

 

[topology]

Note: The IP for Proxy in the above figure should be “192.168.2.3/24”, not “192.168.2.100/24”

This scenario is for “when there are multiple users that are receiving a stream and the bandwidth is limited, so the proxy is used to receive the stream once and users connect to the proxy”

 

[mininet script:test.py]

#!/usr/bin/env python

 

from mininet.net import Mininet

from mininet.cli import CLI

from mininet.link import Link,TCLink

 

if '__main__' == __name__:

  net = Mininet(link=TCLink)

  h1 = net.addHost('h1')

  h2 = net.addHost('h2')

  h3 = net.addHost('h3')

  r1 = net.addHost('r1')

  s1 = net.addHost('s1')

  server = net.addHost('server')

  proxy = net.addHost('proxy')

 

  Link(h1, r1)

  Link(h2, s1)

  Link(h3, s1)

  Link(proxy, s1)

  Link(s1, r1)

  Link(server, r1)

 

  net.build()

 

  r1.cmd("ifconfig r1-eth0 0")

  r1.cmd("ifconfig r1-eth1 0")

  r1.cmd("ifconfig r1-eth2 0")

  r1.cmd("echo 1 > /proc/sys/net/ipv4/ip_forward")

  r1.cmd("ip addr add 192.168.1.254/24 brd + dev r1-eth0")

  r1.cmd("ip addr add 192.168.2.254/24 brd + dev r1-eth1") 

  r1.cmd("ip addr add 192.168.3.254/24 brd + dev r1-eth2")

  s1.cmd("ifconfig s1-eth0 0")

  s1.cmd("ifconfig s1-eth1 0")

  s1.cmd("ifconfig s1-eth2 0")

  s1.cmd("ifconfig s1-eth3 0")

  s1.cmd("brctl addbr br0")

  s1.cmd("brctl addif br0 s1-eth0")

  s1.cmd("brctl addif br0 s1-eth1")

  s1.cmd("brctl addif br0 s1-eth2")

  s1.cmd("brctl addif br0 s1-eth3")

  s1.cmd("ifconfig br0 up")

  h1.cmd("ifconfig h1-eth0 0")

  h1.cmd("ip addr add 192.168.1.1/24 brd + dev h1-eth0")

  h1.cmd("ip route add default via 192.168.1.254")

  h2.cmd("ifconfig h2-eth0 0")

  h2.cmd("ip addr add 192.168.2.1/24 brd + dev h2-eth0")

  h2.cmd("ip route add default via 192.168.2.254")

  h3.cmd("ifconfig h3-eth0 0")

  h3.cmd("ip addr add 192.168.2.2/24 brd + dev h3-eth0")

  h3.cmd("ip route add default via 192.168.2.254")

  proxy.cmd("ifconfig proxy-eth0 0")

  proxy.cmd("ip addr add 192.168.2.3/24 brd + dev proxy-eth0")

  proxy.cmd("ip route add default via 192.168.2.254")

  server.cmd("ifconfig server-eth0 0")

  server.cmd("ip addr add 192.168.3.1/24 brd + dev server-eth0")

  server.cmd("ip route add default via 192.168.3.254")

 

  CLI(net)

 

[configuration file for rtsp-simple-proxy: conf.yml]

server:

  # supported protocols

  protocols: [ tcp, udp ]

  # port of the RTSP TCP listener

  rtspPort: 8554

  # port of the RTP UDP listener

  rtpPort: 8050

  # port of the RTCP UDP listener

  rtcpPort: 8051

 

streams:

  # name of the stream

  mypath:

    # url of the source stream

    url: rtsp://192.168.3.1:8554/mystream

    # whether to receive this stream in udp or tcp

    useTcp: no

 

[Execution]

Open an terminal to run the mininet script

 

Open terminals for h1, h2, h3, proxy, and server

 

Run the rtsp-simple-server at server

 

Publish streams to server from h1

 

Run the rtsp-simple-proxy

 

Connect to proxy from h2 ( ffplay -i rtsp://192.168.2.3:8554/mypath)

 

Connect to proxy from h3 ( ffplay -i rtsp://192.168.2.3:8554/mypath)

 

Dr. Chih-Heng Ke

Department of Computer Science and Information Engineering, National Quemoy University, Kinmen, Taiwan

Email: smallko@gmail.com