File: simulator-tcp.sh

package info (click to toggle)
rtpengine 13.5.1.6-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 13,680 kB
  • sloc: ansic: 86,786; perl: 59,543; python: 3,193; sh: 1,037; makefile: 687; asm: 211
file content (49 lines) | stat: -rwxr-xr-x 1,501 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# # ulimit -n 100000
# # G_SLICE=always-malloc valgrind --leak-check=full --track-origins=yes --show-possibly-lost=yes ./rtpengine -t 0 -i $IP -l 25060 -f

pipe_o() {
	nc localhost 25060
}
pipe() {
	pipe_o > /dev/null
}
ip() {
	echo $((RANDOM % 254 + 1)).$((RANDOM % 254 + 1)).$((RANDOM % 254 + 1)).$((RANDOM % 254 + 1))
}
port() {
	echo $((RANDOM % 64000 + 1024))
}

ids=""
ports=""
for (( i = 0 ; i < 1000 ; i++ )); do
	callid=$(uuid)
	test -z "$callid" && exit 1
	src=$(ip):$(port)
	dst=$(ip):$(port)
	gw=$(ip)
	fromtag=$(uuid)
	totag=$(uuid)

	src_rel=$(echo "request $callid $src:audio $gw voip.inode.at local unknown unknown unknown-agent info=domain:voip.sipwise.local,from:number@voip.inode.at,totag:,to:othernumber@voip.inode.at,fromtag:$fromtag" | pipe_o)
	dst_rel=$(echo "lookup $callid $dst:audio $gw voip.inode.at local unknown unknown unknown-agent info=domain:voip.sipwise.local,from:number@voip.inode.at,totag:$totag,to:othernumber@voip.inode.at,fromtag:$fromtag" | pipe_o)
	echo "lookup $callid $dst:audio $gw voip.inode.at local unknown unknown unknown-agent info=domain:voip.sipwise.local,from:number@voip.inode.at,totag:$totag,to:othernumber@voip.inode.at,fromtag:$fromtag" | pipe
	echo version | pipe
	(echo status | pipe) &

	src_path=${src_rel/ //}
	dst_path=${dst_rel/ //}
	ports="$ports $src_path $dst_path"
	for port in $ports; do
		echo foobar > "/dev/udp/$port"
	done

	ids="$ids $callid"
done

sleep 10

for id in $ids; do
	echo "delete $id info=" | pipe
done