A scenario for rtsp-simple-server and rtsp-simple-proxy: Extended work

 

In the network topology, I add one dns server node (dnsserver) that is connected to r1. The IP address for dnsserver is 192.168.4.1. I have added server.a.com (192.168.3.1) and proxy.a.com (192.168.2.3) in the dnsserver. With these settings, the nodes can connect to rtsp server/proxy through domain name.

 

[test2.py]

#!/usr/bin/env python

 

from mininet.net import Containernet

from mininet.node import Docker

from mininet.cli import CLI

from mininet.link import Link,TCLink

from mininet.log import setLogLevel,info

 

if '__main__' == __name__:

  setLogLevel("debug")

  net = Containernet(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')

  #dnsserver = net.addHost('dnsserver')

  #You need to change the place where you put the a.com.fwd file

  dnsserver = net.addDocker('dnsserver', dimage="smallko/php-apache-dev:dns-server", volumes=["/home/p4/test_rtsp/test2/a.com.fwd:/etc/bind/a.com.fwd"])

 

  Link(h1, r1)

  Link(h2, s1)

  Link(h3, s1)

  Link(proxy, s1)

  Link(s1, r1)

  Link(server, r1)

  Link(dnsserver, r1)

 

  net.build()

 

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

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

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

  r1.cmd("ifconfig r1-eth3 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")

  r1.cmd("ip addr add 192.168.4.254/24 brd + dev r1-eth3")

  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")

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

  dnsserver.cmd("ifconfig dnsserver-eth0 192.168.4.1 netmask 255.255.255.0")

  dnsserver.cmd("route del default gw 172.17.0.1")

  dnsserver.cmd("route add default gw 192.168.4.254")

  dnsserver.cmd("/etc/init.d/bind9 start")

 

  CLI(net)

 

[config.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

  mystream:

    # url of the source stream

    url: rtsp://server.a.com:8554/mystream

    # whether to receive this stream in udp or tcp

    useTcp: no

 

[a.com.fwd]

$TTL 3600

 

@ IN SOA ns.a.com. root.a.com. (

           2014062007 ;

           1800       ;

           900        ;

           86400      ;

           3600 )     ;

 

@ IN NS ns.a.com.

@ IN A  10.0.3.3

 

ns.a.com. IN A 10.0.3.3

www.a.com. IN A 10.0.3.4

ftp.a.com. IN A 10.0.3.5

server.a.com. IN A 192.168.3.1

proxy.a.com. IN A 192.168.2.3

 

[execution]

Before you run the mininet script, you need to download the docker image for dns server.

 

Run the mininet script

 

Open terminal for h1,h2,h3, proxy, server

 

Change the dns server for hosts. (add nameserver 192.168.4.1 in /etc/resolv.conf)

 

You can ping server or proxy. (Test whether the Domain Name  - IP translation function is ok or not.)

 

Start rtsp-simple-server

 

Start rtsp streaming from h1

 

Start rtsp-simple-proxy

 

At h2, connect to rtsp-server

 

At h3, connect to rtsp-proxy

 

 

Dr. Chih-Heng Ke

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

Email: smallko@gmail.com