Le 12/26/14 09:22, Eduardo a écrit :
> El 25/12/14 a las 07:23, Eduardo escribió:
>> ...
>>
>>   I have written a tiny rtsp server and client. I created, with kvm, three 
>> virtual machines, a firewall (router), a server and a client,
>> ...
> 
> Sorry, there are some errors in server and client, try this new version.
> 

I've just tested your scripts and unfortunately, I couldn't reproduce the 
reported bug.
But at least, they require nf_nat_rtsp on the router so I'll make a unit test 
from them.

2 attached files:
- The 'test' script must be run as root in the same directory as your scripts. 
It creates 3 machines using network namespaces and runs the server & client at 
the end. The test fails if the module is not loaded before.
- 'rtsp_output' is what I get on my machine. Server & client outputs are mixed.
[*] father 21984, child 22006
[22006] describe rtsp://10.0.0.1:554/vod1_diascontadosV2PR.mpi RTSP/1.0
[22006] describe tx
RTSP/1.0 200 OK
CSeq: 2
Date: Fri, 05 Dec 2014 01:31:05 GMT
Content-Type: application/sdp
Content-Length: 309

v=0
o=- 1417743065482550 4201396289678 IN IP4 10.0.0.2
s=RTSP Session
t=0 0
i=
b=AS:2800
a=type:vod
a=range:npt=0-5457.661
c=IN IP4 0.0.0.0
a=control:rtsp://0.0.0.0:554/vod1_diascontadosV2PR.mpi
m=video 0 RTP/AVP 33
a=framerate:25.00
a=pmt:ArAdAALBAADh4fAAG+Hh8AAD4eLwBgoERVNQAJCKMR8=


[22006] setup rtsp://10.0.0.1:554/vod1_diascontadosV2PR.mpi RTSP/1.0
[22006] setup tx
RTSP/1.0 200 OK
CSeq: 3
Session: 3424382056990345778;timeout=180
Transport: MP2T/H2221/UDP;unicast;destination=0.0;client_port=27910-27911


[*] father 22005, child 22007
[*] listen udp 10.0.1.2:27910
[22006] play rtsp://10.0.0.1:554/vod1_diascontadosV2PR.mpi RTSP/1.0
RTSP/1.0 200 OK
CSeq: 4
Session: 3424382056990345778;timeout=180
Scale: 1.0
Range: npt=0.000-
x-playNow:
x-noFlush:


[*] father 22006, child 22011
Conecting rtp 10.0.0.2:27910
Hello world!
[22006] teardown rtsp://10.0.0.1:554/vod1_diascontadosV2PR.mpi RTSP/1.0
[22006] teardown tx
RTSP/1.0 200 OK
CSeq: 5
Session: 3424382056990345778;timeout=180
Scale: 1.0
Range: npt=0.000-
x-playNow:
x-noFlush:
#!/bin/bash
# XXX: There's no bashism but 'trap' is buggy in dash:
#        https://bugs.debian.org/390433

set -e
ns=test-nat-rtsp-$$
server() { ip netns exec $ns.server "$@"; }
router() { ip netns exec $ns.router "$@"; }
client() { ip netns exec $ns.client "$@"; }

trap 'set +e; eval $at_exit' 0

for i in server router client; do
  at_exit="ip netns del $ns.$i; $at_exit"
  ip netns add $ns.$i
  $i ip link set lo up
done

ip -b - <<EOF
link add name server type veth peer name router
link set server netns $ns.router
link set router netns $ns.server

link add name client type veth peer name router
link set client netns $ns.router
link set router netns $ns.client
EOF

server ip link set router up; server ip addr add 10.0.0.1/24 dev router
router ip link set server up; router ip addr add 10.0.0.2/24 dev server
router ip link set client up; router ip addr add 10.0.1.1/24 dev client
client ip link set router up; client ip addr add 10.0.1.2/24 dev router

router sysctl net.ipv4.ip_forward=1
router iptables -t nat -A POSTROUTING -o server -j MASQUERADE
client ip route add default via 10.0.1.1

client ping -q -c 1 10.0.0.1 >/dev/null
echo "Network ready."

#bash -i
#exit

at_exit="pkill -f ./rtsp_server.pl; $at_exit"
server ./rtsp_server.pl &
sleep 1 # XXX
client ./rtsp_client.pl 10.0.0.1

exit
# With VLC as RTSP client & server, it works without nf_nat_rtsp module.

vlm_conf=`mktemp`
at_exit="rm $vlm_conf; $at_exit"
cat <<EOF >$vlm_conf
new tst vod enabled
setup tst input "/dev/urandom" option demux=rawvid option rawvid-fps=10 option 
rawvid-width=64 option rawvid-height=64 option rawvid-chroma=YV12 output 
"#transcode{vcodec=mp4v}"
EOF
chmod +r $vlm_conf

at_exit="pkill -f $vlm_conf; $at_exit"
set su -s /bin/sh nobody -c
server "$@" "exec vlc -d -I dummy -A adummy -V vdummy --rtsp-port 8080 
--vlm-conf $vlm_conf"

bash -i

#client "$@" "exec vlc --play-and-exit -I dummy -A adummy -V vdummy 
rtsp://10.0.0.1:8080/tst"

Reply via email to