update demo scripts with LF paths
[demo.git] / vnfs / vLB / scripts / v_packetgen_for_dns_demo_init.sh
1 #!/bin/bash
2
3 # Start VPP
4 start vpp
5 sleep 1
6
7 # Configure VPP for vPacketGenerator
8 IPADDR1=$(ifconfig eth0 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2)
9 HWADDR1=$(ifconfig eth0 | grep HWaddr | tr -s ' ' | cut -d' ' -f5)
10 FAKE_HWADDR1=$(echo -n 00; dd bs=1 count=5 if=/dev/urandom 2>/dev/null | hexdump -v -e '/1 ":%02X"')
11 VLB_IPADDR=$(cat /opt/config/vlb_ipaddr.txt)
12 GW=$(route | grep default | awk '{print $2}')
13
14 ifconfig eth0 down
15 ifconfig eth0 hw ether $FAKE_HWADDR1
16 ip addr flush dev eth0
17 ifconfig eth0 up
18 vppctl tap connect tap111 hwaddr $HWADDR1
19 vppctl set int ip address tap-0 $IPADDR1"/24"
20 vppctl set int state tap-0 up
21 brctl addbr br0
22 brctl addif br0 tap111
23 brctl addif br0 eth0
24 ifconfig br0 up
25 vppctl ip route add 0.0.0.0/0 via $GW
26 sleep 1
27
28
29 #Let's set br0 with public IP and valid MAC so that Linux will have public network access
30 ifconfig br0 hw ether $HWADDR1
31 ifconfig br0 $IPADDR1 netmask 255.255.255.0
32 route add default gw $GW
33
34 #Adding static arp entry for VPP so that it will be able to send packets to default GW
35 ping -c 1 $VLB_IPADDR &>/dev/null &disown
36 sleep 3
37
38 GW_MAC=$(arp -n | grep -w $GW | tr -s ' ' | cut -d' ' -f3)
39 VLB_MAC=$(arp -n | grep -w $VLB_IPADDR | tr -s ' ' | cut -d' ' -f3)
40
41 #if VLB in our network, we will use its mac
42 if [ ! -z "$VLB_MAC" ]; then
43 vppctl set ip arp tap-0 $VLB_IPADDR $VLB_MAC
44 fi
45
46 # in any case let's add arp entry for default gw
47 vppctl set ip arp tap-0 $GW $GW_MAC
48
49
50 # Install packet streams
51 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns1
52 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns2
53 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns3
54 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns4
55 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns5
56 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns6
57 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns7
58 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns8
59 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns9
60 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$VLB_IPADDR"/" /opt/dns_streams/stream_dns10
61
62 #sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns*
63
64 sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns1
65 sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns2
66 sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns3
67 sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns4
68 sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns5
69 sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns6
70 sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns7
71 sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns8
72 sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns9
73 sed -i -e "s/.*-> 53.*/    UDP: $RANDOM -> 53/" /opt/dns_streams/stream_dns10
74
75 vppctl exec /opt/dns_streams/stream_dns1
76 vppctl exec /opt/dns_streams/stream_dns2
77 vppctl exec /opt/dns_streams/stream_dns3
78 vppctl exec /opt/dns_streams/stream_dns4
79 vppctl exec /opt/dns_streams/stream_dns5
80 vppctl exec /opt/dns_streams/stream_dns6
81 vppctl exec /opt/dns_streams/stream_dns7
82 vppctl exec /opt/dns_streams/stream_dns8
83 vppctl exec /opt/dns_streams/stream_dns9
84 vppctl exec /opt/dns_streams/stream_dns10
85 sleep 1
86
87 # Start HoneyComb
88 VERSION=$(cat /opt/config/artifacts_version.txt)
89 echo "" > /var/lib/honeycomb/persist/context/data.json
90 echo "" > /var/lib/honeycomb/persist/config/data.json
91 /opt/honeycomb/sample-distribution-$VERSION/honeycomb &>/dev/null &disown
92 sleep 20
93
94 # Enable traffic flows
95 cd /opt
96 chmod +x run_streams_dns.sh
97 #./run_streams_dns.sh &>/dev/null &disown
98