Fix streams in vLB/vDNS VNF
[demo.git] / vnfs / vLB / scripts / run_streams_dns.sh
1 #!/bin/bash
2
3 #Disable all the running streams
4 vppctl packet-gen disable
5
6 #Initial configuration: run only two streams
7 vppctl packet-gen enable-stream dns1
8 vppctl packet-gen enable-stream dns2
9
10 sleep 180
11
12 #Rehash port numbers and re-run five streams every minute
13 while true; do
14         vppctl packet-gen disable
15         vppctl pac del dns1
16         vppctl pac del dns2
17         vppctl pac del dns3
18         vppctl pac del dns4
19         vppctl pac del dns5
20
21         #Update destination (vLB) IP
22         VLB_IPADDR=$(cat /opt/config/vlb_ipaddr.txt)
23         IPADDR1=$(cat /opt/config/local_private_ipaddr.txt)
24         sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns1
25         sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns2
26         sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns3
27         sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns4
28         sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns5
29
30         #Update source ports (make them random)
31         sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns1
32         sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns2
33         sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns3
34         sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns4
35         sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns5
36
37         vppctl exec /opt/dns_streams/stream_dns1
38         vppctl exec /opt/dns_streams/stream_dns2
39         vppctl exec /opt/dns_streams/stream_dns3
40         vppctl exec /opt/dns_streams/stream_dns4
41         vppctl exec /opt/dns_streams/stream_dns5
42
43         #Resume stream execution
44         vppctl packet-gen enable-stream dns1
45         vppctl packet-gen enable-stream dns2
46         vppctl packet-gen enable-stream dns3
47         vppctl packet-gen enable-stream dns4
48         vppctl packet-gen enable-stream dns5
49
50         sleep 60
51 done