aboutsummaryrefslogtreecommitdiffstats
path: root/vnfs/vLB/scripts/run_streams_dns.sh
blob: db236638fd2f582bec843a7338d59a6b33b5f925 (plain)
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
50
51
52
#!/bin/bash
:<<END
#Disable all the running streams
vppctl packet-gen disable

#Initial configuration: run only two streams
vppctl packet-gen enable-stream dns1
vppctl packet-gen enable-stream dns2

sleep 180

#Rehash port numbers and re-run five streams every minute
while true; do
	vppctl packet-gen disable
	vppctl pac del dns1
	vppctl pac del dns2
	vppctl pac del dns3
	vppctl pac del dns4
	vppctl pac del dns5
END
	#Update destination (vLB) IP
	VLB_IPADDR=$(cat /opt/config/vlb_ipaddr.txt)
	IPADDR1=$(cat /opt/config/local_private_ipaddr.txt)
	sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns1
	sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns2
	sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns3
	sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns4
	sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns5

	#Update source ports (make them random)
	sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns1
	sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns2
	sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns3
	sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns4
	sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns5

	vppctl exec /opt/dns_streams/stream_dns1
	vppctl exec /opt/dns_streams/stream_dns2
	vppctl exec /opt/dns_streams/stream_dns3
	vppctl exec /opt/dns_streams/stream_dns4
	vppctl exec /opt/dns_streams/stream_dns5

	#Resume stream execution
	vppctl packet-gen enable-stream dns1
	vppctl packet-gen enable-stream dns2
	vppctl packet-gen enable-stream dns3
	vppctl packet-gen enable-stream dns4
	vppctl packet-gen enable-stream dns5
:<<END
	sleep 60
done
END